/* =========================================================
   ریحانه — Admin Panel CSS v2.2.0
   Design: Premium SaaS Dashboard 2026
   Inspired: TailAdmin, Shadcn UI, Linear
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@500;600;700;800&display=swap');

@font-face { font-family:'Vazirmatn'; src:url('../fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight:400; font-display:swap; }
@font-face { font-family:'Vazirmatn'; src:url('../fonts/Vazirmatn-Medium.woff2') format('woff2'); font-weight:500; font-display:swap; }
@font-face { font-family:'Vazirmatn'; src:url('../fonts/Vazirmatn-Bold.woff2') format('woff2'); font-weight:700; font-display:swap; }
@font-face { font-family:'Vazirmatn'; src:url('../fonts/Vazirmatn-ExtraBold.woff2') format('woff2'); font-weight:800; font-display:swap; }

/* ─── Tokens ─────────────────────────────────────────── */
:root {
  --sidebar-bg:    #1E1B4B;
  --sidebar-hover: #312E81;
  --sidebar-active:#4C3BBF;
  --sidebar-text:  rgba(255,255,255,.70);
  --sidebar-text-active: #C4C6FC;
  --sidebar-border:rgba(255,255,255,.07);

  --primary:       #5B4FCF;
  --primary-hover: #4737D9;
  --primary-soft:  #EEF0FF;
  --secondary:     #6E63FF;
  --accent:        #F5A623;

  --bg:       #F5F7FB;
  --bg-card:  #FFFFFF;
  --ink:      #111827;
  --ink-soft: #6B7280;
  --border:   #E5E7EB;
  --border-focus: var(--primary);

  --success:  #22C55E;
  --warning:  #F59E0B;
  --danger:   #EF4444;
  --info:     #3B82F6;

  --shadow-sm:    0 2px 8px rgba(0,0,0,.05);
  --shadow-md:    0 8px 24px rgba(0,0,0,.08);
  --shadow-lg:    0 20px 60px rgba(0,0,0,.12);
  --shadow-hover: 0 25px 70px rgba(91,79,207,.18);

  /* نام‌های قدیمی متغیرها (alias) برای سازگاری با صفحات قدیمی‌تر */
  --white:  #FFFFFF;
  --navy:   var(--primary);
  --navy-deep: #1E1B4B;
  --gold:   var(--accent);
  --green:  var(--success);
  --red:    var(--danger);

  --transition: .25s ease;
  --font: 'Vazirmatn', Tahoma, sans-serif;
}

/* ─── Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body.admin-body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.7;
  background: var(--bg);
  color: var(--ink);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; }

/* ─── Login ──────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 80% at 50% -20%, rgba(91,79,207,.3), transparent),
    linear-gradient(135deg, #0F0A2E 0%, #1E1B4B 40%, #2D1B8E 100%);
}
.login-card {
  background: var(--bg-card);
  border-radius: 24px;
  padding: clamp(32px, 5vw, 48px) clamp(28px, 5vw, 44px);
  width: 100%;
  max-width: 400px;
  box-shadow: 0 32px 100px rgba(15,10,46,.45);
  border: 1px solid rgba(255,255,255,.06);
}
.login-card .badge {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(91,79,207,.45);
}
.login-card h1 {
  text-align: center;
  font-size: 21px; font-weight: 800;
  color: var(--ink); margin-bottom: 6px;
}
.login-card .sub {
  text-align: center;
  font-size: 14px; color: var(--ink-soft);
  margin-bottom: 30px;
}

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

/* ─── Sidebar ────────────────────────────────────────── */
.admin-sidebar {
  width: 248px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 0 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.admin-sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 20px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--sidebar-border);
  font-weight: 800;
}
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px 11px 20px;
  font-size: 14px; font-weight: 500;
  color: var(--sidebar-text);
  border-right: 3px solid transparent;
  margin: 1px 8px;
  border-radius: 10px;
  transition: background var(--transition), color var(--transition);
  min-height: 44px;
  text-decoration: none;
}
.admin-nav a:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  border-right-color: transparent;
}
.admin-nav a.active {
  background: rgba(91,79,207,.28);
  color: var(--sidebar-text-active);
  border-right-color: var(--secondary);
  font-weight: 600;
}

/* ─── Main Content ───────────────────────────────────── */
.admin-main {
  flex: 1;
  padding: clamp(20px, 3vw, 32px) clamp(20px, 3.5vw, 36px);
  max-width: 1280px;
  min-width: 0;
}

/* Topbar */
.admin-topbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  justify-content: space-between;
}
.admin-topbar h1 {
  font-size: clamp(18px, 3vw, 22px);
  font-weight: 800;
  color: var(--ink);
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* دکمه‌ی همبرگری هرگز نباید فشرده یا از دید خارج بشه، صرف‌نظر از طول عنوان صفحه */
.admin-menu-toggle { flex-shrink: 0; }
/* گروه دکمه‌های کنار عنوان (مثلا «پرونده دستگاه» + «بازگشت») هم باید بتونه بشکنه */
.admin-topbar > div { flex-wrap: wrap; }

/* ─── Cards ──────────────────────────────────────────── */
.admin-card {
  background: var(--bg-card);
  border-radius: 18px;
  padding: clamp(20px, 3vw, 28px) clamp(20px, 3.5vw, 32px);
  margin-bottom: 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.admin-card:hover { box-shadow: 0 4px 20px rgba(91,79,207,.07); }
.admin-card h2 {
  font-size: 16px; font-weight: 800; color: var(--ink);
  margin: 0 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #F3F4F6;
  display: flex; align-items: center; gap: 8px;
}

/* ─── Stat Cards ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: clamp(12px, 2.5vw, 20px);
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: clamp(18px, 3vw, 24px) clamp(18px, 3vw, 22px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.stat-card .num {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 4px;
}
.stat-card .label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }

/* ─── Tables ─────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table thead { background: #F9FAFB; }
.admin-table th {
  text-align: right;
  padding: 12px 16px;
  font-size: 12.5px; font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #F3F4F6;
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr { transition: background var(--transition); }
.admin-table tbody tr:hover { background: #FAFBFF; }

/* ─── Forms ──────────────────────────────────────────── */
.admin-form .form-group { margin-bottom: 18px; }
.admin-form label {
  display: block;
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  margin-bottom: 7px;
}
.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-family: var(--font);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--bg-card);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 46px;
  appearance: none;
  -webkit-appearance: none;
}
.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(91,79,207,.10);
}
.admin-form textarea { resize: vertical; min-height: 100px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; min-width: 0; }

.req { color: var(--danger); margin-right: 2px; }
.hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; line-height: 1.6; }

/* ─── Alerts ─────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 14px;
  margin-bottom: 20px;
  border-right: 4px solid;
  line-height: 1.7;
}
.alert-success { background: #F0FDF4; border-color: var(--success); color: #166534; }
.alert-error   { background: #FEF2F2; border-color: var(--danger);  color: #991B1B; }
.alert-warning { background: #FFFBEB; border-color: var(--warning); color: #92400E; }
.alert-info    { background: #EFF6FF; border-color: var(--info);    color: #1E40AF; }

/* ─── Badges ─────────────────────────────────────────── */
.badge-status {
  display: inline-flex; align-items: center;
  padding: 4px 12px;
  border-radius: 40px;
  font-size: 12.5px; font-weight: 600;
  line-height: 1.4;
}
.badge-status.active   { background: #DCFCE7; color: #15803D; font-weight: 700; }
.badge-status.expired  { background: #FEE2E2; color: #B91C1C; font-weight: 700; }
.badge-status.pending  { background: #FEF3C7; color: #92400E; font-weight: 700; }
.badge-status.rejected { background: #FEE2E2; color: #B91C1C; font-weight: 700; }
.badge-status.inactive { background: #EEF0F2; color: #52606D; font-weight: 700; box-shadow: inset 0 0 0 1px #D8DCE1; }

/* ─── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 12px;
  font-family: var(--font);
  font-weight: 700; font-size: 14px;
  border: none; cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  line-height: 1; min-height: 44px; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  box-shadow: 0 4px 14px rgba(91,79,207,.3);
}
.btn-primary:hover { box-shadow: 0 8px 24px rgba(91,79,207,.45); }

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #D1D5FF;
}
.btn-secondary:hover { background: #E0E1FF; }

.btn-danger {
  background: #FEF2F2;
  color: #B91C1C;
  border: 1px solid #FECACA;
}
.btn-danger:hover { background: #FEE2E2; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 9px; min-height: 36px; }
.btn-lg { padding: 14px 32px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* action links */
.action-links { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ─── Responsive Sidebar ─────────────────────────────── */
.admin-menu-toggle { display: none; }
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* چک‌باکس‌های ساده (نه سوییچ فعال/غیرفعال) — سراسر پنل، بدون نیاز به style inline جداگانه */
.admin-form input[type="checkbox"],
.admin-main input[type="checkbox"],
.admin-form input[type="radio"],
.admin-main input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

/* کارت‌های انتخابی رادیویی (مثلا نوع نمایش تاریخ روی لیبل) — با هایلایت واضح روی گزینه‌ی انتخاب‌شده */
.radio-card {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--bg); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; font-weight: 400;
  transition: border-color var(--transition), background var(--transition);
}
.radio-card input { margin-top: 3px; }
.radio-card:has(input:checked) {
  border-color: var(--primary);
  background: rgba(91,79,207,.06);
  box-shadow: 0 0 0 1px var(--primary);
}

/* کد نمونه‌ها (مثل راهنمای فرمت‌بندی متن) نباید هیچ‌وقت باعث اسکرول افقی کل صفحه بشن */
.admin-main code, .admin-card code {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

@media (max-width: 992px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  .admin-shell { flex-direction: column; overflow-x: hidden; max-width: 100vw; }
  .admin-sidebar {
    position: fixed; top: 0; right: -280px;
    height: 100vh; width: 260px;
    z-index: 200;
    transition: right .3s cubic-bezier(.4,0,.2,1);
    overflow-y: auto; overflow-x: hidden;
  }
  .admin-sidebar.open { right: 0; }

  .admin-topbar {
    position: sticky; top: 0;
    background: var(--bg);
    z-index: 100;
    padding: 14px 0;
    margin: -20px 0 24px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
  }

  .admin-menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary); color: #fff;
    border: none; border-radius: 10px;
    width: 40px; height: 40px; font-size: 18px;
    cursor: pointer; flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(91,79,207,.3);
  }

  .admin-main { padding: 20px 16px; overflow-x: hidden; max-width: 100vw; }
  .form-row { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .admin-card { padding: 18px; }
  .admin-table th,
  .admin-table td { padding: 10px 12px; font-size: 13px; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .admin-main { padding: 16px 12px; }
}

/* ─── راهنمای جمع‌شونده (Collapsible Help) ──────────────────────────────
   برای متن‌های راهنما/توضیحات بلند که نباید همیشه باز و اشغال‌کننده‌ی فضا
   باشند. استفاده: <details class="help-toggle"><summary>...</summary>
   <div class="help-body">...</div></details>                             */
.help-toggle {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
  background: #F8FAFC;
  overflow: hidden;
}
.help-toggle > summary {
  cursor: pointer;
  padding: 13px 16px;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.help-toggle > summary::-webkit-details-marker { display: none; }
.help-toggle > summary::before {
  content: '❯';
  display: inline-block;
  font-size: 11px;
  color: var(--ink-soft);
  transition: transform .15s ease;
}
.help-toggle[open] > summary::before { transform: rotate(90deg); }
.help-toggle[open] > summary { border-bottom: 1px solid var(--border); }
.help-toggle .help-body {
  padding: 14px 16px 16px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--ink-soft);
}
.help-toggle .help-body code {
  background: rgba(15,42,74,.07);
  padding: 2px 7px;
  border-radius: 5px;
  font-family: monospace;
  font-size: 12.5px;
  direction: ltr;
  display: inline-block;
}
.help-toggle .help-body ol,
.help-toggle .help-body ul { padding-right: 20px; margin: 6px 0 14px; }
.help-toggle .help-body p { margin: 0 0 8px; }
.help-toggle .help-body strong { color: var(--ink); }

/* ─── جعبه‌ی اطلاعاتی (Info Box) — نسخه‌ی مشترک، با لبه‌ی رنگی برای دیده‌شدن بهتر ─── */
.info-box {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-right: 4px solid #3B82F6;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.8;
  color: #1E3A5F;
  margin-bottom: 16px;
}
.info-box strong { color: #1D4ED8; }
.info-box code {
  background: rgba(15,42,74,.08);
  padding: 2px 7px;
  border-radius: 5px;
  font-family: monospace;
  font-size: 12.5px;
  direction: ltr;
  display: inline-block;
}

/* ─── نوار فیلتر (جستجو + انتخاب‌های وضعیت) — استفاده در لیست‌های ادمین ─── */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  align-items: end;
}
.filter-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filter-field label { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.filter-actions { display: flex; gap: 8px; align-items: center; grid-column: 1 / -1; padding-top: 10px; border-top: 1px dashed var(--border); margin-top: 2px; }
.filter-bar input[type="text"],
.filter-bar input[type="search"],
.filter-bar select {
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg-card);
  outline: none;
  min-height: 40px;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-bar select {
  padding-left: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23667' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  cursor: pointer;
}
.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,79,207,.10);
}
.filter-bar .btn { min-height: 40px; }

@media (max-width: 640px) {
  .filter-bar { grid-template-columns: 1fr; }
  .filter-actions { flex-direction: column; align-items: stretch; }
  .filter-actions .btn { width: 100%; }
}

/* ─── سوییچ استاندارد فعال/غیرفعال — یک کامپوننت مشترک برای همه‌ی صفحات ───
   استفاده (تمام عناصر باید هم‌سطح/فرزند مستقیم .switch-field باشند):
   <label class="switch-field">
     <input type="checkbox" class="switch-input" name="is_active" ...>
     <span class="switch-track"><span class="switch-thumb"></span></span>
     <span class="switch-text-off">غیرفعال</span>
     <span class="switch-text-on">فعال</span>
   </label>
   کاملاً با CSS خالص کار می‌کند (بدون جاوااسکریپت)، هم رنگ هم متن، هنگام کلیک زنده تغییر می‌کند.  */
.switch-field { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch-input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track {
  position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0;
  border-radius: 24px; background: #9CA3AF; transition: background .2s ease;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.switch-thumb {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .2s ease; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch-input:checked + .switch-track { background: var(--green); }
.switch-input:checked + .switch-track .switch-thumb { transform: translateX(-20px); }
.switch-text-off { font-size: 13.5px; font-weight: 700; color: #6B7280; }
.switch-text-on  { font-size: 13.5px; font-weight: 700; color: var(--green); display: none; }
.switch-input:checked ~ .switch-text-on  { display: inline; }
.switch-input:checked ~ .switch-text-off { display: none; }
