/* ============================================================
   VentajaQuant — Shared App Stylesheet
   ============================================================
   Covers: CSS variables, reset, body, bg-pattern, header/nav,
   layout (container, main, page-header), card, table wrappers,
   loading / empty states, footer, scroll-top, and animations.

   Page-specific styles remain in each page's <style> block.
   Cache with: Cache-Control: max-age=31536000, immutable
   ============================================================ */

/* ============================================================
   1. CSS VARIABLES
   ============================================================ */
:root {
    /* Backgrounds */
    --bg-body:     #0b0f19;
    --bg-primary:  #0b0f19;           /* alias – older pages */
    --bg-card:     rgba(14, 18, 30, 0.7);
    --bg-elevated: rgba(18, 24, 42, 0.5);
    --bg-input:    rgba(14, 18, 30, 0.5);

    /* Borders */
    --border-color:  rgba(148, 163, 184, 0.06);
    --border-hover:  rgba(148, 163, 184, 0.12);
    --border-subtle: rgba(148, 163, 184, 0.04);

    /* Text */
    --text-primary:   #dce3ed;
    --text-secondary: #94a3b8;
    --text-muted:     #546178;

    /* Accents — canonical names */
    --accent-red:    #c41e3a;
    --accent-yellow: #facc15;
    --accent-green:  #22c55e;
    --accent-blue:   #3b82f6;
    --accent-orange: #f97316;
    --accent-purple: #a855f7;
    --accent-danger: #ef4444;

    /* Accent aliases – kept so existing page CSS doesn't break */
    --accent-spain-red:    var(--accent-red);
    --accent-spain-yellow: var(--accent-yellow);
    --accent-primary:      var(--accent-green);
    --accent-warning:      var(--accent-yellow);
    --impact-high:         var(--accent-danger);
    --impact-medium:       var(--accent-orange);
    --impact-low:          var(--accent-green);

    /* Radii */
    --radius-sm: 3px;
    --radius-md: 4px;
    --radius-lg: 6px;

    /* Typography */
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Layout — pages that need 1400 px override this in their own <style> */
    --container-max: 1200px;
}

/* ============================================================
   2. RESET
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================================
   3. BASE
   ============================================================ */
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ============================================================
   4. BACKGROUND GRID PATTERN
   ============================================================ */
.bg-pattern {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.012) 1px, transparent 1px);
    background-size: 48px 48px;
}

/* ============================================================
   5. HEADER / NAV
   ============================================================ */
header {
    background: rgba(11, 15, 25, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 100;
}

header nav,
nav {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}
.logo span { color: var(--accent-red); }

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    align-items: center;
}
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.82rem;
    font-family: var(--font-mono);
    transition: color 0.2s;
}
.nav-links a:hover,
.nav-links a.active { color: var(--text-primary); }

.mobile-menu {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ============================================================
   6. LAYOUT
   ============================================================ */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    z-index: 1;
}

main {
    padding-top: 80px;
    padding-bottom: 4rem;
    position: relative;
    z-index: 1;
}

.page-header {
    text-align: center;
    padding: 2rem 0 1.5rem;
}
.page-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}
.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 650px;
    margin: 0 auto;
}

/* ============================================================
   7. CARD COMPONENT
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-hover); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.card-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 600;
}
.card-badge {
    background: var(--bg-elevated);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    color: var(--accent-yellow);
    font-weight: 600;
    font-family: var(--font-mono);
}

/* ============================================================
   8. TABLE WRAPPER
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Generic data-table pattern shared across pages */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.data-table thead { position: sticky; top: 0; z-index: 2; }
.data-table th {
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.data-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: rgba(148, 163, 184, 0.03); }

/* Shared cell helpers */
.mono  { font-family: var(--font-mono); }
.data-positive { color: var(--accent-green); }
.data-negative { color: var(--accent-danger); }
.data-neutral  { color: var(--text-muted); }

/* ============================================================
   9. LOADING & EMPTY STATES
   ============================================================ */
.loading-container,
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    text-align: center;
}
.loading-indicator p { margin-top: 0.8rem; font-size: 0.85rem; }

.loading-spinner,
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-red);
    border-radius: 50%;
    animation: vq-spin 0.8s linear infinite;
    margin-bottom: 1rem;
}
.spinner { margin: 0 auto; }  /* strategies page centres it separately */

@keyframes vq-spin { to { transform: rotate(360deg); } }
/* legacy alias used inline by some pages */
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.empty-state .icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
    display: block;
}

/* ============================================================
   10. FOOTER
   ============================================================ */
footer {
    background: rgba(11, 15, 25, 0.5);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-family: var(--font-mono);
}
footer a {
    color: var(--accent-red);
    text-decoration: none;
}
footer a:hover { color: var(--text-secondary); }

/* ============================================================
   11. SCROLL-TO-TOP BUTTON
   ============================================================ */
.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 36px;
    height: 36px;
    background: var(--accent-red);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    z-index: 50;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
}
.scroll-top.visible { opacity: 1; transform: translateY(0); }
.scroll-top:hover { background: #a01830; }

/* ============================================================
   12. ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ============================================================
   13. RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: rgba(11, 15, 25, 0.98);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 0.75rem 2rem 1rem;
        gap: 0.5rem;
        border-bottom: 1px solid var(--border-color);
    }
    /* Both .active and .open are used across pages */
    .nav-links.active,
    .nav-links.open { display: flex; }

    .mobile-menu { display: block; }

    .container  { padding: 0 1rem; }
    .page-header h1 { font-size: 1.6rem; }
}
