/* ================================================================
   Hantavirus Tracker — Dark Theme
   Inspired by Raycast / Linear
   ================================================================ */

/* ── Reset & Base ─────────────────────────────────────────────── */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg:          #0A0A0B;
    --surface:     rgba(22, 22, 30, 0.75);
    --surface-solid: #16161E;
    --border:      rgba(255, 255, 255, 0.08);
    --text:        #F5F5F7;
    --text-secondary: #8A8A9A;
    --text-muted:  #555566;

    /* Danger palette */
    --danger-nodata:   #16161E;
    --danger-none:     #1A1A2E;
    --danger-low:      #F59E0B;
    --danger-moderate: #F97316;
    --danger-high:     #EF4444;
    --danger-critical: #DC2626;

    --glass-bg:    rgba(16, 16, 24, 0.70);
    --glass-blur:  16px;

    --radius:      12px;
    --radius-sm:   8px;

    --nav-height:  56px;
    --footer-height: 36px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --transition:  0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button {
    font-family: inherit;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

ul { list-style: none; }


/* ── Nav ──────────────────────────────────────────────────────── */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border);
}

.nav__left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav__logo {
    display: flex;
    align-items: center;
}

.nav__title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.nav__links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav__link {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.nav__link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.nav__hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.nav__hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: transform var(--transition), opacity var(--transition);
}

.nav__hamburger.is-open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.nav__hamburger.is-open span:nth-child(2) {
    opacity: 0;
}
.nav__hamburger.is-open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}


/* ── Map ──────────────────────────────────────────────────────── */

#map {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: var(--footer-height);
    z-index: 1;
    background: var(--bg);
}

.leaflet-container {
    background: var(--bg) !important;
}

/* Override Leaflet controls to match dark theme */
.leaflet-control-zoom a {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur)) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur)) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-size: 16px !important;
    border-radius: var(--radius-sm) !important;
    transition: background var(--transition) !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.leaflet-control-zoom {
    border: none !important;
    border-radius: var(--radius-sm) !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none !important;
}

.leaflet-control-attribution {
    display: none !important;
}

.leaflet-interactive {
    outline: none !important;
}

.leaflet-interactive:focus {
    outline: none !important;
}

/* Leaflet tooltip override */
.leaflet-tooltip-pane {
    z-index: 700 !important;
}

.leaflet-tooltip {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur)) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur)) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: var(--radius-sm) !important;
    padding: 8px 12px !important;
    font-family: var(--font) !important;
    font-size: 13px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4) !important;
}

.leaflet-tooltip::before {
    display: none !important;
}

.tooltip-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.tooltip-cases {
    color: var(--text-secondary);
    font-size: 12px;
}

.tooltip-risk {
    display: inline-block;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tooltip-risk--critical { background: var(--danger-critical); color: #fff; }
.tooltip-risk--high     { background: var(--danger-high); color: #fff; }
.tooltip-risk--moderate { background: var(--danger-moderate); color: #fff; }
.tooltip-risk--low      { background: var(--danger-low); color: #000; }
.tooltip-risk--none     { background: var(--danger-none); color: var(--text-secondary); border: 1px solid var(--border); }


/* ── Stats Panel ──────────────────────────────────────────────── */

.stats {
    position: fixed;
    top: calc(var(--nav-height) + 16px);
    right: 16px;
    z-index: 800;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 14px 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.stats__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 16px;
}

.stats__value {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.stats__value--deaths {
    color: var(--danger-high);
}

.stats__label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
}

.stats__divider {
    width: 1px;
    height: 32px;
    background: var(--border);
}


/* ── Legend ────────────────────────────────────────────────────── */

.legend {
    position: fixed;
    bottom: calc(var(--footer-height) + 16px);
    left: 16px;
    z-index: 800;
    padding: 14px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.legend__title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.legend__items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend__item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend__color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend__text {
    font-size: 12px;
    color: var(--text-secondary);
}


/* ── Detail Panel ─────────────────────────────────────────────── */

.detail {
    position: fixed;
    top: var(--nav-height);
    right: 0;
    bottom: var(--footer-height);
    width: 340px;
    z-index: 900;
    background: var(--surface-solid);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.detail.is-open {
    transform: translateX(0);
}

.detail__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    font-size: 20px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}

.detail__close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.detail__header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.detail__flag {
    font-size: 32px;
    line-height: 1;
}

.detail__name {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 8px;
}

.detail__badge {
    display: inline-block;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail__badge--critical { background: var(--danger-critical); color: #fff; }
.detail__badge--high     { background: var(--danger-high); color: #fff; }
.detail__badge--moderate { background: var(--danger-moderate); color: #fff; }
.detail__badge--low      { background: var(--danger-low); color: #000; }
.detail__badge--none     { background: var(--danger-none); color: var(--text-secondary); border: 1px solid var(--border); }
.detail__badge--no_data  { background: var(--danger-nodata); color: var(--text-muted); border: 1px solid var(--border); }

.detail__body {
    padding: 20px;
    flex: 1;
}

.detail__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.detail__row:last-child {
    border-bottom: none;
}

.detail__row-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.detail__row-value {
    font-size: 14px;
    font-weight: 600;
}

.detail__notes {
    margin-top: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.detail__notes-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}


/* ── Backdrop ─────────────────────────────────────────────────── */

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 850;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow);
}

.backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}


/* ── Modals ───────────────────────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow);
}

.modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.modal__content {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    transform: translateY(12px) scale(0.98);
    transition: transform var(--transition-slow);
}

.modal.is-open .modal__content {
    transform: translateY(0) scale(1);
}

.modal__content--wide {
    max-width: 720px;
}

.modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    font-size: 20px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}

.modal__close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.modal__title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 16px;
}

.modal p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.modal__section {
    margin-top: 20px;
}

.modal__section h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.modal__section ul {
    padding-left: 0;
}

.modal__section li {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 0;
    padding-left: 14px;
    position: relative;
}

.modal__section li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 4px;
    height: 4px;
    background: var(--text-muted);
    border-radius: 50%;
    transform: translateY(-50%);
}

.modal__disclaimer {
    font-size: 12px !important;
    color: var(--text-muted) !important;
    font-style: italic;
}


/* ── Data Table ───────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
    margin-top: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: color var(--transition);
}

.data-table th:hover {
    color: var(--text-secondary);
}

.data-table th.sorted-asc .sort-arrow::after  { content: ' \2191'; }
.data-table th.sorted-desc .sort-arrow::after { content: ' \2193'; }

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.risk-pill {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.risk-pill--critical { background: var(--danger-critical); color: #fff; }
.risk-pill--high     { background: var(--danger-high); color: #fff; }
.risk-pill--moderate { background: var(--danger-moderate); color: #fff; }
.risk-pill--low      { background: var(--danger-low); color: #000; }
.risk-pill--none     { background: var(--danger-none); color: var(--text-secondary); border: 1px solid var(--border); }


/* ── Graphs ───────────────────────────────────────────────────── */

.graphs-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.graphs-tab {
    flex: 1;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 6px;
    transition: all var(--transition);
}

.graphs-tab:hover {
    color: var(--text-secondary);
}

.graphs-tab.is-active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.graphs-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bar-rank {
    width: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
    flex-shrink: 0;
}

.bar-flag {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.bar-name {
    width: 100px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-track {
    flex: 1;
    height: 28px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.bar-fill--critical { background: linear-gradient(90deg, var(--danger-critical), #ef4444); }
.bar-fill--high     { background: linear-gradient(90deg, var(--danger-high), #f97316); }
.bar-fill--moderate { background: linear-gradient(90deg, var(--danger-moderate), #f59e0b); }
.bar-fill--low      { background: linear-gradient(90deg, var(--danger-low), #eab308); }
.bar-fill--none     { background: rgba(255, 255, 255, 0.1); }

.bar-value {
    width: 40px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    text-align: right;
    flex-shrink: 0;
}

.bar-value--zero {
    color: var(--text-muted);
}


/* ── Footer ───────────────────────────────────────────────────── */

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 800;
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-top: 1px solid var(--border);
}


/* ── Mobile ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .nav__hamburger {
        display: flex;
    }

    .nav__links {
        position: fixed;
        top: var(--nav-height);
        right: 0;
        width: 200px;
        background: var(--surface-solid);
        border: 1px solid var(--border);
        border-top: none;
        border-radius: 0 0 0 var(--radius);
        flex-direction: column;
        padding: 8px;
        gap: 2px;
        transform: translateX(100%);
        opacity: 0;
        transition: transform var(--transition-slow), opacity var(--transition);
    }

    .nav__links.is-open {
        transform: translateX(0);
        opacity: 1;
    }

    .nav__link {
        width: 100%;
        text-align: left;
        padding: 10px 14px;
    }

    /* Stats panel → horizontal compact bar */
    .stats {
        top: calc(var(--nav-height) + 8px);
        left: 8px;
        right: 8px;
        padding: 10px 12px;
        justify-content: space-around;
    }

    .stats__item {
        padding: 0 8px;
    }

    .stats__value {
        font-size: 16px;
    }

    .stats__label {
        font-size: 9px;
    }

    .stats__divider {
        height: 24px;
    }

    /* Legend → smaller */
    .legend {
        bottom: calc(var(--footer-height) + 8px);
        left: 8px;
        padding: 10px 12px;
    }

    .legend__items {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px 16px;
    }

    /* Detail panel → bottom sheet */
    .detail {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 65vh;
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: var(--radius) var(--radius) 0 0;
        transform: translateY(100%);
    }

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

    .detail__header {
        padding: 20px 16px 12px;
    }

    .detail__header::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--text-muted);
        border-radius: 2px;
        margin: 0 auto 12px;
    }

    /* Modals → full-width on small screens */
    .modal {
        padding: 12px;
    }

    .modal__content {
        max-height: 85vh;
        padding: 24px;
    }

    /* Footer → stack if too tight */
    .footer {
        font-size: 10px;
        padding: 0 12px;
    }
}

@media (max-width: 480px) {
    .stats__label {
        display: none;
    }

    .stats__value {
        font-size: 15px;
    }

    .stats {
        padding: 8px 10px;
    }
}


/* ── Splash Screen ────────────────────────────────────────────── */

.splash {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.splash.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: splashFadeIn 0.6s ease both;
}

.splash__icon {
    animation: splashPulse 2s ease-in-out infinite;
}

.splash__title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}

.splash__sub {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.splash__loader {
    width: 120px;
    height: 2px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 1px;
    overflow: hidden;
    margin-top: 8px;
}

.splash__loader span {
    display: block;
    width: 40%;
    height: 100%;
    background: #22C55E;
    border-radius: 1px;
    animation: splashLoad 1.2s ease-in-out infinite;
}

@keyframes splashFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes splashPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

@keyframes splashLoad {
    0%   { transform: translateX(-100%); }
    50%  { transform: translateX(200%); }
    100% { transform: translateX(-100%); }
}


/* ── Scrollbar ────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
