/* مَوقِف — أساس مشترك: توكنات الثيم (نهاري/ليلي)، أُطُر الأجهزة، خرائط، تمرير. */

/* ─── توكنات الثيم النهاري (افتراضي) ─── */
:root {
  --desk:       #d8e2dc;
  --bg:         #f4f8f6;
  --surface:    #ffffff;
  --surface-2:  #eef4f1;
  --ink:        #0F2719;
  --ink-soft:   #3D7558;
  --ink-faint:  #6b8f7b;
  --line:       #e3ede7;
  --header:     #173A29;
  color-scheme: light;
}

/* ─── الثيم الليلي ─── */
html.dark {
  --desk:       #050b09;
  --bg:         #0c1714;
  --surface:    #15231c;
  --surface-2:  #1d2f27;
  --ink:        #e9f3ee;
  --ink-soft:   #a7c8b6;
  --ink-faint:  #6f9482;
  --line:       #243a30;
  --header:     #0e2017;
  color-scheme: dark;
}

/* ─── وضوح الأيقونات/الروابط الخضراء في الوضع الليلي (كي لا تضيع) ─── */
/* أزرار التحكّم العائمة (تكبير/تصغير/موقعي/ملء/القائمة): أبيض طافٍ في الليلي */
.ctl-ico { color: #2A5C44; }                /* النهاري: gov-600 كما هو */
html.dark .ctl-ico { color: var(--ink); }   /* الليلي: فاتح طافٍ */
/* بقية أيقونات/روابط gov-600 و gov-700 على الأسطح الداكنة: أخضر أفتح ظاهر */
html.dark .text-gov-600, html.dark .text-gov-700 { color: #6FB28C; }

/* ─── نوافذ MapLibre المنبثقة (tooltip الاسم / popup المعلومات) — تتكيّف مع الثيم ─── */
.maplibregl-popup-content { background: var(--surface); color: var(--ink);
  border-radius: 14px; box-shadow: 0 8px 26px rgba(0,0,0,.20); padding: 10px 12px; }
.maplibregl-popup-close-button { color: var(--ink-faint); font-size: 18px; padding: 0 7px; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }
.mw-tip .maplibregl-popup-content { padding: 5px 11px; font-weight: 800; font-size: 12px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Cairo','Noto Sans Arabic','Tajawal',system-ui,sans-serif;
  background: var(--desk);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

/* انتقال ناعم عند تبديل الثيم (عدا الخريطة) */
body, body * { transition: background-color .25s ease, border-color .25s ease, color .2s ease; }
.maplibregl-map, .maplibregl-map * { transition: none !important; }

/* ─── أُطُر الأجهزة ─── */
.frame-mobile {
  max-width: 430px; margin: 0 auto; height: 100dvh;
  background: var(--bg);
  box-shadow: 0 0 60px rgba(0,0,0,.18);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
.frame-tablet  { max-width: 1200px; margin: 0 auto; min-height: 100dvh; background: var(--bg); }
.frame-desktop { min-height: 100dvh; background: var(--bg); }

/* ─── تمرير نحيف لطيف ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }

/* حركة دخول لطيفة */
@keyframes rise { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform:none; } }
.rise { animation: rise .35s ease-out both; }

a { text-decoration: none; color: inherit; }

/* ─── مفتاح تبديل (switch) — يعمل RTL/LTR ─── */
.switch {
  -webkit-appearance: none; appearance: none; flex: none;
  width: 44px; height: 26px; border-radius: 9999px; background: var(--line);
  position: relative; cursor: pointer; transition: background .2s;
}
.switch:checked { background: #2A5C44; }
.switch::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 20px; height: 20px; border-radius: 9999px; background: #fff;
  transition: inset-inline-start .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch:checked::after { inset-inline-start: 21px; }

/* ─── صفوف القوائم المشتركة ─── */
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; transition: background .15s; }
.row:hover { background: var(--surface-2); }
.ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-soft); flex: none; }
.chev { width: 18px; height: 18px; color: var(--ink-faint); flex: none; }
[dir="ltr"] .chev { transform: rotate(180deg); }
.badge { font-size: 10px; font-weight: 700; color: var(--ink-faint);
  background: var(--surface-2); padding: 2px 8px; border-radius: 9999px; }

/* ─── دبوس الكراج على الخريطة (SVG path + عدّاد + سعر + حالات) ─── */
/* الجذر: يتحكّم MapLibre بـ transform الخاص به وحده (لا transition/transform هنا حتى لا ينزلق) */
.gpin2 { width: 62px; cursor: pointer; }
.gpin2.sel { z-index: 5; }
/* الغلاف الداخلي: كل التأثيرات البصرية (تكبير/ظل) هنا */
.gpin2-inner { position: relative; display: block; transform-origin: bottom center;
  transition: transform .15s; filter: drop-shadow(0 4px 5px rgba(0,0,0,.45)); }
.gpin2:hover .gpin2-inner { transform: scale(1.06); }
.gpin2.sel  .gpin2-inner { transform: scale(1.16); }
.gpin2-shape { display: block; width: 100%; height: auto; }
.gpin2-shape path { stroke: #fff; stroke-width: 2.5; }
.gpin2.available .gpin2-shape path { fill: #2A5C44; }   /* متوفّر */
.gpin2.limited   .gpin2-shape path { fill: #E0A93B; }   /* محدود */
.gpin2.full      .gpin2-shape path { fill: #DC2626; }   /* ممتلئ */
.gpin2.sel .gpin2-shape path { stroke: #ECB93F; stroke-width: 3.5; }  /* محدّد: إطار ذهبي */
.gpin2-body { position: absolute; top: 1%; left: 0; right: 0; height: 74%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.gpin2-line1 { display: flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 800; line-height: 1; }
.gpin2-line2 { font-size: 9px; font-weight: 700; line-height: 1.05; margin-top: 1px; }
.gpin2.available .gpin2-body, .gpin2.full .gpin2-body { color: #fff; }
.gpin2.limited .gpin2-body { color: #0F2719; }

/* ─── الدرج الجانبي: ينزلق من جهة البداية (يمين في RTL، يسار في LTR) ─── */
.mw-drawer-panel {
  position: absolute; top: 0; height: 100%;
  inset-inline-start: 0;
  transition: transform .3s ease;
  box-shadow: 0 0 50px rgba(0, 0, 0, .28);
}
[dir="rtl"] .mw-drawer-panel:not(.open) { transform: translateX(100%); }
[dir="ltr"] .mw-drawer-panel:not(.open) { transform: translateX(-100%); }
.mw-drawer-panel.open { transform: translateX(0); }

/* ─── MapLibre: نظّف الواجهة ─── */
.maplibregl-ctrl-attrib { font-size: 9px; opacity: .65; }
.maplibregl-ctrl-attrib a { color: var(--ink-faint); }
.maplibregl-canvas:focus { outline: none; }
.maplibregl-ctrl-bottom-left { display: none; }   /* نخفي شعار/أزرار غير لازمة */
