/* ============================================================
   أركان العود — ARC | الثيم (نسخة عادية HTML/CSS/JS)
   مأخوذ من نفس متغيّرات التصميم الأصلية (ذهبي على أسود)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&family=Tajawal:wght@300;400;500;700&display=swap');
@import url('https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css');

:root {
  --background: 0 0% 4%;
  --foreground: 45 30% 90%;
  --card: 43 10% 13%;
  --card-2: 43 10% 17%;
  --border: 45 53% 54%;
  --primary: 45 53% 54%;
  --primary-foreground: 0 0% 4%;
  --muted: 0 0% 11%;
  --muted-foreground: 0 0% 60%;
  --accent: 45 53% 54%;
  --destructive: 0 72% 55%;
  --success: 145 50% 45%;
  --radius: 0.25rem;

  --bg: hsl(var(--background));
  --fg: hsl(var(--foreground));
  --gold: hsl(var(--primary));
  --gold-soft: hsl(var(--primary) / 0.15);
  --gold-line: hsl(var(--primary) / 0.20);
  --gold-line-2: hsl(var(--primary) / 0.12);
  --card-bg: hsl(var(--card));
  --card-bg-2: hsl(var(--card-2));
  --muted-fg: hsl(var(--muted-foreground));
  --danger: hsl(var(--destructive));
  --ok: hsl(var(--success));
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Cairo', sans-serif;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: 'Tajawal', sans-serif; font-weight: 700; margin: 0; }
.serif { font-family: 'Tajawal', sans-serif; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: hsl(var(--primary) / 0.25); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Landing ---------- */
.landing {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 3rem 1.5rem; position: relative;
}
.landing .logo {
  height: 7rem; width: 7rem; border-radius: 1.25rem; object-fit: contain;
  background: #fff; box-shadow: 0 10px 40px hsl(var(--primary) / 0.12);
}
.landing h1 { margin-top: 1.5rem; font-size: 2.6rem; color: var(--gold); letter-spacing: .5px; }
.landing .sub { margin-top: .75rem; color: var(--muted-fg); }
.dest-grid {
  margin-top: 3rem; display: grid; gap: 1.25rem; width: 100%; max-width: 640px;
  grid-template-columns: 1fr 1fr;
}
.dest-card {
  display: flex; flex-direction: column; align-items: center; gap: 1rem; text-align: center;
  border: 1px solid var(--gold-line); background: var(--card-bg); padding: 2rem 1.5rem;
  border-radius: 1rem; transition: all .2s ease;
}
.dest-card:hover { border-color: hsl(var(--primary) / 0.6); background: var(--gold-soft); transform: translateY(-2px); }
.dest-card .ic {
  height: 4rem; width: 4rem; display: grid; place-items: center; border-radius: .85rem;
  background: var(--gold-soft); color: var(--gold); font-size: 1.7rem;
}
.dest-card .t { font-family: 'Tajawal'; font-size: 1.25rem; font-weight: 700; }
.dest-card .d { font-size: .85rem; color: var(--muted-fg); line-height: 1.6; }
.dest-card.disabled { opacity: .55; cursor: not-allowed; }
.dest-card.disabled:hover { transform: none; border-color: var(--gold-line); background: var(--card-bg); }
.tag-soon { font-size: .7rem; color: var(--gold); border: 1px solid var(--gold-line); border-radius: 999px; padding: .1rem .55rem; }
.foot { margin-top: 4rem; font-size: .72rem; color: hsl(var(--muted-foreground) / .6); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; flex-shrink: 0; border-left: 1px solid var(--gold-line);
  background: var(--card-bg); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem;
  border-bottom: 1px solid var(--gold-line); transition: background .2s;
}
.brand:hover { background: var(--gold-soft); }
.brand img { height: 2.5rem; width: 2.5rem; border-radius: .4rem; object-fit: contain; background: #fff; }
.brand .name { font-family: 'Tajawal'; font-size: 1.15rem; color: var(--gold); font-weight: 700; }
.nav { flex: 1; overflow-y: auto; padding: .5rem .6rem; display: flex; flex-direction: column; gap: 0; }

/* عناوين المجموعات */
.nav-section { margin-bottom: .25rem; }
.nav-section-label {
  font-size: .68rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted-fg); opacity: .55; padding: .7rem .75rem .3rem;
}

/* عناصر القائمة */
.nav-item {
  display: flex; align-items: center; justify-content: flex-end; gap: .65rem;
  padding: .6rem .75rem; border-radius: 8px; text-decoration: none;
  color: var(--muted-fg); transition: background .12s, color .12s, border-color .12s;
  margin-bottom: 1px; direction: rtl; position: relative;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--gold-soft); color: var(--fg); }

/* العنصر النشط — تمييز واضح */
.nav-item.active {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: var(--gold-line);
}
.nav-item.active .nav-item-label { font-weight: 600; }
.nav-item.active .nav-item-icon  { color: var(--gold); }
.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 2px 0 0 2px;
  background: var(--gold);
}

.nav-item-label { font-size: .87rem; flex: 1; text-align: right; color: inherit; }
.nav-item-icon  { font-size: 1rem; width: 18px; text-align: center; color: inherit; flex-shrink: 0; }

.sidebar .back { padding: .75rem 1rem; border-top: 1px solid var(--gold-line); }
.sidebar .back a { color: var(--muted-fg); font-size: .85rem; display: flex; align-items: center; gap: .5rem; }
.sidebar .back a:hover { color: var(--gold); }

.main { flex: 1; overflow-y: auto; }
.page { padding: 1.75rem clamp(1rem, 3vw, 2.25rem); max-width: 1200px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head .title h2 { font-size: 1.55rem; color: var(--fg); }
.page-head .title p { margin: .3rem 0 0; color: var(--muted-fg); font-size: .88rem; }

/* mobile topbar */
.topbar { display: none; align-items: center; justify-content: space-between; padding: .7rem 1rem; border-bottom: 1px solid var(--gold-line); background: var(--card-bg); position: sticky; top: 0; z-index: 30; }
.topbar .name { font-family: 'Tajawal'; color: var(--gold); font-weight: 700; }
.hamb { background: none; border: 1px solid var(--gold-line); color: var(--gold); border-radius: var(--radius); padding: .4rem .6rem; font-size: 1.1rem; cursor: pointer; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 1rem; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--card-bg); border: 1px solid var(--gold-line-2); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
.card.hover { transition: border-color .2s, transform .2s; cursor: pointer; }
.card.hover:hover { border-color: hsl(var(--primary) / 0.5); transform: translateY(-2px); }
.card h3 { font-size: 1.05rem; }
.stat.card {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  text-align: right;
  border-top: 3px solid var(--stat-accent, var(--gold));
}
.stat .label { color: var(--muted-fg); font-size: .82rem; }
.stat .value { font-size: 1.15rem; font-weight: 700; color: var(--gold); font-family: 'Tajawal'; margin-top: .25rem; }
.stat .ic { color: var(--stat-accent, var(--gold)); font-size: 1.35rem; opacity: 1; flex-shrink: 0; }
.stat .stat-text { min-width: 0; }
.stat .stat-text .value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; border: 1px solid transparent;
  border-radius: var(--radius); padding: .55rem .95rem; font-family: 'Cairo'; font-size: .88rem;
  font-weight: 600; cursor: pointer; transition: all .15s; background: var(--muted); color: var(--fg);
}
.btn:hover { background: hsl(0 0% 16%); }
.btn-primary { background: var(--gold); color: var(--primary-foreground); }
.btn-primary:hover { background: hsl(var(--primary) / .85); }
.btn-ghost { background: transparent; color: var(--muted-fg); }
.btn-ghost:hover { background: var(--gold-soft); color: var(--gold); }
.btn-outline { background: transparent; border-color: var(--gold-line); color: var(--gold); }
.btn-outline:hover { background: var(--gold-soft); }
.btn-danger { background: transparent; color: var(--danger); border-color: hsl(var(--destructive) / .3); }
.btn-danger:hover { background: hsl(var(--destructive) / .12); }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; }
.btn-icon { padding: .4rem .5rem; }

/* ---------- Inputs ---------- */
.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .82rem; color: var(--muted-fg); margin-bottom: .35rem; }
.field-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 2px hsl(var(--destructive) / .15) !important; }
.field-error { color: var(--danger); font-size: .76rem; margin-top: .3rem; }
.input, .textarea, select {
  width: 100%; background: var(--bg); border: 1px solid var(--gold-line); color: var(--fg);
  border-radius: var(--radius); padding: .55rem .7rem; font-family: 'Cairo'; font-size: .9rem; outline: none;
}
.input:focus, .textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 2px hsl(var(--primary) / .15); }
.textarea { min-height: 70px; resize: vertical; }
.search-wrap { position: relative; max-width: 320px; flex: 1; }
.search-wrap .input { padding-right: 2.2rem; }
.search-wrap .i { position: absolute; right: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted-fg); }

/* ---------- Slider rows ---------- */
.slider-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .6rem; padding: .35rem 0; }
.slider-row .lab { font-size: .85rem; }
.slider-row .val { color: var(--gold); font-weight: 700; font-family: 'Tajawal'; min-width: 1.6rem; text-align: center; }
input[type=range] {
  -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 999px; outline: none; grid-column: 1 / -1;
  cursor: pointer;
  /* مسار محفور: تدرّج ذهبي من اليمين لمكان المقبض (--fill%) ثم لون غامق محفور للباقي */
  background: linear-gradient(to left,
    hsl(var(--primary) / .65) 0%,
    hsl(var(--primary) / .65) var(--fill, 0%),
    hsl(0 0% 0% / .55) var(--fill, 0%),
    hsl(0 0% 0% / .55) 100%);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.6), inset 0 0 0 1px hsl(var(--primary) / .18);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; height: 18px; width: 18px; border-radius: 50%;
  background: var(--gold); cursor: pointer; border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px hsl(var(--primary) / .5), 0 1px 3px rgba(0,0,0,.5);
  margin-top: -1px;
}
input[type=range]::-moz-range-thumb {
  height: 18px; width: 18px; border-radius: 50%; background: var(--gold);
  cursor: pointer; border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px hsl(var(--primary) / .5), 0 1px 3px rgba(0,0,0,.5);
}
input[type=range]::-moz-range-track { height: 6px; border-radius: 999px; background: transparent; }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 999px; background: hsl(var(--primary) / .65); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--gold-line-2); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: right; padding: .7rem .85rem; border-bottom: 1px solid var(--gold-line-2); white-space: nowrap; }
th { color: var(--gold); font-weight: 600; background: var(--card-bg); }
tbody tr:hover { background: var(--gold-soft); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; padding: .15rem .55rem; border-radius: 999px; border: 1px solid var(--gold-line); color: var(--gold); }
.badge.muted { color: var(--muted-fg); border-color: var(--gold-line-2); }
.badge.danger { color: var(--danger); border-color: hsl(var(--destructive) / .35); }
.badge.ok { color: var(--ok); border-color: hsl(var(--success) / .35); }
.badge.warn { color: hsl(30 80% 60%); border-color: hsl(30 80% 60% / .35); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }

/* progress / profile bars */
.bar { background: var(--muted); border-radius: 999px; height: 7px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.profile-row { display: grid; grid-template-columns: 5.5rem 1fr 1.6rem; align-items: center; gap: .6rem; margin-bottom: .45rem; }
.profile-row .pl { font-size: .82rem; color: var(--muted-fg); }
.profile-row .pv { font-size: .8rem; color: var(--gold); text-align: center; }

/* ---------- Dialog ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5,5,6,.94); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center; padding: 2rem 1rem; z-index: 80; overflow-y: auto; }
.overlay.open { display: flex; }
.dialog { background: var(--card-bg); border: 1px solid var(--gold-line); border-radius: .6rem; width: 100%; max-width: 640px; padding: 1.4rem; margin: auto; }
.dialog.wide { max-width: 820px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.dialog-head h3 { color: var(--gold); }
.dialog-head .x { background: none; border: none; color: var(--muted-fg); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.dialog-section-title { color: var(--gold); font-size: .85rem; font-weight: 700; margin: 1rem 0 .5rem; border-bottom: 1px solid var(--gold-line-2); padding-bottom: .35rem; grid-column: 1 / -1; }
.dialog-foot { display: flex; gap: .6rem; justify-content: flex-start; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--gold-line-2); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .4rem; border-bottom: 1px solid var(--gold-line-2); margin-bottom: 1.2rem; flex-wrap: wrap; }
.tabs button { background: none; border: none; color: var(--muted-fg); padding: .6rem .9rem; cursor: pointer; font-family: 'Cairo'; font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 1.25rem; left: 1.25rem; z-index: 99; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--card-bg); border: 1px solid var(--gold-line); border-radius: var(--radius); padding: .7rem 1rem; font-size: .88rem; min-width: 220px; box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: slidein .25s ease; }
.toast.ok { border-color: hsl(var(--success) / .5); }
.toast.err { border-color: hsl(var(--destructive) / .5); color: var(--danger); }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted-fg); border: 1px dashed var(--gold-line-2); border-radius: var(--radius); }
.empty .ic { font-size: 2.2rem; opacity: .5; }
.muted { color: var(--muted-fg); }
.gold { color: var(--gold); }
.row { display: flex; align-items: center; gap: .6rem; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.mt { margin-top: 1rem; } .mt2 { margin-top: 1.5rem; }
.hr { border: none; border-top: 1px solid var(--gold-line-2); margin: 1.1rem 0; }
.kpi { font-family: 'Tajawal'; font-weight: 700; color: var(--gold); }
.comp-row { display: grid; grid-template-columns: 1fr 5rem 4.5rem auto; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.comp-row .input { padding: .4rem .5rem; }
.comp-pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .6rem; }
.comp-pick-grid select, .comp-pick-grid input { width: 100%; }
.comp-pick-grid button { grid-column: 1 / -1; }
.total-line { display: flex; justify-content: space-between; padding: .4rem 0; font-size: .9rem; }
.total-line.big { font-size: 1.05rem; font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .cols-4 { grid-template-columns: 1fr 1fr; }
  .cols-3 { grid-template-columns: 1fr 1fr; }
  .dialog-grid { grid-template-columns: 1fr; }
}

/* القائمة الجانبية → قائمة منسدلة (hamburger) من عرض الديسكتوب الصغير فما دون،
   يشمل الأجهزة اللوحية بالوضع الأفقي (landscape) وأجهزة 2-في-1 مثل
   Surface Pro (عرضها المنطقي يصل حتى 1440px تقريباً حسب الجيل) */
@media (max-width: 1500px) {
  .topbar { display: flex; }
  .sidebar { position: fixed; right: 0; top: 0; z-index: 50; transform: translateX(100%); transition: transform .25s; box-shadow: -10px 0 40px rgba(0,0,0,.5); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 45; display: none; }
  .scrim.show { display: block; }
}

/* تعديلات أعمدة الشبكة تبقى للجوال الضيق فقط */
@media (max-width: 720px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .dest-grid { grid-template-columns: 1fr; }
  .comp-row { grid-template-columns: 1fr 4rem auto; }
  .comp-row .gram { display: none; }
}
