/* ========== Trip planner panel contents ==========
   Panel chrome (positioning, header, close button, scrollbars, mobile sheet)
   comes from the shared .panel base in styles.css. This file used to run on its
   own hardcoded palette (#271E37, #4a90e2, #666, #999), so the trip panel read
   as a different product from the filters panel - everything here is on the
   shared tokens now. */

.panel--trip .panel-body {
  display: grid;
  gap: 12px;
  align-content: start;
}

/* ---------- Header ---------- */
.trip-header {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(0, 119, 190, 0.14);
}

.trip-count {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.trip-total {
  margin: 2px 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Action row ----------
   Three labelled buttons wrapped onto three lines at 340px; icon-over-label
   keeps them on one row at any panel width. */
.trip-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.trip-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: var(--tap-target);
  padding: 8px 4px;
  border: 1.5px solid rgba(0, 119, 190, 0.22);
  border-radius: 10px;
  background: #fff;
  color: var(--brand);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.trip-action-btn:hover:not(:disabled) {
  background: rgba(0, 119, 190, 0.08);
  border-color: var(--brand-2);
}

.trip-action-btn--danger {
  border-color: rgba(220, 38, 38, 0.28);
  color: #b91c1c;
}

.trip-action-btn--danger:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.08);
  border-color: #dc2626;
}

.trip-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.trip-action-btn:focus-visible,
.trip-icon-btn:focus-visible,
.trip-primary-btn:focus-visible,
.trip-secondary-link:focus-visible,
.trip-share-copy:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}

/* ---------- Share link row ---------- */
.trip-share-row {
  display: flex;
  gap: 6px;
}

.trip-share-row[hidden] { display: none; }

.trip-share-input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  border: 1.5px solid rgba(0, 119, 190, 0.2);
  border-radius: 8px;
  background: rgba(0, 119, 190, 0.04);
  font: inherit;
  font-size: 0.78rem;
  color: var(--muted);
}

.trip-share-copy {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Empty state ---------- */
.trip-empty-state {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
}

.trip-empty-state svg {
  margin-bottom: 12px;
  color: rgba(0, 119, 190, 0.35);
}

.trip-empty-state p {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--ink);
}

.trip-empty-state small {
  display: block;
  max-width: 30ch;
  margin: 0 auto;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- Stops ----------
   No negative margins here any more: the old `margin: 0 -10px; padding: 0 10px`
   pair overflowed the panel body and produced a horizontal scrollbar. */
.trip-stops {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.trip-stop {
  display: flex;
  align-items: center;
  /* Wide enough that the order chip on the icon never crowds the name. */
  gap: 11px;
  padding: 8px 8px 8px 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(0, 119, 190, 0.04);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.trip-stop:hover {
  background: rgba(0, 119, 190, 0.08);
  border-color: rgba(0, 119, 190, 0.18);
}

.trip-stop.dragging { opacity: 0.4; }

.trip-stop.drag-over {
  border-color: var(--brand-2);
  box-shadow: 0 -2px 0 var(--brand-2) inset;
}

.trip-grip {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 14px;
  color: rgba(15, 23, 42, 0.3);
  cursor: grab;
}

.trip-stop.dragging .trip-grip { cursor: grabbing; }

/* The order chip. It used to be `position:absolute` inside a static parent, so
   all of them resolved against the fixed .panel and stacked in its top-right
   corner instead of sitting on their own stop. */
.trip-stop-icon {
  position: relative;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}

.trip-stop-order {
  position: absolute;
  top: -6px;
  right: -7px;
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* The name block is the "show this on the map" control, so the row needs one
   fewer icon button and long names get the width back. */
.trip-stop-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1px;
  padding: 2px 0;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.trip-stop-main:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
  border-radius: 6px;
}

.trip-stop-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.trip-stop-meta {
  font-size: 0.73rem;
  color: var(--muted);
}

.trip-stop-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Up and down stacked in one column: two full-width targets would have eaten
   the space the stop names need at a 340px panel width. */
.trip-move {
  display: grid;
  gap: 1px;
}

.trip-move-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 17px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.trip-move-btn:hover:not(:disabled) {
  background: #fff;
  border-color: rgba(0, 119, 190, 0.25);
  color: var(--brand);
}

.trip-move-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.trip-move-btn:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 1px;
}

.trip-icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.trip-icon-btn:hover:not(:disabled) {
  background: #fff;
  border-color: rgba(0, 119, 190, 0.25);
  color: var(--brand);
}

.trip-icon-btn.is-danger:hover:not(:disabled) {
  border-color: rgba(220, 38, 38, 0.3);
  color: #dc2626;
}

.trip-icon-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ---------- Leg distances ---------- */
.trip-leg {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 1px 0 1px 30px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Route section ---------- */
.trip-route-section {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 119, 190, 0.14);
}

.trip-primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap-target);
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.trip-primary-btn:hover:not(:disabled) { filter: brightness(1.06); }

.trip-primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.trip-secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0;
  border: none;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.trip-secondary-link:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .trip-stop,
  .trip-action-btn,
  .trip-icon-btn,
  .trip-primary-btn { transition: none; }
}
