/* ============================================
   CANCER3.AI - Globe Data Explorer
   Dark theme matching main project
   ============================================ */

:root {
    --bg: #0a0e1a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-glass: rgba(10, 14, 26, 0.85);
    --text: #f0f0f0;
    --text-dim: #8a9bb5;
    --text-muted: #4a5f7a;
    --gold: #d4a012;
    --gold-glow: rgba(212, 160, 18, 0.4);
    --blue: #5b9cf6;
    --green: #22c55e;
    --red: #ef4444;
    --border: rgba(255, 255, 255, 0.08);
    --radius: 12px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
}

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

.nav-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-home {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: var(--text-dim);
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid var(--border);
}
.nav-home:hover {
    color: var(--gold);
    border-color: var(--gold);
    background: rgba(212, 160, 18, 0.08);
}

.nav-logo { text-decoration: none; color: var(--text); }
.nav-logo-text { font-size: 1rem; font-weight: 700; letter-spacing: 0.03em; }
.nav-logo-text span { color: var(--gold); }

.nav-center { position: absolute; left: 50%; transform: translateX(-50%); }
.nav-title {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.15em; color: var(--text-dim);
}
.nav-title .gold { color: var(--gold); font-weight: 800; }

.nav-right { display: flex; gap: 0.5rem; }
.stat-pill {
    padding: 0.2rem 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.02em;
}

/* === GLOBE CONTAINER === */
#globe-container {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
}

/* === LOADING OVERLAY === */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease;
}

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

.loader { text-align: center; }

.loader-ring {
    width: 48px; height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loader-text {
    font-size: 0.85rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* === INFO PANEL === */
.info-panel {
    position: fixed;
    top: 56px; right: 12px;
    width: 320px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    z-index: 90;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
}

.info-panel.hidden {
    transform: translateX(340px);
    opacity: 0;
    pointer-events: none;
}

.panel-close {
    position: absolute;
    top: 0.75rem; right: 0.75rem;
    background: none; border: none;
    color: var(--text-dim); font-size: 1.5rem;
    cursor: pointer; padding: 0.25rem;
    transition: color 0.2s;
    line-height: 1;
}
.panel-close:hover { color: var(--text); }

.panel-flag {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.panel-name {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.panel-subtitle {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-bottom: 1.25rem;
    letter-spacing: 0.03em;
}

.panel-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.panel-stat {
    text-align: center;
    padding: 0.75rem 0.4rem;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.panel-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 0.2rem;
}

.panel-stat-label {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

.panel-stat-label small {
    color: var(--text-muted);
    opacity: 0.7;
    text-transform: none;
}

/* Panel bar chart */
.panel-bar { margin-bottom: 1rem; }
.panel-bar-label {
    font-size: 0.68rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}
.panel-bar-track {
    height: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
.panel-bar-fill {
    position: absolute; top: 0; left: 0;
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.panel-bar-fill.incidence { background: var(--gold); z-index: 1; }
.panel-bar-fill.mortality { background: var(--red); opacity: 0.8; z-index: 2; }

.panel-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    line-height: 1.5;
}

/* === CONTROL BAR === */
.control-bar {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding: 0.6rem 1.2rem;
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 100px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.control-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 0.3rem;
    white-space: nowrap;
}

.control-buttons { display: flex; gap: 0.2rem; }

.ctrl-btn {
    padding: 0.35rem 0.85rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-dim);
    font-size: 0.68rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
}

.ctrl-btn:hover {
    border-color: var(--gold);
    color: var(--text);
}

.ctrl-btn.active {
    background: var(--gold);
    border-color: var(--gold);
    color: #000;
}

/* === LEGEND === */
.legend {
    position: fixed;
    bottom: 70px;
    left: 12px;
    z-index: 90;
    padding: 0.75rem 1rem;
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 180px;
}

.legend-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.legend-bar {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg,
        #1a1a4e, #1e3a6e, #2a6d8e, #3da67a, #8cc63f, #d4a012, #e85d04, #d00000);
    margin-bottom: 0.3rem;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* === SEARCH === */
.search-box {
    position: fixed;
    top: 56px; left: 12px;
    z-index: 90;
    width: 260px;
}

.search-box input {
    width: 100%;
    padding: 0.55rem 1rem;
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text);
    font-size: 0.8rem;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus { border-color: var(--gold); }

.search-box input::placeholder { color: var(--text-muted); }

.search-results {
    margin-top: 0.25rem;
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: none;
}

.search-results.visible { display: block; }

.search-result-item {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(212, 160, 18, 0.1); }
.search-result-item .flag { font-size: 1.1rem; }
.search-result-item .name { flex: 1; }
.search-result-item .pop {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* === TOOLTIP (generated by globe.gl) === */
.globe-tooltip {
    background: var(--bg-glass) !important;
    backdrop-filter: blur(16px);
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 0.6rem 0.9rem !important;
    font-family: var(--font) !important;
    color: var(--text) !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4) !important;
}

.tooltip-name {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.tooltip-value {
    font-size: 0.75rem;
    color: var(--gold);
    font-weight: 600;
}

.tooltip-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 2px; }

/* === RESPONSIVE === */
@media (max-width: 900px) {
    .control-bar {
        flex-wrap: wrap;
        border-radius: var(--radius);
        gap: 0.5rem;
        padding: 0.5rem 0.8rem;
        max-width: calc(100vw - 24px);
    }
    .control-label { display: none; }
    .info-panel { width: 280px; right: 8px; top: 52px; }
    .search-box { width: 200px; }
    .nav-right { display: none; }
}

@media (max-width: 600px) {
    .info-panel {
        width: calc(100vw - 16px);
        right: 8px; left: 8px;
        top: auto; bottom: 80px;
        max-height: 45vh;
    }
    .info-panel.hidden { transform: translateY(100%); }
    .search-box { width: calc(100vw - 24px); left: 12px; }
}

/* === TREE PANEL (category picker, left side) === */
.tree-panel {
    position: fixed;
    top: 112px;
    left: 20px;
    width: 300px;
    max-height: calc(100vh - 300px);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s, max-height 0.25s, top 0.25s;
}
.tree-panel.collapsed {
    width: 56px;
    max-height: 56px;
}
.tree-panel.collapsed .tree-body,
.tree-panel.collapsed .tree-title {
    display: none;
}
.tree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}
.tree-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.01em;
    line-height: 1.3;
}
.tree-collapse {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-dim);
    width: 24px;
    height: 24px;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
}
.tree-collapse:hover { color: var(--text); border-color: var(--gold); }
.tree-body {
    padding: 0.6rem 0.9rem 0.9rem;
    overflow-y: auto;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-dim);
}
.tree-loading {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}
.tree-branch {
    margin-bottom: 0.25rem;
}
.tree-branch > summary {
    cursor: pointer;
    padding: 0.35rem 0.35rem;
    border-radius: 4px;
    color: var(--text);
    font-weight: 500;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s;
}
.tree-branch > summary::-webkit-details-marker { display: none; }
.tree-branch > summary::before {
    content: '\25B8';
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.15s;
    display: inline-block;
    width: 0.8rem;
    text-align: center;
    flex-shrink: 0;
}
.tree-branch[open] > summary::before { transform: rotate(90deg); }
.tree-branch:hover > summary { background: rgba(255, 255, 255, 0.04); }
.tree-branch.active > summary {
    background: rgba(91, 156, 246, 0.12);
    color: var(--blue);
}
.tree-branch .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.tree-branch .icd {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 400;
    margin-left: 0.2rem;
}
.tree-children {
    margin-left: 1.25rem;
    padding-left: 0.6rem;
    border-left: 1px dashed var(--border);
    margin-top: 0.25rem;
    margin-bottom: 0.4rem;
}
.tree-leaf {
    padding: 0.3rem 0.4rem;
    font-size: 0.72rem;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.12s;
}
.tree-leaf::before {
    content: '\2013';
    color: var(--text-muted);
    margin-right: 0.3rem;
}
.tree-leaf:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}
.tree-leaf.active {
    color: var(--gold);
    background: rgba(212, 160, 18, 0.08);
    border-left: 2px solid var(--gold);
    padding-left: 0.35rem;
    font-weight: 600;
}

/* Site-button dots in the bottom control bar */
.ctrl-btn .site-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.4rem;
    vertical-align: middle;
}

@media (max-width: 900px) {
    .tree-panel { width: 260px; max-height: calc(100vh - 350px); }
}
@media (max-width: 600px) {
    .tree-panel { display: none; }
}
