/* ==========================================================================
   AurumGamma Institutional Positioning Terminal — Theme & Layout Styles
   Unified with AurumGamma Glassmorphism & Obsidian Dark Mode Design System
   ========================================================================== */

:root {
    /* Mapped directly to AurumGamma Design System Tokens */
    --bg-black: #050608;
    --bg-panel: rgba(13, 15, 18, 0.65);
    --bg-header: rgba(13, 15, 18, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(0, 240, 255, 0.35);
    --text-white: #f5f5f7;
    --text-grey: #8a8d93;
    --text-dim: #555555;
    
    /* Curated Institutional Palette (Harmonized with AurumGamma) */
    --bbg-amber: #ffcf40;
    --bbg-green: #00ff9d;
    --bbg-red: #ff3333;
    --bbg-cyan: #00f0ff;
    --bbg-purple: #df80ff;
    --bbg-blue: #3399ff;
    
    /* Glow Effects */
    --glow-amber: rgba(255, 207, 64, 0.18);
    --glow-cyan: rgba(0, 240, 255, 0.18);
    --glow-green: rgba(0, 255, 157, 0.18);
    --glow-card: 0 8px 32px rgba(0, 0, 0, 0.5);
    
    /* Font stacks */
    --font-mono: 'Share Tech Mono', 'JetBrains Mono', 'Consolas', monospace;
    --font-sans: 'Inter', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body.saas-layout, body {
    background-color: var(--bg-black);
    background-image: radial-gradient(circle at 50% 0%, #0d121c 0%, #050608 75%);
    background-attachment: fixed;
    color: var(--text-white);
    font-family: var(--font-sans);
    line-height: 1.5;
    padding: 0 15px 20px 15px;
    min-height: 100vh;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Custom Modern Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-black);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--bbg-amber);
    box-shadow: 0 0 10px var(--glow-amber);
}

.terminal-container {
    display: flex;
    flex-direction: column;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    gap: 14px;
}

/* ==========================================================================
   GLASSMORPHISM BLOCK CONTAINER UTILITY
   ========================================================================== */
.block-container {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    position: relative;
    box-shadow: var(--glow-card);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.block-container:hover {
    border-color: var(--border-hover);
    box-shadow: 0 12px 40px rgba(0, 240, 255, 0.08), var(--glow-card);
    transform: translateY(-2px);
}

.block-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--bbg-amber);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ==========================================================================
   HEADER / TICKER BAR HUD
   ========================================================================== */
.terminal-header {
    background: var(--bg-header);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 207, 64, 0.25);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    font-family: var(--font-mono);
    box-shadow: 0 4px 25px rgba(255, 207, 64, 0.06);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.terminal-tag {
    background: linear-gradient(135deg, #ffd700, #ffb900);
    color: #050608;
    padding: 3px 8px;
    font-weight: 800;
    font-size: 0.75rem;
    border-radius: 4px;
    letter-spacing: 0.05em;
    box-shadow: 0 0 12px var(--glow-amber);
}

.ticker-title {
    color: var(--text-white);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.market-code {
    color: var(--bbg-cyan);
    font-size: 0.85rem;
    font-weight: 600;
}

.dataset-flag {
    color: var(--text-grey);
    font-size: 0.78rem;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.data-quality-badge {
    color: var(--bbg-green);
    font-size: 0.82rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.data-quality-badge.provisional {
    color: var(--bbg-purple);
}

.time-clock {
    color: var(--text-grey);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ==========================================================================
   TOP PANEL: SCOREBOARD & PLAYBOOK
   ========================================================================== */
.top-panel-grid {
    display: grid;
    grid-template-columns: 1fr 1.35fr 1.35fr;
    gap: 14px;
}

.bias-block {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
}

.ticker-symbol {
    font-size: 1.15rem;
    color: var(--text-grey);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.bias-value {
    font-family: var(--font-mono);
    font-size: 2.6rem;
    font-weight: 800;
    line-height: 1.1;
    margin: 6px 0;
    color: var(--text-white);
    text-shadow: 0 0 25px rgba(255, 207, 64, 0.35);
}

.bias-meter-bg {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

.bias-meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff9900, var(--bbg-amber));
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1), background 0.4s ease;
    box-shadow: 0 0 12px var(--glow-amber);
}

.confidence-container {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    margin-top: auto;
    padding-top: 6px;
}

.confidence-container .value {
    font-weight: 800;
    color: var(--bbg-green);
    text-shadow: 0 0 10px var(--glow-green);
}

/* Summary Block styling */
.summary-block {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.summary-sentence {
    color: var(--text-white);
    font-size: 0.92rem;
    line-height: 1.6;
    margin-bottom: 12px;
    font-weight: 400;
}

.invalidation-target-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 12px;
}

.playbook-point {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.playbook-point .p-label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-grey);
    letter-spacing: 0.04em;
}

.playbook-point .p-val {
    font-family: var(--font-mono);
    font-size: 0.98rem;
    font-weight: 700;
}

.action-highlight {
    color: var(--bbg-cyan);
    text-shadow: 0 0 10px var(--glow-cyan);
}

.target-highlight {
    color: var(--bbg-green);
    text-shadow: 0 0 10px var(--glow-green);
}

/* Playbook Block styling */
.playbook-block {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.playbook-body {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.playbook-explanation {
    color: var(--text-grey);
    font-size: 0.88rem;
    line-height: 1.6;
    margin-bottom: 12px;
}

.playbook-meta {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text-dim);
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    padding-top: 8px;
}

/* ==========================================================================
   FOUR CARDS SECTION
   ========================================================================== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.card {
    min-height: 165px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.card-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-grey);
    letter-spacing: 0.04em;
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot-green { background-color: var(--bbg-green); box-shadow: 0 0 8px var(--bbg-green); }
.dot-yellow { background-color: var(--bbg-amber); box-shadow: 0 0 8px var(--bbg-amber); }
.dot-blue { background-color: var(--bbg-cyan); box-shadow: 0 0 8px var(--bbg-cyan); }
.dot-purple { background-color: var(--bbg-purple); box-shadow: 0 0 8px var(--bbg-purple); }

.card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.metric-row .m-label {
    font-size: 0.8rem;
    color: var(--text-grey);
    font-weight: 500;
}

.metric-row .m-value {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-white);
}

.metric-row-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.metric-row-sub .m-label-sub {
    color: var(--text-dim);
}

.metric-row-sub .m-value-sub {
    font-weight: 700;
}

.metric-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.06);
    margin: 6px 0;
}

.metric-row-small {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-grey);
}

.metric-row-small span:last-child {
    color: var(--text-white);
    font-weight: 700;
}

/* ==========================================================================
   CHARTS SECTION
   ========================================================================== */
.charts-section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.chart-container {
    min-height: 240px;
    display: flex;
    flex-direction: column;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 220px;
    flex-grow: 1;
}

/* ==========================================================================
   HISTORICAL TIMELINE SECTION
   ========================================================================== */
.timeline-section {
    max-height: 380px;
    display: flex;
    flex-direction: column;
}

.table-wrapper {
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-grow: 1;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
}

.timeline-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-align: left;
    white-space: nowrap;
}

.timeline-table th {
    background: rgba(13, 15, 18, 0.95);
    backdrop-filter: blur(12px);
    color: var(--bbg-amber);
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.timeline-table td {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.timeline-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.timeline-table tbody tr:hover {
    background-color: rgba(0, 240, 255, 0.06) !important;
}

.timeline-table tbody tr.selected-row {
    background-color: rgba(255, 207, 64, 0.12) !important;
    border-left: 3px solid var(--bbg-amber);
}

/* Row classification backgrounds */
.row-very-bullish { background-color: rgba(0, 255, 157, 0.08); }
.row-bullish { background-color: rgba(0, 255, 157, 0.03); }
.row-neutral { background-color: transparent; }
.row-bearish { background-color: rgba(255, 51, 51, 0.03); }
.row-very-bearish { background-color: rgba(255, 51, 51, 0.08); }

/* Color utilities for inline values */
.color-green { color: var(--bbg-green); font-weight: 700; }
.color-red { color: var(--bbg-red); font-weight: 700; }
.color-amber { color: var(--bbg-amber); font-weight: 700; }
.color-cyan { color: var(--bbg-cyan); font-weight: 700; }
.color-purple { color: var(--bbg-purple); font-weight: 700; }

/* ==========================================================================
   FOOTER / CONTROLS
   ========================================================================== */
.terminal-footer {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-grey);
}

.system-mode-badge {
    color: var(--bbg-cyan);
    font-weight: bold;
}

.system-mode-badge.firebase {
    color: var(--bbg-purple);
}

.refresh-btn {
    background: var(--bg-black);
    color: var(--bbg-amber);
    border: 1px solid var(--bbg-amber);
    padding: 5px 16px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover:not(:disabled) {
    background: var(--bbg-amber);
    color: var(--bg-black);
    box-shadow: 0 0 12px var(--glow-amber);
}

.refresh-btn:disabled {
    border-color: var(--text-dim);
    color: var(--text-dim);
    cursor: not-allowed;
}

.refresh-btn.refreshing {
    background: var(--bg-black);
    color: var(--text-dim);
    border-color: var(--text-dim);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 0.2; }
    100% { opacity: 0.6; }
}

/* ==========================================================================
   POST-AUDIT DXY CONFIRMATION ADDITIONS & BADGES
   ========================================================================== */
.sub-section-header {
    font-family: var(--font-sans);
    font-size: 0.74rem;
    font-weight: 800;
    color: var(--bbg-cyan);
    margin-top: 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 4px;
    letter-spacing: 0.05em;
}

.terminal-select {
    background: #0d121c;
    color: var(--bbg-amber);
    border: 1px solid rgba(255, 207, 64, 0.3);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.terminal-select:hover {
    border-color: var(--bbg-amber);
    box-shadow: 0 0 10px var(--glow-amber);
}

.terminal-select option {
    background: #0d121c;
    color: var(--bbg-amber);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
}

.badge-green {
    background-color: rgba(0, 255, 157, 0.15);
    color: var(--bbg-green);
    border: 1px solid rgba(0, 255, 157, 0.3);
    box-shadow: 0 0 8px var(--glow-green);
}

.badge-amber {
    background-color: rgba(255, 207, 64, 0.15);
    color: var(--bbg-amber);
    border: 1px solid rgba(255, 207, 64, 0.3);
    box-shadow: 0 0 8px var(--glow-amber);
}

.badge-red {
    background-color: rgba(255, 51, 51, 0.15);
    color: var(--bbg-red);
    border: 1px solid rgba(255, 51, 51, 0.3);
}

.badge-dark-red {
    background-color: rgba(139, 0, 0, 0.25);
    color: #ff6666;
    border: 1px solid #8b0000;
}

/* ==========================================================================
   FULL ADAPTIVE RESPONSIVENESS (MOBILE, TABLET, LAPTOP)
   ========================================================================== */
@media (max-width: 1200px) {
    .top-panel-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
}

@media (max-width: 992px) {
    .charts-section-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

@media (max-width: 768px) {
    body.saas-layout, body {
        padding: 0 10px 20px 10px;
    }
    
    .terminal-container {
        padding-top: 80px !important;
        gap: 12px;
    }

    .terminal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 14px;
    }

    .header-left, .header-right {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .cards-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .invalidation-target-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .chart-container {
        min-height: 260px;
        padding: 12px;
    }

    .canvas-wrapper {
        height: 220px;
    }

    .timeline-section {
        max-height: 420px;
    }

    .terminal-footer {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .footer-left {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .bias-value {
        font-size: 2.1rem;
    }

    .ticker-title {
        font-size: 0.9rem;
    }

    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}
