/**
 * Layout System
 * Desktop: Fixed sidebar + map canvas + optional info panel
 * Mobile: Full-screen map with slide-up drawer panel
 */

/* =================================================================
   APP SHELL
   ================================================================= */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #e8ecef;
}

/* =================================================================
   TOPBAR
   ================================================================= */

.app-topbar {
    flex: 0 0 auto;
    background-color: #ffffff;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    position: sticky;
    top: 0;
    z-index: calc(var(--z-fixed) + 5);
}

.topbar-brand-bar {
    background-color: #155834;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0.3rem 2rem;
}

.topbar-logo {
    width: auto;
    max-width: 260px;
    padding: 6px 0;
}

.topbar-lower {
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.8rem 2rem 0.95rem;
}

.topbar-title {
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.topbar-search {
    flex: 0 1 420px;
    max-width: 480px;
}

/* =================================================================
   ACTIVE STATE PILLS
   ================================================================= */

.active-state-pills-heading {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #000;
    margin-bottom: 0.25rem;
}

.active-state-pills {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.state-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    padding: 0.05rem 0.3rem 0.05rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #0f172a;
    gap: 0.35rem;
}

.state-pill--category {
    border-color: rgba(26, 86, 50, 0.45);
    background-color: rgba(26, 86, 50, 0.8);
    color: #ffffff;
}

.state-pill--building {
    border-color: rgba(15, 23, 42, 0.2);
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.15);
}

.state-pill--overlay {
    border-color: rgba(24, 52, 70, 0.25);
    background-color: rgba(230, 239, 248, 0.9);
}

.state-pill__label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.state-pill__clear {
    border: none;
    background: transparent;
    color: #ffffff;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
    font-size: 0.85rem;
}

.state-pill--building .state-pill__clear {
    color: #1a5632;
}

.state-pill__clear:hover {
    background-color: rgba(26, 86, 50, 0.2);
}

.state-pill__clear:focus-visible {
    outline: 3px solid rgba(26, 86, 50, 0.5);
    outline-offset: 1px;
}

.state-pill-clear-all {
    border: 1px dashed rgba(15, 23, 42, 0.25);
    background: rgba(255, 255, 255, 0.85);
    color: #155834;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.15rem 0.65rem;
    border-radius: 999px;
    min-width: auto;
    min-height: auto;
}

.state-pill-clear-all:focus-visible {
    outline: 3px solid rgba(26, 86, 50, 0.4);
    outline-offset: 2px;
}

/* =================================================================
   MAIN APPLICATION CONTAINER
   ================================================================= */

.app-container {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    overflow: hidden;
    position: relative;
    align-items: stretch;
}

body.mobile-sheet-open {
    overflow: hidden;
}
/* =================================================================
   SIDE PANEL (Navigation)
   ================================================================= */

.side-panel {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    height: 100%;
    align-self: stretch;
    background-color: #ffffff;
    border-right: 1px solid rgba(15, 23, 42, 0.08);
    overflow: hidden;
    flex-shrink: 0;
    z-index: var(--z-fixed);
    box-shadow: 6px 0 18px rgba(15, 23, 42, 0.08);
    transition: opacity var(--transition-base);
    position: relative;
}

.side-panel.is-collapsed {
    display: none;
}

/* Side Panel Content */
.side-panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    padding: 0;
    overflow-y: auto;
    gap: 0;
    transition: opacity var(--transition-base);
}

.side-panel.is-collapsed .side-panel-content {
    opacity: 0;
}

.side-panel--overlay {
    overflow: hidden;
}

.side-panel--overlay .side-panel-content {
    overflow: hidden;
}

/* Panel Header with Logo */
.panel-header {
    padding: 0.75rem 1.5rem 0.25rem;
    border-bottom: none;
}

.panel-header .logo {
    max-width: 300px;
    height: auto;
    display: block;
}

.panel-header svg {
    width: 240px;
    height: auto;
}

.panel-heading {
    padding: 0 1.4rem;
}

.panel-heading-title {
    font-size: 1.55rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0.35rem 0 0 0;
}

.panel-heading-subtitle {
    margin: 0.25rem 0 0;
    color: #616161;
    font-size: 0.85rem;
    line-height: 1.4;
}

.nav-section-heading {
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: none;
    color: #111827;
    margin: 0;
    font-weight: 700;
}

.category-section-header {
    padding: 0.4rem 0 0.25rem;
    margin-top: 0.15rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.category-section-header--parking {
    margin-top: 0.75rem;
    padding-top: 0.4rem;
    margin-bottom: 0.5rem;
}

.category-collapse-toggle {
    border: 1px solid rgba(26, 86, 50, 0.35);
    background: linear-gradient(180deg, #fcfdfb 0%, #f1f4f0 100%);
    border-radius: 1.05rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
    text-transform: none;
    letter-spacing: normal;
}

.category-collapse-toggle:hover,
.category-collapse-toggle:focus-visible {
    background: linear-gradient(180deg, #ffffff 0%, #eff4ef 100%);
    border-color: rgba(26, 86, 50, 0.55);
    box-shadow: 0 16px 34px rgba(26, 86, 50, 0.18);
}

.category-toggle-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #1a5632;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.category-collapse-toggle .category-toggle-icon i {
    transition: transform var(--transition-fast);
}

.category-collapse-toggle[data-state="collapsed"] .category-toggle-icon i {
    transform: rotate(180deg);
}

.category-toggle-text {
    white-space: nowrap;
}

.side-panel.is-collapsed .category-section-header,
.side-panel.is-collapsed .category-list-wrapper,
.side-panel.is-collapsed .building-list-panel,
.side-panel.is-collapsed .parking-list-panel,
.side-panel.is-collapsed .accessible-entrances-panel,
.side-panel.is-collapsed .accessible-parking-panel {
    visibility: hidden;
}

.side-panel-section {
    padding: 0 1.2rem;
    flex: 1 1 auto;
    min-height: 0;
}

.side-panel-active-state {
    padding: 0.9rem 0 0.5rem;
}

.side-panel-active-state[hidden] {
    display: none;
}

/* Floating toggle — desktop: shown when sidebar is collapsed */
.category-floating-toggle {
    display: none;
    justify-content: flex-start;
    width: auto;
    min-width: 190px;
    max-width: min(260px, calc(100vw - 1.5rem));
    padding-right: 0.85rem;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    margin-bottom: 0.35rem;
}

.category-floating-toggle .category-toggle-icon {
    width: 32px;
    height: 32px;
}

/* Desktop: show floating toggle only when sidebar is collapsed */
.side-panel.is-collapsed + .map-container .category-floating-toggle {
    display: inline-flex;
    margin-left: 0;
}

/* =================================================================
   MAP CONTAINER
   ================================================================= */

.map-container {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    padding-bottom: 0;
    transition: margin-right var(--transition-base);
}

.map-canvas {
    width: 100%;
    height: 100%;
}

/* Map Controls (Zoom buttons) */
.map-controls {
    position: absolute;
    right: var(--spacing-md);
    bottom: 100px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    z-index: 10;
}

.map-control-button {
    width: 44px;
    height: 44px;
    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 24px;
    font-weight: var(--font-weight-bold);
    color: var(--color-gray-700);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    padding: 0;
    line-height: 1;
    font-family: Arial, sans-serif;
    margin: 0;
}

.map-control-button span,
.map-control-button img {
    display: block;
    text-align: center;
}

.map-control-button span {
    width: 100%;
}

.map-control-button:hover {
    background-color: var(--color-gray-50);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.map-control-button:active {
    transform: scale(0.95);
}

/* =================================================================
   FOOTER
   ================================================================= */

.map-footer {
    position: relative;
    margin-left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--color-border);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    font-size: var(--font-size-xs);
    z-index: var(--z-sticky);
}

.map-footer nav {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.map-footer-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    justify-content: flex-end;
}

.map-footer a {
    color: var(--color-gray-600);
    white-space: nowrap;
}

.map-footer a:hover {
    color: var(--color-gray-900);
}

/* Feedback button styled to match footer links */
.footer-link-btn {
    font: inherit;
    font-size: var(--font-size-xs);
    color: var(--color-gray-600);
    min-height: 0;
    min-width: 0;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: underline;
    vertical-align: baseline;
    line-height: inherit;
}

.footer-link-btn:hover {
    color: var(--color-gray-900);
}

/* Cookie Settings — override OneTrust injected styles */
#ot-sdk-btn.ot-sdk-show-settings,
.cookie-settings {
    color: var(--color-gray-600) !important;
    font-size: var(--font-size-xs) !important;
    padding: 2px var(--spacing-sm) !important;
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius-sm) !important;
    background-color: transparent !important;
    min-height: 0 !important;
    min-width: 0 !important;
    line-height: 1.5 !important;
    white-space: nowrap;
    font-family: var(--font-family-base) !important;
}

#ot-sdk-btn.ot-sdk-show-settings:hover,
.cookie-settings:hover {
    background-color: var(--color-gray-50) !important;
    color: var(--color-gray-900) !important;
}

/* =================================================================
   SIDEBAR DISMISS BUTTON
   ================================================================= */

.sidebar-dismiss-control {
    display: flex;
    justify-content: flex-end;
    padding: 0.35rem 0.35rem 0;
}

.sidebar-dismiss-btn {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: #1a5632;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.sidebar-dismiss-btn:hover,
.sidebar-dismiss-btn:focus-visible {
    color: #0f2b1f;
    outline: 2px solid rgba(26, 86, 50, 0.4);
    outline-offset: 2px;
}

.sidebar-dismiss-btn i {
    font-size: 0.9rem;
}

.sidebar-dismiss-btn .category-toggle-icon {
    width: 100%;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* =================================================================
   MOBILE BACKDROP
   ================================================================= */

#sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    /* sits above z-fixed (1030) but below the side panel (1050) */
    z-index: 1035;
    backdrop-filter: blur(2px);
}

#sidebar-backdrop.is-visible {
    display: block;
}

/* =================================================================
   TABLET LAYOUT (1024px and below)
   ================================================================= */

@media (max-width: 1024px) {
    .side-panel {
        width: 320px;
    }

    .map-footer {
        margin-left: 0;
        width: 100%;
    }

    .map-footer nav {
        gap: var(--spacing-sm);
    }
}

/* =================================================================
   MOBILE LAYOUT (800px and below)
   ================================================================= */

@media (max-width: 800px) {

    /* --- App container --- */
    .app-container {
        flex-direction: column;
        height: 100vh;
    }

    /* --- Topbar: title + search on one row --- */
    .topbar-lower {
        flex-direction: row;
        align-items: center;
        gap: 0.6rem;
        padding: 0.5rem 1rem;
    }

    .topbar-title {
        font-size: 1.4rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .topbar-search {
        flex: 1 1 auto;
        min-width: 0;
        max-width: 300px;
    }

    /* --- Active state pills: hidden on mobile --- */
    .side-panel-active-state {
        display: none !important;
    }

    /* --- Side panel: fixed bottom drawer --- */
    .side-panel {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 85vh;
        /* Start off-screen; .is-open slides it up */
        transform: translateY(110%);
        transition: transform var(--transition-base);
        border-right: none;
        border-top: 1px solid rgba(15, 23, 42, 0.08);
        border-radius: 1.5rem 1.5rem 0 0;
        box-shadow: var(--shadow-xl);
        background-color: #f2f2f3;
        z-index: 1050;
        /* Allow the content inside to scroll */
        overflow: visible;
    }

    .side-panel.is-open {
        transform: translateY(0);
    }

    /* On mobile, is-collapsed just means off-screen — same as not open */
    .side-panel.is-collapsed {
        display: flex; /* keep in DOM for animation */
        transform: translateY(110%);
        height: 85vh;
    }

    /* Side panel content scrolls independently */
    .side-panel-content {
        position: relative;
        z-index: 1;
        height: 100%;
        overflow-y: scroll; /* scroll instead of auto for mobile reliability */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: 5rem; /* clear the footer */
    }

    /* Panel header hidden on mobile */
    .panel-header {
        display: none;
    }

    /* --- Map container: full screen --- */
    .map-container {
        width: 100%;
        height: 100vh;
        padding-top: 0;
        padding-bottom: 0;
        box-sizing: border-box;
    }

    .map-canvas {
        width: 100%;
        height: 100%;
    }

    /* --- Map controls --- */
    .map-controls {
        bottom: calc(82px + env(safe-area-inset-bottom, 0px));
        right: var(--spacing-md);
    }

    /* --- Footer: fixed single line at bottom --- */
    .map-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        margin: 0;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 0.2rem 0.65rem;
        padding: 0.3rem 0.75rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
        font-size: 0.68rem;
        z-index: 1020; /* below backdrop and panel */
        background-color: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(8px);
        border-top: 1px solid rgba(15, 23, 42, 0.08);
    }

    .map-footer nav {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 0.2rem 0.65rem;
        width: auto;
    }

    .map-footer-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 0.2rem 0.65rem;
        width: auto;
    }

    #ot-sdk-btn.ot-sdk-show-settings,
    .cookie-settings {
        width: auto !important;
    }

    .app-container:has(.info-panel.is-open) ~ .map-footer {
        margin-left: 0;
        width: 100%;
    }
}

/* =================================================================
   SMALL MOBILE (480px and below)
   ================================================================= */

@media (max-width: 480px) {
    .map-footer {
        font-size: 9px;
    }

    .map-controls {
        right: var(--spacing-sm);
        bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    }
}
