/* The start-time control (timeInput.js, speedEntry.js), the date and time
   fields, the dropdowns and the day selector (dateTimeField.js). */

/* ---------- time toggle ---------- */

.time-toggle {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Duration-only toggles (e.g. a stop's "Duration only" mode) have no mode
   buttons of their own, so there's nothing above their fields to create a
   gap via .time-toggle's flex gap — this restores that spacing as real
   padding instead, so they don't sit flush against whatever the caller put
   above them. */
.time-toggle--duration-only {
  padding-top: var(--space-3);
}

.duration-fields,
.other-fields {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.duration-input {
  width: 4.5rem;
  text-align: center;
}

/* The avg-speed mode: one row of boxes per unit, only the active one
   rendered. The rows themselves reuse .duration-fields, since they are the
   same centered box+suffix run. */
.speed-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Just the typed boxes — the row also holds the trailing unit suffix and the
   switch button, and both sit outside this. Positioned because the quick-pick
   list hangs from it and is centred on it, so every extra thing inside would
   push the list right of the numbers by half that thing's width. */
.speed-entry {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* A single box holding "4.5" needs a little more room than one holding "59". */
.speed-fields-kmh .duration-input {
  width: 5.5rem;
}

/* The unit switch, in the entry row rather than on a line of its own. It
   names the unit it switches *to*, so it is deliberately quieter than the
   suffix beside it — it's an alternative on offer, not the current state. */
.speed-unit-button {
  margin-left: var(--space-1);
  border: none;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated-3);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}

.speed-unit-button:hover {
  background: var(--control-chip);
  color: var(--text-primary);
}

/* Reuses .dropdown / .dropdown-option wholesale (see
   dateTimeField.js) — same list, same interaction, just a different set of
   values in it. What differs is width: every label here is four characters
   at most ("10.0", "3:30"), so the list is sized to them and centered under
   the row rather than stretched across it, with a slightly rounder edge to
   suit the narrower box.

   `scrollbar-gutter: both-edges` is what keeps the labels visually centered:
   the list always scrolls (15 km/h entries against a 12rem max-height), and
   on a box this narrow a scrollbar down one side alone throws the numbers
   noticeably off-centre. Reserving the same width on both sides costs
   nothing here, since the width is fixed either way.

   Both classes are in the selector on purpose: .dropdown is
   defined *below* this block, so at equal specificity its `left: 0; right: 0`
   would win on source order and stretch the list across the entry — then
   translateX(-50%) would drag that full-width box half its own width to the
   left, off the sidebar entirely. */
.dropdown.speed-preset-dropdown {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: 6rem;
  border-radius: var(--radius-lg);
  scrollbar-gutter: stable both-edges;
}

.input-suffix {
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

.time-toggle-preview {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

/* ---------- date/time fields ---------- */
/* Custom replacements for native <input type="time"> / type="datetime-local">
   — see dateTimeField.js for why. */

.date-time-field {
  display: flex;
  flex: 1;
  gap: var(--space-2);
}

.date-time-field-date {
  flex: 1;
}

.date-time-field-time {
  flex: 1;
}

.time-field {
  position: relative;
  flex: 1;
}

.time-field-boxes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}

.time-field-box {
  width: 3.30rem;
  text-align: center;
}

.time-field-colon {
  color: var(--text-tertiary);
}

.dropdown {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 12rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  backdrop-filter: var(--glass-filter);
  -webkit-backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-edge), var(--glass-shadow);
}

.dropdown-option {
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition), color var(--transition);
}

.dropdown-option:hover {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* Stacks the (optional, multi-day-only) day selector above the time-of-day
   clock boxes inside a 'durationOrTimeOfDay' toggle's "Time of day" mode. */
.time-of-day-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  width: 100%;
}

/* ---------- day selector ---------- */
/* Thin "Day N · <date>" button + dropdown, shown only above a time-of-day
   field when the activity spans more than one calendar day — see
   createDaySelector in dateTimeField.js. */

.day-selector {
  position: relative;
}

.day-selector-button {
  width: 100%;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated-3);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition), color var(--transition);
}

.day-selector-button:hover {
  background: var(--control-chip);
  color: var(--text-primary);
}

.day-selector-dropdown {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 10rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  backdrop-filter: var(--glass-filter);
  -webkit-backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-edge), var(--glass-shadow);
}

.day-selector-option {
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition), color var(--transition);
}

.day-selector-option:hover {
  background: var(--accent);
  color: var(--accent-contrast);
}
