/* =====================================================================
   سامانه مدیریت نیروهای فروش و توزیع — استایل اصلی
   فونت: Vazirmatn (self-hosted) | جهت: RTL | موبایل-فرست
   ===================================================================== */

/* ---------- فونت‌ها (self-hosted, بدون CDN) ---------- */
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn/Vazirmatn-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn/Vazirmatn-ExtraBold.woff2') format('woff2');
    font-weight: 800;
    font-display: swap;
}

/* ---------- توکن‌های طراحی ---------- */
:root {
    --bg: #0c1322;
    --bg-soft: #111a2e;
    --surface: rgba(255, 255, 255, 0.045);
    --surface-strong: rgba(255, 255, 255, 0.08);
    --surface-solid: #16213a;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text: #eef2f8;
    --text-dim: #97a3b8;
    --text-faint: #6b7890;

    --accent: #f59e0b;       /* کهربایی — اقدام / فروش گرم */
    --accent-ink: #1a1306;
    --accent-2: #16b8a6;     /* فیروزه‌ای — پاداش / موفقیت */
    --danger: #ef5b5b;       /* جریمه */
    --info: #5b9bf5;

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;

    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.35);

    --font: 'Vazirmatn', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: radial-gradient(circle at 15% 0%, #15203a 0%, var(--bg) 55%);
    color: var(--text);
    font-family: var(--font);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button {
    font-family: var(--font);
    cursor: pointer;
}

input, select, textarea, button {
    font-family: var(--font);
}

/* اسکرول‌بار ظریف */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* فوکوس قابل مشاهده برای دسترس‌پذیری کیبورد */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- ساختار کلی اپ ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* --- نوار کناری (دسکتاپ) --- */
.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--bg-soft);
    border-left: 1px solid var(--border);
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 22px;
    margin-bottom: 4px;
}
.brand-mark {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--accent), #c2740a);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: var(--accent-ink);
    flex-shrink: 0;
}
.brand-text { font-weight: 700; font-size: 15px; line-height: 1.3; }
.brand-text small { display: block; font-weight: 400; font-size: 11.5px; color: var(--text-dim); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
    background: var(--surface-strong);
    color: var(--text);
}
.nav-item.active .nav-ic { color: var(--accent); }
.nav-ic { width: 19px; text-align: center; flex-shrink: 0; }

.sidebar-foot {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--text-faint);
}
.sidebar-foot .logout-link { color: var(--danger); display: block; margin-top: 8px; font-weight: 500; }

/* --- محتوای اصلی --- */
.main {
    flex: 1;
    min-width: 0;
    padding: 22px 26px 90px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 800; margin: 0; }
.page-subtitle { color: var(--text-dim); font-size: 13px; margin-top: 3px; }

/* خط مسیر — عنصر امضادار صفحه: نشانگر یک مسیر توزیع با ایستگاه‌ها */
.route-divider {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 22px;
    color: var(--text-faint);
}
.route-divider::before, .route-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background-image: linear-gradient(to left, var(--border-strong) 60%, transparent 0%);
    background-size: 7px 1px;
    background-repeat: repeat-x;
}
.route-divider .stop {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

/* ---------- کارت‌ها ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow-glass);
}
.card + .card { margin-top: 16px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}
.stat-card .stat-label { font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 24px; font-weight: 800; }
.stat-card .stat-value.accent { color: var(--accent); }
.stat-card .stat-value.good { color: var(--accent-2); }
.stat-card .stat-value.bad { color: var(--danger); }

/* ---------- جداول ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
thead th {
    background: var(--surface-strong);
    color: var(--text-dim);
    font-weight: 600;
    text-align: right;
    padding: 11px 12px;
    white-space: nowrap;
    position: sticky;
    top: 0;
}
tbody td { padding: 10px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface); }

/* ---------- بج‌ها ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600;
    white-space: nowrap;
}
.badge-success { background: rgba(22, 184, 166, 0.15); color: var(--accent-2); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--accent); }
.badge-danger  { background: rgba(239, 91, 91, 0.15); color: var(--danger); }
.badge-muted   { background: var(--surface-strong); color: var(--text-faint); }
.badge-info    { background: rgba(91, 155, 245, 0.15); color: var(--info); }

/* ---------- فرم‌ها ---------- */
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 140px; }

input[type=text], input[type=number], input[type=password],
input[type=tel], input[type=search], select, textarea {
    width: 100%;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 11px 13px;
    font-size: 14px;
    transition: border-color 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }

select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: left 14px center, left 9px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-left: 30px; }

.jalali-date-input { display: flex; gap: 6px; }
.jalali-date-input select { text-align: center; }

/* دکمه‌های انتخابی (chip) */
.chip-group { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.chip.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip:hover:not(.selected) { border-color: var(--border-strong); color: var(--text); }

/* ---------- دکمه‌ها ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px; font-weight: 600;
    transition: transform 0.1s, opacity 0.15s, background 0.15s;
    background: var(--surface-strong);
    color: var(--text);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { opacity: 0.92; }
.btn-secondary { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-danger { background: rgba(239, 91, 91, 0.15); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-sm { padding: 7px 13px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- مودال ---------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(5, 8, 16, 0.6);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 100; backdrop-filter: blur(3px);
}
.modal-box {
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%; max-width: 480px;
    padding: 20px;
    max-height: 88vh; overflow-y: auto;
    box-shadow: var(--shadow-glass);
}
@media (min-width: 720px) {
    .modal-backdrop { align-items: center; }
    .modal-box { border-radius: var(--radius-lg); }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 20px; padding: 4px; }

/* ---------- توست/اعلان ---------- */
.toast {
    position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
    background: var(--surface-solid); border: 1px solid var(--border-strong);
    color: var(--text); padding: 11px 18px; border-radius: 999px;
    font-size: 13.5px; box-shadow: var(--shadow-glass);
    z-index: 200; opacity: 0; transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { border-color: var(--accent-2); }
.toast.error { border-color: var(--danger); }

/* ---------- اسکلتون لودینگ ---------- */
.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-strong) 37%, var(--surface) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton-loading {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ---------- ناوبری پایین (موبایل) ---------- */
.bottom-nav {
    display: none;
    position: fixed; bottom: 0; right: 0; left: 0;
    background: var(--bg-soft);
    border-top: 1px solid var(--border);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    z-index: 90;
}
.bottom-nav-inner { display: flex; justify-content: space-around; }
.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--text-faint); font-size: 10.5px; font-weight: 500;
    padding: 4px 10px; flex: 1;
}
.bottom-nav-item .nav-ic { font-size: 17px; }
.bottom-nav-item.active { color: var(--accent); }

/* ---------- صفحه‌ی ورود ---------- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-card {
    width: 100%; max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 30px 26px;
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow-glass);
}
.login-logo { text-align: center; margin-bottom: 18px; }
.login-logo .brand-mark { margin: 0 auto 12px; }
.login-card h1 { font-size: 17px; text-align: center; margin: 0 0 4px; }
.login-card p.sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: 0 0 22px; }
.alert {
    padding: 11px 14px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 14px;
}
.alert-error { background: rgba(239, 91, 91, 0.12); color: var(--danger); border: 1px solid rgba(239,91,91,0.3); }
.alert-success { background: rgba(22, 184, 166, 0.12); color: var(--accent-2); border: 1px solid rgba(22,184,166,0.3); }

/* ---------- واکنش‌گرایی ---------- */
@media (max-width: 880px) {
    .sidebar { display: none; }
    .main { padding: 16px 14px 96px; }
    .bottom-nav { display: block; }
    table { min-width: 540px; }
}

.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.hidden { display: none !important; }
