/* ==========================================================================
   COSMIC TECHNO DESIGN SYSTEM (VARIABLES)
   ========================================================================== */
:root {
    --bg-space: #070a13;
    --surface-glass: rgba(17, 24, 39, 0.6);
    --border-glass: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(0, 212, 255, 0.15);
    
    /* Cosmic Accents */
    --accent-cyan: #00d4ff;
    --accent-blue: #0052ff;
    --accent-purple: #9d4edd;
    
    /* Typography */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #475569;
    
    --font-system: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ==========================================================================
   GLOBAL BASE STYLES
   ========================================================================== */
body {
    margin: 0;
    font-family: var(--font-system);
    background-color: var(--bg-space);
    background-image: 
        radial-gradient(at 0% 0%, rgba(0, 82, 255, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(157, 78, 221, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

.container {
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* ==========================================================================
   HEADER / TOPBAR NAVIGATION
   ========================================================================== */
.topbar {
    background: rgba(11, 16, 32, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    padding: 16px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar > *:first-child {
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(120deg, #ffffff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 24px;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s, text-shadow 0.2s;
}

.nav a:hover {
    color: var(--text-main);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   CARDS & SURFACES (GLASSMORPHISM)
   ========================================================================== */
.card, .stat-card, .login-box {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.card {
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

.login-box {
    max-width: 400px;
    margin: 120px auto;
    padding: 40px;
    border-radius: 16px;
}

/* ==========================================================================
   FORM INPUT CONTROLS & ELEMENT STRUCTURES
   ========================================================================== */
.filter-group, .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label, .form-group label {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Absolute Global Sizing Lock across all interaction fields */
input, select, .filter-group input, .filter-group select, .form-group input, .form-group select {
    height: 46px !important;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 8px;
    background: rgba(3, 7, 18, 0.5) !important;
    color: var(--text-main);
    font-family: var(--font-system);
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: rgba(0, 212, 255, 0.5) !important;
    background: rgba(3, 7, 18, 0.8) !important;
    box-shadow: 0 0 0 3px var(--border-glow);
}

input::-webkit-calendar-picker-indicator {
    filter: invert(1) hue-rotate(180deg);
    cursor: pointer;
    opacity: 0.7;
}

/* ==========================================================================
   BUTTON GLOBAL ENGINE (COSMIC TECHNO GRADIENTS)
   ========================================================================== */
button, .action-button, input[type="submit"] {
    height: 46px !important; /* Locks exactly to input tracks */
    padding: 0 24px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue)) !important;
    color: #030712 !important;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transition: transform 0.1s, box-shadow 0.2s, filter 0.2s;
    box-shadow: 0 4px 14px rgba(0, 212, 255, 0.25);
    white-space: nowrap;
}

button:hover, .action-button:hover {
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.45);
    transform: translateY(-1px);
    filter: brightness(1.1);
}

button:active, .action-button:active {
    transform: translateY(0);
}

/* Explicit size adjustments for isolated context actions */
.card > div > .action-button {
    height: 38px !important;
    font-size: 13px;
    padding: 0 16px;
}

/* ==========================================================================
   LAYOUT CONTAINERS (FLEX & GRID TRACKS)
   ========================================================================== */
/* The Add Wager Multi-row Setup */
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    align-items: end;
}

/* The Inline Clean Search Filters */
.filter-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    min-width: 150px;
    flex: 1 1 auto; /* Flexibly scales boxes naturally based on space */
    max-width: 240px;
}

/* Houses inline button chains perfectly aligned to the same baseline */
.filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ==========================================================================
   DATA TABLES
   ========================================================================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

th, td {
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

th {
    color: var(--accent-cyan);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    /* TABLE DIVIDER: */
    border-bottom: 1px solid var(--accent-cyan) !important; /* Solid bright neon cyan */
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.2); /* Soft neon glow casting downward */
    padding-bottom: 12px;
}

td {
    font-size: 14px;
    color: var(--text-main);
}

tbody tr { transition: background-color 0.15s; }
tbody tr:hover { background-color: rgba(255, 255, 255, 0.02); }

/* ==========================================================================
   DASHBOARD METRICS & FEEDBACK SYSTEM
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    border-radius: 16px;
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(to bottom, var(--accent-cyan), var(--accent-purple));
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.error-box, .success-box {
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    border: 1px solid;
}

.error-box { background: rgba(127, 29, 29, 0.2); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.success-box { background: rgba(6, 78, 59, 0.2); color: #86efac; border-color: rgba(34, 197, 94, 0.3); }
.error-text { color: #ef4444; }
.muted-text { color: var(--text-muted); font-size: 13px; }

.status-badge.wager-placed {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(57, 255, 20, 0.08);
    color: #39ff14 !important;
    border: 1px solid rgba(57, 255, 20, 0.25);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.4);
    letter-spacing: 0.05em;
}

/* ==========================================================================
   RESPONSIVE DESIGN & MOBILE MENU UPGRADE
   ========================================================================== */
@media (max-width: 1024px) {
    .stats-grid, .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .topbar { flex-direction: column; gap: 12px; padding: 12px 16px; align-items: center; }
    .nav {
        width: 100%; display: flex; overflow-x: auto; scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch; padding-bottom: 4px; justify-content: flex-start;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav { -ms-overflow-style: none; scrollbar-width: none; }
    .nav a {
        margin-left: 0; margin-right: 20px; padding: 6px 12px;
        background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 6px; white-space: nowrap; font-size: 13px;
    }
    .nav a:last-child { margin-right: 0; }
    .container { padding: 16px 12px; }
    .filter-row, .form-grid { flex-direction: column; align-items: stretch; gap: 16px; display: flex; }
    .filter-group, .form-group { max-width: none; min-width: 0; }
    .stats-grid { grid-template-columns: 1fr; }
    .card { overflow-x: auto; }
    .filter-actions { width: 100%; flex-direction: column; }
    .filter-actions button, .filter-actions a { width: 100% !important; }
}

/* ==========================================================================
   ACTIVE PAGE NAVIGATION INDICATORS
   ========================================================================== */
/* Desktop Active Style: Glowing Underline Accent */
@media (min-width: 769px) {
    .nav a {
        position: relative;
        padding: 8px 0;
    }
    
    .nav a.active {
        color: var(--text-main) !important;
        text-shadow: 0 0 12px rgba(0, 212, 255, 0.6);
    }
    
    .nav a.active::after {
        content: '';
        position: absolute;
        bottom: -4px;
        left: 0;
        width: 100%;
        height: 2px;
        background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
        box-shadow: 0 0 8px var(--accent-cyan);
        border-radius: 2px;
    }
}

/* Mobile Active Style: Glowing High-Tech Border Outline */
@media (max-width: 768px) {
    .nav a.active {
        color: var(--accent-cyan) !important;
        background: rgba(0, 212, 255, 0.08) !important;
        border-color: rgba(0, 212, 255, 0.4) !important;
        box-shadow: 0 0 12px rgba(0, 212, 255, 0.15);
        font-weight: 700;
    }
}

/* Desktop: Beautiful side-by-side layout (2/3 width line chart, 1/3 width donut) */
.charts-row-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

/* Mobile & Tablet: Automatically switch to a vertical stack at 1024px wide or less */
@media (max-width: 1024px) {
    .charts-row-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
}

/* ==========================================================================
   RESEARCH GRID
   ========================================================================== */

.research-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.research-check-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.025);
    color: var(--accent-cyan);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.research-check-pill input {
    margin: 0;
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}

.research-query-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.research-row {
    display: grid;
    gap: 16px;
    align-items: end;
}

.research-row-top {
    grid-template-columns: repeat(5, minmax(160px, 1fr));
}

.research-row-fields {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.research-final-row {
    grid-template-columns: repeat(4, minmax(180px, 1fr)) minmax(220px, 280px);
}

.research-wide-group {
    width: 100%;
}

.research-check-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.research-confidence-row {
    grid-template-columns: repeat(5, minmax(90px, 120px));
    justify-content: start;
}

.research-check-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.025);
    color: var(--accent-cyan);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.research-small-pill {
    justify-content: flex-start;
}

.research-check-pill input {
    margin: 0;
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}

.research-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 20px;
}

.research-actions button {
    width: 100%;
}

.research-actions a {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    text-decoration: none;
}

@media (max-width: 1100px) {
    .research-row-top,
    .research-row-fields,
    .research-final-row {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .research-check-row {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }
}

@media (max-width: 640px) {
    .research-row-top,
    .research-row-fields,
    .research-final-row,
    .research-check-row,
    .research-confidence-row {
        grid-template-columns: 1fr;
    }
}
