/* پنل بک‌آپ کلودپنل — استایل فارسی راست‌به‌چپ.
   هیچ منبع بیرونی (CDN) بارگذاری نمی‌شود؛ سرور ممکن است دسترسی نداشته باشد.
   فونت IRANSansX از روی خود سرور سرو می‌شود. */

/* فونت متغیر: یک فایل ۱۰۰ کیلوبایتی که همه‌ی وزن‌های ۱۰۰ تا ۹۰۰ را پوشش
   می‌دهد — سبک‌تر از بارگذاری چند فایل جداگانه. */
@font-face {
  font-family: "IRANSansX";
  src: url("/static/fonts/IRANSansXVF.woff2") format("woff2-variations"),
       url("/static/fonts/IRANSansXVF.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* جایگزین برای مرورگرهای قدیمی که فونت متغیر را نمی‌شناسند */
@font-face {
  font-family: "IRANSansX Static";
  src: url("/static/fonts/IRANSansX-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IRANSansX Static";
  src: url("/static/fonts/IRANSansX-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #172033;
    --border: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --ok-bg: #14532d;
    --warn-bg: #451a03;
    --danger-bg: #450a0a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IRANSansX", "IRANSansX Static", "IRANSans", Tahoma, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- چیدمان ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.logo {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.menu { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.menu a {
  padding: 6px 14px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
}
.menu a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.menu a.active { background: var(--primary); color: #fff; }

.user-box { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }

main { padding: 24px; margin: 0 auto; }
main.wide { max-width: 1180px; }
main.narrow { max-width: 420px; padding-top: 8vh; }

.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 24px 40px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- کارت ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }
.card-title {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.card-title h2, .card-title h3 { margin: 0; font-size: 17px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .hint { color: var(--muted); font-size: 12px; }

/* ---------- جدول ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.ltr, .ltr { direction: ltr; text-align: left; font-family: "Cascadia Mono", Consolas, monospace; }

/* ---------- نشانه‌ها ---------- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-error { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ---------- دکمه ---------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- فرم ---------- */
label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
textarea { min-height: 90px; resize: vertical; font-family: "Cascadia Mono", Consolas, monospace; direction: ltr; text-align: left; }
.field { margin-bottom: 16px; }
.field .help { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.checkbox label { margin: 0; font-weight: 400; }

/* ---------- هشدار ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  border: 1px solid transparent;
  font-size: 14px;
}
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: currentColor; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: currentColor; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: currentColor; }
.alert strong { display: block; margin-bottom: 4px; }

/* ---------- لاگ ---------- */
.log {
  background: #0f172a;
  color: #cbd5e1;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  direction: ltr;
  text-align: left;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- مرورگر فایل ---------- */
.breadcrumb { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; margin-bottom: 12px; color: var(--muted); }
.file-icon { display: inline-block; width: 18px; text-align: center; }

/* ---------- متفرقه ---------- */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; direction: ltr; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 8px 16px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.confirm-box { background: var(--danger-bg); border: 1px solid var(--danger); border-radius: var(--radius); padding: 16px; }

@media (max-width: 720px) {
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  main { padding: 16px; }
  .menu { order: 3; width: 100%; }
}
