/* Base Sidebar Styles */
:root {
    /* Increased top space for menu */
    --sidebar-top: 100px;
    --sidebar-width: 350px;
    --transition-speed: 0.3s;
}

#sidebar {
    position: fixed;
    top: var(--sidebar-top);
    /* Below nav + menu */
    left: 20px;
    width: var(--sidebar-width);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    z-index: 1000;
    padding: 20px;
    padding: 20px;
    /* Transition for opacity/visibility/transform */
    transition: opacity var(--transition-speed) ease, visibility var(--transition-speed) ease, transform var(--transition-speed) cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
    /* Default Open State (Desktop) */
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    transform-origin: top left;
}

body.sidebar-closed #sidebar {
    /* Hidden State (Desktop) */
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    /* No TranslateX anymore */
}

/* App Menu (Top Bar) */
#app-menu {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1100;
    display: flex;
    gap: 12px;
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border: none;
    cursor: pointer;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    transition: all var(--transition-speed) ease;
    padding: 6px;
    color: #333;
    font-family: inherit;
    text-decoration: none;
}

.menu-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.menu-item .icon-container {
    position: relative;
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.menu-item .menu-label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

/* App Logo */
.app-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 16px;
    margin-right: 8px;
    height: 64px;
    cursor: default;
    user-select: none;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.logo-text {
    font-weight: 900;
    font-size: 1.2rem;
    color: #333;
    line-height: 1;
    white-space: nowrap;
}

.logo-text-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1;
}

.logo-subtitle {
    font-size: 0.8rem;
    font-weight: normal;
    margin-top: 2px;
}

/* Sidebar Toggle Logic (Icon Swap inside menu item) */
#sidebar-toggle .icon-filter,
#sidebar-toggle .icon-close {
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}


#sidebar-toggle .icon-filter {
    opacity: 0;
    transform: rotate(-90deg);
}

#sidebar-toggle .icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* Closed State: Show Filter */
body.sidebar-closed #sidebar-toggle .icon-filter {
    opacity: 1;
    transform: rotate(0deg);
}

body.sidebar-closed #sidebar-toggle .icon-close {
    opacity: 0;
    transform: rotate(90deg);
}

/* Mobile State Handling */
@media (max-width: 768px) {

    /* Mobile Default (Closed): Show Filter, Hide Close */
    #sidebar-toggle .icon-filter {
        opacity: 1 !important;
        transform: rotate(0deg) !important;
    }

    #sidebar-toggle .icon-close {
        opacity: 0 !important;
        transform: rotate(90deg) !important;
    }

    /* Mobile Open: Show Close, Hide Filter */
    body.sidebar-mobile-open #sidebar-toggle .icon-filter {
        opacity: 0 !important;
        transform: rotate(-90deg) !important;
    }

    body.sidebar-mobile-open #sidebar-toggle .icon-close {
        opacity: 1 !important;
        transform: rotate(0deg) !important;
    }
}


#sidebar h2 {
    margin-top: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-group label {
    font-weight: bold;
}

/* Base Filter Tag Styles */
.filter-tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-tag {
    padding: 6px 12px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    user-select: none;
}

.filter-tag:hover {
    background: #f0f0f0;
}

.filter-tag.selected {
    background: #333;
    color: white;
    border-color: #333;
}


/* Range Slider Styling Reset */
input[type=range] {
    width: 100%;
}

/* Design Switcher */
#design-switcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    max-width: 300px;
}

#design-switcher button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: #f5f5f5;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

#design-switcher button:hover {
    background: #e0e0e0;
}

#design-switcher button.active {
    background: #333;
    color: white;
    border-color: #333;
}

/* Action Button Base */
.action-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-btn.secondary {
    font-size: 0.8rem;
}

/* =========================================
   Design: Glassmorphism
   ========================================= */
body.theme-glass #sidebar {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    color: #333;
    font-family: 'Outfit', sans-serif;
}

body.theme-glass #sidebar h2 {
    color: #2c3e50;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}

body.theme-glass .filter-group input,
body.theme-glass .filter-group select {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 8px;
    border-radius: 8px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    font-family: 'Outfit', sans-serif;
    color: #2c3e50;
    font-weight: 500;
}

body.theme-glass .filter-tag {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(4px);
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    color: #2c3e50;
}

body.theme-glass .filter-tag:hover {
    background: rgba(255, 255, 255, 0.6);
}

body.theme-glass .filter-tag.selected {
    background: rgba(44, 62, 80, 0.8);
    color: white;
    border-color: transparent;
}

@keyframes neonGlowOpacity {
    0% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

body.theme-glass .menu-item {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px 0 rgba(31, 38, 135, 0.05);
    color: #1a1e21;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    position: relative;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    z-index: 1;
}

body.theme-glass .app-logo {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    box-shadow: 0 4px 12px 0 rgba(31, 38, 135, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    position: relative;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    z-index: 1;
}

body.theme-glass .menu-item::before,
body.theme-glass .app-logo::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: -1;
    pointer-events: none;
    transition: background 0.3s ease;
}

body.theme-glass .menu-item:focus,
body.theme-glass .app-logo:focus {
    outline: none;
}

body.theme-glass .menu-item:active,
body.theme-glass .app-logo:active {
    outline: none;
    transform: scale(0.96) translateY(1px);
}

body.theme-glass .menu-item::after,
body.theme-glass .app-logo::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    border: 1px solid rgba(168, 85, 247, 0.6);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.4), inset 0 0 6px rgba(192, 60, 255, 0.3);
    animation: neonGlowOpacity 3.5s infinite ease-in-out;
    pointer-events: none;
    z-index: 2;
}

body.theme-glass .app-logo::after {
    animation-delay: 0s;
}

body.theme-glass #sidebar-toggle::after {
    animation-delay: 0.6s;
}

body.theme-glass #menu-info::after {
    animation-delay: 1.2s;
}

body.theme-glass #menu-table::after {
    animation-delay: 1.8s;
}

@media (hover: hover) and (pointer: fine) {

    body.theme-glass .menu-item:hover,
    body.theme-glass .app-logo:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px 0 rgba(31, 38, 135, 0.1);
    }

    body.theme-glass .menu-item:hover::before,
    body.theme-glass .app-logo:hover::before {
        background: rgba(255, 255, 255, 0.65);
    }
}

body.theme-glass .logo-icon {
    background-image: url('../img/icon_glass.png');
}

body.theme-glass .logo-text {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: #2c3e50;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    letter-spacing: 0px;
    text-transform: none;
}

body.theme-glass .logo-subtitle {
    font-family: 'Quicksand', sans-serif;
    font-size: 0.5rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #34495e;
    font-weight: 700;
    margin-top: 8px;
    text-align: center;
}

body.theme-glass .action-btn {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #2c3e50;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

body.theme-glass .action-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}


/* Response/Mobile Styles */
@media (max-width: 768px) {

    /* Mobile Styles for Menu */
    #app-menu {
        top: 12px;
        /* Compensate for added padding */
        left: 20px;
        right: 20px;
        overflow-x: auto;
        gap: 8px;
        padding-top: 8px;
        padding-bottom: 12px;
        /* for scrollbar and glow overflow bounds */
    }

    .menu-item {
        width: 64px;
        /* Fixed: Match logo height */
        height: 64px;
        /* Fixed: Match logo height */
        border-radius: 12px;
        /* Restore desktop radius */
        flex-shrink: 0;
    }

    .menu-item .menu-label {
        display: none;
        /* Hide labels on mobile to save space */
    }

    /* Adjust specific themes for mobile if needed */

    /* Ensure action buttons on menu are consistent */




    #design-switcher {
        bottom: 10px;
        right: 10px;
        left: 10px;
        flex-direction: row;
        overflow-x: auto;
        justify-content: center;
        max-width: none;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(10px);
        z-index: 2002;
    }

    #mobile-close {
        display: block !important;
    }
}

/* =========================================
   Info / About Page Styles
   ========================================= */
#info-view-container {
    position: fixed;
    top: 100px;
    /* Aligned with sidebar top */
    left: 390px;
    /* Default Open Sidebar: 350px + 20px + 20px gap */
    right: 20px;
    bottom: 20px;
    z-index: 999;
    /* Below sidebar (1000) but above map */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    pointer-events: none;
    pointer-events: auto;
    transition: left 0.3s ease, right 0.3s ease;
}

body.sidebar-closed #info-view-container {
    left: 20px;
    /* Use full width when sidebar is closed */
}

#info-view-container.hidden {
    display: none;
}

.info-content {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    padding: 40px;
    max-width: 800px;
    width: 100%;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    color: #2d3436;
    font-family: 'Outfit', sans-serif;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.info-content h1 {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    text-align: center;
}

.info-subtitle {
    text-align: center;
    font-size: 1.1rem;
    color: #576574;
    margin-bottom: 2rem;
    font-weight: 500;
}

.info-section {
    margin-bottom: 2rem;
    line-height: 1.6;
    font-size: 1.05rem;
    text-align: center;
}

.info-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 3rem;
}

.feature-item {
    background: rgba(255, 255, 255, 0.5);
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    transition: transform 0.2s;
}

.feature-item:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.7);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.feature-item h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.feature-item p {
    margin: 0;
    font-size: 0.95rem;
    color: #636e72;
}

.info-footer {
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-top: 20px;
    font-size: 0.9rem;
    color: #636e72;
}

/* Scrollbar for info content */
.info-content::-webkit-scrollbar {
    width: 8px;
}

.info-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.info-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.info-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Mobile adjustments */
@media (max-width: 768px) {

    /* Shared Mobile View Styles */
    #sidebar,
    #table-view-container,
    #info-view-container {
        position: fixed !important;
        top: 100px !important;
        left: 20px !important;
        right: 20px !important;
        bottom: 20px !important;
        width: auto !important;
        height: auto !important;
        max-height: none !important;
        margin: 0 !important;
        border-radius: 20px !important;
        z-index: 1000;

        /* Glassmorphism Base */
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid rgba(255, 255, 255, 0.4);
        box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);

        /* Animation Base */
        transition: opacity 0.3s ease, transform 0.3s ease;
        opacity: 0;
        transform: translateY(10px);
        pointer-events: none;
        display: flex;
        /* Default layout */
        flex-direction: column;
    }

    /* Active States */

    /* Sidebar Active */
    body.sidebar-mobile-open #sidebar {
        opacity: 1 !important;
        transform: translateY(0) !important;
        pointer-events: auto;
        visibility: visible !important;
    }


    #table-view-container[style*="display: flex"],
    #table-view-container[style*="display:flex"] {
        opacity: 1 !important;
        transform: translateY(0) !important;
        pointer-events: auto;
    }

    /* Info Active */
    #info-view-container:not(.hidden) {
        opacity: 1 !important;
        transform: translateY(0) !important;
        pointer-events: auto;
    }

    /* Overrides for specific IDs to reset previous mobile styles */

    #sidebar {

        transform: translateY(10px);

    }

    #table-view-container {
        /* Ensure table fits */
        overflow: hidden;
        /* Inner content scrolls */
    }

    #info-view-container {
        /* Align content */
        align-items: flex-start;
        padding: 0;
        background: rgba(255, 255, 255, 0.1);

    }

    /* Inner Content adjustments */
    .info-content {
        box-shadow: none;
        /* Container has shadow */
        border: none;
        background: transparent;
        max-height: 100%;
        /* Fill container */
        padding: 20px;
    }

    /* Mobile Menu Styles (Fluid Layout) */
    #app-menu {
        top: 20px;
        left: 20px;
        right: 20px;
        /* No overflow-x, force fit */
        display: flex;
        gap: 8px;
        /* Start with small gap */
        padding-bottom: 0;
        /* No scrollbar needed */
        scrollbar-width: none;
    }

    /* Logo Sizing in Fluid Layout */
    .app-logo {
        flex: 0 1 auto;
        width: auto;
        max-width: 60%;
        min-width: 0;
        margin-right: 0;
        padding: 0 8px;
        overflow: hidden;
    }

    .logo-text-container {
        min-width: 0;
        overflow: hidden;
    }

    .logo-text {
        /* Fluid typography: scale between 0.9rem and 1.5rem (Desktop size) */
        font-size: clamp(1.1rem, 5vw, 1.5rem) !important;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
    }

    .logo-subtitle {

        font-size: clamp(0.5rem, 2vw, 0.65rem) !important;
        white-space: nowrap;
    }

    /* Menu Items Sizing in Fluid Layout */
    .menu-item {
        /* Icons take remaining space equally */
        flex: 1 1 0px;
        width: auto;
        height: 64px;
        min-width: 0;
        max-width: 64px;
        padding: 4px;
        margin: 0;
    }

    .menu-item .icon-container {
        width: 24px;
        height: 24px;
        margin: auto;
    }

    /* Adjust gap for very small screens */
    @media (max-width: 360px) {
        #app-menu {
            gap: 2px;
            left: 10px;
            right: 10px;
        }

        .app-logo {
            padding: 0 4px;
        }
    }

    @media (max-width: 400px) {
        .app-logo .logo-subtitle {
            /* display: none;  <-- REMOVED to keep subtitle */
            font-size: 0.35rem;
            /* Explicit small size */
        }
    }



    /* Design Switcher */
    #design-switcher {
        bottom: 10px;
        right: 10px;
        left: 10px;
        flex-direction: row;
        overflow-x: auto;
        justify-content: center;
        max-width: none;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(10px);
        z-index: 2002;
    }

    #mobile-close {
        display: block !important;
    }

    /* Medium-Small Screen Adjustments (Start scaling down logo earlier) */
    @media (max-width: 480px) {
        .app-logo {
            padding: 0 10px;
            /* Reduce padding */
            margin-right: 4px;
        }

        .app-logo .logo-text {
            font-size: 1rem;
            /* Reduce font size earlier */
        }

        .app-logo .logo-subtitle {
            font-size: 0.65rem;
            /* Shrink subtitle */
        }
    }

    /* Slightly smaller screens: keep subtitle, just scale */
    @media (max-width: 400px) {
        .app-logo .logo-subtitle {
            /* valid, handled by clamp above mostly, but ensuring visibility */
            display: block;
        }
    }

    /* Small Screen Adjustments (e.g., iPhone SE) */
    @media (max-width: 380px) {
        .app-logo .logo-text {
            font-size: 0.9rem;
            /* Further reduce */
        }

        .info-features {
            grid-template-columns: 1fr !important;
            /* Force single column on very narrow screens */
        }



        /* Reduce side margins for container to give more space */
        #sidebar,
        #table-view-container,
        #info-view-container {
            left: 10px !important;
            right: 10px !important;
        }

        /* Further reduce padding for info content */
        .info-content {
            padding: 15px !important;
        }
    }
}

/* Global modifications for responsive safety */
.logo-text {
    white-space: nowrap;
    /* Prevent wrapping generally */
}


@media (max-width: 600px) {
    .info-features {
        grid-template-columns: 1fr;
    }
}