/* ═══════════════════════════════════════════════════════════════════════════
   Qx Design System — Black & Metallic Gold
   Luxury/Refined aesthetic inspired by Vertu, Rolls-Royce, High-End Watches
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Google Fonts ──────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;0,700;1,400&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
    /* Backgrounds */
    --bg-primary:    #0A0A0A;
    --bg-secondary:  #111111;
    --bg-tertiary:   #1A1A1A;
    --bg-elevated:   #222222;

    /* Gold Tones (Herzstück) */
    --gold-primary:  #C9A84C;
    --gold-light:    #E2CC7E;
    --gold-dark:     #8B7332;
    --gold-muted:    rgba(201, 168, 76, 0.15);
    --gold-gradient: linear-gradient(135deg, #C9A84C 0%, #E2CC7E 45%, #C9A84C 55%, #8B7332 100%);

    /* Text */
    --text-primary:   #F5F0E8;
    --text-secondary: #A09882;
    --text-muted:     #6B6356;

    /* Borders */
    --border-subtle:  rgba(201, 168, 76, 0.12);
    --border-default: rgba(201, 168, 76, 0.25);
    --border-strong:  #C9A84C;

    /* Semantic */
    --success: #4A7C59;
    --error:   #9B3D3D;
    --warning: #C9A84C;
    --info:    #4A6B8A;

    /* Semantic — light variants */
    --success-light:  #6AAF7B;
    --error-light:    #C45C5C;
    --info-light:     #6A9BBF;
    --success-muted:  rgba(74, 124, 89, 0.12);
    --error-muted:    rgba(155, 61, 61, 0.12);
    --info-muted:     rgba(74, 107, 138, 0.15);

    /* Supplementary (charts, data vis — all muted) */
    --accent-teal:    #5A8A7A;
    --accent-teal-light: #7AAFA0;
    --accent-purple:  #7A6BAF;
    --accent-rust:    #8B5E3C;
    --accent-slate:   #6B7B8A;

    /* Typography */
    --font-headline: 'Cormorant Garamond', 'Georgia', serif;
    --font-body:     'DM Sans', 'Segoe UI', system-ui, sans-serif;
    --font-mono:     'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;

    /* Bootstrap overrides */
    --bs-body-bg:    #0A0A0A;
    --bs-body-color: #F5F0E8;

    /* Legacy aliases for gradual migration */
    --card-bg:          var(--bg-secondary);
    --border-color:     var(--border-default);
    --text-muted-color: var(--text-secondary);
    --accent-green:     var(--gold-primary);
    --accent-red:       var(--error);
}

/* ── Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: rgba(201, 168, 76, 0.3);
    color: var(--text-primary);
}

:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.3);
}

/* ── Typography ────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-headline);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}
h1 { font-size: 2.25rem; font-weight: 300; letter-spacing: 0.04em; }
h2 { font-size: 1.75rem; font-weight: 300; letter-spacing: 0.03em; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.15rem; }
h5 { font-size: 1rem; }
h6 { font-size: .875rem; }

.font-headline { font-family: var(--font-headline); }
.font-mono { font-family: var(--font-mono); }

/* ── Links ─────────────────────────────────────────────────────────────── */
a {
    color: var(--gold-primary);
    text-decoration: none;
    transition: color 200ms ease-out;
    position: relative;
}
a:hover {
    color: var(--gold-light);
}
/* Animated underline — grows left to right */
.link-underline::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--gold-primary);
    transition: width 300ms ease-in-out;
}
.link-underline:hover::after {
    width: 100%;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }
* { scrollbar-width: thin; scrollbar-color: var(--border-default) transparent; }

/* ── Navbar ────────────────────────────────────────────────────────────── */
.navbar {
    background: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 1030;
}
.navbar-brand span {
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 0.05em;
}
.navbar-brand small {
    color: var(--text-muted) !important;
    font-family: var(--font-body);
    font-size: .75rem !important;
    letter-spacing: 0.03em;
}
.nav-link {
    color: var(--text-secondary) !important;
    font-size: .82rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: color 200ms ease-out;
    position: relative;
    padding-bottom: .4rem !important;
}
.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 1.5px;
    background: var(--gold-primary);
    transition: width 300ms ease-in-out, left 300ms ease-in-out;
}
.nav-link:hover::after, .nav-link.active::after {
    width: 100%;
    left: 0;
}
.nav-link.active, .nav-link:hover {
    color: var(--text-primary) !important;
}
.nav-link i {
    color: var(--text-muted);
    transition: color 200ms ease-out;
}
.nav-link:hover i, .nav-link.active i {
    color: var(--gold-primary);
}

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    transition: border-color 200ms ease-out;
}
.card:hover {
    border-color: var(--border-default);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-body);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-secondary);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

/* Primary CTA — Metallic Gold Gradient */
.btn-gold-primary,
.btn-primary {
    background: var(--gold-gradient);
    color: var(--bg-primary) !important;
    border: none;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: .85rem;
    letter-spacing: 0.02em;
    padding: .6rem 1.5rem;
    border-radius: 6px;
    transition: all 200ms ease-out;
    position: relative;
    overflow: hidden;
}
.btn-gold-primary:hover,
.btn-primary:hover {
    background: linear-gradient(135deg, #E2CC7E 0%, #C9A84C 45%, #E2CC7E 55%, #C9A84C 100%);
    color: var(--bg-primary) !important;
    transform: translateY(-1px);
}
.btn-gold-primary:active,
.btn-primary:active {
    transform: translateY(0);
}

/* Secondary — transparent + gold border */
.btn-gold-secondary,
.btn-outline-secondary {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--gold-primary);
    font-weight: 500;
    font-size: .82rem;
    padding: .5rem 1.2rem;
    border-radius: 6px;
    transition: all 200ms ease-out;
}
.btn-gold-secondary:hover,
.btn-outline-secondary:hover {
    border-color: var(--gold-primary);
    color: var(--gold-light);
    background: var(--gold-muted);
}

/* Ghost — gold text only */
.btn-gold-ghost {
    background: transparent;
    border: none;
    color: var(--gold-primary);
    font-weight: 500;
    padding: .5rem 1rem;
    transition: color 200ms ease-out;
}
.btn-gold-ghost:hover {
    color: var(--gold-light);
}

/* Range buttons (timeframe etc.) */
.btn-range {
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    background: transparent;
    font-family: var(--font-body);
    font-size: .78rem;
    font-weight: 500;
    padding: .25rem .65rem;
    border-radius: 4px;
    transition: all 200ms ease-out;
}
.btn-range.active, .btn-range:hover {
    border-color: var(--gold-primary);
    color: var(--gold-primary);
    background: var(--gold-muted);
}

/* Logout */
.btn-logout {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: .78rem;
    font-weight: 500;
    padding: .25rem .65rem;
    border-radius: 4px;
    transition: all 200ms ease-out;
}
.btn-logout:hover {
    border-color: var(--error);
    color: var(--error);
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-control, .form-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-body);
    border-radius: 6px;
    transition: border-color 200ms ease-out, box-shadow 200ms ease-out;
}
.form-control:focus, .form-select:focus {
    background: var(--bg-tertiary);
    border-color: var(--gold-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.3);
}
.form-control::placeholder {
    color: var(--text-muted);
}
.form-dark {
    background: var(--bg-tertiary);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}
.form-dark:focus {
    background: var(--bg-tertiary);
    border-color: var(--gold-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.2);
}
.form-label {
    color: var(--text-secondary);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .4rem;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table {
    color: var(--text-primary);
    --bs-table-bg: transparent;
}
.table thead th {
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-color: var(--border-default);
    background: var(--bg-secondary);
}
.table tbody td {
    border-color: var(--border-subtle);
    vertical-align: middle;
    font-size: .85rem;
}
.table tbody tr:hover {
    background: rgba(201, 168, 76, 0.04) !important;
    --bs-table-bg-state: rgba(201, 168, 76, 0.04);
}
.table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: rgba(201, 168, 76, 0.04);
}

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge-ticker {
    background: var(--gold-muted);
    color: var(--gold-primary);
    font-size: .72rem;
    font-weight: 600;
    padding: .2em .6em;
    border-radius: 4px;
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
}

/* ── Stat Pills ────────────────────────────────────────────────────────── */
.stat-pill {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: .5rem 1rem;
    transition: border-color 200ms ease-out;
}
.stat-pill:hover {
    border-color: var(--border-default);
}
.stat-pill .label {
    font-size: .68rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.stat-pill .value {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    margin-top: .1rem;
}

/* ── KPI ───────────────────────────────────────────────────────────────── */
.kpi-value {
    font-family: var(--font-headline);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.02em;
}
.kpi-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: .25rem;
}

/* ── Semantic Colors ───────────────────────────────────────────────────── */
.positive { color: var(--success); }
.negative { color: var(--error); }

/* ── Chart Containers ──────────────────────────────────────────────────── */
#chart-container, #volume-container {
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-primary);
}
#volume-container { margin-top: 4px; }

/* ── Metallic Gold Text Effect ─────────────────────────────────────────── */
.metallic-gold {
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Gold shimmer effect on hover */
.gold-shimmer {
    position: relative;
    overflow: hidden;
}
.gold-shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(226, 204, 126, 0.15), transparent);
    transition: left 600ms ease;
}
.gold-shimmer:hover::before {
    left: 100%;
}

/* ── Hero Sections ─────────────────────────────────────────────────────── */
.hero-section {
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0F0D08 50%, var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border-subtle);
    padding: 2rem 0 1.5rem;
    position: relative;
    overflow: hidden;
}
.hero-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 600px 300px at 20% 50%, rgba(201, 168, 76, 0.05) 0%, transparent 70%),
        radial-gradient(ellipse 400px 200px at 80% 30%, rgba(201, 168, 76, 0.03) 0%, transparent 70%);
    pointer-events: none;
}
.hero-title {
    font-family: var(--font-headline);
    font-size: 1.8rem;
    font-weight: 300;
    letter-spacing: 0.04em;
    background: linear-gradient(135deg, #C9A84C, #E2CC7E);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-subtitle {
    color: var(--text-secondary);
    font-size: .85rem;
    letter-spacing: 0.02em;
}

/* ── Dividers / Separators ─────────────────────────────────────────────── */
.divider, hr {
    border: none;
    height: 1px;
    background: var(--border-subtle);
}

/* ── Dropdowns ─────────────────────────────────────────────────────────── */
.dropdown-menu {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.dropdown-item {
    color: var(--text-primary);
    font-size: .85rem;
    transition: all 150ms ease-out;
}
.dropdown-item:hover {
    background: var(--gold-muted);
    color: var(--gold-primary);
}

/* ── Modals ─────────────────────────────────────────────────────────────── */
.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.modal-header { border-bottom: 1px solid var(--border-subtle); }
.modal-footer { border-top: 1px solid var(--border-subtle); }

/* ── Alerts ────────────────────────────────────────────────────────────── */
.alert-danger {
    background: rgba(155, 61, 61, 0.1);
    border-color: rgba(155, 61, 61, 0.3);
    color: var(--error);
}
.alert-success {
    background: var(--gold-muted);
    border-color: rgba(201, 168, 76, 0.3);
    color: var(--gold-primary);
}

/* ── Spinner ───────────────────────────────────────────────────────────── */
.spinner-border {
    border-color: var(--border-default);
    border-right-color: var(--gold-primary);
}
.spinner-ring {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-default);
    border-top-color: var(--gold-primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tooltips (floating overlays) ──────────────────────────────────────── */
.tooltip-overlay {
    position: fixed;
    z-index: 1000;
    background: rgba(10, 10, 10, 0.92);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    padding: 10px 14px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    font-size: .8rem;
    color: var(--text-primary);
}

/* ── Animations ────────────────────────────────────────────────────────── */

/* Staggered fade-in from top */
.stagger-in {
    opacity: 0;
    transform: translateY(12px);
    animation: staggerReveal 0.4s ease-out forwards;
}
@keyframes staggerReveal {
    to { opacity: 1; transform: translateY(0); }
}

/* Page load fade */
.fade-in {
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}
@keyframes fadeIn {
    to { opacity: 1; }
}

/* Pulse (scan/status indicator) */
.scan-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold-primary);
    margin-right: 6px;
    animation: goldPulse 2s ease-in-out infinite;
}
.scan-pulse.loading { background: var(--gold-primary); }
.scan-pulse.error { background: var(--error); animation: none; }
@keyframes goldPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.4); }
    50% { opacity: .7; box-shadow: 0 0 0 6px rgba(201, 168, 76, 0); }
}

/* ── Reduced Motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .stagger-in, .fade-in {
        opacity: 1;
        transform: none;
    }
    .scan-pulse {
        animation: none;
    }
    .nav-link::after,
    .link-underline::after {
        transition: none;
    }
}

/* ── Utility: text-muted override ──────────────────────────────────────── */
.text-muted {
    color: var(--text-secondary) !important;
}

/* ── Bootstrap Overrides ───────────────────────────────────────────────── */
.btn-outline-warning {
    border-color: var(--gold-dark);
    color: var(--gold-primary);
}
.btn-outline-warning:hover, .btn-outline-warning.active {
    background: var(--gold-muted);
    border-color: var(--gold-primary);
    color: var(--gold-primary);
}
.btn-outline-warning:focus {
    box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.3);
}
.btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: .5;
}
.btn-close-white:hover { opacity: .8; }

/* ── Nav Card (Welcome page) ──────────────────────────────────────────── */
.nav-card {
    transition: border-color 200ms ease-out, transform 200ms ease-out;
    cursor: pointer;
}
.nav-card:hover {
    border-color: var(--gold-primary) !important;
    transform: translateY(-2px);
}
