/* Admin panel styling.
 *
 * Self-hosted, no CDN and no build step. Iranian networks reach the usual
 * CSS CDNs unreliably, and a panel that renders as unstyled text on the day
 * the link fails is worse than one that ships its own 8KB.
 *
 * RTL throughout: `direction: rtl` on the root, logical properties
 * (margin-inline, padding-inline, border-inline) everywhere else, so nothing
 * needs a mirrored stylesheet.
 */

:root {
  --bg: #0f1420;
  --surface: #171e2e;
  --surface-2: #1e2739;
  --border: #2a3448;
  --text: #e6eaf2;
  --muted: #8d98ad;
  --accent: #3b82f6;
  --accent-soft: #1e3a5f;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 10px;
  --font: system-ui, "Segoe UI", Tahoma, "Iranian Sans", "Vazirmatn", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #eef1f7;
    --border: #d9dfeb;
    --text: #16203a;
    --muted: #64708a;
    --accent-soft: #dbeafe;
  }
}

* { box-sizing: border-box; }

html { direction: rtl; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- layout --- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 20px 18px;
  font-weight: 700;
  font-size: 17px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }

.nav { list-style: none; margin: 0; padding: 0 10px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 3px;
  border-radius: var(--radius);
  color: var(--text); font-size: 14px;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.sidebar-footer { padding: 14px 20px 0; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

.main { flex: 1; padding: 24px 28px 60px; min-width: 0; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* --- cards --- */

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.card h2 .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-inline-start: 6px; }

.stat .label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* --- tables --- */

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { font-variant-numeric: tabular-nums; direction: ltr; text-align: left; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* --- badges --- */

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge.green { background: rgba(34,197,94,.16); color: var(--green); }
.badge.red { background: rgba(239,68,68,.16); color: var(--red); }
.badge.amber { background: rgba(245,158,11,.16); color: var(--amber); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.amber { background: var(--amber); }
.dot.grey { background: var(--muted); }

/* --- forms --- */

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

input[type="text"], input[type="password"], input[type="number"],
input[type="datetime-local"], select, textarea {
  width: 100%; padding: 8px 11px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.7; }
input.ltr, textarea.ltr { direction: ltr; text-align: left; font-family: ui-monospace, monospace; }

.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.check { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--text); margin-bottom: 8px; }
.check input { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

form.inline { display: inline; }

/* --- filters --- */

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 140px; }

/* --- notices --- */

.notice { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.notice.ok { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.3); }
.notice.warn { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.3); }
.notice.err { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.3); }

.empty { padding: 34px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* --- signal preview --- */

.preview {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px; white-space: pre-wrap; word-break: break-word;
  font-size: 14px; line-height: 1.9; max-height: 560px; overflow-y: auto;
}
.preview code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.preview blockquote { margin: 10px 0 0; padding-inline-start: 12px; border-inline-start: 3px solid var(--border); color: var(--muted); font-size: 13px; }

/* --- login --- */

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { border: none; text-align: center; padding-bottom: 8px; }

/* --- responsive --- */

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; border: none; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
  .nav { display: flex; overflow-x: auto; padding: 0 10px; gap: 4px; }
  .nav a { white-space: nowrap; }
  .sidebar-footer { display: none; }
  .main { padding: 18px 16px 50px; }
}
