/* الهوية: أزرق النيل + أصفر الركشة */
:root {
  --nile: #0E4D64;
  --nile-2: #13637F;
  --nile-soft: #E3EEF2;
  --amber: #F2B705;
  --amber-soft: #FFF3C4;
  --ink: #14212B;
  --muted: #5C6B75;
  --line: #D9E1E5;
  --paper: #F6F8F9;
  --card: #FFFFFF;
  --ok: #1E8A5A;
  --ok-soft: #E2F4EB;
  --bad: #C8352E;
  --bad-soft: #FBE7E5;
  --radius-sheet: 22px;
  --radius-ctl: 12px;
  --shadow-sheet: 0 -6px 24px rgba(14, 77, 100, .14);
  --font-head: 'Alexandria', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Arabic', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.25; margin: 0 0 .4em; font-weight: 600; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--nile-2); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* أزرار */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: 600 1rem/1 var(--font-head);
  padding: 15px 18px; border-radius: var(--radius-ctl);
  background: var(--nile); color: #fff; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px;
  transition: transform .08s ease, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.amber { background: var(--amber); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--nile); border: 1.5px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1.5px solid var(--bad-soft); }
.btn.ok { background: var(--ok); }
.btn.sm { min-height: 40px; padding: 10px 14px; font-size: .9rem; width: auto; white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 12px; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* حقول */
label.field { display: block; }
label.field > span { display: block; font-size: .875rem; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: 13px 14px; border-radius: var(--radius-ctl);
  border: 1.5px solid var(--line); background: #fff;
  min-height: 50px;
}
input:focus, select:focus, textarea:focus { border-color: var(--nile-2); outline: none; box-shadow: 0 0 0 3px var(--nile-soft); }
input[inputmode="numeric"], input[type="tel"], .code-input { direction: ltr; text-align: right; letter-spacing: .04em; }
.code-input { font-size: 1.6rem; text-align: center; letter-spacing: .5em; font-variant-numeric: tabular-nums; }

/* رسائل منبثقة */
#toast {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%) translateY(calc(-100% - 40px));
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px;
  z-index: 9999; max-width: calc(100% - 32px); transition: transform .25s ease; font-size: .95rem;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); }
#toast.ok { background: var(--ok); }

/* شريط الاتصال */
#netbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9998;
  background: var(--bad); color: #fff; text-align: center; font-size: .85rem; padding: 4px;
}

.sheet-actions { position: sticky; bottom: 0; background: var(--card); padding: 10px 0 2px; box-shadow: 0 -10px 12px -8px rgba(255,255,255,.9); }

/* شاشة الدخول */
.auth {
  min-height: 100%; display: flex; flex-direction: column; justify-content: center;
  padding: 32px 22px max(32px, env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto;
}
.brand { font-family: var(--font-head); font-weight: 700; font-size: 2.6rem; color: var(--nile); letter-spacing: -.01em; margin-bottom: 4px; }
.brand-mark { width: 54px; height: 54px; border-radius: 16px; background: var(--amber); display: grid; place-items: center; font-size: 28px; margin-bottom: 18px; }
.phone-wrap { display: flex; direction: ltr; border: 1.5px solid var(--line); border-radius: var(--radius-ctl); background: #fff; overflow: hidden; }
.phone-wrap:focus-within { border-color: var(--nile-2); box-shadow: 0 0 0 3px var(--nile-soft); }
.phone-wrap .cc { padding: 0 12px; display: grid; place-items: center; background: var(--paper); color: var(--muted); border-left: 1.5px solid var(--line); font-variant-numeric: tabular-nums; }
.phone-wrap input { border: 0; box-shadow: none !important; text-align: left; }

/* الخريطة + اللوحة السفلية */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#map { position: absolute; inset: 0; z-index: 1; background: #dfe7ea; }
.topbar {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 500;
  display: flex; gap: 8px; align-items: center; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.chip {
  background: #fff; border-radius: 999px; padding: 8px 14px; box-shadow: 0 2px 10px rgba(20,33,43,.14);
  font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; border: 0; font-family: inherit; color: var(--ink); cursor: pointer; min-height: 42px;
}
.chip.icon { width: 44px; height: 44px; padding: 0; justify-content: center; font-size: 1.2rem; }
.spacer { flex: 1; }

.sheet {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 600;
  background: var(--card); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: var(--shadow-sheet);
  padding: 10px 18px max(18px, env(safe-area-inset-bottom));
  max-height: 78vh; overflow-y: auto;
  max-width: 560px; margin: 0 auto;
}
.sheet::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }

/* دبوس منتصف الخريطة */
.center-pin {
  position: absolute; left: 50%; top: 50%; z-index: 450; pointer-events: none;
  transform: translate(-50%, -100%); font-size: 0;
}
.center-pin .head { width: 26px; height: 26px; border-radius: 50%; border: 7px solid var(--nile); background: #fff; }
.center-pin .stem { width: 3px; height: 16px; background: var(--nile); margin: 0 auto; border-radius: 0 0 2px 2px; }
.center-pin.drop .head { border-color: var(--amber); }
.center-pin.drop .stem { background: var(--ink); }

/* تذكرة الأجرة — العنصر المميز */
.ticket {
  background: var(--amber); border-radius: 16px; padding: 14px 16px; position: relative;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.ticket::before, .ticket::after {
  content: ''; position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; background: var(--card); transform: translateY(-50%);
}
.ticket::before { right: -8px; }
.ticket::after { left: -8px; }
.ticket .fare { font-family: var(--font-head); font-weight: 700; font-size: 2rem; font-variant-numeric: tabular-nums; }
.ticket .fare small { font-size: .9rem; font-weight: 500; margin-inline-start: 4px; }

/* خيارات المركبات */
.options { display: grid; gap: 8px; }
.opt {
  display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; text-align: start; font: inherit; color: inherit; width: 100%;
}
.opt .ic { font-size: 1.6rem; text-align: center; }
.opt .price { font-family: var(--font-head); font-weight: 600; font-variant-numeric: tabular-nums; }
.opt[aria-pressed="true"] { border-color: var(--nile); background: var(--nile-soft); }

.seg { display: flex; background: var(--paper); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; white-space: nowrap; border: 0; background: transparent; padding: 10px; border-radius: 9px; font: 600 .95rem var(--font-head); color: var(--muted); cursor: pointer; min-height: 44px; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(20,33,43,.12); }

/* بطاقة الشخص */
.person { display: flex; gap: 12px; align-items: center; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--nile-soft); color: var(--nile); display: grid; place-items: center; font: 700 1.3rem var(--font-head); flex: none; }
.plate { display: inline-block; border: 2px solid var(--ink); border-radius: 6px; padding: 1px 8px; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; background: #fff; }
.call { width: 48px; height: 48px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; text-decoration: none; font-size: 1.3rem; flex: none; }

.status-line { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 600; font-size: 1.1rem; margin-bottom: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(30,138,90,.5); } 50% { box-shadow: 0 0 0 10px rgba(30,138,90,0); } }

.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 600; }
.copy { border: 0; background: var(--nile-soft); color: var(--nile); border-radius: 8px; padding: 4px 10px; font: 600 .8rem var(--font-head); cursor: pointer; }

.notice { padding: 12px 14px; border-radius: 12px; background: var(--nile-soft); color: var(--nile); font-size: .92rem; }
.notice.warn { background: var(--amber-soft); color: #6b5100; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

.stars { display: flex; gap: 6px; justify-content: center; direction: ltr; }
.stars button { font-size: 2.2rem; background: none; border: 0; cursor: pointer; color: var(--line); padding: 2px; line-height: 1; }
.stars button.on { color: var(--amber); }

.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); }

/* قائمة جانبية */
.drawer-bg { position: fixed; inset: 0; background: rgba(20,33,43,.4); z-index: 900; }
.drawer {
  position: fixed; top: 0; bottom: 0; right: 0; width: min(340px, 88vw); background: #fff; z-index: 901;
  padding: max(20px, env(safe-area-inset-top)) 20px 20px; overflow-y: auto;
}
.drawer nav button { display: block; width: 100%; text-align: start; background: none; border: 0; padding: 14px 4px; font: 500 1rem var(--font-body); color: var(--ink); border-bottom: 1px solid var(--line); cursor: pointer; }

.page { position: fixed; inset: 0; background: var(--paper); z-index: 800; overflow-y: auto; padding: max(16px, env(safe-area-inset-top)) 18px 40px; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.page-inner { max-width: 560px; margin: 0 auto; }
.card { background: #fff; border-radius: 16px; padding: 16px; border: 1px solid var(--line); }

.leaflet-container { font-family: var(--font-body); }
.marker-car { font-size: 26px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.marker-dot { width: 18px; height: 18px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.35); }
.marker-dot.pickup { background: var(--nile); }
.marker-dot.drop { background: var(--amber); }
.marker-dot.me { background: #2C7BE5; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
button.plate { font: inherit; font-weight: 700; color: var(--ink); }
