/* ============================================================
   Components — buttons, forms, cards, badges, tables, alerts
   ============================================================ */

/* ---- Buttons ----
   The angled corner is the one stylistic flourish, borrowed from the
   reference's cut-corner CTA. No glow, no gradient. */
.btn {
  --btn-bg: var(--ink);
  --btn-fg: var(--on-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.85rem 1.6rem;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }

.btn[disabled], .btn.is-disabled {
  opacity: 0.55;
  pointer-events: none;
  transform: none;
}

.btn--primary { --btn-bg: var(--green); --btn-fg: var(--ink); }
/* The hover state darkens to the logo's own green, which is dark enough that
   the label has to flip to light with it — keeping the ink foreground here
   would drop the button's own text to 2.8:1 on hover. */
.btn--primary:hover { --btn-bg: var(--green-deep); --btn-fg: var(--on-dark); }

.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  border: 1px solid var(--line);
}
.btn--ghost:hover { --btn-bg: var(--surface); box-shadow: none; }

.btn--ghost-light {
  --btn-bg: transparent;
  --btn-fg: var(--on-dark);
  border: 1px solid var(--line-dark);
}
.btn--ghost-light:hover { --btn-bg: rgba(243, 243, 244, 0.08); box-shadow: none; }

.btn--danger { --btn-bg: var(--danger); --btn-fg: #fff; }
.btn--sm { padding: 0.55rem 1rem; font-size: 0.76rem; }
.btn--lg { padding: 1.05rem 2.1rem; font-size: 0.92rem; }
.btn--block { width: 100%; }

/* Cut-corner variant for the hero CTA */
.btn--cut {
  border-radius: 0;
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
  padding-right: 2.1rem;
}

/* ---- Forms ---- */
.field { display: block; margin-bottom: 1.05rem; }

.field__label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.42rem;
}

.field__hint {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.input, .select, .textarea {
  width: 100%;
  padding: 0.78rem 0.95rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }

.input:hover, .select:hover, .textarea:hover { border-color: #c9cace; }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--green-deep);
  /* A ring, not a glow — 3px flat tint */
  box-shadow: 0 0 0 3px rgba(92, 201, 138, 0.22);
}

.textarea { resize: vertical; min-height: 110px; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2374777f' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.95rem center;
  padding-right: 2.4rem;
}

.input--error, .textarea--error, .select--error { border-color: var(--danger); }

.field-error {
  display: block;
  font-size: 0.82rem;
  color: var(--danger);
  margin-top: 0.35rem;
}

/* Checkbox / radio */
.check {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text-soft);
}
.check input {
  width: 18px; height: 18px;
  margin-top: 0.15rem;
  flex: none;
  accent-color: var(--green-deep);
  cursor: pointer;
}

/* Segmented control — used for "now / scheduled" */
.segment {
  display: inline-flex;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  gap: 2px;
}
.segment__btn {
  padding: 0.5rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: var(--r-pill);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segment__btn.is-active { background: var(--ink); color: var(--paper); }

/* Autocomplete list for address fields */
.autocomplete { position: relative; }
.autocomplete__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 40;
  max-height: 260px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}
.autocomplete__list[hidden] { display: none; }
.autocomplete__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  color: var(--text-soft);
  border-bottom: 1px solid var(--line-soft);
}
.autocomplete__item:last-child { border-bottom: 0; }
.autocomplete__item:hover,
.autocomplete__item.is-active { background: var(--surface); color: var(--text); }

/* ---- Cards ---- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(1.25rem, 2.5vw, 1.85rem);
}
.card--flat { box-shadow: none; }
.card--raised { box-shadow: var(--shadow-md); border-color: transparent; }
.card--dark {
  background: var(--ink-soft);
  border-color: var(--line-dark);
  color: var(--on-dark);
}
.card--dark p { color: var(--on-dark-mut); }

.card__icon {
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--green-tint);
  color: var(--green-deep);
  margin-bottom: 1rem;
}
.card--dark .card__icon { background: rgba(92, 201, 138, 0.14); color: var(--green); }

.card__title { margin-bottom: 0.5rem; }

/* ---- Stat tiles ---- */
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.15rem 1.3rem;
}
.stat__label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat__value {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-top: 0.3rem;
}
.stat__meta { font-size: 0.82rem; color: var(--muted); margin-top: 0.2rem; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.24rem 0.62rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: var(--r-pill);
  background: var(--surface-alt);
  color: var(--text-soft);
  white-space: nowrap;
}
.badge--ok      { background: var(--ok-tint);     color: var(--ok); }
.badge--warn    { background: var(--warn-tint);   color: var(--warn); }
.badge--danger  { background: var(--danger-tint); color: var(--danger); }
.badge--info    { background: var(--info-tint);   color: var(--info); }
/* Solid, where every other badge is a tint. With the accent now green, a
   tinted green badge was all but identical to badge--ok beside it — and the
   two it separates are "in progress" and "completed", which is the one
   distinction a dispatcher cannot afford to misread. Differentiating by fill
   rather than hue also puts the loudest chip on the active ride, which is the
   one worth spotting first. */
.badge--green   { background: var(--green);       color: var(--ink); }

/* A small solid dot, no pulsing */
.badge__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ---- Alerts ---- */
.alert {
  display: flex;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--r-md);
  border-left: 3px solid;
  font-size: 0.92rem;
  margin-bottom: 1.1rem;
}
.alert--success { background: var(--ok-tint);     border-color: var(--ok);     color: #1d5735; }
.alert--warning { background: var(--warn-tint);   border-color: var(--warn);   color: #7a5309; }
.alert--error   { background: var(--danger-tint); border-color: var(--danger); color: #8c1d17; }
.alert--info    { background: var(--info-tint);   border-color: var(--info);   color: #1d4877; }

.validation-summary { margin-bottom: 1.1rem; }
.validation-summary ul { padding-left: 1.1rem; list-style: disc; }
.validation-summary li { font-size: 0.9rem; }

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper);
}
.table { min-width: 640px; }
.table th, .table td {
  padding: 0.78rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface); }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Definition list ---- */
.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 0.55rem 1rem; }
.kv dt { font-size: 0.82rem; color: var(--muted); }
.kv dd { margin: 0; font-size: 0.94rem; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 1.75rem;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  min-width: 38px;
  padding: 0.45rem 0.7rem;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 0.86rem;
  color: var(--text-soft);
}
.pagination a:hover { background: var(--surface); }
.pagination .is-current { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---- Timeline (ride history) ---- */
.timeline { position: relative; padding-left: 1.55rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--line);
}
.timeline__item { position: relative; padding-bottom: 1.1rem; }
.timeline__item::before {
  content: "";
  position: absolute;
  left: -1.55rem; top: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--line);
}
.timeline__item.is-done::before { background: var(--green); border-color: var(--green-deep); }
.timeline__time { font-size: 0.78rem; color: var(--muted); }
.timeline__label { font-weight: 600; }

/* ---- Map ---- */
.map {
  width: 100%;
  height: clamp(260px, 42vh, 460px);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface-alt);
  z-index: 0; /* keeps Leaflet panes under the side menu */
}
.map--tall { height: clamp(340px, 58vh, 620px); }

/* Leaflet's default attribution is tiny and low contrast; nudge it up */
.leaflet-container { font-family: var(--font-sans); }
.leaflet-control-attribution { font-size: 10px; }

/* ---- Map markers ----
   Defined here rather than in the marker HTML so a taxi looks the same on the
   dispatch board, the passenger's tracking page and the admin live view. */
.map-taxi {
  display: block;
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
}
.map-taxi__body {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  /* Heading changes arrive every few seconds; easing them stops the car from
     twitching between fixes. Positioning is Leaflet's and is left alone. */
  transition: transform 0.6s ease-out;
  will-change: transform;
}
/* A driver whose last fix is old is still shown — a dispatcher needs to know
   the car was there — but must not be mistaken for a live one. */
.map-taxi.is-stale { opacity: 0.45; filter: grayscale(0.7); }

.map-point {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
}
.map-point--from { background: var(--green, #5cc98a); border: 3px solid #0f1012; }
.map-point--to { background: #0f1012; border: 3px solid #ffffff; }

@media (prefers-reduced-motion: reduce) {
  .map-taxi__body { transition: none; }
}

/* ---- Divider ---- */
.divider { height: 1px; background: var(--line); border: 0; margin-block: 1.5rem; }
.divider--dark { background: var(--line-dark); }

/* ---- Empty state ---- */
.empty {
  text-align: center;
  padding: clamp(2rem, 6vw, 3.5rem) 1rem;
  color: var(--muted);
}
.empty__title { font-weight: 600; color: var(--text-soft); margin-bottom: 0.35rem; }

/* ============================================================
   Ratings
   Two components: a read-only star row, and an input built from
   radios so it works with JavaScript disabled.
   ============================================================ */

.rating-stars {
  display: inline-flex;
  align-items: center;
  gap: .1em;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--line);
}

.rating-stars .is-on { color: var(--green); }

.rating-stars--sm { font-size: .82rem; margin: .18rem 0 .1rem; }

.rating-stars__value {
  margin-left: .4em;
  font-weight: 600;
  color: var(--text);
}

.rating-stars__count {
  margin-left: .25em;
  color: var(--muted);
  font-size: .92em;
}

/* On the dark driver card the neutral star needs to lift off the background. */
.driver-card .rating-stars { color: rgba(255, 255, 255, .22); }
.driver-card .rating-stars__value { color: var(--on-dark); }
.driver-card .rating-stars__count { color: var(--on-dark-mut); }

/* ---- Star input ---------------------------------------------------------
   Stars are emitted 5..1 and laid out row-reverse, so they read 1..5 on
   screen while `~` can still reach every star to the left of the hovered or
   checked one. That is what makes the fill cascade work without script. */
.rating-input {
  display: inline-flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: .12em;
  border: 0;
  padding: 0;
  margin: 0;
}

.rating-input input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.rating-input label {
  font-size: 1.9rem;
  line-height: 1;
  color: var(--line);
  cursor: pointer;
  transition: color .12s ease, transform .12s ease;
}

.rating-input label:hover,
.rating-input label:hover ~ label,
.rating-input input:checked ~ label {
  color: var(--green);
}

.rating-input label:active { transform: scale(.92); }

/* Keyboard users get a visible ring on the star the focus is actually on. */
.rating-input input:focus-visible + label {
  outline: 2px solid var(--green-deep);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .rating-input label { transition: none; }
}

.card--rated { border-left: 3px solid var(--green); }

/* ---- Legal pages --------------------------------------------------------
   Section bodies come from the resource files as HTML, so the list and link
   styling has to live here rather than on per-element classes. */
.legal-prose h3 { font-size: 1.02rem; }

.legal-prose ul {
  margin: .55rem 0 0;
  padding-left: 1.15rem;
  list-style: disc;
}

.legal-prose li {
  margin-bottom: .4rem;
  line-height: 1.6;
}

.legal-prose li:last-child { margin-bottom: 0; }

.legal-prose a { text-decoration: underline; }

/* Unresolved facts are wrapped in guillemets by the generator so they are
   impossible to miss in review, and obvious if one ever reaches production. */
.legal-prose { --todo: #b3261e; }

/* ---- Ride chat ----------------------------------------------------------
   One component, two homes: an inline card on the passenger's tracking page,
   and a bottom sheet on the driver's console. The markup is identical — see
   Views/Shared/_RideChat.cshtml — so everything that differs is a modifier
   here rather than a second template.

   It replaced the tap-to-call buttons on both screens. */
.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat--inline {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--line);
}

.chat__title {
  font-weight: 700;
  font-size: .92rem;
}

.chat__sub {
  font-size: .8rem;
  color: var(--muted);
}

.chat__close {
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
}

/* Fixed height rather than growing without bound: the log is the only part
   that scrolls, so the composer never walks off the bottom of the screen. */
.chat__log {
  flex: 1;
  min-height: 160px;
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.chat__empty {
  margin: auto;
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
}

.chat__msg {
  max-width: 80%;
  padding: .5rem .7rem;
  border-radius: var(--r-md);
  font-size: .9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat__msg--mine {
  align-self: flex-end;
  background: var(--green-tint);
  border: 1px solid rgba(92, 201, 138, .45);
  border-bottom-right-radius: 3px;
}

.chat__msg--theirs {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
}

/* System lines are the app talking, not a person: centred, quiet, no bubble. */
.chat__msg--system {
  align-self: center;
  max-width: 100%;
  background: none;
  border: 0;
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
}

.chat__author {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: .15rem;
}

.chat__body { display: block; white-space: pre-wrap; }

.chat__time {
  display: block;
  margin-top: .2rem;
  font-size: .68rem;
  color: var(--faint);
  text-align: right;
}

.chat__form {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .7rem 1rem;
  border-top: 1px solid var(--line);
}

.chat__input {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper);
  font-size: .92rem;
  line-height: 1.4;
}

.chat__input:focus-visible {
  outline: 2px solid var(--green-deep);
  outline-offset: 1px;
}

.chat__send {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--green);
}

.chat__form.is-sending .chat__send { opacity: .5; pointer-events: none; }

.chat__note,
.chat__closed {
  padding: .55rem 1rem .75rem;
  font-size: .74rem;
  color: var(--muted);
}

.chat__closed {
  border-top: 1px solid var(--line);
  text-align: center;
}

.chat__error {
  margin: 0;
  padding: .5rem 1rem .7rem;
  font-size: .8rem;
  color: var(--danger);
}

/* ---- Sheet form, for the driver console ----
   Off-screen until opened, and never taller than the viewport: Arrived and
   Complete live under this, and covering them permanently would be worse than
   having no chat at all. */
.chat--sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  max-height: min(80dvh, 560px);
  background: var(--ink-soft);
  color: var(--on-dark);
  border-top: 1px solid var(--line-dark);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(101%);
  transition: transform var(--dur-fast) var(--ease);
  visibility: hidden;
}

.chat--sheet.is-open {
  transform: translateY(0);
  visibility: visible;
}

.chat--sheet .chat__head,
.chat--sheet .chat__form,
.chat--sheet .chat__closed { border-color: var(--line-dark); }

.chat--sheet .chat__close,
.chat--sheet .chat__sub,
.chat--sheet .chat__empty,
.chat--sheet .chat__note,
.chat--sheet .chat__closed,
.chat--sheet .chat__author { color: var(--on-dark-mut); }

.chat--sheet .chat__log { max-height: min(56dvh, 380px); }

.chat--sheet .chat__msg--mine {
  background: rgba(92, 201, 138, .16);
  border-color: rgba(92, 201, 138, .3);
}

.chat--sheet .chat__msg--theirs {
  background: var(--ink-raised);
  border-color: var(--line-dark);
}

.chat--sheet .chat__time { color: var(--on-dark-mut); }

.chat--sheet .chat__input {
  background: var(--ink-raised);
  border-color: var(--line-dark);
  color: var(--on-dark);
}

.chat--sheet .chat__send { background: var(--green); color: var(--ink); }

/* Unread count on the button that opens the sheet. */
.chat-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-left: .35rem;
  padding: 0 .3rem;
  border-radius: var(--r-pill);
  background: var(--green);
  color: var(--ink);
  font-size: .7rem;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .chat--sheet { transition: none; }
}


/* ---- Ride chat transcript -----------------------------------------------
   The dispatcher's read-only view of what the passenger and driver said to
   each other. Not styled as a chat: it is a record being read, so it reads
   top-to-bottom as a log with the speaker named, rather than as two columns
   of bubbles that make the reader work out who is who. */
.transcript {
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.transcript__line {
  padding: .55rem .8rem;
  border-left: 3px solid var(--line);
  background: var(--surface);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.transcript__line--customer { border-left-color: var(--info); }
.transcript__line--driver   { border-left-color: var(--green-deep); }
.transcript__line--system   { border-left-color: var(--line); background: none; }

.transcript__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .45rem;
  margin-bottom: .2rem;
  font-size: .74rem;
}

.transcript__meta time { color: var(--faint); margin-left: auto; }

.transcript__body {
  font-size: .9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
