/* public/css/topbar.css
 *
 * Top bar: brand, location/status line, and the co-equal filter chips.
 * Theming rides entirely on the CSS variables defined in base.css (light + dark
 * safe). The five quality dimensions are co-equal here -- every chip shares one
 * neutral resting style and one identical active treatment. Price gets no
 * special size, color, or position. No '$' framing anywhere.
 *
 * Quality color tiers (great/ok/poor) are NOT used in the top bar: the chips are
 * selectors, not scores. Those tiers live on markers, badges, detail, and
 * rating, used identically there.
 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 12px;
  background: var(--surface, #ffffff);
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  /* Keep the bar legible over the map without a hard, heavy edge. */
  box-shadow: 0 1px 0 var(--border, rgba(0, 0, 0, 0.06)),
              0 6px 18px -14px rgba(0, 0, 0, 0.45);
}

/* --- Brand ------------------------------------------------------------ */

.tb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tb-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft, rgba(37, 99, 235, 0.12));
  color: var(--accent, #2563eb);
  font-size: 18px;
}

.tb-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text, #111827);
}

/* --- Status / location line ------------------------------------------ */

.tb-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-2, rgba(0, 0, 0, 0.035));
  border: 1px solid transparent;
}

.tb-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  font-size: 19px;
  color: var(--text-muted, #6b7280);
}

.tb-status-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0; /* allow the label to ellipsize instead of overflowing */
  flex: 1 1 auto;
}

.tb-status-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #111827);
}

/* The resolved place label can be long -- keep it to one clean line. */
.tb-status-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-status-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted, #6b7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* State accents -- semantic, not the quality tiers. */
.tb-status--denied,
.tb-status--error {
  background: var(--danger-soft, rgba(220, 38, 38, 0.10));
  border-color: var(--danger-border, rgba(220, 38, 38, 0.25));
}
.tb-status--denied .tb-status-icon,
.tb-status--error .tb-status-icon {
  color: var(--danger, #dc2626);
}

.tb-status--busy {
  background: var(--accent-soft, rgba(37, 99, 235, 0.10));
  border-color: var(--accent-border, rgba(37, 99, 235, 0.22));
}

/* --- Action buttons (enable / retry) --------------------------------- */

.tb-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent, #2563eb);
  /* the fill is the brand, so the label takes the brand's ink -- a hardcoded
     white goes invisible when dark mode flips the accent to a pale blue */
  color: var(--brand-ink, #ffffff);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tb-action:active { transform: translateY(1px); }

.tb-status--denied .tb-action,
.tb-status--error .tb-action {
  background: var(--danger, #dc2626);
  /* --danger resolves to the poor tier, so this fill takes the tier ink */
  color: var(--tier-ink, #ffffff);
}

/* Small round icon button (recenter). Big enough for a thumb. */
.tb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.10));
  border-radius: 10px;
  background: var(--surface, #ffffff);
  color: var(--text-muted, #6b7280);
  font-size: 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tb-icon-btn:active { transform: translateY(1px); }

/* --- Filter chips ----------------------------------------------------- */

.tb-filters {
  display: flex;
  gap: 8px;
  /* Horizontal scroll so all six chips stay reachable one-handed on a narrow
     phone without wrapping into a tall, jumpy block. */
  overflow-x: auto;
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;         /* old Edge */
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.tb-filters::-webkit-scrollbar { display: none; } /* WebKit */

.tb-filters.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.tb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 999px;
  background: var(--surface, #ffffff);
  color: var(--text, #111827);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.tb-chip i {
  font-size: 16px;
  color: var(--text-muted, #6b7280);
}

.tb-chip:active { transform: translateY(1px); }

/* Active chip: one identical selected treatment for ALL six chips. No chip is
   visually privileged -- price looks exactly like best/bathroom/food/etc. */
.tb-chip.is-active {
  background: var(--accent, #2563eb);
  border-color: var(--accent, #2563eb);
  color: var(--brand-ink, #ffffff);
}
.tb-chip.is-active i {
  color: var(--brand-ink, #ffffff);
}

.tb-chip:disabled {
  cursor: default;
}

/* --- Spinners --------------------------------------------------------- */

.tb-spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--accent-border, rgba(37, 99, 235, 0.3));
  border-top-color: var(--accent, #2563eb);
  animation: tb-spin 0.7s linear infinite;
}

.tb-inline-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--text-muted, rgba(107, 114, 128, 0.35));
  border-top-color: var(--text-muted, #6b7280);
  animation: tb-spin 0.7s linear infinite;
}

@keyframes tb-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .tb-spinner,
  .tb-inline-spinner {
    animation-duration: 1.6s;
  }
}

/* --- Dark-mode safety net -------------------------------------------- *
 * base.css owns the real theme tokens; these fallbacks only apply if the host
 * sets a color-scheme but leaves a token undefined, so the bar never renders
 * black-on-black or white-on-white. */
@media (prefers-color-scheme: dark) {
  .topbar {
    background: var(--surface, #15171c);
    border-bottom-color: var(--border, rgba(255, 255, 255, 0.08));
  }
  .tb-status { background: var(--surface-2, rgba(255, 255, 255, 0.05)); }
  .tb-icon-btn,
  .tb-chip {
    background: var(--surface, #1c1f26);
    border-color: var(--border, rgba(255, 255, 255, 0.12));
    color: var(--text, #f3f4f6);
  }
  .tb-name,
  .tb-status-title,
  .tb-status-label { color: var(--text, #f3f4f6); }
}

/* ---------- trip mode + priorities (top bar additions) ---------- */

.tb-brand-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tb-trip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-pill, 999px);
  background: var(--brand, #2f6df0);
  color: var(--brand-ink, #ffffff);
  font-weight: 700;
  font-size: 0.85rem;
}
.tb-trip-btn:active { transform: translateY(1px); }

.tb-icon-btn--brand {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2, #f0f2f5);
  color: var(--text-dim, #5b6470);
  font-size: 1.05rem;
}
.tb-icon-btn--brand.has-dot::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand, #2f6df0);
}

.tb-status--trip .tb-status-icon { color: var(--brand, #2f6df0); }

.tb-action--end {
  background: var(--surface-2, #f0f2f5);
  color: var(--text-dim, #5b6470);
}
