/* ==============================================
   Analytics Dashboard — Core Stylesheet
   Palette / typography from user's sample reports
   ============================================== */

:root {
    --bg:    #090b10;
    --page:  #0f1117;
    --card:  #161920;
    --card2: #1b1e28;
    --line:  #1e2130;
    --line2: #262a3c;

    --gold:   #f0b429;
    --green:  #1ecf87;
    --red:    #ff5454;
    --blue:   #4b9eff;
    --purple: #9e71ff;
    --orange: #ff8c42;
    --teal:   #00cec8;

    --t1: #edf0f8;
    --t2: #7880a0;
    --t3: #383d55;

    --radius:    14px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px rgba(0,0,0,0.35);

    --font-display: 'Playfair Display', 'Cairo', serif;
    --font-body:    'DM Sans', 'Cairo', system-ui, -apple-system, sans-serif;
    --font-arabic:  'Cairo', 'DM Sans', system-ui, sans-serif;

    --sidebar-w: 264px;
}

/* ----- Reset ----- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--t1);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
html[lang="ar"] body { font-family: var(--font-arabic); }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; margin: 0; color: var(--t1); }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] h4 {
    font-family: var(--font-arabic); font-weight: 700;
}

code, pre {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    background: rgba(255,255,255,0.04);
    padding: 1px 6px;
    border-radius: 4px;
    direction: ltr;
    unicode-bidi: bidi-override;
}

/* ----- Layout ----- */
.app-shell { min-height: 100vh; background: var(--page); }

.layout-grid {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    align-items: stretch;
}

.main-content {
    padding: 24px 32px 80px;
    min-width: 0;
    width: 100%;
}

.page-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}
.topbar { max-width: 1280px; width: 100%; margin: 0 auto; }

/* ----- Sidebar ----- */
.sidebar {
    background: var(--card);
    border-inline-end: 1px solid var(--line);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    min-width: 0;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 8px 16px;
    border-bottom: 1px solid var(--line);
}
.brand-mark {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--gold), #c98f0f);
    color: #1a1408;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 20px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--t1); }

.nav-group { margin-bottom: 16px; }
.nav-group-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--t3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0 12px 8px;
}

.nav-list { list-style: none; padding: 0; margin: 0; }
.nav-item { margin-bottom: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--t2);
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--card2); color: var(--t1); text-decoration: none; }
.nav-item.is-active .nav-link {
    background: linear-gradient(90deg, rgba(240,180,41,0.12), transparent);
    color: var(--gold);
    border-inline-start: 3px solid var(--gold);
    padding-inline-start: 9px;
}

.nav-icon { width: 16px; height: 16px; background: currentColor; mask-size: contain; -webkit-mask-size: contain; mask-repeat: no-repeat; -webkit-mask-repeat: no-repeat; opacity: 0.85; }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.user-card { display: flex; align-items: center; gap: 12px; padding: 8px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--card2); color: var(--gold);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px;
    text-transform: uppercase;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-weight: 600; color: var(--t1); font-size: 13px; truncate: ellipsis; }
.user-role { font-size: 11px; color: var(--t2); }
.logout-link {
    display: block; text-align: center;
    padding: 8px;
    margin-top: 8px;
    color: var(--t2);
    font-size: 12px;
    border-radius: var(--radius-sm);
}
.logout-link:hover { color: var(--red); background: rgba(255,84,84,0.06); text-decoration: none; }

/* ----- Topbar ----- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 8px 0 16px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 8px;
}
.topbar-left { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 24px;
    color: var(--t1);
}
html[lang="ar"] .page-title { font-family: var(--font-arabic); }

.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter-form, .inline-form { display: flex; align-items: center; gap: 8px; margin: 0; }

/* ----- Mobile hamburger toggle ----- */
.nav-toggle {
    display: none;
    background: var(--card);
    border: 1px solid var(--line2);
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0;
    color: var(--t1);
    flex-shrink: 0;
}
.nav-toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* ----- Form controls ----- */
.input, .select {
    background: var(--card);
    border: 1px solid var(--line2);
    color: var(--t1);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.input:focus, .select:focus { border-color: var(--gold); background: var(--card2); }
.input--date { font-family: ui-monospace, monospace; }

.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--t2); text-transform: uppercase; letter-spacing: 0.05em; }

/* ----- Buttons ----- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 13px;
    color: var(--t1);
    background: var(--card);
    transition: transform 0.05s, background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--card2); }
.btn:active { transform: translateY(1px); }
.btn--gold {
    background: linear-gradient(135deg, var(--gold), #c98f0f);
    color: #1a1408;
    border-color: rgba(240,180,41,0.45);
}
.btn--gold:hover { background: linear-gradient(135deg, #ffc94d, var(--gold)); }
.btn--ghost { background: transparent; border-color: var(--line2); color: var(--t2); }
.btn--ghost:hover { background: var(--card); color: var(--t1); }
.btn--small { padding: 6px 12px; font-size: 12px; }
.btn--full { width: 100%; justify-content: center; }

/* Compact icon button (topbar refresh). Shows icon + short label on desktop;
 * collapses to icon-only on narrow screens. */
.btn--icon {
    padding: 8px 12px;
    gap: 6px;
}
.btn--icon .btn-icon {
    font-size: 15px;
    line-height: 1;
    display: inline-block;
}
.btn--icon:hover .btn-icon {
    transform: rotate(60deg);
    transition: transform 0.25s ease;
}
@media (max-width: 720px) {
    .btn--icon { padding: 8px 10px; }
    .btn--icon .btn-label-short { display: none; }
}

/* ----- Alerts ----- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    border-inline-start: 3px solid;
}
.alert--success { background: rgba(30,207,135,0.08); color: var(--green); border-color: var(--green); }
.alert--error   { background: rgba(255,84,84,0.08);  color: var(--red);   border-color: var(--red); }

/* ----- Empty / placeholder states ----- */
.empty-state { text-align: center; padding: 80px 24px; }
.empty-state__code { font-family: var(--font-display); font-size: 96px; font-weight: 900; color: var(--gold); }
.empty-state__msg  { color: var(--t2); margin: 0 0 24px; }
