/* JeenyChatbot UI. Colour tokens live here; swap them to re-theme the whole app. */

/* Palette sampled from the Jeeny app (magenta + plum on light grey) for a familiar demo feel.
   This is an independent demo with its own logo; see the disclaimer in the UI. */
:root,
:root[data-theme="light"] {
  --paper: #ffffff;
  --mist: #f2f3f7;
  --map-bg: #f7f8fc;
  --line: #e4e5ec;
  --ink: #1b1c20;
  --ink-2: #55576a;
  --ink-3: #6e7086;
  --brand: #ec008c;
  --brand-strong: #d6007e;
  --brand-ink: #ffffff;
  --brand-soft: #fef0f7;
  --brand-line: #f5b3d8;
  --brand-glow: rgba(236, 0, 140, 0.14);
  --pink: #fde3f1;
  --pink-soft: #fef3f9;
  --on-pink: #1b1c20;
  --plum: #5e2a84;
  --plum-soft: #f6f0fa;
  --chip: #eeeff3;
  --danger: #b42343;
  --shadow: 0 28px 70px -28px rgba(27, 28, 32, 0.4), 0 2px 6px rgba(27, 28, 32, 0.06);
  --backdrop: rgba(27, 20, 38, 0.45);
  --logo-body: #ec008c;
  --logo-pickup: #ffffff;
  --logo-drop: #ffffff;
  --logo-route: #ffffff;
  --route-casing: #ffffff;
  --map-filter: grayscale(1) brightness(1.06) contrast(0.88);
  --font-ui: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #1e1828;
  --mist: #2a2236;
  --map-bg: #17121f;
  --line: #382e48;
  --ink: #f3eff8;
  --ink-2: #c5bcd3;
  --ink-3: #9a90ab;
  --brand: #ff3da8;
  --brand-strong: #ff5cb5;
  --brand-ink: #1b1020;
  --brand-soft: #3a1f33;
  --brand-line: #6b2e58;
  --brand-glow: rgba(255, 61, 168, 0.22);
  --pink: #4a2340;
  --pink-soft: #3a1f33;
  --on-pink: #f3eff8;
  --plum: #c9a3ec;
  --plum-soft: #2e2340;
  --chip: #2e2640;
  --danger: #ff8fa6;
  --shadow: 0 28px 70px -24px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.3);
  --backdrop: rgba(8, 5, 14, 0.6);
  --logo-body: #ff3da8;
  --logo-pickup: #ffffff;
  --logo-drop: #ffffff;
  --logo-route: #ffffff;
  --route-casing: #17121f;
  --map-filter: grayscale(1) invert(1) brightness(0.78) contrast(0.85);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--mist);
  color: var(--ink);
  font: 400 15px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ layout */
.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.map {
  position: absolute;
  inset: 0;
  direction: ltr;
  background: var(--map-bg);
}

.map.picking,
.map.picking .leaflet-interactive {
  cursor: crosshair;
}

.panel {
  position: absolute;
  z-index: 500;
  inset-block: 16px;
  inset-inline-start: 16px;
  width: min(420px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ------------------------------------------------------------------ header */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--line);
}

[dir="rtl"] .panel-head {
  padding: 12px 16px 12px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
}

.brand-name {
  font: 600 17px/1.2 var(--font-display);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:hover {
  background: var(--mist);
  color: var(--ink);
}

.lang-btn {
  height: 32px;
  margin-inline-start: 4px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 600;
}

.lang-btn:hover {
  border-color: var(--ink-3);
}

.mode-banner {
  margin: 10px 16px 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--plum-soft);
  font-size: 13px;
  line-height: 1.5;
}

/* --------------------------------------------------------------------- log */
.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 16px 12px;
  scroll-behavior: smooth;
}

.hero {
  margin-block: auto;
  padding-bottom: 8px;
}

.hero-title {
  margin: 0;
  font: 700 clamp(2.5rem, 4.2vw, 3.3rem) / 1.1 var(--font-display);
  letter-spacing: -0.015em;
}

.hero-route {
  display: block;
  width: 168px;
  height: 22px;
  margin: 10px 0 14px;
}

[dir="rtl"] .hero-route {
  transform: scaleX(-1);
}

.hero-route .route-draw {
  stroke: var(--brand);
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: draw-route 1.4s 0.25s cubic-bezier(0.6, 0, 0.2, 1) forwards;
}

@keyframes draw-route {
  to {
    stroke-dashoffset: 0;
  }
}

.hero-sub {
  margin: 0;
  max-width: 34ch;
  color: var(--ink-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.chip {
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink-2);
  font-size: 14px;
  text-align: start;
}

.chip:hover {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

/* ---------------------------------------------------------------- messages */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.msg-user {
  align-self: flex-end;
}

.msg-bot {
  align-self: flex-start;
}

.bubble {
  padding: 9px 14px;
  border-radius: 16px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.msg-user .bubble {
  background: var(--pink);
  color: var(--on-pink);
  border-end-end-radius: 5px;
}

.msg-bot .bubble {
  background: var(--mist);
  border-end-start-radius: 5px;
}

.msg-error .bubble {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 12px 14px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: typing 1.1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.pin-btn {
  align-self: flex-start;
  margin-top: 6px;
  padding: 7px 12px;
  border: 1.5px solid var(--brand-line);
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 13.5px;
  font-weight: 600;
}

.pin-btn:hover {
  border-color: var(--brand);
}

/* ------------------------------------------------------------- trip panel */
.trip-panel {
  margin: 2px 12px 6px;
  padding: 10px 10px 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 -10px 24px -20px rgba(27, 20, 38, 0.35);
}

.trip-panel.is-busy {
  opacity: 0.65;
  pointer-events: none;
}

.trip-route {
  display: flex;
  align-items: center;
  gap: 12px;
}

.itinerary {
  position: relative;
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.itinerary::before {
  content: "";
  position: absolute;
  inset-inline-start: 8px;
  top: 14px;
  bottom: 14px;
  border-inline-start: 2px dotted var(--ink-3);
}

.stop {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: center;
  padding: 1px 0;
}

.stop-dot {
  justify-self: center;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 4.5px var(--brand);
}

.stop-dropoff .stop-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--plum);
  box-shadow: none;
}

.stop-name {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  margin: 0;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.trip-stats b {
  color: var(--ink);
  font: 600 14px var(--font-display);
}

.est-badge {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--pink-soft);
  color: var(--ink);
  font-size: 11.5px;
}

.car-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 8px 0;
}

.car-opt {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  column-gap: 6px;
  padding: 5px 4px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
  color: var(--ink-2);
  line-height: 1.25;
  text-align: start;
}

.car-opt svg {
  grid-row: 1 / span 2;
  width: 26px;
  height: 13px;
}

.car-opt:hover {
  border-color: var(--ink-3);
}

.car-name {
  font-size: 11.5px;
  font-weight: 600;
}

.car-price {
  color: var(--ink);
  font: 600 13.5px var(--font-display);
  font-variant-numeric: tabular-nums;
}

.car-opt[aria-checked="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.car-opt[aria-checked="true"] .car-price {
  color: var(--brand-strong);
}

.confirm-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border: 0;
  border-radius: 11px;
  background: var(--brand-strong);
  color: var(--brand-ink);
  font-size: 14.5px;
  font-weight: 600;
}

.confirm-btn:hover {
  background: var(--brand);
}

.confirm-price {
  font: 600 14.5px var(--font-display);
  font-variant-numeric: tabular-nums;
}

.driver-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.driver-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: var(--plum);
  color: var(--paper);
  font: 600 13px var(--font-display);
}

.driver-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.driver-name {
  font-weight: 600;
  font-size: 14px;
}

.driver-car {
  font-size: 12.5px;
  color: var(--ink-2);
}

.driver-eta {
  margin-inline-start: auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-strong);
  color: var(--brand-ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.cancel-btn {
  display: block;
  margin: 2px auto 0;
  padding: 4px 10px;
  color: var(--ink-2);
  font-size: 12.5px;
}

.cancel-btn:hover {
  color: var(--danger);
}


/* ---------------------------------------------------------------- composer */
.composer {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 2px 12px 6px;
  padding: 4px;
  border: 1.5px solid var(--brand-line);
  border-radius: 16px;
  background: var(--paper);
}

.composer:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-glow);
}

.comp-input {
  flex: 1;
  min-width: 0;
  padding: 8px 6px;
  border: 0;
  background: transparent;
  font-size: 15px;
  outline: none;
}

.comp-input::placeholder {
  color: var(--ink-3);
}

.comp-btn,
.send-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
}

.comp-btn svg,
.send-btn svg {
  width: 21px;
  height: 21px;
}

.comp-btn:hover {
  background: var(--mist);
  color: var(--ink);
}

.comp-btn.is-active {
  color: var(--brand);
}

.comp-btn.is-listening {
  background: var(--pink);
  color: var(--on-pink);
  animation: listening 1.4s infinite;
}

@keyframes listening {
  0% {
    box-shadow: 0 0 0 0 rgba(236, 0, 140, 0.35);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(236, 0, 140, 0);
  }
}

.send-btn {
  background: var(--brand);
  color: var(--brand-ink);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

[dir="rtl"] .send-btn svg {
  transform: scaleX(-1);
}

.disclaimer {
  margin: 0 16px 8px;
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
}

/* ------------------------------------------------------ banners and toasts */
.pick-banner,
.toast {
  position: absolute;
  z-index: 700;
  inset-inline-end: 24px;
  max-width: min(360px, calc(100% - 48px));
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
}

.pick-banner {
  top: 24px;
  inset-inline-end: 64px; /* clear of the zoom buttons */
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.pick-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pick-confirm {
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--brand-strong);
  color: #ffffff;
  font-weight: 700;
}

.pick-confirm:hover {
  background: var(--brand);
}

.toast {
  bottom: 28px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
}

.text-btn {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--brand-strong);
  font-weight: 600;
}

.pick-banner .text-btn {
  border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
  color: inherit;
}

/* ----------------------------------------------------------------- dialogs */
.sheet {
  width: min(440px, calc(100% - 32px));
  max-height: min(640px, calc(100% - 32px));
  padding: 18px 20px 20px;
  border: 0;
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.sheet::backdrop {
  background: var(--backdrop);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.sheet h2 {
  margin: 0;
  font: 600 20px/1.3 var(--font-display);
}

.sheet p {
  margin: 0 0 12px;
  max-width: 62ch;
}

.sheet-note {
  font-size: 13px;
  color: var(--ink-2);
}

.place-list {
  margin: 4px 0 16px;
  padding: 0;
  list-style: none;
}

.place-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.place-list .empty {
  color: var(--ink-2);
  font-size: 14px;
  border-bottom: 0;
}

.place-name {
  font-weight: 600;
}

.place-tag {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--mist);
  color: var(--ink-2);
  font-size: 11.5px;
}

.place-actions {
  display: flex;
  align-items: center;
  margin-inline-start: auto;
}

.place-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

.place-form input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  outline: none;
}

.place-form input:focus {
  border-color: var(--brand);
}

.form-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.place-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.primary-btn,
.secondary-btn {
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
}

.primary-btn {
  border: 0;
  background: var(--brand-strong);
  color: var(--brand-ink);
}

.secondary-btn {
  border: 1.5px solid var(--line);
  background: var(--paper);
}

.secondary-btn:hover {
  border-color: var(--ink-3);
}

.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 4px;
}

.about-links a {
  color: var(--plum);
  font-weight: 600;
}

/* --------------------------------------------------------------- map pins */
.leaflet-container {
  background: var(--map-bg);
  font-family: var(--font-ui);
}

.leaflet-tile-pane {
  filter: var(--map-filter);
}

.leaflet-control-attribution {
  font-size: 11px;
}

:root[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(30, 24, 40, 0.85) !important;
  color: var(--ink-2);
}

:root[data-theme="dark"] .leaflet-control-attribution a {
  color: var(--plum);
}

.leaflet-bar a {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

.leaflet-bar a:hover {
  background: var(--mist);
}

.leaflet-tooltip.pin-label {
  padding: 3px 8px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font: 500 12.5px var(--font-ui);
  box-shadow: none;
}

.leaflet-tooltip.pin-label::before {
  display: none;
}

.pin {
  display: block;
  box-shadow: 0 2px 8px rgba(27, 20, 38, 0.35);
}

.pin-pickup {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ec008c;
  border: 4px solid #ffffff;
}

.pin-pick {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ec008c;
  border: 4px solid #ffffff;
  box-shadow: 0 0 0 7px rgba(236, 0, 140, 0.22), 0 4px 12px rgba(27, 20, 38, 0.35);
  cursor: grab;
}

.pin-dropoff {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #5e2a84;
  border: 3px solid #ffffff;
}

.pin-car {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--plum);
  color: var(--plum);
}

.pin-car svg {
  width: 24px;
  height: 12px;
}

.pin-saved {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink-3);
  color: var(--ink-2);
}

.pin-saved svg {
  width: 13px;
  height: 13px;
}

.pin-here {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2d5be3;
  border: 3px solid #ffffff;
  animation: here 2s infinite;
}

@keyframes here {
  0% {
    box-shadow: 0 0 0 0 rgba(45, 91, 227, 0.5);
  }
  100% {
    box-shadow: 0 0 0 14px rgba(45, 91, 227, 0);
  }
}

/* ------------------------------------------------------------------ mobile */
@media (max-width: 760px) {
  .map {
    bottom: auto;
    height: 36dvh;
  }

  .panel {
    inset: calc(36dvh - 20px) 0 0 0;
    width: 100%;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    box-shadow: 0 -12px 40px -20px rgba(27, 20, 38, 0.45);
  }

  .hero-title {
    font-size: 2.3rem;
  }

  .log {
    padding-top: 14px;
  }

  .composer {
    margin-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .trip-panel {
    margin-bottom: 6px;
    padding: 10px;
  }

  .car-rail {
    margin: 8px 0;
  }

  .disclaimer {
    margin-top: 4px;
    font-size: 10.5px;
  }

  .mode-banner {
    margin: 8px 12px 0;
    padding: 6px 10px;
    font-size: 12px;
  }

  .pick-banner,
  .toast {
    inset-inline: 12px;
    max-width: none;
  }

  .pick-banner {
    top: 10px;
    gap: 8px;
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Picking on a phone: a taller map, no zoom buttons (pinch instead). */
  .app.is-picking .map {
    height: 64dvh;
  }

  .app.is-picking .panel {
    inset: calc(64dvh - 20px) 0 0 0;
  }

  .app.is-picking .leaflet-control-zoom {
    display: none;
  }

  .toast {
    top: 12px;
    bottom: auto;
  }
}

@media (max-width: 420px) {
  .brand-name {
    display: none;
  }

  .icon-btn {
    width: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .hero-route .route-draw {
    stroke-dashoffset: 0;
  }
}
