/* ─── App Theme Variables ─── */
:root, [data-theme="dark"] {
    --brand: #38bdf8;        /* sky-400 */
    --brand-dark: #0284c7;   /* sky-600 */
    --brand-darker: #0369a1; /* sky-700 */
    --brand-light: #7dd3fc;  /* sky-300 */
    --positive: #34d399;     /* emerald-400 */
    --negative: #fb7185;     /* rose-400 */
    --bg-primary: #030712;   /* gray-950 */
    --bg-card: #111827;      /* gray-900 */
    --bg-input: #030712;     /* gray-950 */
    --border: #1f2937;       /* gray-800 */
    --border-light: #374151; /* gray-700 */
    --text-primary: #ffffff;
    --text-secondary: #9ca3af; /* gray-400 */
    --text-muted: #6b7280;   /* gray-500 */
    --nav-link: #d1d5db;
    --nav-link-hover-bg: rgba(255,255,255,0.05);
    --flash-error-bg: rgba(127,29,29,0.5);
    --flash-error-text: #fca5a5;
    --flash-error-border: #991b1b;
    --flash-success-bg: rgba(6,78,59,0.5);
    --flash-success-text: #6ee7b7;
    --flash-success-border: #065f46;
    --ticker-divider: #374151;
    --progress-bg: #1f2937;
    --btn-disabled-bg: #1f2937;
    --btn-disabled-text: #4b5563;
    --btn-secondary-bg: #1f2937;
    --btn-secondary-text: #d1d5db;
    --btn-secondary-hover: #374151;
    --chain-row-hover: rgba(255,255,255,0.02);
    --chain-strike-bg: rgba(255,255,255,0.02);
    --chain-atm-bg: rgba(234,179,8,0.08);
}

[data-theme="light"] {
    --brand: #0284c7;        /* sky-600 */
    --brand-dark: #0369a1;   /* sky-700 */
    --brand-darker: #075985; /* sky-800 */
    --brand-light: #38bdf8;  /* sky-400 */
    --positive: #059669;     /* emerald-600 */
    --negative: #e11d48;     /* rose-600 */
    --bg-primary: #f8fafc;   /* slate-50 */
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --border: #e2e8f0;       /* slate-200 */
    --border-light: #cbd5e1; /* slate-300 */
    --text-primary: #0f172a; /* slate-900 */
    --text-secondary: #475569; /* slate-600 */
    --text-muted: #94a3b8;   /* slate-400 */
    --nav-link: #475569;
    --nav-link-hover-bg: rgba(0,0,0,0.05);
    --flash-error-bg: #fef2f2;
    --flash-error-text: #dc2626;
    --flash-error-border: #fecaca;
    --flash-success-bg: #f0fdf4;
    --flash-success-text: #16a34a;
    --flash-success-border: #bbf7d0;
    --ticker-divider: #e2e8f0;
    --progress-bg: #e2e8f0;
    --btn-disabled-bg: #e2e8f0;
    --btn-disabled-text: #94a3b8;
    --btn-secondary-bg: #f1f5f9;
    --btn-secondary-text: #334155;
    --btn-secondary-hover: #e2e8f0;
    --chain-row-hover: rgba(0,0,0,0.02);
    --chain-strike-bg: rgba(0,0,0,0.02);
    --chain-atm-bg: rgba(234,179,8,0.08);
}

/* ─── Base ─── */
html { background: var(--bg-primary) !important; }
body { color: var(--text-primary); }

/* ─── Navbar ─── */
.nav-bar {
    background: var(--bg-card);
    border-bottom: 1px solid rgba(56, 189, 248, 0.15);
}
.nav-brand {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--brand);
}
.nav-link {
    font-size: 0.875rem;
    color: var(--nav-link);
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    transition: all 0.15s;
}
.nav-link:hover {
    color: var(--text-primary);
    background: var(--nav-link-hover-bg);
}

/* ─── Ticker Bar ─── */
.ticker-bar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    padding: 0.375rem 0;
}
.ticker-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
    font-size: 0.75rem;
}
.ticker-symbol { color: var(--text-secondary); font-weight: 500; }
.ticker-price { color: var(--text-primary); font-weight: 600; }
.ticker-divider { color: var(--ticker-divider); }

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
}
.card-inner {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

/* ─── Buttons ─── */
.btn-primary {
    background: var(--brand-dark);
    color: #fff;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.15s;
    border: none;
    cursor: pointer;
}
.btn-primary:hover { background: var(--brand-darker); }
.btn-primary:disabled {
    background: var(--btn-disabled-bg);
    color: var(--btn-disabled-text);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    transition: all 0.15s;
    border: none;
    cursor: pointer;
}
.btn-secondary:hover { background: var(--btn-secondary-hover); }

.btn-success {
    background: #059669;
    color: #fff;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.15s;
    border: none;
    cursor: pointer;
}
.btn-success:hover { background: #047857; }
.btn-success:disabled {
    background: var(--btn-disabled-bg);
    color: var(--btn-disabled-text);
    cursor: not-allowed;
}

/* ─── Form Inputs ─── */
.form-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}
.form-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}
.form-input::placeholder { color: var(--text-muted); }

.form-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.form-select {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
}
.form-select:focus {
    border-color: var(--brand);
}

/* ─── Price Colors ─── */
.price-up { color: var(--positive); }
.price-down { color: var(--negative); }
.price-neutral { color: var(--text-muted); }

/* ─── Exchange Badges ─── */
.badge-nse {
    font-size: 0.625rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.badge-bse {
    font-size: 0.625rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

/* ─── Status Indicators ─── */
.status-live { color: var(--positive); }
.status-offline { color: var(--negative); }
.status-connecting { color: #facc15; }

/* ─── Option Chain Table ─── */
.chain-table {
    width: 100%;
    font-size: 0.875rem;
    border-collapse: collapse;
}
.chain-table th {
    padding: 0.5rem 0.75rem;
}
.chain-table td {
    padding: 0.5rem 0.75rem;
}
.chain-header-ce {
    color: var(--positive);
    text-align: center;
    background: rgba(16, 185, 129, 0.05);
}
.chain-header-pe {
    color: var(--negative);
    text-align: center;
    background: rgba(251, 113, 133, 0.05);
}
.chain-strike {
    text-align: center;
    font-weight: 700;
    background: var(--chain-strike-bg);
}
.chain-strike-atm {
    color: #fbbf24;
    font-size: 1rem;
}
.chain-row:hover {
    background: var(--chain-row-hover);
}
.chain-row-atm {
    background: var(--chain-atm-bg);
    border-left: 2px solid #eab308;
    border-right: 2px solid #eab308;
}

/* ─── Progress Bar ─── */
.progress-bar {
    width: 100%;
    background: var(--progress-bg);
    border-radius: 9999px;
    height: 0.5rem;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 9999px;
    background: var(--brand-dark);
    transition: width 0.3s;
}
.progress-fill-success {
    background: #059669;
}

/* ─── Step Indicators ─── */
.step-circle {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
}
.step-done {
    background: #059669;
    color: #fff;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.3);
}
.step-active {
    background: var(--brand-dark);
    color: #fff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
    animation: pulse 2s infinite;
}
.step-pending {
    background: var(--btn-disabled-bg);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

/* ─── Alerts ─── */
.alert-success {
    background: rgba(5, 150, 105, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(5, 150, 105, 0.3);
    border-radius: 0.375rem;
    padding: 0.75rem;
    font-size: 0.875rem;
}
.alert-error {
    background: rgba(220, 38, 38, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 0.375rem;
    padding: 0.75rem;
    font-size: 0.875rem;
}

/* ─── Misc ─── */
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}
.text-brand { color: var(--brand); }
.border-brand { border-color: var(--brand); }
.tabular { font-variant-numeric: tabular-nums; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ─── Theme Toggle ─── */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1;
    transition: all 0.15s;
}
.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--brand);
}

/* ─── Light theme overrides for Tailwind utility classes used in templates ─── */
/* Backgrounds */
[data-theme="light"] .bg-gray-950 { background: var(--bg-primary) !important; }
[data-theme="light"] .bg-gray-900 { background: var(--bg-card) !important; }
[data-theme="light"] .bg-gray-800 { background: #e2e8f0 !important; }
[data-theme="light"] .bg-gray-800\/50,
[data-theme="light"] .bg-gray-800\/30 { background: rgba(0,0,0,0.04) !important; }
[data-theme="light"] .hover\:bg-gray-800\/30:hover { background: rgba(0,0,0,0.06) !important; }
[data-theme="light"] .hover\:bg-gray-700:hover { background: #e2e8f0 !important; }
[data-theme="light"] .hover\:bg-gray-800:hover { background: #e2e8f0 !important; }

/* Borders */
[data-theme="light"] .border-gray-800 { border-color: var(--border) !important; }
[data-theme="light"] .border-gray-800\/50 { border-color: rgba(0,0,0,0.08) !important; }
[data-theme="light"] .border-gray-700 { border-color: var(--border-light) !important; }
[data-theme="light"] .border-sky-500 { border-color: #0284c7 !important; }
[data-theme="light"] .border-sky-500\/50 { border-color: rgba(2,132,199,0.3) !important; }

/* Text */
[data-theme="light"] .text-white { color: var(--text-primary) !important; }
[data-theme="light"] .text-gray-100 { color: var(--text-primary) !important; }
[data-theme="light"] .text-gray-200 { color: var(--text-primary) !important; }
[data-theme="light"] .text-gray-300 { color: var(--text-secondary) !important; }
[data-theme="light"] .text-gray-400 { color: var(--text-secondary) !important; }
[data-theme="light"] .text-gray-500 { color: var(--text-muted) !important; }
[data-theme="light"] .text-gray-600 { color: #64748b !important; }
[data-theme="light"] .text-gray-700 { color: var(--ticker-divider) !important; }
[data-theme="light"] .hover\:text-white:hover { color: var(--text-primary) !important; }

/* Colored text — use slightly darker variants in light mode */
[data-theme="light"] .text-emerald-400 { color: #059669 !important; }
[data-theme="light"] .text-rose-400 { color: #e11d48 !important; }
[data-theme="light"] .text-red-400 { color: #dc2626 !important; }
[data-theme="light"] .text-yellow-400 { color: #d97706 !important; }
[data-theme="light"] .text-yellow-500 { color: #b45309 !important; }
[data-theme="light"] .text-sky-400 { color: #0284c7 !important; }
[data-theme="light"] .text-sky-500 { color: #0369a1 !important; }

/* Colored backgrounds */
[data-theme="light"] .bg-emerald-900\/10 { background: rgba(5,150,105,0.08) !important; }
[data-theme="light"] .bg-rose-900\/10 { background: rgba(225,29,72,0.08) !important; }
[data-theme="light"] .bg-yellow-900\/20 { background: rgba(217,119,6,0.1) !important; }
[data-theme="light"] .bg-emerald-400 { background: #059669 !important; }

/* Flash messages */
[data-theme="light"] .bg-red-900\/50 { background: var(--flash-error-bg) !important; }
[data-theme="light"] .text-red-300 { color: var(--flash-error-text) !important; }
[data-theme="light"] .border-red-800 { border-color: var(--flash-error-border) !important; }
[data-theme="light"] .bg-emerald-900\/50 { background: var(--flash-success-bg) !important; }
[data-theme="light"] .text-emerald-300 { color: var(--flash-success-text) !important; }
[data-theme="light"] .border-emerald-800 { border-color: var(--flash-success-border) !important; }

/* Sky button backgrounds stay readable */
[data-theme="light"] .bg-sky-600 { background: #0284c7 !important; color: #fff !important; }
[data-theme="light"] .hover\:bg-sky-700:hover { background: #0369a1 !important; }

/* Navbar brand border */
[data-theme="light"] .nav-bar {
    border-bottom-color: rgba(2,132,199,0.2) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Dashboard quick action cards */
[data-theme="light"] a.bg-gray-900 { background: var(--bg-card) !important; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

/* Setup page step circles */
[data-theme="light"] .step-active { box-shadow: 0 4px 14px rgba(2,132,199,0.2); }
[data-theme="light"] .step-done { box-shadow: 0 4px 14px rgba(5,150,105,0.2); }

/* Card shadows in light mode */
[data-theme="light"] .card { box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

/* ─── Entry Animations ───────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-in    { animation: fadeIn   0.28s ease both; }
.animate-fade-in-up { animation: fadeInUp 0.32s ease both; }

/* Stagger helpers — use as companion class */
.anim-d1 { animation-delay: 0.06s; }
.anim-d2 { animation-delay: 0.12s; }
.anim-d3 { animation-delay: 0.18s; }
.anim-d4 { animation-delay: 0.24s; }
.anim-d5 { animation-delay: 0.30s; }
.anim-d6 { animation-delay: 0.36s; }

/* ─── Card Hover Lift ────────────────────────────────────────────────────────── */
.card {
    transition: transform 0.18s ease, box-shadow 0.18s ease,
                border-color 0.18s ease, background-color 0.15s ease;
}
@media (hover: hover) {
    .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
        border-color: var(--border-light);
    }
    [data-theme="light"] .card:hover {
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.10);
    }
}

/* ─── Button Press Feedback ──────────────────────────────────────────────────── */
.btn-primary:active:not([disabled]),
.btn-success:active:not([disabled])  { transform: scale(0.96); }
.btn-secondary:active:not([disabled]){ transform: scale(0.96); }

/* ─── Price Tick Flash ───────────────────────────────────────────────────────── */
@keyframes tickUp {
    0%   { background: transparent; }
    20%  { background: rgba(52, 211, 153, 0.20); }
    100% { background: transparent; }
}
@keyframes tickDown {
    0%   { background: transparent; }
    20%  { background: rgba(251, 113, 133, 0.20); }
    100% { background: transparent; }
}
.tick-up   { animation: tickUp   0.65s ease; border-radius: 0.375rem; }
.tick-down { animation: tickDown 0.65s ease; border-radius: 0.375rem; }

/* ─── Number Value Flash ─────────────────────────────────────────────────────── */
@keyframes numUpdate {
    0%   { opacity: 1; }
    25%  { opacity: 0.3; }
    100% { opacity: 1; }
}
.num-update { animation: numUpdate 0.32s ease; }

/* ─── Table Row Insert ───────────────────────────────────────────────────────── */
@keyframes rowIn {
    from { opacity: 0; transform: translateX(-5px); }
    to   { opacity: 1; transform: translateX(0); }
}
.row-in { animation: rowIn 0.22s ease both; }

/* ─── Flash / Toast Slide-Down ───────────────────────────────────────────────── */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.flash-message { animation: slideDown 0.22s ease both; }

/* ─── Skeleton Shimmer ───────────────────────────────────────────────────────── */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}
.skeleton {
    background: linear-gradient(
        90deg,
        var(--border) 25%,
        var(--border-light) 50%,
        var(--border) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: 0.375rem;
    color: transparent !important;
    pointer-events: none;
}
