/* ─────────────────────────────────────────────────────────────────────────────
   plans.css — «الأيام» day plans: the list (/plans, .view-plans), the builder
   (/plans/:id, .view-plan-day), and the stop-picker sheet (.sp-*). Reuses the
   app design tokens (style.css) so light/dark + Thmanyah type come for free.
   RTL, mobile-first, same utilitarian register as places.css/finances.css.
   ───────────────────────────────────────────────────────────────────────────── */

.view-plans,
.view-plan-day {
  max-width: var(--container);
  margin: 0 auto;
  padding: 14px 16px calc(48px + env(safe-area-inset-bottom, 0px));
}

/* ── List header ────────────────────────────────────────────────────────────*/
.dp-head {
  padding: 8px 2px 14px;
}
.dp-eyebrow {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.dp-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.dp-lede {
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 0.95rem;
}

/* ── «خطة جديدة» composer ───────────────────────────────────────────────────*/
.dp-new {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  margin-bottom: 16px;
}
.dp-new-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}
.dp-new-lede {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
}
.dp-new-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dp-new-date,
.dp-new-city {
  flex: 1 1 130px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
.dp-new-btn {
  flex: 1 1 100%;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.dp-new-btn:active {
  transform: scale(0.98);
}

/* ── Plan cards ─────────────────────────────────────────────────────────────*/
.dp-list {
  display: grid;
  gap: 10px;
}
.dp-empty {
  color: var(--muted);
  text-align: center;
  padding: 22px 8px;
}
.dp-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 10px 12px;
}
.dp-card.is-today {
  border-inline-start: 3px solid var(--brand);
}
.dp-card-main {
  flex: 1;
  display: grid;
  gap: 4px;
  text-align: start;
  background: none;
  border: 0;
  padding: 4px 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.dp-card-day {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink);
}
.dp-card-today {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  border-radius: 999px;
  padding: 2px 8px;
}
.dp-card-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}
.dp-card-city {
  color: var(--brand);
  font-weight: 700;
}
.dp-card-by {
  font-size: 0.76rem;
}
.dp-card-spend {
  font-weight: 700;
  color: var(--brand);
}

/* ── Builder: day header ────────────────────────────────────────────────────*/
.dp-back {
  display: inline-block;
  color: var(--brand);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 8px;
}
.dp-day-title {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  font-weight: 800;
  color: var(--ink);
}
.dp-day-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 0.88rem;
}
.dp-missing {
  padding: 40px 8px;
  text-align: center;
  color: var(--ink-2);
  display: grid;
  gap: 10px;
}

/* ── Builder: stops ─────────────────────────────────────────────────────────*/
.dp-stops {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.dp-start {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 0.86rem;
  font-weight: 700;
  padding: 4px 2px;
}
.dp-start-ico svg {
  width: 16px;
  height: 16px;
  display: block;
  color: var(--brand);
}
.dp-leg {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-inline-start: 34px;
  color: var(--muted);
  font-size: 0.78rem;
}
.dp-leg::before {
  content: "";
  display: block;
  width: 2px;
  height: 14px;
  border-inline-start: 2px dotted var(--line-strong);
}
.dp-stop {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.dp-stop-n {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
}
.dp-stop-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.dp-stop-name {
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.dp-stop-approx {
  margin-inline-start: 6px;
  color: var(--muted);
  font-weight: 400;
}
.dp-stop-area {
  font-size: 0.78rem;
  color: var(--muted);
}
.dp-stop-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dp-move {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink-2);
  cursor: pointer;
}
.dp-move:disabled {
  opacity: 0.35;
  cursor: default;
}
.dp-move svg {
  width: 18px;
  height: 18px;
  display: block;
}
.dp-stop-maps {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--brand);
}
.dp-stop-maps svg {
  width: 18px;
  height: 18px;
  display: block;
}
/* The shared two-tap delete, tightened for the stop row */
.dp-stop-actions .fin-del,
.dp-card .fin-del {
  min-height: 40px;
}

.dp-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--brand);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.dp-add-ico svg {
  width: 18px;
  height: 18px;
  display: block;
}
.dp-footnote {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}
.dp-danger {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.dp-danger-label {
  color: var(--muted);
  font-size: 0.82rem;
}

/* ── Today-card plan links (places page) ────────────────────────────────────*/
.pl-today-plans {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.pl-today-plan {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand);
  text-decoration: none;
}
.pl-today-plan.is-nudge {
  color: var(--brand-2);
}

/* ── Stop-picker sheet ──────────────────────────────────────────────────────*/
.sp {
  display: grid;
  gap: 10px;
}
.sp-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.sp-tab {
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.sp-tab.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.sp-search {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
.sp-list {
  display: grid;
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
}
.sp-empty {
  color: var(--muted);
  text-align: center;
  padding: 14px 0;
}
.sp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.sp-row.is-added {
  opacity: 0.55;
  cursor: default;
}
.sp-row-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.sp-row-name {
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.sp-row-sub {
  font-size: 0.76rem;
  color: var(--muted);
}
.sp-row-sel {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 999px;
  padding: 2px 8px;
}
.sp-row-add {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--brand);
  font-size: 1.1rem;
  font-weight: 700;
}
.sp-row-added {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand);
}
.sp-done {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

/* ── Phase 2: route tools (start picker · optimize · Maps deep link) ────────*/

/* The start row becomes an interactive picker (hotel / GPS / a stop). */
.dp-start--btn {
  width: 100%;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px 12px;
  cursor: pointer;
  text-align: start;
}
.dp-start-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1px;
}
.dp-start-lead {
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.dp-start-hint,
.dp-start-time,
.dp-start-note {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--muted);
}
.dp-start-edit svg {
  width: 16px;
  height: 16px;
  display: block;
  color: var(--brand);
}

/* The immutable ferry anchor: pinned, highlighted, not repickable. */
.dp-start--must {
  align-items: flex-start;
  gap: 10px;
  border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--line));
  border-inline-start: 3px solid var(--gold);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--gold) 10%, var(--surface));
  padding: 10px 12px;
}
.dp-start--must .dp-start-ico svg {
  color: var(--gold);
}
.dp-start--must .dp-start-lead {
  color: var(--ink);
}
.dp-start-time {
  font-weight: 700;
  color: var(--gold);
}
.dp-start-note {
  color: var(--ink-2);
}

/* Route tools row: the optimize button + its km-saved flash. */
.dp-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 4px 0 12px;
}
.dp-optimize {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 8%, var(--surface));
  color: var(--brand);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.dp-optimize-ico svg {
  width: 17px;
  height: 17px;
  display: block;
}
.dp-optimize-msg {
  color: var(--ink-2);
  font-size: 0.84rem;
  font-weight: 600;
}

/* One-tap Google Maps multi-stop route. */
.dp-route-actions {
  margin-top: 14px;
}
.dp-maps-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}
.dp-maps-ico svg {
  width: 19px;
  height: 19px;
  display: block;
}
.dp-maps-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

/* ── Suggestion rails: «في طريقك» / «قريبة من خطتك» ──────────────────────────*/
.dp-rail {
  margin-top: 14px;
}
.dp-rail-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.dp-rail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dp-suggest {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 12px 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}
.dp-suggest.is-sel {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 12%, var(--bg));
}
.dp-suggest-plus svg {
  width: 15px;
  height: 15px;
  display: block;
  color: var(--brand);
}
.dp-suggest-star {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--gold);
}
.dp-suggest-km {
  font-size: 0.74rem;
  color: var(--muted);
}

/* ── Plan-level actions: share · duplicate · move-to-date ────────────────────*/
.dp-plan-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.dp-plan-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
}
.dp-plan-action-ico svg {
  width: 17px;
  height: 17px;
  display: block;
  color: var(--brand);
}
.dp-plan-move {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
.dp-plan-move-date {
  min-height: 40px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
}

/* Start-point picker sheet rows. */
.dp-startpick {
  display: grid;
  gap: 8px;
}
.dp-startpick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: start;
}
.dp-startpick-ico svg {
  width: 18px;
  height: 18px;
  display: block;
  color: var(--brand);
}

/* ── Phase 3: follow mode (check-offs · progress · replace · ferry alerts) ───*/

/* Stops can hold a fuller action cluster now (＋ replace) — let it wrap on a
   narrow phone rather than overflow. */
.dp-stop {
  flex-wrap: wrap;
}
.dp-stop-main {
  flex: 1 1 42%;
}
.dp-stop-actions {
  margin-inline-start: auto;
}

/* «تم» check circle — leading each stop; fills brand-green when done. */
.dp-check {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
  color: #fff;
  cursor: pointer;
}
.dp-check.is-done {
  background: var(--brand);
  border-color: var(--brand);
}
.dp-check svg {
  width: 17px;
  height: 17px;
  display: block;
}
/* A done stop reads as settled; the next one gets a soft brand ring. */
.dp-stop.is-done {
  opacity: 0.62;
}
.dp-stop.is-done .dp-stop-name > span:first-child {
  text-decoration: line-through;
  text-decoration-color: var(--muted);
}
.dp-stop.is-next {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand) inset;
}
.dp-stop-next {
  margin-inline-start: 8px;
  font-size: 0.68rem;
  font-weight: 800;
  color: #fff;
  background: var(--brand);
  border-radius: 999px;
  padding: 1px 7px;
  vertical-align: middle;
}
.dp-stop-replaced {
  font-size: 0.74rem;
  color: var(--gold);
  font-weight: 700;
}
.dp-replace {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink-2);
  cursor: pointer;
}
.dp-replace svg {
  width: 18px;
  height: 18px;
  display: block;
}
.dp-spend {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--brand);
  cursor: pointer;
}
.dp-spend svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Follow-mode progress bar + label. */
.dp-progress {
  display: grid;
  gap: 6px;
  margin: 2px 0 14px;
}
.dp-progress-track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.dp-progress-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  transition: width 0.25s ease;
}
.dp-progress.is-complete .dp-progress-fill {
  background: var(--gold);
}
.dp-progress-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

/* Pack-up alert (the night before a ferry) — plan-day + today-card share it. */
.dp-packup,
.pl-packup {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--line));
  border-inline-start: 3px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 10%, var(--surface));
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}
.dp-packup-ico svg,
.pl-packup-ico svg {
  width: 19px;
  height: 19px;
  display: block;
  color: var(--gold);
  flex: 0 0 auto;
}

/* Today-card ferry banner. */
.pl-ferry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 6px 0 4px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--line));
  border-inline-start: 3px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
}
.pl-ferry-ico svg {
  width: 20px;
  height: 20px;
  display: block;
  color: var(--gold);
  flex: 0 0 auto;
}
.pl-ferry-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1px;
}
.pl-ferry-main strong {
  color: var(--ink);
  font-size: 0.92rem;
}
.pl-ferry-time {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold);
}
.pl-ferry-note {
  font-size: 0.76rem;
  color: var(--ink-2);
}
.pl-ferry-map {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--gold);
}
.pl-ferry-map svg {
  width: 18px;
  height: 18px;
  display: block;
}
.pl-today-nextstop {
  flex: 1 1 100%;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-2);
}

/* «مكان خاص» affordance in the picker + the shared typed-stop form sheet. */
.sp-custom {
  min-height: 44px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--brand);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
.stopform {
  display: grid;
  gap: 10px;
}
.stopform-lede {
  color: var(--muted);
  font-size: 0.86rem;
}
.stopform-input {
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
.stopform-err {
  color: var(--brand-2, #c0392b);
  font-size: 0.8rem;
  min-height: 1em;
}
.stopform-err:empty {
  display: none;
}
.stopform-submit {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

/* ── Narrow phones: keep the 5-link topbar on one line ──────────────────────*/
@media (max-width: 380px) {
  .topbar-link {
    padding-inline: 7px;
    font-size: 0.82rem;
  }
}
