/* ═══════════════════════════════════════════════════════════════════
   حوافز كهرباء إربد — نظام التصميم المشترك (بوابة الورشة + لوحة الإدارة)
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(2, 6, 23, .35);
  --ring: 0 0 0 3px rgba(56, 189, 248, .25);
  --tr: .18s ease;
}

html[data-theme='dark'] {
  --bg: #060b16;
  --bg-grad-1: #0b1424;
  --bg-grad-2: #060b16;
  --panel: rgba(17, 26, 43, .78);
  --panel-solid: #111a2b;
  --panel-2: rgba(30, 41, 59, .55);
  --border: rgba(148, 163, 184, .16);
  --border-strong: rgba(148, 163, 184, .28);
  --text: #e9eff9;
  --text-2: #b6c4d8;
  --muted: #8296b0;
  --primary: #38bdf8;
  --primary-ink: #04121c;
  --primary-soft: rgba(56, 189, 248, .14);
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, .14);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, .14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .14);
  --input-bg: rgba(2, 8, 20, .55);
  --hover: rgba(148, 163, 184, .08);
}

html[data-theme='light'] {
  --bg: #eef3fa;
  --bg-grad-1: #f7fafd;
  --bg-grad-2: #e6eef8;
  --panel: rgba(255, 255, 255, .92);
  --panel-solid: #ffffff;
  --panel-2: rgba(241, 245, 249, .9);
  --border: rgba(15, 23, 42, .1);
  --border-strong: rgba(15, 23, 42, .18);
  --text: #0b1526;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #0284c7;
  --primary-ink: #ffffff;
  --primary-soft: rgba(2, 132, 199, .1);
  --accent: #b45309;
  --accent-soft: rgba(180, 83, 9, .1);
  --success: #059669;
  --success-soft: rgba(5, 150, 105, .1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, .1);
  --input-bg: #ffffff;
  --hover: rgba(15, 23, 42, .04);
  --shadow: 0 10px 28px rgba(15, 23, 42, .09);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 85% -10%, var(--bg-grad-1), transparent),
              linear-gradient(160deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.35; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ── الحاويات ─────────────────────────────────────────────── */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.wrap-narrow { max-width: 560px; margin: 0 auto; padding: 0 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.card-pad { padding: 18px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap-row { display: flex; flex-wrap: wrap; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { display: flex; align-items: center; justify-content: center; }

/* ── الترويسة ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--panel-solid) 82%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--primary), #2563eb);
  color: #fff;
  font-size: 18px;
  flex: 0 0 auto;
  box-shadow: 0 6px 18px rgba(56, 189, 248, .3);
}

.brand-title { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* ── الأزرار ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform var(--tr), background var(--tr), border-color var(--tr), opacity var(--tr);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary { background: linear-gradient(135deg, var(--primary), #2563eb); color: #fff; border-color: transparent; }
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--primary), #2563eb); }

.btn-ghost { background: transparent; border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--hover); }

.btn-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-block { width: 100%; }

/* ── الحقول ───────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }

.input, .select, textarea.input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  transition: border-color var(--tr), box-shadow var(--tr);
  min-height: 44px;
}
.input::placeholder { color: var(--muted); }
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.input:disabled, .select:disabled { opacity: .6; cursor: not-allowed; }
textarea.input { min-height: 84px; resize: vertical; }

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(0% + 16px) calc(50% + 2px), calc(0% + 21px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-left: 36px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

/* ── الشارات والحالات ─────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill-ok { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 32%, transparent); }
.pill-warn { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 32%, transparent); }
.pill-bad { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 32%, transparent); }
.pill-info { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 32%, transparent); }
.pill-mute { background: var(--hover); color: var(--muted); border-color: var(--border); }

/* ── الجداول ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.tbl th, table.tbl td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--border); }
table.tbl th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--panel-2); position: sticky; top: 0; }
table.tbl tbody tr:hover { background: var(--hover); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.actions { white-space: nowrap; }

/* ── النوافذ المنبثقة ─────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .62);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }

.modal {
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(2, 6, 23, .5);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(10px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel-solid);
  z-index: 2;
}
.modal-body { padding: 18px; }
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--panel-solid);
}

/* ── التنبيهات ────────────────────────────────────────────── */
#toasts {
  position: fixed;
  inset-inline: 0;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  padding: 0 12px;
}
.toast {
  max-width: 520px;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 30px rgba(2, 6, 23, .35);
  animation: toastIn .2s ease;
}
.toast.ok { border-color: color-mix(in srgb, var(--success) 55%, transparent); color: var(--success); }
.toast.err { border-color: color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); }
.toast.info { border-color: color-mix(in srgb, var(--primary) 55%, transparent); color: var(--primary); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── حالات فارغة / تحميل ──────────────────────────────────── */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty i { font-size: 34px; display: block; margin-bottom: 10px; opacity: .6; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--hover) 50%, var(--panel-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 10px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── أدوات مساعدة ─────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.bold { font-weight: 800; }
.hr { height: 1px; background: var(--border); margin: 14px 0; border: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

@media (max-width: 720px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-pad { padding: 14px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 460px) {
  .grid-2 { grid-template-columns: 1fr; }
  .btn { padding: 10px 13px; }
}
