/* ==========================================================================
   پنل مدیریت لایسنس پویا — سیستم طراحی
   RTL، دو تم (روشن/تیره)، بدون وابستگی به فریم‌ورک بیرونی.
   ========================================================================== */

:root {
    --brand: #4f6ef7;
    --brand-strong: #3b55d9;
    --brand-soft: rgba(79, 110, 247, .12);

    --success: #14a06a;
    --success-soft: rgba(20, 160, 106, .12);
    --warning: #d98404;
    --warning-soft: rgba(217, 132, 4, .14);
    --danger: #e0393e;
    --danger-soft: rgba(224, 57, 62, .12);
    --muted-soft: rgba(120, 130, 150, .14);

    --bg: #f5f7fb;
    --bg-elevated: #ffffff;
    --bg-sunken: #eef1f7;
    --sidebar-bg: #101a33;
    --sidebar-fg: #b9c4de;
    --sidebar-fg-strong: #ffffff;

    --text: #17203a;
    --text-soft: #5c6883;
    --text-faint: #8b95ab;
    --border: #e2e7f0;
    --border-strong: #cdd5e3;

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(16, 26, 51, .06), 0 1px 3px rgba(16, 26, 51, .04);
    --shadow: 0 4px 16px rgba(16, 26, 51, .07);
    --shadow-lg: 0 18px 50px rgba(16, 26, 51, .16);

    --sidebar-w: 250px;
}

html[data-theme="dark"] {
    --bg: #0d1220;
    --bg-elevated: #151c2e;
    --bg-sunken: #10172a;
    --sidebar-bg: #0a0f1c;
    --sidebar-fg: #93a1c0;

    --text: #e7ecf7;
    --text-soft: #9daac6;
    --text-faint: #74809c;
    --border: #24304a;
    --border-strong: #33415f;

    --brand-soft: rgba(79, 110, 247, .2);
    --success-soft: rgba(20, 160, 106, .18);
    --warning-soft: rgba(217, 132, 4, .2);
    --danger-soft: rgba(224, 57, 62, .18);
    --muted-soft: rgba(120, 130, 150, .18);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 4px 18px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
}

@font-face {
    font-family: 'Vazirmatn';
    font-display: swap;
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
}

@font-face {
    font-family: 'Vazirmatn';
    font-display: swap;
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    font-size: 14px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 700; line-height: 1.4; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }

/* ---------------------------------------------------------------- چیدمان */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
    color: var(--sidebar-fg-strong);
}

.sidebar__logo {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand), #8b5cf6);
    display: grid; place-items: center;
    font-weight: 700; font-size: 16px; color: #fff;
    flex: 0 0 auto;
}

.sidebar__title { font-weight: 700; font-size: 14px; }
.sidebar__subtitle { font-size: 11px; color: var(--sidebar-fg); opacity: .75; }

.sidebar__group { padding: 10px 12px 0; }
.sidebar__group-label {
    font-size: 10.5px; letter-spacing: .04em;
    color: var(--sidebar-fg); opacity: .55;
    padding: 6px 10px; text-transform: uppercase;
}

.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; margin: 2px 0;
    border-radius: var(--radius-sm);
    color: var(--sidebar-fg);
    font-size: 13.5px;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(79, 110, 247, .35); }
.nav-link svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .9; }
.nav-link__badge {
    margin-inline-start: auto;
    background: rgba(255, 255, 255, .16);
    border-radius: 999px; padding: 0 7px;
    font-size: 11px; min-width: 20px; text-align: center;
}

.sidebar__footer { margin-top: auto; padding: 14px; font-size: 11px; color: var(--sidebar-fg); opacity: .6; }

.content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 22px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-weight: 700; font-size: 16px; }
.topbar__crumb { font-size: 12px; color: var(--text-faint); }
.topbar__spacer { flex: 1 1 auto; }

.icon-btn {
    display: grid; place-items: center;
    width: 36px; height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-soft);
    cursor: pointer;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.user-chip {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px 5px 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12.5px;
}
.user-chip__avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--brand-soft); color: var(--brand);
    display: grid; place-items: center; font-weight: 700; font-size: 12px;
}

.page { padding: 22px; max-width: 1500px; width: 100%; margin: 0 auto; }
.page__head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page__head p { color: var(--text-soft); font-size: 13px; margin: 0; }
.page__actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.menu-toggle { display: none; }

@media (max-width: 1000px) {
    .sidebar {
        position: fixed; inset-inline-end: 0; top: 0; z-index: 60;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    html[dir="rtl"] .sidebar { transform: translateX(100%); }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open::after {
        content: ''; position: fixed; inset: 0; background: rgba(6, 10, 20, .5); z-index: 50;
    }
    .menu-toggle { display: grid; }
    .page { padding: 16px; }
}

/* ------------------------------------------------------------------ کارت */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
    overflow: hidden;
}
.card__head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.card__head h2 { margin: 0; }
.card__head .card__actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.card__body { padding: 18px; }
.card__body--tight { padding: 0; }
.card__hint { color: var(--text-soft); font-size: 12.5px; }

.grid { display: grid; gap: 16px; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ------------------------------------------------------------------- KPI */
.kpi {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    display: flex; gap: 14px; align-items: flex-start;
}
.kpi__icon {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand);
    flex: 0 0 auto;
}
.kpi__icon svg { width: 21px; height: 21px; }
.kpi__icon--success { background: var(--success-soft); color: var(--success); }
.kpi__icon--warning { background: var(--warning-soft); color: var(--warning); }
.kpi__icon--danger { background: var(--danger-soft); color: var(--danger); }
.kpi__label { font-size: 12.5px; color: var(--text-soft); }
.kpi__value { font-size: 25px; font-weight: 700; line-height: 1.25; }
.kpi__meta { font-size: 11.5px; color: var(--text-faint); }

/* ----------------------------------------------------------------- جدول */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data thead th {
    background: var(--bg-sunken);
    color: var(--text-soft);
    font-weight: 700; font-size: 12px;
    white-space: nowrap;
    position: sticky; top: 0;
}
table.data tbody tr:hover { background: var(--bg-sunken); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data td.actions { white-space: nowrap; }
.cell-main { font-weight: 700; }
.cell-sub { font-size: 11.5px; color: var(--text-faint); }
.mono { font-family: 'Cascadia Mono', Consolas, monospace; direction: ltr; unicode-bidi: embed; font-size: 12px; }

.empty { padding: 46px 20px; text-align: center; color: var(--text-faint); }
.empty svg { width: 42px; height: 42px; opacity: .4; margin-bottom: 8px; }

/* ----------------------------------------------------------------- نشان */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700;
    background: var(--muted-soft); color: var(--text-soft);
    white-space: nowrap;
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--brand { background: var(--brand-soft); color: var(--brand); }
.badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    background: var(--brand-soft); color: var(--brand);
    font-size: 11.5px; font-weight: 700;
}
.chip--muted { background: var(--muted-soft); color: var(--text-soft); }

/* ------------------------------------------------------- نوار پیشرفت صندلی */
.seat { min-width: 130px; }
.seat__row { display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.seat__value { font-weight: 700; }
.seat__max { font-size: 11.5px; color: var(--text-faint); }
.seat__bar { height: 6px; border-radius: 999px; background: var(--muted-soft); margin-top: 5px; overflow: hidden; }
.seat__fill { height: 100%; border-radius: 999px; background: var(--success); transition: width .3s; }
.seat__fill--warn { background: var(--warning); }
.seat__fill--over { background: var(--danger); }

/* ----------------------------------------------------------------- دکمه */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 15px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--brand); color: #fff;
    font-family: inherit; font-size: 13px; font-weight: 700;
    cursor: pointer; transition: background .15s, box-shadow .15s, transform .05s;
    white-space: nowrap;
}
.btn:hover { background: var(--brand-strong); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn--ghost { background: var(--bg-elevated); color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #c2282d; }
.btn--success { background: var(--success); }
.btn--success:hover { background: #0f8657; }
.btn--sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn--icon { padding: 6px; width: 30px; height: 30px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ فرم */
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field > label { font-size: 12.5px; font-weight: 700; color: var(--text-soft); }
.field__hint { font-size: 11px; color: var(--text-faint); }

input[type=text], input[type=password], input[type=number], input[type=email], input[type=search], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--bg-elevated);
    color: var(--text);
    font-family: inherit; font-size: 13px;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 70px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 49%, var(--text-faint) 50%), linear-gradient(-45deg, transparent 49%, var(--text-faint) 50%); background-size: 6px 6px; background-position: left 14px center, left 20px center; background-repeat: no-repeat; }

.check-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.check {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-elevated);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.check:hover { border-color: var(--border-strong); }
.check input { margin: 3px 0 0; accent-color: var(--brand); width: 15px; height: 15px; flex: 0 0 auto; }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.check__title { font-weight: 700; font-size: 12.5px; }
.check__meta { font-size: 11px; color: var(--text-faint); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; }
.switch input { width: 16px; height: 16px; accent-color: var(--brand); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 150px; }

/* --------------------------------------------------------------- پیام‌ها */
.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 15px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; }
.alert--success { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.alert--warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }
.alert--danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert--info { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

pre.code {
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px; margin: 0;
    overflow: auto; direction: ltr; text-align: left;
    font-family: 'Cascadia Mono', Consolas, monospace; font-size: 11.5px;
    max-height: 320px;
    color: var(--text-soft);
}

/* ------------------------------------------------------- دیالوگ (modal) */
dialog.modal {
    border: none; padding: 0;
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    width: min(760px, 94vw);
    max-height: 90vh;
}
dialog.modal--wide { width: min(1020px, 96vw); }
dialog.modal::backdrop { background: rgba(8, 12, 22, .55); backdrop-filter: blur(2px); }
.modal__head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal__head h2 { margin: 0; }
.modal__head .icon-btn { margin-inline-start: auto; }
.modal__body { padding: 20px; overflow-y: auto; max-height: calc(90vh - 140px); }
.modal__foot { display: flex; gap: 8px; justify-content: flex-start; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg-sunken); }

/* -------------------------------------------------------- فهرست توصیفی */
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 20px; }
.dl__item { min-width: 0; }
.dl__label { font-size: 11.5px; color: var(--text-faint); }
.dl__value { font-size: 13.5px; font-weight: 700; word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.timeline li:last-child { border-bottom: none; }
.timeline__time { color: var(--text-faint); white-space: nowrap; font-size: 11.5px; min-width: 110px; }

/* ------------------------------------------------------- نمودار میله‌ای */
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar__head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.bar__track { height: 8px; border-radius: 999px; background: var(--muted-soft); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; background: var(--brand); }
.bar__fill--success { background: var(--success); }
.bar__fill--warning { background: var(--warning); }
.bar__fill--danger { background: var(--danger); }

/* ------------------------------------------------------------- صفحهٔ ورود */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: radial-gradient(1000px 500px at 80% -10%, rgba(79, 110, 247, .22), transparent),
                radial-gradient(800px 400px at 10% 110%, rgba(139, 92, 246, .18), transparent), var(--bg); }
.login-card {
    width: min(400px, 100%);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 30px 28px;
}
.login-card__logo { width: 52px; height: 52px; border-radius: 15px; background: linear-gradient(135deg, var(--brand), #8b5cf6); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 20px; margin-bottom: 16px; }

.pager { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 14px; }
.pager a, .pager span { padding: 5px 11px; border-radius: 8px; font-size: 12.5px; border: 1px solid var(--border); }
.pager .current { background: var(--brand); color: #fff; border-color: var(--brand); }

.text-soft { color: var(--text-soft); }
.text-faint { color: var(--text-faint); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
