/* ==========================================================
   FuturesVal — NQ Trading Dashboard
   Modern pastel design inspired by Claude
   ========================================================== */

:root {
    --bg-main: #f5f3f0;
    --bg-card: #ffffff;
    --bg-header: #1e1b2e;
    --primary: #6b5ce7;
    --primary-light: #8b7cf0;
    --primary-dark: #5548c4;
    --accent-green: #4ade80;
    --accent-green-bg: rgba(74, 222, 128, 0.12);
    --accent-red: #f87171;
    --accent-red-bg: rgba(248, 113, 113, 0.12);
    --accent-blue: #60a5fa;
    --accent-amber: #fbbf24;
    --accent-amber-bg: rgba(251, 191, 36, 0.12);
    --text-dark: #1e1b2e;
    --text-body: #374151;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow-sm: 0 1px 3px rgba(107, 92, 231, 0.06);
    --shadow: 0 4px 24px rgba(107, 92, 231, 0.08);
    --shadow-lg: 0 12px 40px rgba(107, 92, 231, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--text-body);
    line-height: 1.5;
    min-height: 100vh;
}

/* --- Header --- */
.header {
    background: var(--bg-header);
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

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

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo-icon {
    color: var(--primary-light);
    font-size: 1.4rem;
}

.header-subtitle {
    color: var(--text-light);
    font-size: 0.8rem;
    font-weight: 400;
}

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

.session-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.session-label {
    font-size: 0.75rem;
    color: var(--accent-amber);
    font-weight: 500;
}

.select-expiry {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
}
.select-expiry option { color: var(--text-dark); background: white; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}
.btn-secondary:hover { background: rgba(255,255,255,0.25); }

.btn-ghost {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border-light); color: var(--text-dark); }

.btn-sm { padding: 4px 10px; font-size: 0.75rem; }

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge.cached { background: var(--accent-amber-bg); color: #92400e; }
.badge.fresh { background: var(--accent-green-bg); color: #166534; }

/* --- Market Bar --- */
.market-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
    display: flex;
    gap: 32px;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.market-item {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.market-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.market-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.market-change {
    font-size: 0.8rem;
    font-weight: 600;
}
.market-change.positive { color: var(--accent-green); }
.market-change.negative { color: var(--accent-red); }

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    gap: 8px;
}

.card-icon { font-size: 1.1rem; margin-right: 4px; }

.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
}

.card-badge {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* --- Metrics Row --- */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 20px 24px 0;
}

.metric-card {
    text-align: center;
    padding-bottom: 16px;
}

.metric-big {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
    padding: 8px 20px 2px;
    line-height: 1.2;
}
.metric-big.small { font-size: 1.2rem; }
.metric-big.bullish { color: var(--accent-green); }
.metric-big.bearish { color: var(--accent-red); }
.metric-big.neutral { color: var(--accent-amber); }

.metric-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0 20px;
}

.metric-detail {
    font-size: 0.7rem;
    color: var(--text-light);
    padding: 4px 20px 0;
}

/* --- Charts --- */
.chart-card { margin: 16px 24px 0; }

.chart-container {
    padding: 12px 16px 16px;
    height: 320px;
    position: relative;
}
.chart-short { height: 240px; }

/* --- Two Column Layout --- */
.two-col {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 16px;
    padding: 16px 24px 0;
}

/* --- Table --- */
.table-scroll { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.data-table th {
    background: var(--border-light);
    padding: 8px 10px;
    text-align: right;
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.data-table th:first-child { text-align: left; }

.data-table td {
    padding: 7px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border-light);
}
.data-table td:first-child { text-align: left; font-weight: 600; }
.data-table td.strike { font-weight: 700; color: var(--text-dark); }

.data-table tr.call-dominant { background: rgba(74, 222, 128, 0.04); }
.data-table tr.put-dominant { background: rgba(248, 113, 113, 0.04); }
.data-table tr:hover { background: var(--border-light); }

.data-table .call { color: #16a34a; }
.data-table .put { color: #dc2626; }
.data-table .positive { color: #16a34a; font-weight: 600; }
.data-table .negative { color: #dc2626; font-weight: 600; }

.empty-cell {
    text-align: center !important;
    color: var(--text-muted);
    padding: 24px !important;
}

/* --- Volatility Card --- */
.vol-card { padding-bottom: 16px; }

.vol-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px 20px;
}

.vol-item { text-align: center; }

.vol-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.vol-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-dark);
}
.vol-value.expensive { color: var(--accent-red); }
.vol-value.cheap { color: var(--accent-green); }

.vol-read {
    padding: 8px 20px;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}

/* --- Analysis Card --- */
.analysis-card { margin: 16px 24px; }

.analysis-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.analysis-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.analysis-content {
    padding: 20px 24px;
    line-height: 1.7;
    font-size: 0.88rem;
    color: var(--text-body);
}

.analysis-content.empty { text-align: center; }

.analysis-content .empty-msg {
    color: var(--text-muted);
    font-style: italic;
    padding: 40px 0;
}

.analysis-content h2 {
    font-size: 1.15rem;
    color: var(--primary);
    margin: 20px 0 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--primary-light);
}
.analysis-content h2:first-child { margin-top: 0; }

.analysis-content h3 {
    font-size: 1rem;
    color: var(--text-dark);
    margin: 16px 0 6px;
}

.analysis-content h4 {
    font-size: 0.9rem;
    color: var(--text-dark);
    margin: 12px 0 4px;
}

.analysis-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.analysis-content li {
    margin-bottom: 4px;
}

.analysis-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.82rem;
}

.analysis-content th, .analysis-content td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.analysis-content th {
    background: var(--border-light);
    font-weight: 600;
}

.analysis-content code {
    background: var(--border-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.82rem;
}

.analysis-content strong {
    color: var(--text-dark);
}

/* --- Loading --- */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(245, 243, 240, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    gap: 16px;
}

.loading-overlay p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.loading-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* --- Error --- */
.error-banner {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-red);
    color: white;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 300;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    text-align: center;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: white;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    z-index: 300;
    animation: fadeInUp 0.3s ease;
    box-shadow: var(--shadow-lg);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Footer --- */
.footer {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    color: var(--text-light);
    font-size: 0.72rem;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .metrics-row { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
    .header { flex-direction: column; align-items: flex-start; }
    .header-right { width: 100%; justify-content: flex-start; }
    .market-bar { gap: 16px; }
}

@media (max-width: 600px) {
    .metrics-row { grid-template-columns: 1fr; }
    .chart-container { height: 250px; }
    .chart-short { height: 200px; }
    .analysis-card { margin: 16px 12px; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 4px; }
    .analysis-actions { flex-wrap: wrap; }
    body { font-size: 14px; }
    .metric-big { font-size: 1.5rem; }
}
