/* =====================================================
   QuantEdge AI — Design System
   Light glass, gradient-accent trading platform theme
   ===================================================== */

:root {
    /* Surface */
    --bg-deep: #f4f6fb;
    --bg-deep-2: #ffffff;
    --bg-panel: rgba(255, 255, 255, 0.78);
    --bg-panel-solid: #ffffff;
    --border-glass: rgba(15, 23, 42, 0.08);
    --border-glass-strong: rgba(15, 23, 42, 0.16);

    /* Accents */
    --cyan: #00b8a0;
    --violet: #6c4cff;
    --pink: #e11d48;
    --amber: #d97706;
    --gradient-primary: linear-gradient(135deg, #00c9ac 0%, #6c4cff 100%);
    --gradient-radial: radial-gradient(circle at 20% 10%, rgba(108, 76, 255, 0.10), transparent 45%),
                        radial-gradient(circle at 85% 0%, rgba(0, 201, 172, 0.10), transparent 40%);

    /* Text */
    --text-primary: #10192e;
    --text-secondary: #56607a;
    --text-muted: #8993ac;

    /* Type */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Radius / shadow */
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --shadow-glow: 0 20px 50px -20px rgba(0, 184, 160, 0.25);
    --shadow-card: 0 10px 28px -14px rgba(16, 25, 46, 0.12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

body {
    background-image: var(--gradient-radial);
    background-attachment: fixed;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
::selection { background: rgba(0, 184, 160, 0.18); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-glass-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15,23,42,0.28); }

h1, h2, h3, h4, .font-display { font-family: var(--font-display); letter-spacing: -0.02em; }
.mono { font-family: var(--font-mono); }

/* ---------- Glass panel ---------- */
.glass {
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow-card);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
    background: var(--gradient-primary);
    color: #ffffff;
    box-shadow: 0 10px 24px -10px rgba(0, 184, 160, 0.45);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 30px -10px rgba(0, 184, 160, 0.55); transform: translateY(-1px); }

.btn-ghost {
    background: rgba(15,23,42,0.03);
    color: var(--text-primary);
    border-color: var(--border-glass);
}
.btn-ghost:hover:not(:disabled) { background: rgba(15,23,42,0.06); border-color: var(--border-glass-strong); }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn .spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn-label { opacity: 0.75; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Inputs ---------- */
.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}
.input-wrap { position: relative; }
.input-wrap i.fa-solid, .input-wrap i.fa-brands {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 14px;
}
.field input, .field select {
    width: 100%;
    background: rgba(15,23,42,0.025);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14.5px;
    padding: 13px 16px 13px 42px;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.field select { padding-left: 16px; appearance: none; cursor: pointer; }
.field input:focus, .field select:focus {
    border-color: var(--cyan);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 184, 160, 0.14);
}
.field .error-msg {
    color: var(--pink);
    font-size: 12.5px;
    margin-top: 6px;
    display: none;
}
.field.has-error input { border-color: var(--pink); }
.field.has-error .error-msg { display: block; }

.toggle-pass {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px;
}

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0; cursor: pointer;
    background: rgba(15,23,42,0.14);
    border-radius: 999px;
    transition: 0.2s;
}
.switch .slider::before {
    content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: 0.2s;
    box-shadow: 0 1px 3px rgba(16,25,46,0.25);
}
.switch input:checked + .slider { background: var(--gradient-primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
    font-family: var(--font-mono);
}
.badge-buy { background: rgba(0,184,160,0.12); color: var(--cyan); }
.badge-sell { background: rgba(225,29,72,0.10); color: var(--pink); }
.badge-hold { background: rgba(217,119,6,0.12); color: var(--amber); }
.badge-open { background: rgba(108,76,255,0.12); color: var(--violet); }
.badge-closed { background: rgba(15,23,42,0.06); color: var(--text-secondary); }

/* ---------- Scroll reveal ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.fade-up { animation: fadeUp 0.5s ease both; }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--bg-panel-solid);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    transition: width 0.2s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 20;
}
.sidebar.collapsed { width: 84px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-foot .foot-text { display: none; }

.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 26px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px;
    background: var(--gradient-primary);
    display: flex; align-items: center; justify-content: center;
    color: #ffffff; font-size: 17px; flex-shrink: 0;
    box-shadow: 0 6px 16px -6px rgba(0,184,160,0.5);
}
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.brand-text span { color: var(--cyan); }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item a {
    display: flex; align-items: center; gap: 13px;
    padding: 11px 12px; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 14px; font-weight: 500;
    position: relative;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-item a i { width: 18px; text-align: center; font-size: 15px; }
.nav-item a:hover { background: rgba(15,23,42,0.04); color: var(--text-primary); }
.nav-item.active a {
    color: var(--text-primary);
    background: linear-gradient(90deg, rgba(0,184,160,0.10), rgba(108,76,255,0.06));
}
.nav-item.active a::before {
    content: "";
    position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; border-radius: 4px;
    background: var(--gradient-primary);
    box-shadow: 0 0 10px rgba(0,184,160,0.5);
}
.sidebar.collapsed .nav-item.active a::before { left: -8px; }

.sidebar-toggle {
    width: 100%; margin-top: 6px; padding: 10px; border-radius: var(--radius-sm);
    background: rgba(15,23,42,0.03); border: 1px solid var(--border-glass);
    color: var(--text-muted); cursor: pointer; font-size: 13px;
}
.sidebar-toggle:hover { background: rgba(15,23,42,0.06); color: var(--text-primary); }

.sidebar-foot {
    display: flex; align-items: center; gap: 10px;
    padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--border-glass);
}
.sidebar-foot .avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--gradient-primary); color: #ffffff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.foot-text { line-height: 1.3; overflow: hidden; }
.foot-text b { display: block; font-size: 13px; }
.foot-text span { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Main / topbar ---------- */
.main { flex: 1; min-width: 0; }
.topbar {
    height: 72px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; border-bottom: 1px solid var(--border-glass);
    background: rgba(255,255,255,0.75); backdrop-filter: blur(14px);
    position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(15,23,42,0.03); border: 1px solid var(--border-glass);
    color: var(--text-secondary); cursor: pointer; position: relative;
    transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: rgba(15,23,42,0.06); color: var(--text-primary); }
.icon-btn .dot {
    position: absolute; top: 8px; right: 9px;
    width: 7px; height: 7px; border-radius: 50%; background: var(--pink);
    box-shadow: 0 0 0 2px var(--bg-deep-2);
}

.content { padding: 26px 28px 60px; max-width: 1400px; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { padding: 20px; position: relative; overflow: hidden; }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.02em; }
.stat-card .value { font-family: var(--font-mono); font-size: 26px; font-weight: 600; margin-top: 10px; }
.stat-card .icon {
    position: absolute; right: 16px; top: 16px; width: 34px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 14px;
    background: rgba(0,184,160,0.08); color: var(--cyan);
}
.stat-card .delta { font-size: 12px; margin-top: 8px; color: var(--text-muted); }
.stat-card .delta.up { color: var(--cyan); }
.stat-card .delta.down { color: var(--pink); }

/* ---------- Panels ---------- */
.panel { padding: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel-head h3 { margin: 0; font-size: 15.5px; }
.panel-head .link { font-size: 12.5px; color: var(--cyan); cursor: pointer; }

.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table thead th {
    text-align: left; color: var(--text-muted); font-weight: 600; font-size: 11.5px;
    letter-spacing: 0.04em; text-transform: uppercase;
    padding: 0 14px 12px; position: sticky; top: 0; background: var(--bg-panel-solid);
}
table.data-table tbody td { padding: 13px 14px; border-top: 1px solid var(--border-glass); vertical-align: middle; }
table.data-table tbody tr { transition: background 0.15s ease; }
table.data-table tbody tr:hover { background: rgba(15,23,42,0.02); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { font-size: 26px; margin-bottom: 10px; display: block; color: var(--text-muted); opacity: 0.6; }

/* ---------- Activity list ---------- */
.activity-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-glass); }
.activity-item:first-child { border-top: none; }
.activity-icon {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.activity-body { flex: 1; min-width: 0; }
.activity-body b { font-size: 13.5px; display: block; }
.activity-body span { font-size: 12px; color: var(--text-muted); }
.activity-pnl { font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-section-title { font-size: 14px; margin: 0 0 4px; }
.settings-section-desc { font-size: 12.5px; color: var(--text-muted); margin: 0 0 18px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--border-glass); }
.toggle-row:first-child { border-top: none; }
.toggle-row b { font-size: 13.5px; display: block; }
.toggle-row span { font-size: 12px; color: var(--text-muted); }

/* ---------- Sidebar mobile overlay backdrop ---------- */
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(16,25,46,0.35);
    backdrop-filter: blur(2px);
    z-index: 40;
}
.sidebar-backdrop.show { display: block; }

/* ---------- Mobile nav trigger (hidden on desktop by default) ---------- */
#mobileNavBtn { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .content { max-width: 100%; }
}

@media (max-width: 900px) {
    .brand-panel { display: none; }
}

@media (max-width: 780px) {
    .sidebar {
        position: fixed; left: -270px; top: 0; z-index: 50;
        transition: left 0.25s ease;
        width: 260px;
    }
    .sidebar.mobile-open { left: 0; box-shadow: 20px 0 50px rgba(16,25,46,0.18); }
    .sidebar.collapsed { width: 260px; }
    .sidebar.collapsed .brand-text,
    .sidebar.collapsed .nav-label,
    .sidebar.collapsed .sidebar-foot .foot-text { display: block; }
    .sidebar-toggle { display: none; }

    #mobileNavBtn { display: flex; }

    .stat-grid { grid-template-columns: 1fr; }
    .content { padding: 16px 14px 50px; }
    .topbar { padding: 0 16px; height: 64px; }
    .topbar h1 { font-size: 17px; }
    .topbar .sub { display: none; }

    .panel { padding: 16px; }
    .stat-card { padding: 16px; }
    .stat-card .value { font-size: 22px; }

    .login-card { padding: 30px 22px; }
    .form-panel { padding: 20px; }
}

@media (max-width: 480px) {
    .topbar-actions { gap: 8px; }
    .icon-btn { width: 36px; height: 36px; }
    .stat-card .icon { width: 28px; height: 28px; font-size: 12px; }
    .login-card h2 { font-size: 21px; }
    .btn { font-size: 13.5px; padding: 11px 16px; }
    table.data-table { font-size: 12.5px; }
    .settings-grid, .grid-2 { gap: 12px; }
}
