:root {
  --primary: #0f766e;
  --primary-dark: #134e4a;
  --primary-soft: #ccfbf1;
  --accent: #f59e0b;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --info-soft: #e0f2fe;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700;
  background: var(--primary); color: #fff; text-decoration: none; transition: filter 0.15s, transform 0.05s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.lg { padding: 15px 20px; font-size: 1.05rem; }
.btn.sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 9px; }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.warning { background: var(--accent); color: #1f1300; }
.btn.link { background: none; color: var(--primary); padding: 6px; }

/* Forms */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px;
  background: #fff; outline: none; transition: border-color 0.15s;
}
.input:focus { border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 90px; }
.input.ltr { direction: ltr; text-align: right; }
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { padding-left: 48px; }
.pw-eye {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent;
  font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.pw-eye:hover { background: rgba(0,0,0,.06); }

/* Cards & badges */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
  background: #e2e8f0; color: var(--text); white-space: nowrap;
}
.badge.green { background: var(--success-soft); color: #166534; }
.badge.red { background: var(--danger-soft); color: #991b1b; }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.blue { background: var(--info-soft); color: #075985; }
.badge.teal { background: var(--primary-soft); color: var(--primary-dark); }

/* Auth */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 20% 10%, #14b8a6 0%, var(--primary) 40%, var(--primary-dark) 100%);
}
.auth-card { width: 100%; max-width: 400px; }
.brand { text-align: center; margin-bottom: 18px; }
.brand .logo { font-size: 46px; line-height: 1; }
.brand h1 { margin: 8px 0 2px; font-size: 1.6rem; }
.brand p { margin: 0; color: var(--muted); }
.dev-hint { background: var(--warning-soft); color: var(--warning); padding: 8px 12px; border-radius: 10px; font-size: 0.85rem; margin-bottom: 12px; }

/* Map apps */
.map-app { position: fixed; inset: 0; overflow: hidden; }
#map { position: absolute; inset: 0; z-index: 1; }
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 500; display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--shadow);
  font-size: 19px; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn.active { background: var(--primary); color: #fff; }
.pill { background: #fff; border-radius: 999px; padding: 9px 16px; box-shadow: var(--shadow); font-weight: 700; }
.map-fab { position: absolute; z-index: 550; left: 16px; }

.sheet {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 600; background: #fff;
  border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.16);
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 72vh; overflow-y: auto;
  max-width: 560px; margin: 0 auto;
}
.sheet::before { content: ''; display: block; width: 42px; height: 5px; border-radius: 9px; background: #cbd5e1; margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 12px; font-size: 1.1rem; }
.with-nav .sheet { bottom: 64px; }

/* Location fields */
.loc-field {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1.5px solid var(--border);
  border-radius: 12px; margin-bottom: 8px; cursor: pointer; background: #fff; width: 100%; text-align: start;
}
.loc-field.active { border-color: var(--primary); background: #f0fdfa; }
.loc-field .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot.a { background: var(--success); }
.dot.b { background: var(--danger); }
.loc-field .txt { flex: 1; min-width: 0; }
.loc-field .lbl { font-size: 0.75rem; color: var(--muted); }
.loc-field .addr { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results { list-style: none; margin: 0 0 8px; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.search-results li { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 0.9rem; }
.search-results li:last-child { border-bottom: 0; }
.search-results li:hover { background: #f8fafc; }

/* Vehicle options */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.option {
  border: 2px solid var(--border); border-radius: 14px; padding: 12px; background: #fff; text-align: center;
}
.option.selected { border-color: var(--primary); background: #f0fdfa; }
.option .ico { font-size: 30px; }
.option .name { font-weight: 700; }
.option .price { font-size: 1.15rem; font-weight: 800; color: var(--primary-dark); }
.trip-meta { display: flex; justify-content: center; gap: 16px; color: var(--muted); font-size: 0.9rem; }

/* Driver card */
.person { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 54px; height: 54px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.3rem; flex: none;
}
.plate { direction: ltr; display: inline-block; border: 2px solid var(--text); border-radius: 6px; padding: 1px 8px; font-weight: 800; letter-spacing: 1px; font-size: 0.9rem; }
.status-banner { background: var(--primary); color: #fff; border-radius: 12px; padding: 10px 14px; font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; gap: 8px; }
.status-banner.arrived { background: var(--accent); color: #1f1300; }
.status-banner.started { background: #2563eb; }
.points { border-inline-start: 2px dashed var(--border); padding-inline-start: 12px; margin: 12px 4px; }
.points div { margin: 6px 0; font-size: 0.92rem; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.actions > * { flex: 1; }

/* Spinner / searching */
.pulse { width: 74px; height: 74px; margin: 6px auto 12px; border-radius: 50%; background: var(--primary); position: relative; display: flex; align-items: center; justify-content: center; font-size: 30px; }
.pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--primary); animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: 1; } to { transform: scale(1.9); opacity: 0; } }

/* Stars */
.stars { display: flex; justify-content: center; gap: 6px; direction: ltr; margin: 14px 0; }
.stars button { background: none; border: 0; font-size: 40px; color: #cbd5e1; padding: 0; line-height: 1; }
.stars button.on { color: var(--accent); }

/* Pages (non-map screens) */
.page { max-width: 640px; margin: 0 auto; padding: 16px 16px 90px; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head h2 { margin: 0; font-size: 1.25rem; flex: 1; }
.list-item { background: #fff; border-radius: 14px; padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border-radius: 14px; padding: 14px; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08); }
.stat .label { color: var(--muted); font-size: 0.82rem; }
.stat .value { font-size: 1.35rem; font-weight: 800; margin-top: 2px; }
.stat.primary { background: var(--primary); color: #fff; }
.stat.primary .label { color: #ccfbf1; }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 900; }
.drawer {
  position: fixed; top: 0; bottom: 0; right: 0; width: 280px; max-width: 85vw; background: #fff; z-index: 901;
  padding: calc(20px + env(safe-area-inset-top)) 16px 20px; box-shadow: var(--shadow);
}
.drawer .who { padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.drawer button { display: block; width: 100%; text-align: start; background: none; border: 0; padding: 13px 8px; border-radius: 10px; font-weight: 600; }
.drawer button:hover { background: var(--bg); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); z-index: 1000; display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 20px; padding: 20px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; }
@media (min-width: 700px) { .modal-backdrop { align-items: center; } }

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 700; height: 64px; background: #fff; display: flex;
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav button { flex: 1; background: none; border: 0; font-size: 0.78rem; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.bottom-nav button span { font-size: 20px; }
.bottom-nav button.active { color: var(--primary); }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 10px; background: #fff; border-radius: 999px; padding: 6px 8px 6px 16px; box-shadow: var(--shadow); border: 0; font-weight: 800; }
.switch .track { width: 46px; height: 26px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background 0.2s; }
.switch .track::after { content: ''; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: right 0.2s; }
.switch.on .track { background: var(--success); }
.switch.on .track::after { right: 23px; }

/* Toast */
#toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast-item { background: var(--text); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; animation: toastIn 0.2s ease-out; }
.toast-item.error { background: var(--danger); }
.toast-item.success { background: var(--success); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Map markers */
.mk { background: none; border: 0; }
.mk .pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: flex; align-items: center; justify-content: center;
  border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35); color: #fff; font-weight: 800; font-size: 13px;
}
.mk .pin b { transform: rotate(45deg); }
.mk .pin.a { background: var(--success); }
.mk .pin.b { background: var(--danger); }
.mk .veh {
  width: 38px; height: 38px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 22px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35); border: 3px solid var(--primary);
}
.mk .veh.busy { border-color: var(--accent); }
.mk .veh.small { width: 30px; height: 30px; font-size: 17px; border-width: 2px; }
.mk .me { width: 22px; height: 22px; border-radius: 50%; background: #2563eb; border: 4px solid #fff; box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.25); }

/* ===== المطاعم والمحلات ===== */
.mk .veh.store { border-color: var(--accent); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--border); background: #fff; border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 0.88rem; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.thumb { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; flex: none; background: var(--primary-soft); }
.thumb.ph { display: flex; align-items: center; justify-content: center; font-size: 30px; }
.thumb.lg { width: 84px; height: 84px; font-size: 40px; }
.store-card { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.store-card.closed { opacity: 0.6; }
.store-card .meta { font-size: 0.82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.store-hero { display: flex; gap: 14px; align-items: center; }
.section-title { margin: 18px 0 8px; font-size: 1rem; color: var(--muted); }
.product { display: flex; gap: 12px; align-items: center; }
.product.off { opacity: 0.5; }
.product .info { flex: 1; min-width: 0; }
.product .desc { font-size: 0.82rem; color: var(--muted); }
.product .price { font-weight: 800; color: var(--primary-dark); margin-top: 2px; }
.qty { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.qty button { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 18px; font-weight: 800; line-height: 1; }
.qty button.minus { background: #e2e8f0; color: var(--text); }
.qty b { min-width: 20px; text-align: center; }
.cart-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 700; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(241, 245, 249, 0.95) 30%);
}
.cart-bar .btn { max-width: 608px; margin: 0 auto; display: flex; justify-content: space-between; width: 100%; }
#checkout-map, #order-map { height: 230px; border-radius: 14px; margin-bottom: 10px; z-index: 1; }
.steps { display: flex; justify-content: space-between; margin: 14px 0 6px; position: relative; }
.steps::before { content: ''; position: absolute; top: 15px; right: 8%; left: 8%; height: 3px; background: var(--border); }
.steps div { position: relative; flex: 1; text-align: center; font-size: 0.72rem; color: var(--muted); font-weight: 700; }
.steps span { display: flex; width: 32px; height: 32px; margin: 0 auto 4px; border-radius: 50%; background: #fff; border: 3px solid var(--border); align-items: center; justify-content: center; font-size: 15px; }
.steps .done { color: var(--primary-dark); }
.steps .done span { border-color: var(--primary); background: var(--primary-soft); }
.order-pill { background: var(--accent); color: #1f1300; border: 0; }
.delivery-tag { background: var(--warning-soft); color: var(--warning); border-radius: 10px; padding: 8px 12px; font-size: 0.88rem; margin: 10px 0; }

/* ===== التفاوض على السعر ===== */
.fare-box { border: 2px dashed var(--primary); border-radius: 14px; padding: 10px 12px; margin-top: 10px; background: #f0fdfa; }
.fare-ctl { display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; }
.fare-ctl button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 24px; font-weight: 800; flex: none; }
.fare-ctl input { flex: 1; min-width: 0; text-align: center; font-size: 1.5rem; font-weight: 800; border: 0; background: transparent; color: var(--primary-dark); outline: none; }
.raise-chips { display: flex; gap: 6px; margin: 6px 0 4px; }
.raise-chips button { flex: 1; border: 1.5px solid var(--accent); background: #fff; color: var(--warning); border-radius: 12px; padding: 7px 4px; font-weight: 800; }
.bid-card { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--border); border-radius: 14px; padding: 10px; margin-bottom: 8px; background: #fff; animation: toastIn 0.25s ease-out; }
.bid-card .avatar { width: 44px; height: 44px; font-size: 1.1rem; }
.bid-card .price { font-size: 1.2rem; font-weight: 800; color: var(--primary-dark); white-space: nowrap; }
.bid-card .btns { display: flex; flex-direction: column; gap: 4px; }
.bid-timer { height: 3px; background: var(--accent); border-radius: 3px; margin-top: 4px; transition: width 1s linear; }

/* التتبع المباشر */
.live-wrap { position: relative; }
.live-chip { position: absolute; z-index: 560; top: 10px; right: 10px; background: rgba(15, 23, 42, .82); color: #fff; font-size: .8rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; pointer-events: none; }
.live-chip:empty { display: none; }
.follow-btn { position: absolute; z-index: 560; bottom: 10px; left: 10px; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.15); cursor: pointer; }
.trip-live { font-size: .8rem; font-weight: 700; margin-top: 6px; }

/* السلامة: PIN، SOS، الحجز لشخص آخر */
.pin-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--primary-soft); border-radius: 12px; padding: 8px 12px; margin: 8px 0; }
.pin-box b { font-size: 1.6rem; letter-spacing: 6px; direction: ltr; }
.pin-box small { display: block; color: var(--muted); font-size: .75rem; }
.sos-btn { background: #dc2626 !important; color: #fff !important; font-weight: 800; }
.map-fab.sos-btn { width: auto; padding: 0 12px; border-radius: 999px; }
.sos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sos-grid .btn { font-size: .85rem; padding: 10px 6px; }
.for-other { border: 1px dashed var(--border); border-radius: 12px; padding: 8px 10px; margin-top: 10px; }
.for-other summary { cursor: pointer; font-weight: 700; font-size: .9rem; }
.for-other .input { margin-top: 8px; }
.pin-input { font-size: 1.6rem; letter-spacing: 8px; text-align: center; direction: ltr; }

/* طريقة الدفع */
.pay-box { border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; margin-top: 10px; }
.pay-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.pay-opts label { display: flex; align-items: center; gap: 6px; border: 2px solid var(--border); border-radius: 10px; padding: 8px; font-size: .85rem; font-weight: 700; cursor: pointer; }
.pay-opts label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.paid-tag { display: inline-block; background: #ede9fe; color: #5b21b6; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 800; }

/* اللغة والعملة */
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.lang-grid .btn { padding: 8px 6px; font-size: .9rem; }
.cur-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; }
.cur-item { display: flex; gap: 8px; width: 100%; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--border); background: transparent; font: inherit; text-align: start; cursor: pointer; }
.cur-item:hover, .cur-item.active { background: var(--primary-soft); }
.cur-item b { min-width: 44px; }
.lang-btn { font-size: .85rem; }

/* شعار AG DELIVERY */
.brand .logo-img { display: block; width: 132px; height: 132px; margin: 0 auto 6px; border-radius: 28px; object-fit: cover; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }

/* شاشة البداية */
.app-splash { position: fixed; inset: 0; z-index: 5000; background: #FF7A1C; display: flex; align-items: center; justify-content: center; transition: opacity .45s; }
.app-splash img { width: min(60vw, 280px); height: auto; border-radius: 22%; }
.app-splash.out { opacity: 0; pointer-events: none; }
