/* ============================================
   HantaVirus Global Tracker - Styles
   ============================================ */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-panel: rgba(16, 16, 26, 0.92);
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-hover: rgba(255, 68, 68, 0.08);
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted: #555570;
    --accent: #ff4444;
    --accent-glow: rgba(255, 68, 68, 0.3);
    --accent-soft: #ff6b6b;
    --warning: #ffaa33;
    --success: #44cc88;
    --danger: #ff3333;
    --border: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(255, 68, 68, 0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --panel-width: 340px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ---- Loading Screen ---- */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    text-align: center;
}

.virus-icon {
    animation: spin 4s linear infinite;
    margin-bottom: 24px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-content h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

.loader-content p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 12px;
}

.loading-bar {
    width: 200px;
    height: 3px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto;
}

.loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-soft));
    border-radius: 3px;
    animation: loading 2s ease-in-out forwards;
}

@keyframes loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* ---- Header ---- */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.6rem;
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo h1 .accent {
    color: var(--accent);
}

.badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.live-badge {
    background: rgba(255, 68, 68, 0.12);
    color: var(--accent);
    border: 1px solid var(--border-accent);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.header-right {
    display: flex;
    gap: 12px;
}

.stat-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 100px;
}

.stat-chip.danger { border-color: rgba(255, 51, 51, 0.2); }
.stat-chip.warning { border-color: rgba(255, 170, 51, 0.2); }

.stat-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-chip.danger .stat-value { color: var(--danger); }
.stat-chip.warning .stat-value { color: var(--warning); }

/* ---- Main Layout ---- */
main {
    position: relative;
    height: 100vh;
    width: 100vw;
}

#globe-container {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* ---- AI Brief ---- */
.ai-brief {
    position: fixed;
    top: 74px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 92;
    width: min(680px, calc(100vw - 740px));
    min-width: 280px;
    background: var(--bg-panel);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius);
    padding: 10px 14px;
    backdrop-filter: blur(24px);
    box-shadow: var(--shadow);
}

.ai-brief-title {
    font-size: 0.62rem;
    letter-spacing: 1.3px;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 4px;
}

.ai-brief-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ai-runtime-badge {
    font-size: 0.58rem;
    letter-spacing: 0.8px;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 2px 8px;
    white-space: nowrap;
}

.ai-runtime-badge.live {
    color: var(--success);
    border-color: rgba(68, 204, 136, 0.3);
    background: rgba(68, 204, 136, 0.1);
}

#ai-brief-text {
    font-size: 0.76rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ---- Panels ---- */
.panel {
    position: fixed;
    top: 72px;
    bottom: 52px;
    width: var(--panel-width);
    z-index: 50;
    background: var(--bg-panel);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

#left-panel {
    left: 16px;
}

#right-panel {
    right: 16px;
}

.panel-header {
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

#search-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: var(--accent);
}

#search-input::placeholder {
    color: var(--text-muted);
}

/* ---- Year Filter ---- */
.year-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.year-filter-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.year-filter-select {
    flex: 1;
    padding: 6px 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.72rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.year-filter-select:hover,
.year-filter-select:focus {
    border-color: var(--accent);
}

.year-filter-select option {
    background: #0a0a0f;
    color: var(--text-primary);
}

/* ---- Country List ---- */
.country-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* ---- AI Alerts ---- */
.ai-alerts {
    display: none;
    border-bottom: 1px solid var(--border);
    padding: 10px;
    max-height: 130px;
    overflow-y: auto;
}

.ai-alerts.visible {
    display: block;
}

.ai-alert-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(255, 170, 51, 0.06);
    border: 1px solid rgba(255, 170, 51, 0.2);
    border-radius: 8px;
    padding: 7px 9px;
    margin-bottom: 6px;
}

.ai-alert-item:last-child {
    margin-bottom: 0;
}

.ai-alert-label {
    font-size: 0.7rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.ai-alert-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.64rem;
    color: var(--warning);
    white-space: nowrap;
}

.country-list::-webkit-scrollbar {
    width: 4px;
}

.country-list::-webkit-scrollbar-track {
    background: transparent;
}

.country-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.country-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.country-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
}

.country-item.active {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.country-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.country-flag {
    font-size: 1.3rem;
    width: 28px;
    text-align: center;
}

.country-name {
    font-size: 0.82rem;
    font-weight: 500;
}

.country-region {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.country-ai-flag {
    margin-top: 2px;
    font-size: 0.58rem;
    letter-spacing: 0.4px;
    color: var(--warning);
    text-transform: uppercase;
}

.country-cases {
    text-align: right;
}

.country-cases-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
}

.country-deaths-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ---- Severity indicator ---- */
.severity-bar {
    width: 3px;
    height: 24px;
    border-radius: 3px;
    flex-shrink: 0;
}

.severity-low { background: var(--success); }
.severity-medium { background: var(--warning); }
.severity-high { background: var(--accent); }
.severity-critical { background: var(--danger); }

/* ---- Country Details Panel ---- */
#country-details {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ---- Ask the Data ---- */
.ai-assistant {
    border-top: 1px solid var(--border);
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.ai-assistant-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--success);
    font-weight: 700;
    margin-bottom: 8px;
}

.ai-assistant-controls {
    display: flex;
    gap: 8px;
}

#ai-question {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.74rem;
    outline: none;
}

#ai-question:focus {
    border-color: var(--success);
}

#ai-ask-btn {
    border: 1px solid rgba(68, 204, 136, 0.3);
    background: rgba(68, 204, 136, 0.12);
    color: var(--success);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
}

#ai-ask-btn:hover {
    background: rgba(68, 204, 136, 0.2);
}

.ai-answer {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.45;
    min-height: 34px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 16px;
}

.empty-state p {
    font-size: 0.8rem;
    line-height: 1.5;
    max-width: 200px;
}

.detail-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.detail-flag {
    font-size: 3rem;
    margin-bottom: 8px;
}

.detail-country-name {
    font-size: 1.15rem;
    font-weight: 700;
}

.detail-region {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.detail-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.detail-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.detail-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
}

.detail-stat-value.cases { color: var(--accent); }
.detail-stat-value.deaths { color: var(--danger); }
.detail-stat-value.rate { color: var(--warning); }
.detail-stat-value.strain { color: var(--success); font-size: 0.85rem; }

.detail-stat-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.detail-section {
    margin-bottom: 16px;
}

.detail-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

.detail-info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.detail-info-label {
    color: var(--text-secondary);
}

.detail-info-value {
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

.detail-description {
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid var(--border);
}

/* ---- Tooltip ---- */
.tooltip {
    position: fixed;
    z-index: 200;
    padding: 10px 14px;
    background: rgba(10, 10, 20, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s, transform 0.2s;
    max-width: 220px;
}

.tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.tooltip-country {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.tooltip-cases {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent);
}

/* ---- Footer ---- */
#footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 0 24px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
}

.footer-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Outbreak News Ticker ---- */
#news-ticker {
    position: fixed;
    bottom: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    width: 480px;
    max-width: calc(100vw - 32px);
    background: var(--bg-panel);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.news-ticker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
}

.news-ticker-badge {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--accent);
    background: rgba(255, 68, 68, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
}

.news-ticker-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.news-ticker-close:hover {
    color: var(--text-primary);
}

.news-ticker-list {
    padding: 6px 0;
}

.news-ticker-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 6px 14px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.2s;
}

.news-ticker-item:hover {
    background: var(--bg-hover);
}

.news-ticker-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.news-ticker-title {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.footer-label {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.footer-value {
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
}

.footer-value a {
    color: var(--accent);
    text-decoration: none;
}

.footer-value a:hover {
    text-decoration: underline;
}

.footer-separator {
    width: 1px;
    height: 16px;
    background: var(--border);
}

/* ---- Ring Animation on Points ---- */
@keyframes ringPulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}

/* ---- Mobile Toggle Buttons ---- */
.mobile-toggle {
    display: none;
    position: fixed;
    z-index: 60;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-accent);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: background 0.2s, transform 0.2s;
}

.mobile-toggle:active {
    transform: scale(0.92);
}

.mobile-toggle.active {
    background: var(--accent);
    color: #fff;
}

#toggle-left {
    bottom: 56px;
    left: 12px;
}

#toggle-right {
    bottom: 56px;
    right: 12px;
}

/* ---- Responsive ---- */
@media (max-width: 1200px) {
    :root { --panel-width: 280px; }
}

@media (max-width: 900px) {
    .ai-brief {
        top: 62px;
        width: calc(100vw - 20px);
        min-width: 0;
        padding: 8px 10px;
        max-height: 78px;
        overflow: hidden;
    }

    #ai-brief-text {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .mobile-toggle {
        display: flex;
    }

    #news-ticker {
        bottom: 96px;
        width: calc(100vw - 24px);
        max-height: 140px;
        overflow-y: auto;
    }

    #header {
        height: 58px;
        padding: 0 12px;
    }

    .header-left {
        gap: 8px;
    }

    .logo h1 {
        font-size: 0.9rem;
        line-height: 1;
    }

    .logo-icon {
        font-size: 1.3rem;
    }

    .header-nav {
        display: none;
    }

    .header-right {
        display: none;
    }

    #left-panel, #right-panel {
        position: fixed;
        top: 150px;
        bottom: 110px;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 14px 14px 0 0;
        z-index: 55;
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .panel-header {
        padding: 12px 14px 10px;
    }

    .country-item {
        padding: 12px 10px;
    }

    .country-cases-count {
        font-size: 0.95rem;
    }

    .country-name {
        font-size: 0.88rem;
    }

    #left-panel.mobile-visible,
    #right-panel.mobile-visible {
        transform: translateY(0);
    }

    #footer {
        height: 58px;
        gap: 12px;
        padding: 0 12px;
        font-size: 0.6rem;
        flex-wrap: wrap;
        justify-content: center;
        overflow: hidden;
    }

    .footer-item {
        gap: 4px;
    }

    .footer-separator:nth-child(n+4) {
        display: none;
    }

    .footer-item:nth-child(n+5) {
        display: none;
    }

    .panel {
        bottom: 110px;
    }

    #toggle-left {
        bottom: 70px;
        left: 10px;
    }

    #toggle-right {
        bottom: 70px;
        right: 10px;
    }

    .country-list {
        padding-bottom: 18px;
    }

    #country-details {
        padding-bottom: 20px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 0.78rem;
    }

    .ai-brief {
        top: 60px;
    }

    .ai-brief-title {
        font-size: 0.56rem;
        letter-spacing: 1px;
    }

    #ai-brief-text {
        font-size: 0.72rem;
    }

    .live-badge {
        display: none;
    }

    #footer {
        gap: 8px;
    }

    .footer-separator:nth-child(n+2) {
        display: none;
    }

    .footer-item:nth-child(n+3) {
        display: none;
    }
}
