/* ═══════════════════════════════════════════════════════════════
   Maylight Capital — Design System v3
   Dark & Light mode  |  Lighthouse brand  |  Inter typography
   ═══════════════════════════════════════════════════════════════ */

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

/* ── DARK MODE (default) ──────────────────────────────────────── */
:root,
[data-theme="dark"] {
    --bg:            #0a0d14;
    --surface:       #111520;
    --surface2:      #171c2e;
    --surface3:      #1a1f30;
    --border:        #1e2540;
    --border-hover:  #2a3155;
    --text:          #e2e8f0;
    --text-secondary:#94a3b8;
    --muted:         #64748b;
    --green:         #22c55e;
    --green-dim:     rgba(34,197,94,0.12);
    --red:           #ef4444;
    --red-dim:       rgba(239,68,68,0.12);
    --yellow:        #eab308;
    --yellow-dim:    rgba(234,179,8,0.12);
    --orange:        #f97316;
    --orange-dim:    rgba(249,115,22,0.12);
    --blue:          #3b82f6;
    --blue-dim:      rgba(59,130,246,0.12);
    --accent:        #6366f1;
    --accent-dim:    rgba(99,102,241,0.12);
    --purple:        #8b5cf6;

    /* Logo rendering in dark mode: invert to white */
    --logo-filter:   invert(1) brightness(2);
    --logo-text-color: #e2e8f0;
    --theme-toggle-icon: '☀️';

    --sidebar-width: 210px;
    --topbar-height: 46px;
    --radius:        12px;
    --radius-sm:     8px;
    --radius-lg:     16px;
}

/* ── LIGHT MODE ───────────────────────────────────────────────── */
[data-theme="light"] {
    --bg:            #f4f6fb;
    --surface:       #ffffff;
    --surface2:      #f0f2f8;
    --surface3:      #e8ecf4;
    --border:        #dde1ec;
    --border-hover:  #b8c0d4;
    --text:          #0f172a;
    --text-secondary:#475569;
    --muted:         #94a3b8;
    --green:         #16a34a;
    --green-dim:     rgba(22,163,74,0.10);
    --red:           #dc2626;
    --red-dim:       rgba(220,38,38,0.10);
    --yellow:        #ca8a04;
    --yellow-dim:    rgba(202,138,4,0.10);
    --orange:        #ea580c;
    --orange-dim:    rgba(234,88,12,0.10);
    --blue:          #2563eb;
    --blue-dim:      rgba(37,99,235,0.10);
    --accent:        #4f46e5;
    --accent-dim:    rgba(79,70,229,0.10);
    --purple:        #7c3aed;

    /* Logo in light mode: keep original black */
    --logo-filter:   none;
    --logo-text-color: #0f172a;
    --theme-toggle-icon: '🌙';
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background 0.25s ease, color 0.25s ease;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.mc-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    transition: width 0.22s ease, background 0.25s ease;
}

body.sidebar-collapsed .mc-sidebar          { width: 60px; overflow-x: hidden; }
body.sidebar-collapsed .mc-sidebar-logo-text { display: none; }
body.sidebar-collapsed .mc-sidebar-section-title { display: none; }
body.sidebar-collapsed .mc-sidebar-item     { justify-content: center; padding: 10px 0; font-size: 0; }
body.sidebar-collapsed .mc-sidebar-item .icon { font-size: 1.2rem; }
body.sidebar-collapsed .mc-sidebar-bottom   { display: none; }
body.sidebar-collapsed .mc-topbar           { left: 60px; }
body.sidebar-collapsed .mc-main            { margin-left: 60px; }

/* ── Logo ─────────────────────────────────────────────────────── */
.mc-sidebar-logo {
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.mc-sidebar-logo-img {
    height: 36px;
    width: auto;
    object-fit: contain;
    filter: var(--logo-filter);
    transition: filter 0.25s ease;
    flex-shrink: 0;
}
.mc-sidebar-logo-text {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--logo-text-color);
    letter-spacing: -0.01em;
    line-height: 1.25;
    transition: color 0.25s ease;
}

/* ── Nav sections ─────────────────────────────────────────────── */
.mc-sidebar-section {
    padding: 14px 10px 4px;
}
.mc-sidebar-section-title {
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.10em;
    padding: 0 8px;
    margin-bottom: 5px;
}

.mc-sidebar-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.77rem;
    font-weight: 500;
    transition: all 0.14s ease;
    cursor: pointer;
    margin-bottom: 1px;
}
.mc-sidebar-item:hover {
    background: var(--surface2);
    color: var(--text);
}
.mc-sidebar-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
    border-left: 2px solid var(--accent);
}
.mc-sidebar-item .icon {
    font-size: 0.88rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* ── Sidebar bottom ───────────────────────────────────────────── */
.mc-sidebar-bottom {
    margin-top: auto;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}

/* ── Theme toggle button ──────────────────────────────────────── */
#mc-theme-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 8px;
}
#mc-theme-toggle:hover {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border-hover);
}

/* ── Top Bar ──────────────────────────────────────────────────── */
.mc-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 150;
    font-size: 0.70rem;
    color: var(--muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
    transition: left 0.22s ease, background 0.25s ease;
}
.mc-topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.mc-ws-indicator {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.66rem; font-weight: 500;
    text-transform: none; letter-spacing: 0;
}
.mc-ws-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: pulse-dot 2s ease-in-out infinite;
}
.mc-ws-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); animation: none; }
@keyframes pulse-dot { 0%,100% { opacity:1; } 50% { opacity:0.45; } }

/* ── Main Content ─────────────────────────────────────────────── */
.mc-main {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 28px 32px;
    min-height: calc(100vh - var(--topbar-height));
    transition: margin-left 0.22s ease;
}

/* ── Page Header ──────────────────────────────────────────────── */
.mc-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}
.mc-page-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
}
.mc-page-subtitle {
    font-size: 0.77rem;
    color: var(--muted);
    margin-top: 4px;
    font-weight: 400;
}

/* ── Stat Cards ───────────────────────────────────────────────── */
.mc-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}
.mc-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    transition: border-color 0.2s, background 0.25s;
}
.mc-stat-card:hover { border-color: var(--border-hover); }
.mc-stat-label {
    font-size: 0.63rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    display: flex; align-items: center; gap: 6px;
}
.mc-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 6px;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
    color: var(--text);
}
.mc-stat-value.green  { color: var(--green); }
.mc-stat-value.red    { color: var(--red); }
.mc-stat-value.yellow { color: var(--yellow); }
.mc-stat-value.accent { color: var(--accent); }

/* ── Cards ────────────────────────────────────────────────────── */
.mc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 20px;
    transition: background 0.25s, border-color 0.2s;
}
.mc-card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mc-card-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1rem;
    display: flex; align-items: center; gap: 10px;
    color: var(--text);
}
.mc-card-body { padding: 0; }

/* ── Tables ───────────────────────────────────────────────────── */
.mc-table { width: 100%; border-collapse: collapse; }
.mc-table thead th {
    font-size: 0.61rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    background: rgba(99,102,241,0.03);
    white-space: nowrap;
}
.mc-table tbody td {
    padding: 13px 16px;
    font-size: 0.81rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}
.mc-table tbody tr { transition: background 0.14s; }
.mc-table tbody tr:hover { background: rgba(99,102,241,0.04); }
.mc-table .mono {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 0.78rem;
}

/* ── Badges ───────────────────────────────────────────────────── */
.mc-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.mc-badge.green  { background: var(--green-dim);  color: var(--green); }
.mc-badge.red    { background: var(--red-dim);    color: var(--red); }
.mc-badge.yellow { background: var(--yellow-dim); color: var(--yellow); }
.mc-badge.blue   { background: var(--blue-dim);   color: var(--blue); }
.mc-badge.accent { background: var(--accent-dim); color: var(--accent); }
.mc-badge.orange { background: var(--orange-dim); color: var(--orange); }
.mc-badge.muted  { background: rgba(100,116,139,0.12); color: var(--muted); }

/* ── Tabs ─────────────────────────────────────────────────────── */
.mc-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}
.mc-tab {
    padding: 10px 16px;
    font-size: 0.77rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.18s;
    background: none;
    border-top: none; border-left: none; border-right: none;
    font-family: inherit;
}
.mc-tab:hover { color: var(--text); }
.mc-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Buttons ──────────────────────────────────────────────────── */
.mc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    border: 1px solid transparent;
}
.mc-btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff; border: none;
}
.mc-btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.mc-btn-danger  { background: var(--red); color: #fff; border: none; }
.mc-btn-danger:hover  { opacity: 0.88; }
.mc-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.mc-btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* ── Forms ────────────────────────────────────────────────────── */
.mc-input, .mc-select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s, background 0.25s;
}
.mc-input:focus, .mc-select:focus { border-color: var(--accent); }
.mc-input::placeholder { color: var(--muted); }

/* ── Connection status bar (signals page) ─────────────────────── */
.conn-bar {
    display: flex; gap: 20px; margin-bottom: 24px; padding: 14px 20px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    align-items: center; flex-wrap: wrap;
    transition: background 0.25s;
}
.conn-item { display: flex; align-items: center; gap: 8px; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.conn-dot.on  { background: var(--green); box-shadow: 0 0 7px var(--green); animation: pulse-dot 2s infinite; }
.conn-dot.off { background: var(--red); }
.conn-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.conn-value { font-size: 0.78rem; font-weight: 600; color: var(--text); }

/* ── Empty States ─────────────────────────────────────────────── */
.mc-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.mc-empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.mc-empty h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.mc-empty p  { font-size: 0.8rem; line-height: 1.6; }

/* ── Kill Switch ──────────────────────────────────────────────── */
.mc-kill-switch { border: 2px solid var(--red); border-radius: var(--radius); padding: 20px 24px; margin-top: 20px; }
.mc-kill-switch-title { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 1rem; color: var(--text); display: flex; align-items: center; gap: 8px; }
.mc-kill-switch-desc  { font-size: 0.78rem; color: var(--muted); margin: 6px 0 12px; }
.mc-kill-switch-status { display: inline-flex; padding: 6px 14px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; }
.mc-kill-switch-status.active   { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(239,68,68,0.3); }
.mc-kill-switch-status.inactive { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }

/* ── Spinner ──────────────────────────────────────────────────── */
.mc-spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: mc-spin 0.7s linear infinite;
    margin: 0 auto;
}
@keyframes mc-spin { to { transform: rotate(360deg); } }
.mc-loading { text-align: center; padding: 40px; color: var(--muted); font-size: 0.82rem; }

/* ── Utilities ────────────────────────────────────────────────── */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted  { color: var(--muted); }
.text-accent { color: var(--accent); }
.font-mono   { font-family: 'JetBrains Mono', monospace; }
.font-serif  { font-family: 'Playfair Display', serif; }
.fw-700      { font-weight: 700; }

/* ── Theme transition on all key elements ─────────────────────── */
.mc-sidebar, .mc-topbar, .mc-stat-card, .mc-card,
.mc-table thead th, .mc-table tbody td { transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
    .mc-sidebar  { display: none; }
    .mc-topbar   { left: 0; }
    .mc-main     { margin-left: 0; }
    .mc-stats    { grid-template-columns: repeat(2, 1fr); }
}
