/**
 * Mapbox Globe View - CSS
 * @author      Sakar Joshi <sakarjoshi11@gmail.com>
 * @github      Deluxecoder12
 */

/* ==========================================================================
   Variables
   ========================================================================== */
:root {
    /* Colors */
    --color-primary: #800000; /* Main color for buttons*/
    
    /* Category-specific colors */
    --color-conferences: rgb(205, 122, 119); /* Conference markers */
    --color-people: rgb(139, 170, 210); /* People markers */
    --color-virtual: #ff6b6b; /* Virtual markers */
    
    /* Lighter for hover states */
    --color-primary-hover: rgba(128, 0, 0, 0.5);
    --color-conferences-hover: rgb(227, 142, 139); 
    --color-people-hover: rgb(159, 192, 235);
    
    /* Text colors for hierarchy */
    --color-text: #333; /* Primary text color */
    --color-text-light: #666; /* Secondary text color */
    --color-text-muted: #999; /* Muted text for debug info */
    
    /* Border */
    --color-border: #ddd; /* Standard border color */
    --color-border-light: #eee; /* Lighter borders for subtle divisions */

    /* Background colors  */
    --color-background: white; /* Primary background color */
    --color-background-overlay: rgba(255, 255, 255, 0.95); /* Semi-transparent overlay */
    --color-background-overlay-transparent: rgba(255, 255, 255, 0.1); /* Transparent overlay */
    --color-background-section: #f9f9f9; /* Background for filter sections */
    
    /* Error and notification colors */
    --color-error: #ff4444;
    
    /* Spacing */
    --spacing-xs: 2px;
    --spacing-sm: 5px;
    --spacing-md: 8px;
    --spacing-lg: 10px;
    --spacing-xl: 15px;
    --spacing-xxl: 20px;

    /* Consistent sizing for overlay panels and interactive elements */
    --overlay-width-max: 320px; /* Maximum overlay width on desktop */
    --overlay-width-tablet: 320px; /* Overlay width on tablets */
    --filter-height-max: 200px; /* Maximum height for filter lists */
    --filter-height-tablet: 150px; /* Filter height on tablets */
    --filter-height-mobile: 120px; /* Filter height on mobile devices */
    --touch-target-min: 44px; /* Minimum touch target size for accessibility */
    
    /* Animation timings */
    --transition-standard: 0.3s ease; /* Standard */
    --transition-fast: 0.2s ease; /* For immediate feedback */
    --transition-loading: 0.5s ease; /* For loading states */
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
}

html {
    overflow-x: hidden;
}

/* ==========================================================================
   Map Container
   ========================================================================== */

#map {
    width: 100vw;
    height: calc(100vh + 280px); /* The extra height accomodates for the header */
    display: block;
    position: relative;
    overflow: hidden;
}

/* ==========================================================================
   Loading Screen
   ========================================================================== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-background);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-loading);
    font-family: sans-serif;
    font-size: 14px;
    color: var(--color-text);
}

#loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ccc;
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Map Overlay Container
   ========================================================================== */
.map-overlay {
    position: absolute;
    top: 350px;
    left: var(--spacing-xxl);
    background-color: var(--color-background-overlay);
    padding: var(--spacing-md) var(--spacing-lg) var(--spacing-md) 13px;
    border-radius: var(--spacing-md);
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: var(--overlay-width-max);
    min-width: var(--overlay-width-max);
    transition: opacity var(--transition-standard), background-color var(--transition-standard);
}

/* Transparent state applied during map interactions */
.map-overlay.transparent {
    opacity: 0.3;
    background-color: var(--color-background-overlay-transparent);
    pointer-events: none;
}

/* Keep collapse toggle interactive even when overlay is transparent */
.map-overlay.transparent .collapse-toggle {
    pointer-events: auto;
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.9);
}

/* Collapsed state */
.map-overlay.collapsed {
    max-height: 50px;
    overflow: hidden;
}

.map-overlay.collapsed .collapsible-content {
    display: none;
}

/* ==========================================================================
   Overlay Header (for header title and collapse toggle)
   ========================================================================== */
.map-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.map-overlay-title {
    margin: 0;
    color: var(--color-text);
    font-size: 18px;
    flex-grow: 1;
    font-weight: bold;
}

.map-overlay h3 {
    margin: 0 0 var(--spacing-xl) 0;
    color: var(--color-text);
    font-size: 16px;
}

.collapse-toggle {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: var(--color-text-light);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background-color var(--transition-fast);
    flex-shrink: 0;
    margin-left: var(--spacing-lg);
    transform: translateY(-3px);
}

.collapse-toggle:hover {
    background-color: #f0f0f0;
    color: var(--color-text);
}

.collapse-toggle i {
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900 !important; /* Critical for FA6 solid icons */
    font-style: normal !important;
    line-height: 1;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

/* Base button styles */
.map-overlay button {
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: var(--spacing-lg) var(--spacing-sm);
    border-radius: var(--spacing-sm);
    cursor: pointer;
    margin-bottom: var(--spacing-sm);
    font-size: 14px;
    transition: background-color var(--transition-standard);
}

.map-overlay button:hover {
    background-color: var(--color-primary-hover);
}

/* Category buttons */
.category-btn {
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 4px;
    cursor: pointer;
    margin-right: 0;
    margin-bottom: 0;
    font-size: 11px;
    transition: background-color var(--transition-standard);
    display: inline-block;
    flex: 1;
    text-align: center;
    min-width: 0;
    white-space: nowrap; 
    vertical-align: top;
    line-height: 1.2;
}

.category-btn:hover {
    background-color: var(--color-primary-hover);
}

.category-btn.active.conferences {
    background-color: var(--color-conferences);
}

.category-btn.active.people {
    background-color: var(--color-people);
}

.category-btn.active.all {
    background-color: var(--color-primary-hover);
}

.category-btn.conferences:hover {
    background-color: var(--color-conferences-hover);
}

.category-btn.people:hover {
    background-color: var(--color-people-hover);
}

.category-btn.all:hover {
    background-color: var(--color-primary-hover);
}

/* ==========================================================================
   Filter Sections
   ========================================================================== */
.category-controls {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: nowrap;
}

.conference-filter,
.people-filter,
.virtual-conferences-section {
    margin-bottom: var(--spacing-lg);
    /* padding-bottom: var(--spacing-md); */
    border-bottom: 1px solid var(--color-border);
}

/* Hide people and virtual conference sections by default
 * JS will show/hide based on selected category */
.people-filter,
.virtual-conferences-section {
    display: none;
}

.people-filter div {
    display: flex;
    align-items: center;
}

.people-filter h3 {
    margin: 0;
    flex-grow: 1;
    font-size: 15px;
    line-height: 1.2;
}

/* Dropdown select styling for both conference and virtual conference filters */
.conference-filter select,
.virtual-conferences-section select {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--color-background);
    margin-top: 0;
    cursor: pointer;
    padding-right: 30px;
    position: relative;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: none;
}

.conference-filter,
.virtual-conferences-section {
    position: relative;
}

.conference-filter::after,
.virtual-conferences-section::after {
    content: '\f078'; /* FontAwesome chevron-down */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--color-text-light);
    font-size: 12px;
}

.conference-filter select:focus,
.virtual-conferences-section select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Filter and Virtual Conference Spacing and style */
.filter-section {
    margin-bottom: var(--spacing-lg);
    width: 100%;
}

.filter-section h5 {
    margin: 0 0 var(--spacing-md) 0;
    font-size: 14px;
    color: var(--color-text);
    font-weight: bold;
}

.filter-checkboxes {
    padding-top: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: var(--filter-height-max);
    overflow-y: auto;
    background: var(--color-background-section);
    border-radius: 4px;
    width: 100%;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    width: 100%;
    padding: var(--spacing-xs) var(--spacing-xs) var(--spacing-xs) 0;
}

.filter-checkbox input[type="checkbox"] {
    margin-right: var(--spacing-md);
    transform: scale(1.0);
}

.filter-checkbox label {
    cursor: pointer;
    white-space: normal;
    overflow: visible;
    text-overflow: none;
    max-width: none;
    line-height: 1.3;
}

#clear-people-btn {
    min-width: fit-content;
    flex-shrink: 0;
    font-size: 14px; 
    line-height: 1.2; 
}

/* ==========================================================================
   Statistics Info
   ========================================================================== */
.bottom-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: var(--spacing-lg);
    gap: var(--spacing-lg);
}

.bottom-controls button {
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: var(--spacing-lg);
    border-radius: var(--spacing-sm);
    cursor: pointer;
    font-size: 14px;
    transition: background-color var(--transition-standard);
    margin-right: 0;
}

.bottom-controls button:hover {
    background-color: var(--color-primary-hover);
}

.stats-info {
    font-size: 11px;
    color: var(--color-text-light);
    margin-top: 0;
    padding-top: 4px;
    border-top: none;
    flex: 1;
}

.stats-row {
    display: flex;
    gap: 2rem;
}

.stat-item {
    white-space: nowrap;
}

/* When WP_DEBUG is enabled */
.debug-info {
    font-size: 10px;
    color: var(--color-text-muted);
    margin-top: var(--spacing-sm);
}

/* ==========================================================================
   Popup Styles
   ========================================================================== */
.mapboxgl-popup {
    transition: opacity var(--transition-standard);
}

.marker-popup .popup-link {
    color: white;
    text-decoration: none;
    font-weight: bold;
    display: inline-block;
    margin-top: var(--spacing-md);
    padding: 4px var(--spacing-md);
    background-color: var(--color-primary);
    border-radius: 3px;
    font-size: 12px;
    transition: all var(--transition-fast);
}

.marker-popup .popup-link:hover {
    background-color: #f8f8f8;
    color: var(--color-primary);
}

.marker-popup .popup-link.people-link {
    background-color: #0066cc;
    color: white;
}

.marker-popup .popup-link.people-link:hover {
    background-color: #f8f8f8;
    color: #0066cc;
}

.virtual-badge {
    display: inline-block;
    background-color: var(--color-virtual);
    color: white;
    padding: var(--spacing-xs) 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-left: var(--spacing-sm);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
/* Tablet styles */
@media (max-width: 1024px) {
    .map-overlay {
        top: 300px;
        max-width: var(--overlay-width-tablet);
        padding: 12px;
    }
    
    .filter-checkboxes {
        max-height: var(--filter-height-tablet);
        width: 100%;
    }
}

/* Smaller Tablet styles */
@media (max-width: 768px) {
    #map {
        height: 100vh;
        width: 100vw;
    }

    .map-overlay {
        top: 230px;
        left: var(--spacing-lg);
        right: var(--spacing-lg);
        max-width: none;
        width: auto;
        padding: var(--spacing-lg);
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .map-overlay button {
        padding: var(--spacing-md) 12px;
        font-size: 12px;
    }
    
    .category-controls {
        display: flex;
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .category-btn {
        flex: 1;
        min-width: 70px;
        padding: 4px var(--spacing-sm);
        font-size: 10px;
        margin-right: 0;
    }
    
    .conference-filter select,
    .virtual-conferences-section select {
        font-size: 14px;
        padding: 6px 25px 6px var(--spacing-md);
        width: calc(100% - 2px);
    }
    
    .filter-checkboxes {
        max-height: var(--filter-height-mobile);
        padding: var(--spacing-sm);
        width: 100%;
    }
    
    .filter-checkbox {
        font-size: 13px;
        padding: 1px 0;
    }
    
    .virtual-conference-item {
        padding-bottom: var(--spacing-sm);
        font-size: 11px;
    }
    
    .collapse-toggle {
        display: flex;
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    
    .map-overlay-title {
        font-size: 18px;
    }
}

/* Mobile styles */
@media (max-width: 480px) {
    #map {
        height: calc(100vh - 60px);
    }

    .map-overlay {
        top: 200px;
        left: var(--spacing-sm);
        right: var(--spacing-sm);
        padding: var(--spacing-md);
        max-height: 52vh;
    }
    
    .map-overlay h3,
    .map-overlay-title {
        font-size: 16px;
        margin-bottom: var(--spacing-lg);
    }
    
    .filter-section h5 {
        font-size: 14px;
    }
    
    .category-btn {
        padding: var(--spacing-sm) 6px;
        font-size: 10px;
    }
    
    .map-overlay button {
        padding: 6px var(--spacing-lg);
        font-size: 14px;
        margin-bottom: 3px;
    }

    .conference-filter select,
    .virtual-conferences-section select {
        font-size: 11px;
        padding: var(--spacing-sm) 25px var(--spacing-sm) 6px;
    }
    
    .conference-filter::after,
    .virtual-conferences-section::after {
        font-size: 10px;
        right: 8px;
    }
    
    .conference-filter select option {
        font-size: 11px;
        width: 100%;
    }
}

/* Smaller mobile styles */
@media (max-width: 320px) {
    .conference-filter select,
    .virtual-conferences-section select {
        font-size: 11px;
        padding: 4px 20px 4px var(--spacing-sm);
    }
    
    .conference-filter::after,
    .virtual-conferences-section::after {
        font-size: 9px;
        right: 6px;
    }
}

/* ==========================================================================
   Touch-Friendly Improvements
   ========================================================================== */
@media (hover: none) and (pointer: coarse) {
    .category-btn, 
    .map-overlay button {
        min-height: var(--touch-target-min);
        padding: var(--spacing-lg) var(--spacing-xl);
    }
    
    .filter-checkbox {
        min-height: 40px;
        padding: var(--spacing-md) 0;
    }
    
    .filter-checkbox input[type="checkbox"] {
        transform: scale(1.3);
        margin-right: 12px;
    }
    
    .collapse-toggle {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
        font-size: 20px;
    }
}