/* ==========================================================================
   MAP CSS - v8.6.0 Solaris Expanse
   Map Canvas, Left-Hand Panel, Country Header, Sync Status
   ========================================================================== */


/* ==========================================================================
   1. MAP CANVAS
   ========================================================================== */

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

.maplibregl-ctrl-bottom-right {
    margin-bottom: 60px;
    margin-right: 15px;
}


/* ==========================================================================
   2. LEFT-HAND PANEL
   ========================================================================== */

#left-hand-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 380px;
    max-height: 90vh;
    z-index: 100;
    display: none;
    flex-direction: column;
    background: rgba(241, 240, 236, 0.1);
    border: 1px solid rgba(184, 134, 11, 0.3);
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(15px);
}

#feed-container {
    overflow-y: auto;
    flex-grow: 1;
}

.prediction-entry {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    background: transparent;
}

.prediction-entry div {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-main);
}

#close-panel {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(91, 88, 88, 0.5);
    color: var(--card-bg);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background 0.2s ease;
}

#close-panel:hover {
    background: rgba(255, 255, 255, 0.4);
}


/* ==========================================================================
   3. COUNTRY HEADER GRID
   ========================================================================== */

.header-grid-container {
    display: grid;
    grid-template-columns: 80px 1fr 130px;
    grid-template-rows: 60px 30px;
    height: 90px;
    margin: 15px 15px 10px;
    border-radius: 4px;
    border-bottom: 1px solid rgba(184, 134, 11, 0.2);
    background: transparent;
    backdrop-filter: blur(8px);
}

.grid-box-flag {
    grid-area: 1 / 1 / 2 / 2;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: transparent;
}

.flag-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grid-box-name {
    grid-area: 1 / 2 / 2 / 3;
    display: flex;
    align-items: center;
    padding-left: 15px;
    background: transparent;
}

#ui-country {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.grid-box-predictions {
    grid-area: 2 / 1 / 3 / 3;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
}

#ui-count-badge {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 400;
    text-transform: uppercase;
}

.grid-box-econ-stack > div,
.econ-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-main);
    text-transform: uppercase;
    text-align: left;
    padding: 2px 10px;
    line-height: 1.2;
    word-wrap: break-word;
    border-bottom: 0.5px solid var(--border);
}

#ui-inflation {
    border-bottom: none;
}


/* ==========================================================================
   4. SYNC STATUS BOX
   ========================================================================== */

#sync-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
}

#system-status-box {
    display: none;
    margin-bottom: 8px;
    padding: 20px;
    min-width: 220px;
    background: white;
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    font-size: 11px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

@media (hover: hover) {
    #sync-container:hover #system-status-box { display: block; }
}

.status-meta {
    margin-bottom: 10px;
    padding-bottom: 5px;
    font-size: 9px;
    font-weight: 800;
    color: var(--accent);
    border-bottom: 1px solid #eee;
}

.status-row {
    margin-bottom: 6px;
    color: var(--text-muted);
    font-family: monospace;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    color: #64748b;
    font-weight: 500;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.dot.red    { background: #ef4444; }
.dot.orange { background: #f97316; }
.dot.yellow { background: #fbbf24; }

.sync-label {
    font-size: 10px;
    font-weight: 600;
    color: #546379;;
}


/* ==========================================================================
   5. DARK MODE OVERRIDES
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    #left-hand-panel .prediction-entry,
    #left-hand-panel .prediction-entry div,
    #left-hand-panel .prediction-text,
    #left-hand-panel #ui-country,
    #left-hand-panel #ui-count-badge,
    #left-hand-panel .econ-item,
    #left-hand-panel .grid-box-econ-stack > div {
        color: #000000 !important;
    }
}


/* ==========================================================================
   6. MOBILE OVERRIDES  (max-width: 768px)
   ========================================================================== */

@media (max-width: 768px) {

    #page-map {
        left: 0 !important;
        width: 100%;
        bottom: 65px !important;
    }

    /* Panel slides up from the bottom as a sheet */
    #left-hand-panel {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 55vh !important;
        max-height: unset;
        flex-direction: column !important;
        display: none;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        pointer-events: none !important;
    }

    #left-hand-panel > * {
        pointer-events: auto !important;
        width: 100% !important;
        margin: 0 !important;
        background: transparent !important;
    }

    #feed-container {
        flex-grow: 1 !important;
        height: 100% !important;
        width: 100% !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y !important;
        background: transparent !important;
        padding-bottom: 80px !important;
        pointer-events: auto !important;
    }

    .header-grid-container {
        padding-bottom: 0;
    }

    .prediction-entry {
        width: 100% !important;
        margin: 0 !important;
        padding: 15px 10px !important;
        border: none !important;
        border-bottom: 1px solid rgba(148, 150, 153, 0.3) !important;
        border-radius: 0 !important;
        background: rgba(241, 240, 236, 0.1) !important;
        backdrop-filter: blur(8px) saturate(180%);
        -webkit-backdrop-filter: blur(8px) saturate(180%);
    }

    /* Close button grows slightly for easier touch target */
    #close-panel {
        width: 36px !important;
        height: 36px !important;
        font-size: 22px !important;
        line-height: 36px !important;
        background: rgba(91, 88, 88, 0.5) !important;
        color: var(--card-bg) !important;
        border: 1px solid rgba(181, 177, 177, 0.86) !important;
    }

    #close-panel:hover,
    #close-panel:active {
        background: rgba(255, 59, 48, 0.7) !important;
    }

    /* Sync container fixed above the bottom nav bar */
    #sync-container {
        position: fixed !important;
        bottom: 70px !important;
        left: 10px !important;
        z-index: 20000 !important;
        display: block !important;
        pointer-events: auto !important;
    }

    #sync-container.hidden-state {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    #system-status-box {
        display: none;
        position: absolute;
        bottom: 35px;
        left: 0;
        min-width: 200px;
        padding: 12px;
        background: rgba(253, 251, 247, 0.98) !important;
        border: 1px solid var(--accent);
        border-radius: 8px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    }

    #system-status-box.mobile-reveal {
        display: block !important;
    }
}