/* ===================================================================
   جاهد — لوحة التحكم  (Jahed Admin Panel)
   Vanilla CSS. Branding matches jahed.net.
   =================================================================== */

:root {
  /* Brand palette */
  --bg: #060d1f;
  --panel: #0a1628;
  --accent: #00d4ff;          /* cyan */
  --accent-dim: #00a6c9;
  --gold: #d4af37;            /* secondary accent */
  --text: #f0f6ff;
  --muted: #8899b5;
  --danger: #ef4444;
  --success: #22c55e;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* Derived surfaces */
  --panel-hover: #0e1c33;
  --input-bg: #06101f;
  --accent-glow: rgba(0, 212, 255, 0.25);

  /* Spacing / radii */
  --radius: 14px;
  --radius-sm: 9px;
  --gap: 16px;

  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --font: 'Cairo', 'Tajawal', 'Segoe UI', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Subtle radial glow to echo the marketing site */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(0, 212, 255, 0.08), transparent 60%),
    radial-gradient(700px 500px at 10% 110%, rgba(212, 175, 55, 0.05), transparent 60%);
  z-index: 0;
}

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

/* ── Logo mark ─────────────────────────────────────────────────── */
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #00131c;
  font-weight: 800;
  font-size: 20px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.35), 0 4px 14px var(--accent-glow);
  line-height: 1;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-row .brand-name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2px;
}

/* ── Top bar ───────────────────────────────────────────────────── */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.topbar nav a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.topbar nav a:hover {
  background: var(--panel-hover);
  color: var(--text);
  text-decoration: none;
}
.topbar nav a.active {
  background: rgba(0, 212, 255, 0.12);
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-email {
  color: var(--muted);
  font-size: 13px;
  direction: ltr;
  unicode-bidi: isolate;
}

/* ── Layout ────────────────────────────────────────────────────── */
.page {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 60px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}
.page-head .subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ── Cards / panels ────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card {
  margin-top: 20px;
}
.card-pad {
  padding: 20px;
}
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 16px;
}

/* ── Toolbar (search + filters above a table) ──────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.toolbar .spacer {
  flex: 1 1 auto;
}
.toolbar .result-count {
  color: var(--muted);
  font-size: 13px;
}

/* ── Forms ─────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='search'],
select,
textarea {
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder {
  color: #5b6b88;
}
input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
/* LTR technical inputs (package names etc.) */
input[dir='ltr'] {
  text-align: left;
  direction: ltr;
}

.field {
  margin-bottom: 0;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  align-items: end;
}
.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field-inline label {
  margin: 0;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #00131c;
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold), #b8932c);
  color: #1a1304;
}
.btn-gold:hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--panel-hover);
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ── Tables ────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  text-align: right;
  font-weight: 700;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr.clickable {
  cursor: pointer;
  transition: background 0.12s;
}
tbody tr.clickable:hover {
  background: var(--panel-hover);
}
.cell-ltr {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 13px;
}
.cell-muted {
  color: var(--muted);
}
.cell-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}

/* ── Toggle switch ─────────────────────────────────────────────── */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch .slider {
  position: absolute;
  inset: 0;
  background: #1c2c44;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition: background 0.18s, border-color 0.18s;
}
.switch .slider::before {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px; /* RTL: knob starts on the right */
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s, background 0.18s;
}
.switch input:checked + .slider {
  background: rgba(0, 212, 255, 0.25);
  border-color: var(--accent);
}
.switch input:checked + .slider::before {
  background: var(--accent);
  transform: translateX(-20px); /* RTL: move knob to the left */
}
.switch input:focus-visible + .slider {
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.switch input:disabled + .slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Badges / status pills ─────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border-strong);
  white-space: nowrap;
}
.badge-active {
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.1);
}
.badge-pending {
  color: var(--gold);
  border-color: rgba(212, 175, 55, 0.4);
  background: rgba(212, 175, 55, 0.1);
}
.badge-suspended,
.badge-expired,
.badge-banned {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
}

/* ── States: loading / empty / error ───────────────────────────── */
.state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.spinner {
  display: inline-block;
  width: 26px;
  height: 26px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Inline / banner alerts */
.alert {
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
}
.alert-error {
  color: #ffd9d9;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.alert-success {
  color: #c9f7d8;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.4);
}
.alert[hidden] {
  display: none;
}

/* Tiny inline save-status text used per-row */
.save-status {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.save-status.ok {
  color: var(--success);
}
.save-status.err {
  color: var(--danger);
}
.save-status.busy {
  color: var(--muted);
}

/* ── Pagination ────────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.pager .page-info {
  color: var(--muted);
  font-size: 13px;
}

/* ── Login screen ──────────────────────────────────────────────── */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.login-card .brand-row {
  justify-content: center;
  margin-bottom: 6px;
}
.login-card .login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}
.login-card .field + .field {
  margin-top: 16px;
}
.login-card .btn {
  width: 100%;
  margin-top: 20px;
}

/* ── Misc ──────────────────────────────────────────────────────── */
.mono {
  font-family: 'Consolas', 'Courier New', monospace;
}
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}
.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Visually-hidden helper for global page loader before app boots */
.boot-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 100vh;
  color: var(--muted);
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px 16px;
  }
  .page {
    padding: 20px 14px 48px;
  }
  .page-head h1 {
    font-size: 20px;
  }
}
