/* ==========================================================================
   الإدارة المركزية — تصميم v2 (بسيط وواضح، الموبايل أولاً)
   يعمل فقط داخل .lx — لا يؤثر على باقي المنصة.
   ملاحظة: هذا الملف خارج طبقات Tailwind، لذلك يتقدّم عليها؛ لا نغيّر هنا
   الحشوات والهوامش والعرض للعناصر العامة حتى تبقى أدوات الصفحات كما هي.
   ========================================================================== */
.lx {
  --lx-bg: #f3f6fb;
  --lx-surface: #ffffff;
  --lx-surface-2: #f7f9fc;
  --lx-surface-3: #eef2f8;
  --lx-line: #e3e9f2;
  --lx-line-strong: #cfd8e6;
  --lx-ink: #0f1b33;
  --lx-ink-2: #34425c;
  --lx-muted: #6b7a93;
  --lx-accent: #2563eb;
  --lx-accent-2: #1d4ed8;
  --lx-accent-soft: #eaf1ff;
  --lx-ok: #059669;
  --lx-ok-soft: #e7f7f1;
  --lx-warn: #d97706;
  --lx-warn-soft: #fff5e5;
  --lx-bad: #dc2626;
  --lx-bad-soft: #fdecec;
  --lx-r: 14px;
  --lx-r-lg: 18px;
  --lx-shadow: 0 1px 2px rgba(15, 27, 51, .05), 0 4px 14px rgba(15, 27, 51, .05);
  --lx-shadow-lg: 0 10px 30px rgba(15, 27, 51, .14);
  --lx-side-w: 264px;
  --lx-top-h: 64px;
  --lx-bottom-h: 64px;
  /* ربط ألوان الصفحات القديمة بالجديدة */
  --color-surface: var(--lx-surface);
  --color-surface-elevated: var(--lx-surface);
  --color-surface-muted: var(--lx-bg);
  --color-border: var(--lx-line);
  --color-text: var(--lx-ink);
  --color-text-muted: var(--lx-muted);
  min-height: 100vh;
  background: var(--lx-bg);
  color: var(--lx-ink);
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}
html.dark .lx {
  --lx-bg: #0a1222;
  --lx-surface: #111b2e;
  --lx-surface-2: #0e1728;
  --lx-surface-3: #18243b;
  --lx-line: #1f2d48;
  --lx-line-strong: #2b3c5d;
  --lx-ink: #e8eef9;
  --lx-ink-2: #c3cfe3;
  --lx-muted: #8596b3;
  --lx-accent: #3b82f6;
  --lx-accent-2: #2563eb;
  --lx-accent-soft: rgba(59, 130, 246, .14);
  --lx-ok: #34d399;
  --lx-ok-soft: rgba(52, 211, 153, .12);
  --lx-warn: #fbbf24;
  --lx-warn-soft: rgba(251, 191, 36, .12);
  --lx-bad: #f87171;
  --lx-bad-soft: rgba(248, 113, 113, .12);
  --lx-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --lx-shadow-lg: 0 12px 32px rgba(0, 0, 0, .45);
}
body:has(.lx) { background: var(--lx-bg, #f3f6fb); overflow-x: clip; }
html.dark body:has(.lx) { background: #0a1222; }
.lx [x-cloak] { display: none !important; }
.lx a { text-decoration: none; }

/* ---------- القائمة الجانبية ---------- */
.lx-side {
  position: fixed; inset-block: 0; right: 0; z-index: 70; width: var(--lx-side-w);
  display: flex; flex-direction: column; background: var(--lx-surface); border-left: 1px solid var(--lx-line);
  transition: transform .25s ease;
}
.lx-brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: var(--lx-top-h); padding: 0 18px; border-bottom: 1px solid var(--lx-line); }
.lx-brand a { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--lx-ink); }
.lx-brand .lx-brand-sub { font-size: 11.5px; font-weight: 700; color: var(--lx-muted); white-space: nowrap; }
.lx-side .lx-side-close { display: none; }
.lx-nav { flex: 1; overflow-y: auto; padding: 12px 12px 16px; }
.lx-nav-group + .lx-nav-group { margin-top: 14px; }
.lx-nav-title { margin: 0 10px 6px; font-size: 11.5px; font-weight: 700; color: var(--lx-muted); }
.lx-nav-link {
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border-radius: 11px;
  color: var(--lx-ink-2); font-size: 14px; font-weight: 600; transition: background .15s, color .15s;
}
.lx-nav-link svg { width: 20px; height: 20px; color: var(--lx-muted); flex: 0 0 auto; }
.lx-nav-link:hover { background: var(--lx-surface-3); color: var(--lx-ink); }
.lx-nav-link.is-active { background: var(--lx-accent-soft); color: var(--lx-accent); font-weight: 700; }
.lx-nav-link.is-active svg { color: var(--lx-accent); }
.lx-nav-link .lx-badge { margin-inline-start: auto; }
.lx-side-foot { border-top: 1px solid var(--lx-line); padding: 12px; }
.lx-side-foot a { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 10px; color: var(--lx-muted); font-size: 13px; font-weight: 600; }
.lx-side-foot a:hover { background: var(--lx-surface-3); color: var(--lx-accent); }
.lx-side-foot svg { width: 18px; height: 18px; }
.lx-scrim { position: fixed; inset: 0; z-index: 65; background: rgba(6, 12, 26, .5); backdrop-filter: blur(2px); }

/* ---------- الشريط العلوي ---------- */
.lx-main { margin-right: var(--lx-side-w); min-width: 0; }
.lx-top {
  position: sticky; top: 0; z-index: 50; height: var(--lx-top-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: color-mix(in srgb, var(--lx-surface) 92%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--lx-line);
}
.lx-top-title { flex: 1; min-width: 0; }
.lx-top-title h1 { margin: 0; font-size: 18px; font-weight: 800; line-height: 1.3; color: var(--lx-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lx-top-title p { margin: 0; font-size: 12.5px; color: var(--lx-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lx-top-acts { display: flex; align-items: center; gap: 8px; }
.lx-ibtn {
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px;
  border: 1px solid var(--lx-line); background: var(--lx-surface); color: var(--lx-ink-2); cursor: pointer;
}
.lx-ibtn:hover { border-color: var(--lx-accent); color: var(--lx-accent); }
.lx-ibtn svg { width: 20px; height: 20px; }
.lx-menu-btn { display: none; }
.lx-top-logo { display: none; }
.lx-user { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 12px; border: 1px solid var(--lx-line); border-radius: 999px; background: var(--lx-surface); }
.lx-avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--lx-accent); color: #fff; font-weight: 800; font-size: 14px; flex: 0 0 auto; }
.lx-user-name { font-size: 13px; font-weight: 700; color: var(--lx-ink); max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lx-logout { border: 0; background: transparent; color: var(--lx-bad); font-weight: 700; font-size: 12.5px; cursor: pointer; padding: 6px 8px; border-radius: 8px; font-family: inherit; }
.lx-logout:hover { background: var(--lx-bad-soft); }

/* ---------- المحتوى ---------- */
.lx-content { padding: 24px; max-width: 1400px; margin: 0 auto; }
.lx-alert { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; padding: 12px 14px; border-radius: var(--lx-r); border: 1px solid; font-size: 14px; font-weight: 600; }
.lx-alert.is-ok { background: var(--lx-ok-soft); border-color: color-mix(in srgb, var(--lx-ok) 30%, transparent); color: var(--lx-ok); }
.lx-alert.is-bad { background: var(--lx-bad-soft); border-color: color-mix(in srgb, var(--lx-bad) 30%, transparent); color: var(--lx-bad); }
.lx-alert p { margin: 0; white-space: pre-line; }

/* ---------- الشريط السفلي (موبايل) ---------- */
.lx-bottom { display: none; }

/* ---------- مكوّنات عامة جديدة ---------- */
.lx-card { background: var(--lx-surface); border: 1px solid var(--lx-line); border-radius: var(--lx-r-lg); box-shadow: var(--lx-shadow); }
.lx-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--lx-line); flex-wrap: wrap; }
.lx-card-head h2, .lx-card-head h3 { margin: 0; font-size: 16px; font-weight: 800; color: var(--lx-ink); display: flex; align-items: center; gap: 8px; }
.lx-card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--lx-muted); }
.lx-card-body { padding: 16px 18px; }
.lx-link { color: var(--lx-accent); font-weight: 700; font-size: 13.5px; }
.lx-link:hover { text-decoration: underline; }
.lx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 12px;
  font-weight: 700; font-size: 14px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; font-family: inherit;
}
.lx-btn svg { width: 18px; height: 18px; }
.lx-btn-primary { background: var(--lx-accent); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .22); }
.lx-btn-primary:hover { background: var(--lx-accent-2); color: #fff; }
.lx-btn-soft { background: var(--lx-surface); color: var(--lx-ink); border-color: var(--lx-line-strong); }
.lx-btn-soft:hover { border-color: var(--lx-accent); color: var(--lx-accent); }
.lx-badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--lx-surface-3); color: var(--lx-ink-2); }
.lx-badge.is-ok { background: var(--lx-ok-soft); color: var(--lx-ok); }
.lx-badge.is-warn { background: var(--lx-warn-soft); color: var(--lx-warn); }
.lx-badge.is-bad { background: var(--lx-bad-soft); color: var(--lx-bad); }
.lx-badge.is-info { background: var(--lx-accent-soft); color: var(--lx-accent); }
.lx-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.lx-empty { padding: 32px 16px; text-align: center; color: var(--lx-muted); font-size: 14px; }
.lx-mono { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: isolate; }

/* لوحة التحكم */
.lx-hello { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.lx-hello h2 { margin: 0; font-size: 22px; font-weight: 800; color: var(--lx-ink); }
.lx-hello p { margin: 2px 0 0; color: var(--lx-muted); font-size: 14px; }
.lx-hello-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.lx-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.lx-kpi { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--lx-surface); border: 1px solid var(--lx-line); border-radius: var(--lx-r-lg); box-shadow: var(--lx-shadow); color: inherit; min-width: 0; transition: border-color .15s, transform .15s; }
.lx-kpi:hover { border-color: var(--lx-accent); transform: translateY(-1px); }
.lx-kpi-ico { width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; background: var(--lx-accent-soft); color: var(--lx-accent); }
.lx-kpi-ico svg { width: 22px; height: 22px; }
.lx-kpi.is-ok .lx-kpi-ico { background: var(--lx-ok-soft); color: var(--lx-ok); }
.lx-kpi.is-warn .lx-kpi-ico { background: var(--lx-warn-soft); color: var(--lx-warn); }
.lx-kpi b { display: block; font-size: 24px; font-weight: 800; line-height: 1.15; color: var(--lx-ink); font-variant-numeric: tabular-nums; }
.lx-kpi span { display: block; font-size: 12.5px; color: var(--lx-muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lx-kpi-txt { min-width: 0; }
.lx-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 18px; }
.lx-list { list-style: none; margin: 0; padding: 0; }
.lx-list li + li { border-top: 1px solid var(--lx-line); }
.lx-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: inherit; min-width: 0; }
a.lx-row:hover { background: var(--lx-surface-2); }
.lx-row-main { flex: 1; min-width: 0; }
.lx-row-main strong { display: block; font-size: 14px; font-weight: 700; color: var(--lx-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lx-row-main small { display: block; font-size: 12px; color: var(--lx-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lx-row-end { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.lx-status-ico { width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; background: var(--lx-ok-soft); color: var(--lx-ok); }
.lx-status-ico svg { width: 18px; height: 18px; }

/* ---------- إعادة تلوين مكوّنات الصفحات القديمة (بدون تغيير الحشوات) ---------- */
.lx .cards-card { background: var(--lx-surface); border-color: var(--lx-line); border-radius: var(--lx-r-lg); box-shadow: var(--lx-shadow); }
.lx .cards-subtitle { color: var(--lx-muted); }
.lx .cards-btn-primary { background: var(--lx-accent); color: #fff; border-radius: 12px; box-shadow: 0 6px 16px rgba(37, 99, 235, .2); font-weight: 700; }
.lx .cards-btn-primary:hover { background: var(--lx-accent-2); }
.lx .cards-btn-ghost { border-radius: 11px; color: var(--lx-ink-2); }
.lx .cards-btn-ghost:hover { background: var(--lx-surface-3); color: var(--lx-ink); }
.lx .cards-input { background: var(--lx-surface); border-color: var(--lx-line-strong); border-radius: 12px; color: var(--lx-ink); min-height: 44px; font-size: 14.5px; }
.lx .cards-input:focus { border-color: var(--lx-accent); box-shadow: 0 0 0 4px var(--lx-accent-soft); outline: 0; }
.lx label { color: var(--lx-ink-2); }
.lx .license-hq-chip { border-radius: 999px; font-weight: 700; }
.lx .license-hq-kpi, .lx .license-hq-server-card { background: var(--lx-surface); border: 1px solid var(--lx-line); border-radius: var(--lx-r-lg); box-shadow: var(--lx-shadow); }
.lx .license-hq-hero { border-radius: var(--lx-r-lg); }

/* الجداول */
.lx .cards-data-table, .lx .cards-card table { width: 100%; border-collapse: separate; border-spacing: 0; }
.lx .cards-data-table thead th, .lx .cards-card table thead th {
  background: var(--lx-surface-2); color: var(--lx-muted); font-size: 12.5px; font-weight: 700; border-bottom: 1px solid var(--lx-line); white-space: nowrap; text-align: start;
}
.lx .cards-data-table tbody td, .lx .cards-card table tbody td { border-bottom: 1px solid var(--lx-line); color: var(--lx-ink); font-size: 14px; vertical-align: middle; }
.lx .cards-data-table tbody tr:nth-child(even), .lx .cards-card table tbody tr:nth-child(even) { background: transparent; }
.lx .cards-data-table tbody tr:hover, .lx .cards-card table tbody tr:hover { background: var(--lx-surface-2); }
.lx .cards-data-table tbody tr:last-child td, .lx .cards-card table tbody tr:last-child td { border-bottom: 0; }

/* الوضع الداكن: ألوان Tailwind الفاتحة الشائعة داخل الصفحات */
html.dark .lx .bg-white { background-color: var(--lx-surface) !important; }

/* ==========================================================================
   الموبايل والتابلت
   ========================================================================== */
@media (max-width: 1279.98px) {
  .lx-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1023.98px) {
  .lx-side { transform: translateX(100%); box-shadow: none; }
  .lx-side.is-open { transform: none; box-shadow: var(--lx-shadow-lg); }
  .lx-side .lx-side-close { display: inline-flex; }
  .lx-main { margin-right: 0; }
  .lx-menu-btn { display: inline-flex; }
  .lx-top-logo { display: inline-flex; flex: 0 0 auto; }
  .lx-top { padding: 0 14px; gap: 10px; }
  .lx-content { padding: 16px 14px calc(var(--lx-bottom-h) + 24px + env(safe-area-inset-bottom, 0px)); }
  .lx-grid2 { grid-template-columns: minmax(0, 1fr); }
  .lx-bottom {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 60; display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--lx-bottom-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--lx-surface) 94%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--lx-line);
  }
  .lx-bottom a, .lx-bottom button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none;
    color: var(--lx-muted); font-size: 11.5px; font-weight: 700; cursor: pointer; font-family: inherit;
  }
  .lx-bottom svg { width: 22px; height: 22px; }
  .lx-bottom .is-active { color: var(--lx-accent); }
}
@media (max-width: 767.98px) {
  .lx-user-name, .lx-theme-btn { display: none; }
  .lx-user { padding: 3px; border: 0; }
  .lx-top-title h1 { font-size: 16px; }
  .lx-hello h2 { font-size: 19px; }
  .lx-hello-acts { width: 100%; }
  .lx-hello-acts .lx-btn { flex: 1; }
  .lx-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .lx-kpi { padding: 12px; gap: 10px; }
  .lx-kpi-ico { width: 38px; height: 38px; }
  .lx-kpi b { font-size: 20px; }
  .lx-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .lx-row { padding: 12px 14px; }
  .lx-card-head { padding: 14px; }

  /* الجداول تتحول لبطاقات */
  .lx table.lx-stack { min-width: 0 !important; }
  .lx table.lx-stack thead { display: none; }
  .lx table.lx-stack, .lx table.lx-stack tbody, .lx table.lx-stack tr, .lx table.lx-stack td { display: block; width: 100%; }
  .lx table.lx-stack tr { padding: 10px 14px; border-bottom: 1px solid var(--lx-line); }
  .lx table.lx-stack tbody tr:last-child { border-bottom: 0; }
  .lx table.lx-stack td { border: 0 !important; padding: 4px 0 !important; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: start; min-width: 0; overflow-wrap: anywhere; }
  .lx table.lx-stack td::before { content: attr(data-label); flex: 0 0 auto; color: var(--lx-muted); font-size: 12px; font-weight: 700; font-family: "IBM Plex Sans Arabic", Tahoma, sans-serif; direction: rtl; }
  .lx table.lx-stack td[data-label=""]::before { display: none; }
  .lx table.lx-stack td[colspan] { display: block; text-align: center; }
  .lx table.lx-stack td[colspan]::before { display: none; }
  .lx .overflow-x-auto:has(> table.lx-stack) { overflow: visible; }
}

/* ==========================================================================
   صفحة الدخول
   ========================================================================== */
.lx-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(900px 500px at 85% -10%, color-mix(in srgb, var(--lx-accent) 18%, transparent), transparent 60%),
  radial-gradient(700px 420px at 0% 110%, color-mix(in srgb, var(--lx-ok) 12%, transparent), transparent 60%), var(--lx-bg); }
.lx-auth-box { width: 100%; max-width: 420px; }
.lx-auth-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.lx-auth-card { background: var(--lx-surface); border: 1px solid var(--lx-line); border-radius: 22px; box-shadow: var(--lx-shadow-lg); padding: 28px 24px; }
.lx-auth-card h1 { margin: 0; font-size: 21px; font-weight: 800; text-align: center; color: var(--lx-ink); }
.lx-auth-card > p { margin: 4px 0 22px; text-align: center; color: var(--lx-muted); font-size: 13.5px; }
.lx-field { display: block; margin-bottom: 14px; }
.lx-field > span { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 700; color: var(--lx-ink-2); }
.lx-auth .lx-check { display: flex; align-items: center; gap: 8px; margin: 4px 0 18px; font-size: 13.5px; color: var(--lx-muted); }
.lx-auth .lx-btn { width: 100%; height: 48px; font-size: 15px; }
.lx-auth-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; font-size: 12.5px; color: var(--lx-muted); }
.lx-auth-err { margin: -4px 0 12px; color: var(--lx-bad); font-size: 13px; font-weight: 600; }
.lx-auth .lx-auth-foot .lx-btn { width: auto; height: 36px; font-size: 12.5px; padding: 0 12px; }
.lx-auth-foot .lx-link { white-space: nowrap; }

/* حقل كلمة المرور: العين على اليسار، فالمساحة الفاضية لازم تكون يسار كمان */
.lx .relative > input.cards-input.pe-12[dir="ltr"] { padding-left: 3rem; padding-right: .875rem; }
