/* ═══════════════════════════════════════════════
   Formulogic – Base Design Tokens & Core Styles
   Laboratory / Scientific R&D Theme
   ═══════════════════════════════════════════════ */

/* ── Light Mode (DEFAULT for guests / login) ── */
:root, [data-bs-theme="light"] {
    --fl-bg: #f0f4f8;
    --fl-bg-alt: #e2e8f0;
    --fl-surface: #ffffff;
    --fl-surface-hover: #f8fafc;
    --fl-accent: #0d9488;
    --fl-accent-hover: #0f766e;
    --fl-accent-subtle: rgba(13, 148, 136, .10);
    --fl-accent-glow: rgba(0, 229, 199, .15);
    --fl-text: #1e293b;
    --fl-text-secondary: #475569;
    --fl-muted: #64748b;
    --fl-border: #e2e8f0;
    --fl-success: #10b981;
    --fl-danger: #ef4444;
    --fl-warning: #f59e0b;
    --fl-info: #06b6d4;
    --fl-radius: 12px;
    --fl-radius-sm: 8px;
    --fl-shadow: 0 4px 24px rgba(0, 0, 0, .06);
    --fl-transition: .2s ease;
    --fl-glass: #ffffff;
    --fl-glass-sidebar: #f8fafc;
    --fl-input-bg: #ffffff;
    --fl-input-border: #cbd5e1;
    --fl-overlay: rgba(0, 0, 0, .25);
    --fl-grid-color: rgba(13, 148, 136, .06);
    --fl-glow-color: rgba(0, 229, 199, .25);
    --fl-scanline: rgba(13, 148, 136, .04);
}

/* ── Dark Mode (Lab Night Mode) ────────────── */
[data-bs-theme="dark"] {
    --fl-bg: #0a0e1a;
    --fl-bg-alt: #060a14;
    --fl-surface: #0c1223;
    --fl-surface-hover: #121c32;
    --fl-accent: #00e5c7;
    --fl-accent-hover: #00ccb0;
    --fl-accent-subtle: rgba(0, 229, 199, .12);
    --fl-accent-glow: rgba(0, 229, 199, .20);
    --fl-text: #e2e8f0;
    --fl-text-secondary: #cbd5e1;
    --fl-muted: #94a3b8;
    --fl-border: rgba(0, 229, 199, .12);
    --fl-success: #34d399;
    --fl-danger: #f87171;
    --fl-warning: #fbbf24;
    --fl-info: #38bdf8;
    --fl-radius: 12px;
    --fl-radius-sm: 8px;
    --fl-shadow: 0 4px 24px rgba(0, 0, 0, .4);
    --fl-transition: .2s ease;
    --fl-glass: #0a0e1a;
    --fl-glass-sidebar: #0c1223;
    --fl-input-bg: #0c1223;
    --fl-input-border: rgba(0, 229, 199, .18);
    --fl-overlay: rgba(0, 0, 0, .55);
    --fl-grid-color: rgba(0, 229, 199, .04);
    --fl-glow-color: rgba(0, 229, 199, .30);
    --fl-scanline: rgba(0, 229, 199, .03);
}

/* ── Backward compat aliases (--nex-* → --fl-*) ── */
:root, [data-bs-theme="light"], [data-bs-theme="dark"] {
    --nex-bg: var(--fl-bg);
    --nex-bg-alt: var(--fl-bg-alt);
    --nex-surface: var(--fl-surface);
    --nex-surface-hover: var(--fl-surface-hover);
    --nex-accent: var(--fl-accent);
    --nex-accent-hover: var(--fl-accent-hover);
    --nex-accent-subtle: var(--fl-accent-subtle);
    --nex-text: var(--fl-text);
    --nex-text-secondary: var(--fl-text-secondary);
    --nex-muted: var(--fl-muted);
    --nex-border: var(--fl-border);
    --nex-success: var(--fl-success);
    --nex-danger: var(--fl-danger);
    --nex-warning: var(--fl-warning);
    --nex-info: var(--fl-info);
    --nex-radius: var(--fl-radius);
    --nex-radius-sm: var(--fl-radius-sm);
    --nex-shadow: var(--fl-shadow);
    --nex-transition: var(--fl-transition);
    --nex-glass: var(--fl-glass);
    --nex-glass-sidebar: var(--fl-glass-sidebar);
    --nex-input-bg: var(--fl-input-bg);
    --nex-input-border: var(--fl-input-border);
    --nex-overlay: var(--fl-overlay);
}

/* ── Theme transition ────────────────────────── */
html { transition: background-color .3s ease, color .3s ease; }
body, .nex-card, .nex-sidebar, .nex-navbar, .nex-sidebar-rail,
.form-control, .form-select, .table, .stat-card, .card {
    transition: background-color .3s ease, color .3s ease, border-color .3s ease, box-shadow .3s ease;
}

/* ── Base ─────────────────────────────────────── */

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--fl-bg);
    color: var(--fl-text);
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* Lab grid background pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--fl-grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--fl-grid-color) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
    opacity: .6;
}

body > * { position: relative; z-index: 1; }

a { color: var(--fl-accent); text-decoration: none; }
a:hover { color: var(--fl-accent-hover); }

/* Monospace for data values */
.font-mono, .stat-value, .hpp-value, .cost-value, code {
    font-family: 'JetBrains Mono', monospace, 'Inter';
}

/* ── Scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--fl-bg); }
::-webkit-scrollbar-thumb {
    background: var(--fl-accent-subtle);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--fl-accent); }

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

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}

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

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 8px var(--fl-accent-glow); }
    50%      { box-shadow: 0 0 20px var(--fl-glow-color); }
}

@keyframes scanLine {
    0%   { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

@keyframes moleculeFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    33%      { transform: translateY(-12px) rotate(120deg); }
    66%      { transform: translateY(6px) rotate(240deg); }
}

@keyframes borderGlow {
    0%, 100% { border-color: var(--fl-accent-subtle); }
    50%      { border-color: var(--fl-accent); }
}

main > * { animation: fadeInUp .3s ease-out; }

/* ── Navbar ───────────────────────────────────── */
.nex-navbar {
    background: var(--fl-glass);
    position: sticky;
    top: 0;
    z-index: 1050;
    border-bottom: 1px solid var(--fl-border) !important;
}

/* Scan-line accent on navbar bottom */
.nex-navbar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        var(--fl-accent) 20%,
        var(--fl-glow-color) 50%,
        var(--fl-accent) 80%,
        transparent);
    opacity: .6;
}

.nex-brand {
    color: var(--fl-accent) !important;
    font-weight: 700;
    letter-spacing: -.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nex-brand svg {
    width: 26px;
    height: 26px;
}

/* ── Sidebar ──────────────────────────────────── */
.nex-sidebar, .nex-sidebar-rail {
    background: var(--fl-glass-sidebar);
    overflow: visible;
    border-right: 1px solid var(--fl-border);
}

/* ── Utility ──────────────────────────────────── */
.text-accent { color: var(--fl-accent) !important; }
.bg-surface { background-color: var(--fl-surface); }
.border-nex { border-color: var(--fl-border) !important; }

.badge.bg-indigo { background: var(--fl-accent) !important; color: #0a0e1a !important; }
.badge.bg-teal { background: #0d9488 !important; color: #fff !important; }
.bg-teal { background-color: #0d9488 !important; }
.text-teal { color: #0d9488 !important; }
.bg-opacity-10.bg-teal { background-color: rgba(13, 148, 136, .1) !important; }

.status-draft      { color: var(--fl-muted); }
.status-pending    { color: var(--fl-warning); }
.status-approved   { color: var(--fl-success); }
.status-rejected   { color: var(--fl-danger); }

/* ── Card glow on hover ──────────────────────── */
.nex-card:hover {
    box-shadow: 0 0 20px var(--fl-accent-glow), var(--fl-shadow);
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
    .nex-sidebar, .nex-sidebar-rail {
        position: fixed;
        left: -260px;
        top: 56px;
        bottom: 0;
        z-index: 1040;
        transition: left .3s ease;
    }
    .nex-sidebar.show, .nex-sidebar-rail.show { left: 0; }
    .sidebar-backdrop {
        position: fixed; inset: 0; top: 56px;
        background: rgba(0,0,0,.4);
        z-index: 1039;
        display: none;
    }
    .sidebar-backdrop.show { display: block; }
    main { padding: 1rem !important; }
    .stat-card .stat-icon { font-size: 1.5rem !important; }
}
