/* ══════════════════════════════════════════════
   PADEL MASTERY — Trip P&L Module
   Extends the pm-retreat.css design system (dark theme, --pm-* tokens)
══════════════════════════════════════════════ */

/* ── Field grid (trip-detail header fields; not a shared name — see pm-form-grid-2/3 in pm-retreat.css) ── */
.pm-field-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1rem;
}

/* ── Numbers ── */
.pm-num {
  text-align: right;
  font-family: var(--pm-font-data);
  font-variant-numeric: tabular-nums;
}
.pm-neg { color: var(--pm-danger); }
.pm-pos { color: var(--pm-success); }
.pm-muted { color: var(--pm-text-secondary); }
.pm-warn { color: var(--pm-warning); }
.pm-strong { font-weight: 700; color: var(--pm-text); }

/* ── Generic status badge (neutral pill, e.g. trip status) ── */
.pm-badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 9999px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--pm-border); color: var(--pm-text);
}

/* ── Row actions ── */
.pm-row-actions {
  display: flex; align-items: center; gap: 0.5rem; justify-content: flex-end; white-space: nowrap;
}
.pm-page-header .pm-row-actions { flex-wrap: wrap; }

/* ── Buttons ── */
.pm-btn-danger {
  background: transparent; color: var(--pm-danger); border: 1px solid var(--pm-danger);
  padding: 0.45rem 0.9rem; border-radius: 0.5rem; font-weight: 600; font-size: 0.8rem;
  cursor: pointer; white-space: nowrap; transition: background 0.15s, color 0.15s;
}
.pm-btn-danger:hover { background: rgba(244, 67, 54, 0.12); }
.pm-btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Toggle group (segmented control) ──
   Buttons are styled by their own classes (.pm-toggle-btn / .pm-toggle-btn-active), not by
   descendant/tag selectors, so nothing here depends on out-specifying pm-retreat.css's
   unrelated .pm-toggle / .pm-shell .pm-toggle rules. ── */
.pm-toggle-group {
  display: inline-flex; border: 1px solid var(--pm-border); border-radius: 0.5rem;
  overflow: hidden; background: var(--pm-surface);
}
.pm-toggle-btn {
  background: none; border: none; color: var(--pm-text-secondary);
  padding: 0.4rem 0.9rem; font-size: 0.8rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  border-right: 1px solid var(--pm-border);
}
.pm-toggle-btn:last-child { border-right: none; }
.pm-toggle-btn:hover { color: var(--pm-text); }
.pm-toggle-btn-active {
  background: var(--pm-accent); color: #0a0a0a;
}

/* ── Checkbox ── */
/* pm-check goes on the LABEL that wraps a checkbox and its text, so it must size
   itself to that content. Sizing the label directly collapses it to 1rem square and
   the text spills over whatever sits next to it — inside .pm-row-actions, which is a
   flex container, the label is blockified and the collapse really does take effect. */
.pm-check {
  display: inline-flex; align-items: center; gap: 0.4rem;
  cursor: pointer; white-space: nowrap;
  font-size: 0.8rem; color: var(--pm-text-secondary);
}
.pm-check input[type="checkbox"] {
  accent-color: var(--pm-accent);
  flex: none; width: 1rem; height: 1rem; margin: 0; cursor: pointer;
}

/* ── Range slider ── */
.pm-slider-row {
  display: flex; align-items: center; gap: 0.75rem;
}
.pm-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 28px; background: transparent; outline: none;
  cursor: pointer;
}
.pm-slider:focus-visible { outline: 2px solid var(--pm-accent); outline-offset: 2px; }
.pm-slider::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: var(--pm-border);
}
.pm-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 28px; height: 28px; border-radius: 50%; margin-top: -12px;
  background: var(--pm-accent); cursor: pointer; border: none;
  transition: background 0.15s;
}
.pm-slider::-webkit-slider-thumb:hover { background: var(--pm-accent-dim); }
.pm-slider::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--pm-accent); cursor: pointer; border: none;
  transition: background 0.15s;
}
.pm-slider::-moz-range-thumb:hover { background: var(--pm-accent-dim); }
.pm-slider::-moz-range-track {
  height: 4px; border-radius: 2px; background: var(--pm-border);
}

/* ── Editable tables (tight padding so inline inputs fit) ── */
.pm-table-editable th,
.pm-table-editable td { padding: 0.35rem 0.5rem; }
.pm-table-editable td .pm-input,
.pm-table-editable td .pm-input-num,
.pm-table-editable td .pm-input-short { padding: 0.3rem 0.5rem; font-size: 0.8rem; }

/* Give each control room to show its value. Without these the browser shrinks every
   column to fit the container and the numbers get clipped mid-digit. */
.pm-table-editable td .pm-input { min-width: 11rem; }
.pm-table-editable td select.pm-input { min-width: 10rem; }
.pm-table-editable td .pm-input-num { min-width: 6rem; max-width: 8rem; }
.pm-table-editable td .pm-input-short { min-width: 4.5rem; max-width: 5rem; }

/* Below 1100px the table is used by touch (tablet): every inline control is a full tap target.
   The desktop table keeps its tight rows. */
@media (max-width: 1099.98px) {
  .pm-table-editable td .pm-input,
  .pm-table-editable td select.pm-input,
  .pm-table-editable td .pm-input-short { min-height: var(--pm-tap); }
}

/* ── Horizontal scroll for wide tables ──
   The line tables carry 13 columns. Rather than squeezing them into the card and
   clipping the values, let the table take its natural width and scroll sideways. */
.pm-table-scroll {
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scrollbar-color: var(--pm-border) var(--pm-surface);
}
.pm-table-scroll > .pm-table {
  width: max-content;
  min-width: 100%;
}
.pm-table-scroll > .pm-table th,
.pm-table-scroll > .pm-table td { white-space: nowrap; }

.pm-table-scroll::-webkit-scrollbar { height: 10px; }
.pm-table-scroll::-webkit-scrollbar-track {
  background: var(--pm-surface); border-radius: 5px;
}
.pm-table-scroll::-webkit-scrollbar-thumb {
  background: var(--pm-border); border-radius: 5px;
}
.pm-table-scroll::-webkit-scrollbar-thumb:hover { background: var(--pm-text-secondary); }

/* ── Inline numeric / short inputs ── */
.pm-input-num {
  width: 100%; max-width: 8rem; background: var(--pm-surface); color: var(--pm-text);
  border: 1px solid var(--pm-border); border-radius: 0.4rem;
  padding: 0.4rem 0.6rem; font-size: 0.85rem; font-family: var(--pm-font-data); font-variant-numeric: tabular-nums;
  text-align: right; box-sizing: border-box; transition: border-color 0.15s;
}
.pm-input-num:focus { outline: none; border-color: var(--pm-accent); }

/* A foreign-currency rate sitting at 1 converts nothing. That is right when the two
   currencies match and wrong the rest of the time, and the two look identical — so
   flag it rather than letting an unconverted cost pass for a priced one. */
.pm-input-unpriced {
  border-color: var(--pm-warning); color: var(--pm-warning);
  background: color-mix(in srgb, var(--pm-warning) 8%, var(--pm-surface));
}
.pm-input-unpriced:focus { border-color: var(--pm-warning); }

.pm-input-short {
  width: 100%; max-width: 5rem; background: var(--pm-surface); color: var(--pm-text);
  border: 1px solid var(--pm-border); border-radius: 0.4rem;
  padding: 0.4rem 0.5rem; font-size: 0.85rem; font-family: inherit;
  box-sizing: border-box; transition: border-color 0.15s;
}
.pm-input-short:focus { outline: none; border-color: var(--pm-accent); }

@media (max-width: 767.98px) {
  /* 16px stops iOS Safari zooming the page when one of these inputs is focused. */
  .pm-input-short, .pm-table-editable td .pm-input-short { font-size: 16px; }
}

/* ── Trip line cards (phone, Plan mode) ── */
.pm-line-cards { display: flex; flex-direction: column; gap: 0.5rem; }
.pm-line-card { display: flex; flex-direction: column; gap: 0.25rem; width: 100%; min-height: var(--pm-tap); padding: 0.75rem 0.9rem; text-align: left; background: var(--pm-card); border: 1px solid var(--pm-border); border-radius: 0.75rem; color: var(--pm-text); font: inherit; cursor: pointer; }
.pm-line-card:focus-visible { outline: 2px solid var(--pm-accent); outline-offset: 2px; }
.pm-line-card-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.pm-line-card-title { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.pm-line-card-sub { color: var(--pm-text-secondary); font-size: 0.9rem; }
.pm-line-chip { display: inline-block; margin-left: 0.35rem; padding: 0.05rem 0.45rem; border: 1px solid var(--pm-border); border-radius: 999px; color: var(--pm-text-secondary); font-size: 0.75rem; font-weight: 600; vertical-align: middle; }
.pm-fx-warn { display: block; margin-top: 0.15rem; color: var(--pm-warning); font-size: 0.8rem; }
/* pm-ui.css loads later and sets .pm-phone-only to display: block, which would drop the card gap. */
@media (max-width: 767.98px) {
  .pm-phone-only.pm-line-cards { display: flex; }
}

/* ── Actuals entry (all widths) ── */
.pm-actuals-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; color: var(--pm-text-secondary); }
.pm-actuals-list { display: flex; flex-direction: column; gap: 0.5rem; }
.pm-actual-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(12rem, 16rem) auto auto; align-items: center; gap: 0.5rem 0.75rem; padding: 0.75rem 0.9rem; background: var(--pm-card); border: 1px solid var(--pm-border); border-radius: 0.75rem; }
.pm-actual-row-unconfirmed { opacity: 0.75; }
.pm-actual-name { font-weight: 600; overflow-wrap: anywhere; }
.pm-actual-planned { color: var(--pm-text-secondary); font-size: 0.9rem; }
.pm-actual-entry { display: flex; align-items: center; gap: 0.5rem; }
.pm-shell .pm-actual-input { flex: 1; min-width: 0; min-height: 48px; font-size: 1.15rem; text-align: right; font-variant-numeric: tabular-nums; }
.pm-actual-ccy { color: var(--pm-text-secondary); font-size: 0.8rem; }
.pm-actual-variance { min-width: 5.5rem; text-align: right; }
.pm-actual-other { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.pm-shell .pm-actual-other .pm-input { width: 8rem; font-size: 16px; min-height: var(--pm-tap); }
@media (max-width: 767.98px) {
  /* Three rows: name and menu, the full-width amount, then the Confirmed switch. */
  .pm-actual-row { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "info info menu" "entry entry entry" "switch switch switch" "other other other"; }
  .pm-actual-info { grid-area: info; min-width: 0; }
  .pm-actual-menu { grid-area: menu; justify-self: end; align-self: start; }
  .pm-actual-entry { grid-area: entry; }
  .pm-actual-confirm { grid-area: switch; justify-self: start; }
  .pm-actual-other { grid-area: other; }
}

/* ── Trip detail ── */
.pm-trip-summary { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.pm-trip-summary-text { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.pm-pnl-chips { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.25rem; margin-bottom: 0.75rem; }
.pm-pnl-pivot { list-style: none; margin: 0; padding: 0; }
.pm-pnl-pivot li { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 0; border-top: 1px solid var(--pm-border); }
.pm-pnl-pivot li:first-child { border-top: none; }
.pm-pnl-partial { margin: 0.5rem 0 0; color: var(--pm-warning); font-size: 0.9rem; }
.pm-event-list { display: flex; flex-direction: column; gap: 0.5rem; }
.pm-event-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.25rem 0.75rem; padding: 0.85rem 1rem; background: var(--pm-surface); border: 1px solid var(--pm-border); border-radius: 0.75rem; }
.pm-event-card:focus-within { border-color: var(--pm-accent); }
.pm-event-card-link { display: flex; flex-direction: column; gap: 0.15rem; min-height: var(--pm-tap); justify-content: center; color: var(--pm-text); text-decoration: none; }
.pm-event-card-link:focus-visible { outline: none; }
.pm-event-card-title { font-weight: 600; }
.pm-event-card-sub { color: var(--pm-text-secondary); font-size: 0.9rem; }
.pm-event-card-figures { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.9rem; }
.pm-alert-error ul { margin: 0; padding-left: 1.2rem; }

/* Profit and variance colours must beat .pm-shell .pm-table td { color: var(--pm-text) } (specificity 0,2,1). */
.pm-shell .pm-table td.pm-pos { color: var(--pm-success); }
.pm-shell .pm-table td.pm-neg { color: var(--pm-danger); }

/* ── Event editor ── */
.pm-slider-input-row { display: flex; align-items: center; gap: 0.75rem; }
.pm-slider-input-row .pm-slider { flex: 1; min-height: var(--pm-tap); }
.pm-shell .pm-slider-input-row .pm-input { flex: 0 0 5.5rem; width: 5.5rem; }
.pm-day-list { display: flex; flex-direction: column; gap: 0.5rem; }
.pm-day-card { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.9rem; background: var(--pm-surface); border: 1px solid var(--pm-border); border-radius: 0.75rem; }
.pm-day-card-main { flex: 1; min-width: 0; min-height: var(--pm-tap); display: flex; flex-direction: column; justify-content: center; gap: 0.15rem; padding: 0; text-align: left; background: none; border: 0; color: var(--pm-text); font: inherit; cursor: pointer; }
.pm-day-card-main:focus-visible { outline: 2px solid var(--pm-accent); outline-offset: 2px; }
.pm-day-card-title { font-weight: 600; }
.pm-day-card-sub { color: var(--pm-text-secondary); font-size: 0.9rem; }
.pm-day-card-lessons { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* pm-ui.css sets .pm-kpi-value's colour later at the same specificity, so profit tiles need the extra class. */
.pm-kpi-value.pm-pos { color: var(--pm-success); }
.pm-kpi-value.pm-neg { color: var(--pm-danger); }
/* The same actions are in the topbar menu on a phone, where three buttons do not fit a card header. */
@media (max-width: 767.98px) { .pm-card-header-actions { display: none; } }

/* ── Trip templates ── */
/* The topbar is sticky at top: 0 at every width, so the filter bar sits just under it:
   57px on desktop (40px controls + 2 x 0.5rem padding + 1px border), 61px below 1100px (44px controls). */
.pm-template-filters { position: sticky; top: 57px; z-index: 5; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; padding: 0.75rem 0; margin-bottom: 1rem; background: var(--pm-bg); }
.pm-template-filters .pm-field { margin: 0; min-width: 14rem; }
@media (max-width: 1099.98px) { .pm-template-filters { top: 61px; } }
@media (max-width: 767.98px) { .pm-template-filters .pm-field { flex: 1 1 100%; min-width: 0; } }
