/* ألوان مؤقتة لحد ما الهوية تتحدد: كلها متغيرات هنا فوق */
:root {
  --bg: #F2F3F6;
  --surface: #FFFFFF;
  --ink: #1D2030;
  --muted: #646A7D;
  --line: #DADDE5;
  --brand: #2E3B8F;        /* الأزرار والعناوين */
  --brand-ink: #FFFFFF;
  --seat: #2F7A66;         /* كرسي متاح */
  --seat-ink: #FFFFFF;
  --picked: #F0A22E;       /* اختيارك */
  --picked-ink: #2A1A00;
  --taken: #C9CCD6;        /* محجوز */
  --taken-ink: #8C91A1;
  --danger: #B3261E;
  --ok: #1F7A3E;
  --radius: 12px;
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
}
body.has-tray { padding-bottom: 96px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--picked); outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px max(16px, env(safe-area-inset-left));
  background: var(--brand); color: var(--brand-ink);
}
.brand { margin: 0; font-size: 1.15rem; font-weight: 700; }
.lang {
  background: transparent; color: inherit; border: 1px solid rgb(255 255 255 / .45);
  border-radius: 999px; padding: 4px 14px; cursor: pointer; min-height: 36px;
}

.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 32px; display: grid; gap: 28px; }
.step { display: grid; gap: 14px; }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.step-title { margin: 0; font-size: 1.2rem; display: flex; align-items: center; gap: 10px; }
.step-n {
  inline-size: 30px; block-size: 30px; border-radius: 50%;
  display: inline-grid; place-items: center; font-size: .95rem;
  background: var(--brand); color: var(--brand-ink);
}
.empty { color: var(--muted); margin: 0; }

/* اختيار المسرح */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.choice {
  text-align: start; padding: 16px 18px; border-radius: var(--radius); cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); display: grid; gap: 2px;
}
.choice strong { font-size: 1.15rem; }
.choice small { color: var(--muted); }
.choice[aria-checked="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }

/* المواعيد */
.dates { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.date {
  flex: 0 0 auto; min-width: 128px; scroll-snap-align: start;
  display: grid; gap: 0; text-align: center; padding: 10px 14px; cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
}
.date small { color: var(--muted); }
.date strong { font-size: 1.05rem; }
.date span { font-size: .9rem; }
.date[aria-checked="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.date[aria-checked="true"] small { color: inherit; opacity: .85; }

/* عروض اليوم */
.day-shows { display: grid; gap: 10px; }
.sub-title { margin: 4px 0 0; font-size: 1rem; color: var(--muted); font-weight: 600; }
.show-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 10px; }
.show-card {
  display: flex; gap: 14px; align-items: flex-start; text-align: start; cursor: pointer;
  padding: 14px 16px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
}
.show-card[aria-checked="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.show-time {
  flex: none; min-width: 64px; padding: 6px 8px; border-radius: 8px; text-align: center;
  background: var(--bg); font-weight: 700; font-variant-numeric: tabular-nums;
}
.show-card[aria-checked="true"] .show-time { background: var(--brand); color: var(--brand-ink); }
.show-body { display: grid; gap: 2px; min-width: 0; }
.show-body strong { font-size: 1.08rem; line-height: 1.4; }
.show-meta { color: var(--muted); font-size: .92rem; }
.show-notes { font-size: .9rem; margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--line); white-space: pre-line; }

/* البلان */
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .9rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .seat { inline-size: 18px; block-size: 18px; font-size: 0; pointer-events: none; }
.zoom { display: flex; gap: 6px; }
.zoom button {
  inline-size: 40px; block-size: 40px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-size: 1.3rem; line-height: 1;
}

.map-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: auto; overscroll-behavior: contain; max-height: min(72vh, 820px);
  -webkit-overflow-scrolling: touch;
}
.map { --z: 1; padding: 16px; width: max-content; min-width: 100%; }
.loading { color: var(--muted); text-align: center; }

.plan {
  --s: calc(30px * var(--z));
  --g: calc(4px * var(--z));
  display: grid; gap: calc(22px * var(--z)); justify-items: center; width: max-content; margin-inline: auto;
}
.plan-stage {
  justify-self: stretch; text-align: center; padding: calc(8px * var(--z));
  font-size: calc(14px * var(--z)); font-weight: 600; letter-spacing: .02em;
  background: var(--ink); color: var(--bg);
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  margin-bottom: calc(6px * var(--z));
}
.plan-tier { display: flex; gap: calc(var(--s) * .9); align-items: flex-start; }
.plan-block, .plan-labels { display: grid; gap: var(--g); }
.plan-row { display: flex; gap: var(--g); min-height: var(--s); }
.align-start .plan-row { justify-content: flex-start; }
.align-end .plan-row { justify-content: flex-end; }
.plan-labels span {
  block-size: var(--s); inline-size: calc(var(--s) * .8);
  display: grid; place-items: center; font-weight: 700; font-size: calc(13px * var(--z)); color: var(--muted);
}
.plan-labels.is-aisle span { inline-size: calc(var(--s) * 1.2); }
.plan-labels span.is-off { opacity: .4; }

.seat {
  inline-size: var(--s); block-size: var(--s); padding: 0; flex: 0 0 auto;
  border: 0; border-radius: calc(7px * var(--z)) calc(7px * var(--z)) calc(3px * var(--z)) calc(3px * var(--z));
  background: var(--seat); color: var(--seat-ink);
  font-size: calc(12px * var(--z)); font-weight: 600; font-variant-numeric: tabular-nums;
  cursor: pointer; display: inline-grid; place-items: center;
  transition: transform .12s ease, background-color .12s ease;
}
@media (hover: hover) { .seat:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.1); } }
.seat.is-picked { background: var(--picked); color: var(--picked-ink); box-shadow: 0 0 0 2px var(--ink) inset; }
.seat.is-taken { background: var(--taken); color: var(--taken-ink); cursor: not-allowed; }
.seat.is-off { background: transparent; color: var(--taken-ink); box-shadow: inset 0 0 0 1px var(--line); cursor: not-allowed; }
.legend .seat.is-off { box-shadow: inset 0 0 0 1.5px var(--taken); }

/* الشريط اللي تحت */
.tray {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgb(29 32 48 / .08);
}
.tray-info { display: grid; min-width: 0; }
.tray-seats { color: var(--muted); font-size: .92rem; direction: ltr; text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 700px) { .tray { padding-inline: max(16px, calc((100vw - 1100px) / 2 + 16px)); } }

.btn {
  min-height: 46px; padding: 0 20px; border-radius: 10px; cursor: pointer; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface);
}
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* الفورم */
.sheet {
  border: 0; padding: 0; border-radius: 16px; width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px); background: var(--surface); color: var(--ink);
}
.sheet::backdrop { background: rgb(15 17 28 / .55); }
@media (max-width: 599px) {
  .sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.sheet form, .done { padding: 22px 20px; display: grid; gap: 14px; }
.sheet h2 { margin: 0; font-size: 1.25rem; }
.summary { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; background: var(--bg); padding: 12px 14px; border-radius: 10px; font-size: .95rem; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; }
.hint { margin: 0; color: var(--muted); font-size: .92rem; }
.field { display: grid; gap: 4px; font-weight: 500; }
.field input {
  min-height: 46px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font-size: 16px; /* يمنع الزوم التلقائي على iPhone */
}
[dir="rtl"] .field input[dir="ltr"] { text-align: right; }
.field input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgb(46 59 143 / .2); }
.error { margin: 0; color: var(--danger); font-weight: 500; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; }
.done p { margin: 0; color: var(--muted); }
.ticket {
  display: grid; justify-items: center; gap: 2px; padding: 14px; border-radius: 12px;
  border: 2px dashed var(--brand); color: var(--muted);
}
.ticket strong { font-size: 1.8rem; letter-spacing: .12em; color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50;
  max-width: calc(100vw - 32px); text-align: center; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
