/* Raparin Group Timetable — application styles (RTL-first, light/dark). */

:root {
    --bg: #eef2f7;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #6d28d9;
    --brand-strong: #5b21b6;
    --brand-soft: #f0e9fb;
    --accent: #d97706;
    --ok: #16a34a;
    --ok-soft: #e7f6ec;
    --warn: #d97706;
    --warn-soft: #fdf1e0;
    --danger: #dc2626;
    --danger-soft: #fdeaea;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
    --radius: 12px;
    --radius-sm: 8px;
    --topbar-h: 58px;
    --sidebar-w: 240px;
}

[data-theme="dark"] {
    --bg: #0b1220;
    --panel: #121a2b;
    --panel-2: #182338;
    --text: #e6ecf5;
    --muted: #8fa0b8;
    --line: #24304a;
    --brand: #a78bfa;
    --brand-strong: #b9a3f7;
    --brand-soft: #2a1f47;
    --ok: #34c46b;
    --ok-soft: #10281a;
    --warn: #e79a2e;
    --warn-soft: #2d2110;
    --danger: #ef5350;
    --danger-soft: #331313;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: 'Vazirmatn', 'Noto Sans Arabic', 'Noto Sans', Tahoma, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.35; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); }

.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }

.text-muted { color: var(--muted); }
.text-sm { font-size: .85rem; }
.fw-bold { font-weight: 700; }
.mt-4 { margin-block-start: 1.25rem; }
.hide-sm { display: inline; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: .5rem 1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    background: transparent;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
    white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { color: var(--text); }
.btn-ghost:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.btn-outline { border-color: var(--line); background: var(--panel); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-block { width: 100%; }
.btn-icon { padding: .5rem; }

/* ---------- Forms ---------- */
.form-stack { display: flex; flex-direction: column; gap: 1rem; }
.form-title { font-size: 1.25rem; margin: 0; }
.form-subtitle { margin-block-end: .25rem; }
.form-actions { display: flex; gap: .6rem; align-items: center; }

.field { display: flex; flex-direction: column; gap: .35rem; }
.field-label { font-weight: 600; font-size: .9rem; }
.field-error { color: var(--danger); font-size: .82rem; }

.input, select.input, textarea.input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: .55rem .8rem;
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

.input-wrap { position: relative; display: block; }
.input-wrap .input { padding-inline-end: 2.6rem; }
.input-affix {
    position: absolute;
    inset-inline-end: .35rem;
    inset-block-start: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: .35rem;
    border-radius: 6px;
}
.input-affix:hover { color: var(--text); }
.password-row { display: flex; align-items: stretch; gap: .5rem; }
.password-row .input { min-width: 0; flex: 1; }
.password-toggle { flex: none; width: 42px; padding: .5rem; }

/* ---------- Cards / alerts ---------- */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.card-title { font-size: 1.05rem; }
.card-narrow { max-width: 460px; }

.alert {
    border-radius: var(--radius-sm);
    padding: .7rem 1rem;
    margin-block-end: 1rem;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    border-radius: 999px;
    padding: .15rem .7rem;
    font-size: .8rem;
    font-weight: 700;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--panel-2); color: var(--muted); }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    inset-inline-start: 0;
    top: calc(100% + 6px);
    min-width: 200px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: .35rem;
    display: none;
    z-index: 60;
}
.dropdown-end .dropdown-menu { inset-inline-start: auto; inset-inline-end: 0; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
    display: block;
    width: 100%;
    text-align: start;
    background: transparent;
    border: 0;
    font: inherit;
    color: var(--text);
    padding: .5rem .7rem;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
}
.dropdown-item:hover { background: var(--brand-soft); color: var(--brand); }
.dropdown-item.is-active { font-weight: 700; color: var(--brand); }
.dropdown-item-danger:hover { background: var(--danger-soft); color: var(--danger); }
.dropdown-header { padding: .5rem .7rem; border-block-end: 1px solid var(--line); margin-block-end: .35rem; }

/* ---------- Plain (login/activation) layout ---------- */
.page-plain { min-height: 100vh; display: flex; flex-direction: column; }
.plain-topbar {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: 1rem 1.25rem;
}
.plain-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    gap: 1rem;
}
.plain-card { width: 100%; max-width: 430px; padding: 2rem; }
.plain-footer { font-size: .8rem; }

.brand-block { text-align: center; margin-block-end: 1.5rem; }
.brand-mark { width: 52px; height: 52px; }
.brand-name { font-size: 1.2rem; margin: .6rem 0 .2rem; }
.brand-tagline { color: var(--muted); font-size: .85rem; margin: 0; }

/* ---------- App shell ---------- */
.page-app { min-height: 100vh; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: .5rem;
    height: var(--topbar-h);
    padding-inline: .75rem;
    background: var(--panel);
    border-block-end: 1px solid var(--line);
}
.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
}
.topbar-brand .brand-mark { width: 30px; height: 30px; }
.topbar-title { font-size: 1rem; }
.topbar-spacer { flex: 1; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
}

.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--panel);
    border-inline-end: 1px solid var(--line);
    padding: .9rem .6rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: .15rem; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .8rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}
.sidebar-link:hover { background: var(--brand-soft); color: var(--brand); }
.sidebar-link.is-active { background: var(--brand); color: #fff; }
.sidebar-toggle { display: none; }

.content { flex: 1; padding: 1.5rem; min-width: 0; }

.page-head { margin-block-end: 1.25rem; }
.page-title { font-size: 1.35rem; margin: 0 0 .25rem; }

/* ---------- Grid / stats ---------- */
.grid { display: grid; gap: 1rem; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.stat-card { display: flex; flex-direction: column; gap: .35rem; }
.stat-label { color: var(--muted); font-weight: 600; font-size: .85rem; }
.stat-value { font-size: 1.5rem; font-weight: 800; display: flex; align-items: center; gap: .4rem; }
.stat-ok { color: var(--ok); }
.stat-warn { color: var(--warn); font-size: 1.05rem; }
.stat-foot { font-size: .8rem; }

/* ---------- Tables (used across modules) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .8rem; border-block-end: 1px solid var(--line); text-align: start; }
.table th { color: var(--muted); font-size: .82rem; font-weight: 700; }
.table tbody tr:hover { background: var(--panel-2); }

/* ---------- Theme toggle icons ---------- */
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        inset-block: var(--topbar-h) 0;
        inset-inline-start: 0;
        transform: translateX(calc(var(--rtl-flip, 1) * -100%));
        transition: transform .2s ease;
        z-index: 55;
    }
    [dir="rtl"] .sidebar { --rtl-flip: -1; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; }
    .hide-sm { display: none; }
    .content { padding: 1rem; }
}

/* ---- Module utilities: toolbars, chips, pagination, timelines, lists ---- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-block-end: 16px; }
.toolbar .input { max-width: 320px; }
.select-auto { width: auto; }
.code-chip { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: .92em; letter-spacing: .04em; }
.code-chip-lg { font-size: 1.15rem; padding: 6px 12px; }
.empty-note { padding: 24px 0; text-align: center; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-block-start: 16px; }
.is-disabled { pointer-events: none; opacity: .45; }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row form { display: inline-flex; margin: 0; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-warn:hover { filter: brightness(.92); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(.92); }
.badge-info { background: var(--brand-soft); color: var(--brand); }
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .grid-2col { grid-template-columns: 1fr; } }
.divider { border: 0; border-block-start: 1px solid var(--line); margin-block: 20px; }
.hint { color: var(--muted); font-size: .85rem; margin-block-start: 6px; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; }
.ta-end { text-align: end; }
.list-plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.list-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item { position: relative; padding-inline-start: 22px; padding-block-end: 14px; }
.timeline-item::before { content: ""; position: absolute; inset-inline-start: 5px; inset-block-start: 14px; inset-block-end: 0; width: 2px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: absolute; inset-inline-start: 0; inset-block-start: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.is-copied { outline: 2px solid var(--ok); }
