/* Aethelgard Dashboard — Design System */

/* ═══════════════════════════════════════════════
   DARK THEME (default)
═══════════════════════════════════════════════ */
:root, [data-theme="dark"] {
    --bg: #0a0e14;
    --surface: #12171f;
    --surface-2: #1a2030;
    --surface-3: #222b3a;
    --border: #2a3545;
    --border-sub: #1e2838;
    --text: #e2e8f0;
    --text-muted: #8892a4;
    --text-faint: #5a6578;
    --accent: #6366f1;
    --accent-2: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.08);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.08);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.08);
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --sans: 'Inter', system-ui, -apple-system, sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --chart-line: #6366f1;
    --chart-fill-start: rgba(99, 102, 241, 0.15);
    --chart-fill-end: rgba(99, 102, 241, 0);
    --chart-grid: #1e2838;
    --chart-bar: #2a3545;
    --chart-text: #e2e8f0;
    --chart-text-muted: #8892a4;
}

/* ═══════════════════════════════════════════════
   LIGHT THEME
═══════════════════════════════════════════════ */
[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --border: #cbd5e1;
    --border-sub: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-faint: #94a3b8;
    --accent: #4f46e5;
    --accent-2: #6366f1;
    --accent-glow: rgba(79, 70, 229, 0.1);
    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.08);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.08);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.06);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --chart-line: #4f46e5;
    --chart-fill-start: rgba(79, 70, 229, 0.1);
    --chart-fill-end: rgba(79, 70, 229, 0);
    --chart-grid: #e2e8f0;
    --chart-bar: #e2e8f0;
    --chart-text: #1e293b;
    --chart-text-muted: #64748b;
}

/* Theme toggle button */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    margin: 0.5rem 0.5rem;
    border: 1px solid var(--border-sub);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    width: calc(100% - 1rem);
}
.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--text);
}
.theme-toggle-icon {
    font-size: 1rem;
    line-height: 1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }

/* ═══════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════ */
.layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}
.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border-sub);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform var(--transition), width var(--transition);
}
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* ═══════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════ */
.sb-brand {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border-sub);
}
.sb-brand h1 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}
.sb-brand p {
    font-size: 0.7rem;
    color: var(--text-faint);
    margin-top: 0.15rem;
}
.sb-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-xs);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    margin-top: 0.75rem;
}
.sb-badge-paper {
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--success);
}
.sb-badge-live {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--danger);
    animation: pulse 2.5s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.sb-badge-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.sb-nav {
    padding: 1rem 0.5rem;
    flex: 1;
}
.sb-nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.sb-nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}
.sb-nav-item.active {
    background: var(--surface-2);
    color: var(--text);
    border-left: 3px solid var(--accent);
    font-weight: 600;
}
.sb-nav-item svg {
    width: 16px; height: 16px;
    opacity: 0.7;
}

.sb-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-sub);
}
.sb-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}
.sb-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; color: white; font-weight: 700;
}
.sb-username {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.sb-logout {
    width: 100%;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.sb-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ═══════════════════════════════════════════════
   PAGE HEADER
═══════════════════════════════════════════════ */
.page-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.page-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}
.page-meta {
    font-size: 0.72rem;
    color: var(--text-faint);
    font-family: var(--mono);
}

/* ═══════════════════════════════════════════════
   KPI CARDS
═══════════════════════════════════════════════ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border-sub);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    transition: all var(--transition);
}
.kpi-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow), var(--shadow-sm);
    transform: translateY(-2px);
}
.kpi-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.4rem;
}
.kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    font-family: var(--mono);
    letter-spacing: -0.02em;
}
.kpi-delta {
    font-size: 0.7rem;
    font-family: var(--mono);
    margin-top: 0.3rem;
}
.kpi-delta.positive { color: var(--success); }
.kpi-delta.negative { color: var(--danger); }
.kpi-delta.neutral { color: var(--text-muted); }

/* ═══════════════════════════════════════════════
   SECTION HEADERS
═══════════════════════════════════════════════ */
.section-hdr {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 1.75rem 0 1rem;
}
.section-hdr::before {
    content: '';
    width: 4px; height: 18px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.section-hdr h3 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ═══════════════════════════════════════════════
   CHARTS
═══════════════════════════════════════════════ */
.chart-container {
    background: var(--surface);
    border: 1px solid var(--border-sub);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.chart-container canvas {
    width: 100% !important;
    height: 200px !important;
}

/* ═══════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════ */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border-sub);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
.table-wrap thead th {
    background: var(--surface-2);
    color: var(--text-faint);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-sub);
}
.table-wrap tbody td {
    padding: 0.6rem 1rem;
    font-family: var(--mono);
    font-size: 0.76rem;
    border-bottom: 1px solid var(--border-sub);
    color: var(--text);
}
.table-wrap tbody tr:last-child td { border-bottom: none; }
.table-wrap tbody tr:hover td { background: rgba(99, 102, 241, 0.03); }

/* ═══════════════════════════════════════════════
   POSITION CARD
═══════════════════════════════════════════════ */
.pos-card {
    background: var(--surface);
    border: 1px solid var(--border-sub);
    border-radius: var(--radius);
    padding: 1.75rem;
    position: relative;
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.pos-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--success));
}
.pos-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.pos-symbol {
    font-size: 1.1rem;
    font-weight: 800;
    font-family: var(--mono);
}
.pos-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.pos-badge-open {
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}
.pos-badge-mode {
    background: var(--accent-glow);
    border: 1px solid rgba(99, 102, 241, 0.25);
    color: var(--accent-2);
}
.pos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.25rem;
}
.pos-field-label {
    font-size: 0.63rem;
    color: var(--text-faint);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}
.pos-field-value {
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--mono);
    color: var(--text);
}
.pos-empty {
    text-align: center;
    padding: 3.5rem 1rem;
}
.pos-empty-icon { font-size: 2.5rem; opacity: 0.4; margin-bottom: 0.75rem; }
.pos-empty h4 { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 0.3rem; }
.pos-empty p { color: var(--text-faint); font-size: 0.78rem; }

/* ═══════════════════════════════════════════════
   ADMIN
═══════════════════════════════════════════════ */
.admin-card {
    background: var(--surface);
    border: 1px solid var(--border-sub);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: border-color var(--transition);
}
.admin-card:hover { border-color: var(--border); }
.admin-card h4 { font-size: 0.88rem; font-weight: 700; margin-bottom: 0.4rem; }
.admin-card p { font-size: 0.78rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 1rem; }
.admin-card-danger { border-left: 3px solid var(--danger); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
}
.pill-active { background: var(--success-bg); color: var(--success); }
.pill-paused { background: var(--warning-bg); color: var(--warning); }

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

/* ═══════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--sans);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    width: 100%;
}
.btn:hover {
    background: var(--surface-3);
    color: var(--text);
    transform: translateY(-1px);
}
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-2);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-danger {
    background: var(--danger-bg);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.15);
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* ═══════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border-sub);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow);
}
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.login-header .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.login-header h1 { font-size: 1.2rem; font-weight: 800; }
.login-header p { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; }

.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}
.form-group input {
    width: 100%;
    padding: 0.6rem 0.9rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--sans);
    transition: border-color var(--transition);
    outline: none;
}
.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group input::placeholder { color: var(--text-faint); }

.form-error {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-xs);
    padding: 0.6rem 0.9rem;
    font-size: 0.78rem;
    color: var(--danger);
    margin-bottom: 1rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.checkbox-group input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
}
.checkbox-group label {
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* ═══════════════════════════════════════════════
   PERIOD SELECTOR
═══════════════════════════════════════════════ */
.period-selector {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.period-btn {
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.period-btn:hover { border-color: var(--accent); color: var(--text); }
.period-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Date range picker */
.date-range-picker {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.date-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.date-field label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.date-field input[type="date"] {
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.8rem;
    font-family: var(--mono);
    outline: none;
    transition: border-color var(--transition);
}
.date-field input[type="date"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.date-field input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}
[data-theme="light"] .date-field input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}
.date-separator {
    font-size: 1rem;
    color: var(--text-faint);
    padding-bottom: 0.4rem;
}

/* ═══════════════════════════════════════════════
   SENTIMENT CHIPS
═══════════════════════════════════════════════ */
.info-chips {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}
.info-chip {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    border: 1px solid var(--border-sub);
}

/* ═══════════════════════════════════════════════
   MOBILE HAMBURGER
═══════════════════════════════════════════════ */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-sub);
    z-index: 100;
    padding: 0 1rem;
    align-items: center;
    gap: 0.75rem;
}
.hamburger {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: none; color: var(--text);
    cursor: pointer; border-radius: var(--radius-xs);
}
.hamburger:hover { background: var(--surface-2); }
.mobile-title { font-size: 0.88rem; font-weight: 700; }

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .mobile-header { display: flex; }
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 200;
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), var(--shadow);
    }
    .main-content {
        padding: 72px 1rem 2rem;
    }
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .pos-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .page-header { margin-bottom: 1rem; }
    .page-title { font-size: 1rem; }
}
@media (max-width: 480px) {
    .main-content { padding: 64px 0.75rem 1.5rem; }
    .kpi-grid { grid-template-columns: 1fr; }
    .pos-grid { grid-template-columns: 1fr; }
    .kpi-value { font-size: 1.15rem; }
    .admin-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════
   UTILITIES
═══════════════════════════════════════════════ */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent-2); }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.divider {
    height: 1px;
    background: var(--border-sub);
    margin: 1.5rem 0;
}
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Scrollbar for main content */
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
