/* ═══════════════════════════════════════════════════
   globe.css — Institutional Terminal UI (V2)
   Aesthetic: White & Blue Theme (Responsive)
   ═══════════════════════════════════════════════════ */

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

@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;700&family=Inter:wght@400;600;700;800&display=swap');

:root {
    --bg-base: #f8fafc;        /* Light canvas */
    --panel-bg: rgba(255, 255, 255, 0.9); /* Translucent panels */
    --border-color: #e2e8f0;   /* Clean borders */
    --text-main: #0f172a;
    --text-muted: #475569;
    
    /* Terminal Signal Colors */
    --signal-bearish: #ef4444; /* Red-500 */
    --signal-bullish: #10b981; /* Emerald-500 */
    --signal-neutral: #94a3b8; /* Slate-400 */
    --signal-accent: #6366f1;  /* Indigo-500 */

    --font-mono: 'Roboto Mono', monospace;
    --font-sans: 'Inter', sans-serif;
    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.08); /* Unified softer shadow */
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    background-image: radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%),
                      radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

body::before {
    display: none;
}

/* ── Typography & Basics ── */
.mono { font-family: var(--font-mono); }
.text-bearish { color: var(--signal-bearish) !important; font-weight: 600; }
.text-bullish { color: var(--signal-bullish) !important; font-weight: 600; }
.text-neutral { color: var(--signal-neutral) !important; font-weight: 600; }
.text-accent { color: var(--signal-accent) !important; font-weight: 600; }

/* ── Panel Common ── */
.terminal-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    border-radius: 12px;
    overflow: hidden;
}

.panel-header {
    background: #f1f5f9;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-main);
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── Top Header / Command Bar ── */
.command-bar {
    position: fixed;
    top: 16px; left: 16px; right: 16px;
    height: 54px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.sys-title {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--signal-accent), #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cmd-btn {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.cmd-btn:hover { background: #f8fafc; border-color: var(--signal-accent); transform: translateY(-1px); box-shadow: 0 4px 6px rgba(0,0,0,0.05); }

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--signal-bullish);
    background: #ffffff;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.status-dot {
    width: 8px; height: 8px;
    background: var(--signal-bullish);
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.2); } 100% { opacity: 1; transform: scale(1); } }

@keyframes pulse { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.2); } 100% { opacity: 1; transform: scale(1); } }

/* ── Top Indices Bar ── */
.top-indices-bar {
    position: absolute;
    top: 76px;
    left: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    justify-content: center;
    gap: 16px;
    pointer-events: auto;
}

.index-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 250px;
    transition: transform 0.2s;
}

.index-info {
    display: flex;
    flex-direction: column;
}

.index-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.index-price {
    font-size: 1.15rem;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-main);
}

.index-change {
    text-align: right;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    font-weight: 700;
}

/* ── Main Layout ── */
#globeViz {
    width: 100vw;
    height: 100vh;
    cursor: crosshair;
    pointer-events: auto; /* Restores drag/scroll on desktop */
}

/* ── Layout Wrapper ── */
.main-layout {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; height: 100vh;
    pointer-events: none;
}

/* ── Left Data Column ── */
.left-column {
    pointer-events: auto;
    position: absolute;
    top: 156px; left: 16px; bottom: 50px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 90;
}

.risk-panel, .sector-panel {
    flex-shrink: 0;
}

.risk-table {
    width: 100%;
    border-collapse: collapse;
}

.risk-row {
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    display: flex;
    align-items: stretch;
    transition: background 0.2s;
}
.risk-row:last-child { border-bottom: none; }
.risk-row:hover { background: #f8fafc; }

.risk-cell {
    padding: 10px 12px;
    display: flex;
    align-items: center;
}

.risk-col-city { flex: 1; font-weight: 600; color: var(--text-main); }
.risk-col-score { width: 70px; justify-content: flex-end; font-weight: 700; }
.risk-col-meter { width: 90px; padding: 0 12px; }

.meter-bg {
    width: 100%; height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}
.meter-fill {
    height: 100%;
    position: absolute; left: 0; top: 0;
    border-radius: 3px;
}

/* ── Right: Live Intelligence Feed ── */
.feed-panel {
    pointer-events: auto;
    position: absolute;
    top: 156px; right: 16px; bottom: 50px;
    width: 400px;
    display: flex;
    flex-direction: column;
    z-index: 90;
}

.feed-filters {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
}
.filter-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 10px 0;
    cursor: pointer;
    transition: all 0.2s;
}
.filter-btn:last-child { border-right: none; }
.filter-btn:hover { background: #f8fafc; color: var(--text-main); }
.filter-btn.active { background: #f1f5f9; color: var(--signal-accent); font-weight: 700; box-shadow: inset 0 -2px 0 var(--signal-accent); }

.ticker-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(255, 255, 255, 0.5);
}

.ticker-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
}
.ticker-item:hover { background: #ffffff; box-shadow: inset 2px 0 0 var(--signal-accent); }

.ticker-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
}

.ticker-time { color: var(--signal-accent); background: #dbeafe; padding: 2px 6px; border-radius: 4px; }
.ticker-source { color: var(--text-muted); }
.ticker-city { color: var(--text-main); }

.ticker-sentiment {
    padding: 2px 6px;
    font-weight: 800;
    border-radius: 4px;
    color: #fff;
}
.ticker-sentiment.BEARISH { background: var(--signal-bearish); }
.ticker-sentiment.BULLISH { background: var(--signal-bullish); }
.ticker-sentiment.NEUTRAL { background: var(--signal-neutral); }

.ticker-headline {
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 1.5;
    font-weight: 500;
}

/* ── Bottom: System Status Bar ── */
.sys-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 34px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    gap: 24px;
}

/* ── Loading Overlay ── */
.terminal-loader {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    border-radius: 12px;
    padding: 24px 32px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    z-index: 200;
    text-align: center;
    transition: opacity 0.5s;
}
.terminal-loader.hidden { opacity: 0; pointer-events: none; }
.loader-cursor {
    display: inline-block;
    width: 6px; height: 12px;
    background: var(--signal-accent);
    animation: blink 1s step-end infinite;
    vertical-align: middle;
    margin-left: 4px;
}
@keyframes blink { 50% { opacity: 0; } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Mobile Responsiveness (MAX-WIDTH 768px) ── */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .command-bar {
        position: relative;
        top: 0; left: 0; right: 0;
        padding: 12px;
        height: auto;
        flex-direction: column;
        gap: 12px;
        border-radius: 0;
        background: #f8fafc;
        border: none;
        border-bottom: 1px solid var(--border-color);
        box-shadow: none;
    }

    .main-layout {
        position: relative;
        top: 0; left: 0; right: 0; bottom: auto;
        width: 100%; height: auto;
        display: flex;
        flex-direction: column;
        padding: 12px;
        gap: 16px;
        pointer-events: auto;
    }

    /* Reset absolute positioning from desktop */
    #globeViz, .left-column, .feed-panel, .top-indices-bar {
        position: relative;
        top: auto; left: auto; right: auto; bottom: auto;
        z-index: 1;
    }

    .top-indices-bar {
        flex-direction: column;
        width: 100%;
        padding: 0;
        gap: 12px;
        order: 0;
    }

    .index-card {
        width: 100%;
    }

    /* We need to separate Risk and Sector to slot the globe in between */
    .left-column {
        display: contents;
    }

    /* 1. Globe */
    #globeViz {
        width: 100% !important;
        height: 380px !important;
        overflow: hidden;
        order: 1;
        border-radius: 12px;
        border: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #globeViz canvas {
        width: 100% !important;
        height: 100% !important;
        outline: none;
    }

    /* 2. Live Intelligence Feed panel */
    .feed-panel {
        width: 100%;
        height: 400px;
        max-height: 400px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        order: 2;
    }

    .feed-filters {
        flex-shrink: 0; 
        /* keeps the tabs pinned */
    }

    .ticker-container {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 3. Global Risk Analysis panel */
    .risk-panel {
        width: 100%;
        order: 3;
    }

    /* 4. Sector Risk Matrix panel */
    .sector-panel {
        width: 100%;
        order: 4;
    }

    .sys-footer {
        display: none;
    }

    /* Readability: min 13px */
    .panel-header { font-size: 13px; }
    .risk-row { font-size: 13px; }
    .filter-btn { font-size: 13px; }
    .ticker-headline { font-size: 13px; line-height: 1.4; }
    .ticker-meta { font-size: 13px; }
    .sys-title { font-size: 14px; }
}
