/* ============================================
   OPTIONS DASHBOARD - Main Stylesheet
   Dark theme, premium financial UI
   ============================================ */

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

:root {
    --bg-main:        #0d1117;
    --bg-card:        #161b22;
    --bg-hover:       #21262d;
    --bg-input:       #0d1117;

    --text-main:      #e6edf3;
    --text-muted:     #8b949e;
    --text-dim:       #6e7681;

    --accent:         #f78166;
    --accent-blue:    #58a6ff;
    --accent-green:   #3fb950;
    --accent-orange:  #d29922;

    --border:         #30363d;
    --border-muted:   #21262d;

    --success:        #00e5a0;
    --danger:         #ff6b6b;

    --sidebar-width:  220px;
    --radius:         8px;
    --radius-lg:      12px;
    --shadow:         0 4px 24px rgba(0,0,0,0.4);
    --shadow-sm:      0 1px 8px rgba(0,0,0,0.3);

    --font-sans:      'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:      'SFMono-Regular', Consolas, monospace;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

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

/* === LAYOUT === */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    padding: 0;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 0.02em;
}

.sidebar-brand .brand-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-section {
    padding: 1rem 0.75rem 0.5rem;
}

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    padding: 0 0.5rem;
    margin-bottom: 0.4rem;
}

.nav-links { list-style: none; }

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-links li a:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.nav-links li a.active {
    background: rgba(88, 166, 255, 0.12);
    color: var(--text-main);
    border-left: 3px solid var(--accent-blue);
    padding-left: calc(0.75rem - 3px);
}

.nav-links li a .nav-icon {
    font-size: 1rem;
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 2.5rem;
    max-width: 1600px;
    min-height: 100vh;
}

/* === PAGE HEADER === */
.page-header {
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.page-header .page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* === CARD === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

/* === CONTROLS === */
.controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 160px;
}

.control-group label,
.form-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* === FORM INPUTS === */
select, input[type="date"], input[type="text"], input[type="number"] {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    width: 100%;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    color-scheme: dark;
    appearance: none;
    -webkit-appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

select:focus, input[type="date"]:focus, input[type="text"]:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-blue);
    color: #0d1117;
    border-color: var(--accent-blue);
}
.btn-primary:hover { background: #79b8ff; }

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-main);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-main); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: rgba(255,107,107,0.3);
}
.btn-danger:hover { background: rgba(255,107,107,0.1); }

/* Date nav row */
.date-nav-row {
    display: inline-flex;
    align-items: flex-end;
    gap: 0.5rem;
}
.date-nav-row .control-group {
    min-width: unset;
    width: 180px;
}


/* === RADIO GROUP === */
.radio-group {
    display: flex;
    gap: 0.5rem;
}

.radio-btn {
    padding: 0.45rem 1rem;
    border-radius: var(--radius);
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
}
.radio-btn.active {
    background: rgba(88, 166, 255, 0.12);
    border-color: var(--accent-blue);
    color: var(--text-main);
    font-weight: 600;
}

/* === CHECKBOX === */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: grab;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.5rem 0;
    transition: all 0.2s ease;
}
.checkbox-label:active {
    cursor: grabbing;
}
.checkbox-label.dragging {
    opacity: 0.4;
    border-color: var(--accent-blue) !important;
    background: rgba(88, 166, 255, 0.1) !important;
}
.checkbox-label input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent-blue);
}

/* === MULTISELECT === */
.multiselect-container {
    position: relative;
}

.multiselect-toggle {
    width: 100%;
    text-align: left;
    justify-content: space-between;
}

.multiselect-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    z-index: 200;
    max-height: 280px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.multiselect-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: background 0.1s;
}
.multiselect-option:hover { background: var(--bg-hover); color: var(--text-main); }
.multiselect-option input[type="checkbox"] { accent-color: var(--accent-blue); }
.multiselect-option.checked { color: var(--text-main); }

/* === ALERTS === */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.alert-info    { background: rgba(88,166,255,0.08); border: 1px solid rgba(88,166,255,0.2); color: var(--accent-blue); }
.alert-error   { background: rgba(255,107,107,0.08); border: 1px solid rgba(255,107,107,0.2); color: var(--danger); }
.alert-warning { background: rgba(210,153,34,0.08); border: 1px solid rgba(210,153,34,0.2); color: var(--accent-orange); }
.alert-success { background: rgba(63,185,80,0.08); border: 1px solid rgba(63,185,80,0.2); color: var(--accent-green); }
.hidden { display: none !important; }

/* === TABLE === */
.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.data-table th {
    background: var(--bg-main);
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.75rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}
.data-table th:first-child { text-align: left; }

.data-table td {
    padding: 0.6rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-muted);
    font-variant-numeric: tabular-nums;
}
.data-table td:first-child { text-align: left; font-weight: 500; }

.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table .group-separator td { border-top: 2px solid var(--border); }
.data-table .net-row { background: rgba(255,255,255,0.025); font-weight: 600; }

/* === CHART WRAPPER === */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.chart-grid {
    display: grid;
    grid-template-columns: 4fr 1fr;
    gap: 1rem;
}
.chart-grid > div {
    min-width: 0;
}

/* === COLORS === */
.text-green  { color: var(--success) !important; }
.text-red    { color: var(--danger) !important; }
.text-blue   { color: var(--accent-blue) !important; }
.text-orange { color: var(--accent-orange) !important; }
.text-muted  { color: var(--text-muted) !important; }

/* === LOADING SPINNER === */
.spinner-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    gap: 0.75rem;
    font-size: 0.9rem;
}
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === PROGRESS BAR === */
.progress-bar-wrap {
    width: 100%;
    background: var(--bg-hover);
    border-radius: 4px;
    height: 6px;
    overflow: hidden;
    margin-top: 0.5rem;
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent-blue);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* === BADGE === */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.badge-blue   { background: rgba(88,166,255,0.15); color: var(--accent-blue); }
.badge-green  { background: rgba(63,185,80,0.15);  color: var(--accent-green); }
.badge-orange { background: rgba(210,153,34,0.15); color: var(--accent-orange); }

/* === PINNED CHARTS === */
.pinned-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.pinned-title {
    font-size: 0.875rem;
    font-weight: 600;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; padding: 1rem; }
    .chart-grid { grid-template-columns: 1fr; }
    .controls-row { flex-direction: column; }
    .date-nav-row { display: flex; width: 100%; }
    .date-nav-row .control-group { flex: 1; }
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* === GLOBAL TOP LOADING BAR === */
.loading-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(to right, var(--accent-blue), var(--accent), var(--accent-green), var(--accent-blue));
    background-size: 200% 100%;
    z-index: 99999;
    animation: shift-loading 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    display: none;
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.5);
}
.loading-bar.active {
    display: block;
}
@keyframes shift-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* === FOOTER === */
.site-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    background: transparent;
}
.footer-inner {
    max-width: 1600px;
    margin: 0 auto;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}
.footer-col {
    display: flex;
    flex-direction: column;
}
.footer-heading {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.footer-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}
.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}
.footer-links li {
    margin-bottom: 0.5rem;
}
.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}
.footer-links a:hover {
    color: var(--accent-blue);
}
.footer-disclaimer {
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.5;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-muted);
    border-bottom: 1px solid var(--border-muted);
    margin-bottom: 1.5rem;
}
.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding-bottom: 2rem;
}
.footer-sep {
    color: var(--border);
}
