/* ── availability.css ──────────────────────────────────────────*/

/* ── AVAILABILITY PAGE ──────────────────────────────────────────────────────── */

/* Member-grid / captain-heatmap view switcher — two panes side by side in a
   200%-wide track; toggling slides the track left/right by 50%. */
.av-view-port {
  overflow: hidden;
}
.av-view-track {
  display: flex;
  align-items: flex-start;
  width: 200%;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.av-view-track--heatmap {
  transform: translateX(-50%);
}
.av-view-pane {
  width: 50%;
  flex-shrink: 0;
  min-width: 0;
}

/* Day tabs — shown on mobile, hidden on desktop */
.av-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.av-tabs::-webkit-scrollbar { display: none; }

.av-tab {
  flex: 1;
  min-width: 40px;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
}
.av-tab.active {
  color: var(--navy-dark);
  border-bottom-color: var(--navy-dark);
  font-weight: 600;
}

/* Header layout — title+week-nav on their own row, action buttons on a row
   below. Scoped to .av-page-header so the shared .page-header/.week-nav
   classes used by other pages (e.g. Sessions) are unaffected. */
.av-page-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 12px;
}
.av-header-text {
  display: flex;
  flex-direction: column;
}

/* Title row — page title with the week switcher pushed to the far right */
.av-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
}

/* Header action buttons — the primary view-mode group (Club overview /
   Enter availability) carries more visual weight than the secondary
   bulk-action group beside/below it. Groups wrap as whole units so neither
   individual buttons nor the divider get stranded at in-between widths. */
.av-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}
.av-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.av-action-group--bulk {
  padding-left: 0;
  border-left: none;
}
@media (min-width: 900px) {
  .av-action-group--bulk {
    padding-left: 16px;
    border-left: 0.5px solid var(--border-strong);
  }
}

.avp-btn {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 0.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.avp-btn:hover { background: var(--navy-light); }
.avp-btn.active { background: var(--nav-navy); color: #fff; border-color: var(--nav-navy); }

/* Primary actions — Club overview / Enter availability */
.av-action-group--view .avp-btn {
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 700;
}

/* Secondary/bulk actions — Same as last week / Fill rest free / Fill rest unavailable */
.av-action-group--bulk .avp-btn {
  padding: 6px 10px;
  font-size: 11px;
}

/* Bulk-fill buttons — light tint matching the free/unavailable slot colours */
.avp-btn--fill-free {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}
.avp-btn--fill-free:hover { background: #bbf7d0; }
.avp-btn--fill-unavail {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}
.avp-btn--fill-unavail:hover { background: #fecaca; }
[data-theme="dark"] .avp-btn--fill-free { background: rgba(22,163,74,0.22); border-color: rgba(22,163,74,0.4); color: #86efac; }
[data-theme="dark"] .avp-btn--fill-free:hover { background: rgba(22,163,74,0.32); }
[data-theme="dark"] .avp-btn--fill-unavail { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.4); color: #fca5a5; }
[data-theme="dark"] .avp-btn--fill-unavail:hover { background: rgba(239,68,68,0.3); }

/* Mobile: primary actions become a full-width, evenly-split row; the
   bulk group drops to its own row below with no divider. The bulk-fill
   buttons are hidden — fast-entry is the primary mobile flow, and they're
   only genuinely useful on the desktop grid. */
@media (max-width: 767px) {
  .av-header-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .av-action-group--view .avp-btn {
    flex: 1 1 0;
    text-align: center;
  }
  .avp-btn--fill-free,
  .avp-btn--fill-unavail {
    display: none;
  }
  #av-copy-btn {
    display: none;
  }
}

/* Grid layout */
.av-grid {
  display: block; /* mobile: single-column via tab visibility */
}

/* Day columns */
.av-day-col {
  display: none; /* mobile: only active column shown */
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
}
.av-day-col--active { display: block; }

/* Column header */
.av-col-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 2px;
}
.av-col-day {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* "Add note"/"Edit note" text button — inline with the day header, right-aligned */
.av-day-note-btn {
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-tertiary);
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.av-day-note-btn:hover { color: var(--text-secondary); }
.av-day-note-btn--has-note { color: var(--navy-mid); font-weight: 600; }

/* Per-day save indicator */
.av-save-ind {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 500;
  transition: color 0.2s;
}
.av-save-ind--saving { color: #d97706; }
.av-save-ind--saved  { color: #16a34a; }
.av-save-ind--error  { color: #dc2626; }

/* Time slots — adjacent slots sharing a status (free/unavailable/blank) form
   one continuous run: rounded corners only at the top/bottom of the run
   (via .av-slot--run-top/--run-bottom, set per-slot in availability.js),
   no gap between slots inside it. */
.av-slot {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 0;
  cursor: pointer;
  margin-bottom: 0;
  min-height: 34px;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s;
  background: transparent;
}
.av-slot--run-top {
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}
.av-slot--run-bottom {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  margin-bottom: 2px;
}
.av-slot:hover {
  background: var(--navy-light);
}
.av-slot--free {
  background: #dcfce7;
}
.av-slot--free:hover {
  background: #bbf7d0;
}
.av-slot--unavail {
  background: #fee2e2;
}
.av-slot--unavail:hover {
  background: #fecaca;
}
[data-theme="dark"] .av-slot--free { background: rgba(22,163,74,0.22); }
[data-theme="dark"] .av-slot--free:hover { background: rgba(22,163,74,0.32); }
[data-theme="dark"] .av-slot--unavail { background: rgba(239,68,68,0.2); }
[data-theme="dark"] .av-slot--unavail:hover { background: rgba(239,68,68,0.3); }
.av-slot-time {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 36px;
  font-variant-numeric: tabular-nums;
}
.av-slot--free .av-slot-time { color: #166534; }
.av-slot--unavail .av-slot-time { color: #991b1b; }
[data-theme="dark"] .av-slot--free .av-slot-time { color: #86efac; }
[data-theme="dark"] .av-slot--unavail .av-slot-time { color: #fca5a5; }
.av-slot--readonly { cursor: default; }

/* Committed slots — a session sign-up/assignment overrides whatever the member's
   own stored free/unavailable/blank status is for that slot. Each committed role
   gets its own colour (not the free/unavailable greens/reds) and a full-word label:
   Rowing, Coxing, Coaching. Computed overlay only, see avCommitted /
   getCommittedAvailability in utils.js — never written back on save. Colours reuse
   the shared --w2/--m1/--m2 tokens (base.css) so dark mode is handled automatically
   rather than needing separate [data-theme="dark"] overrides here. Rowing uses --w2
   (same orange as the W2 squad legend) rather than green/red, since those are already
   the free/unavailable colours elsewhere on this page. */
.av-slot--committed {
  justify-content: center;
}
.av-slot--committed:hover {
  filter: brightness(0.95);
}
.av-slot--committed-row   { background: var(--w2-bg); }
.av-slot--committed-cox   { background: var(--m2-bg); }
.av-slot--committed-coach { background: var(--m1-bg); }
.av-slot-committed-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.av-slot--committed-row   .av-slot-committed-label { color: var(--w2-text); }
.av-slot--committed-cox   .av-slot-committed-label { color: var(--m2-text); }
.av-slot--committed-coach .av-slot-committed-label { color: var(--m1-text); }

/* Note editor (rendered inside the shared .modal-bg/.modal overlay) */
.av-note-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  font-family: inherit;
  border: 0.5px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  outline: none;
  line-height: 1.5;
}
.av-note-input:focus { border-color: var(--navy-mid); }

/* Note badge (display existing note) */
.av-note-badge {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
  padding: 5px 8px;
  background: var(--navy-light);
  border-radius: 6px;
  cursor: pointer;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.av-note-badge:hover { background: var(--border); }

/* ── Desktop: 7-column grid, tabs hidden ─────────────────────────────────── */
@media (min-width: 768px) {
  .av-tabs       { display: none; }

  .av-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    align-items: start;
  }

  /* All day columns visible on desktop */
  .av-day-col { display: block; }

  .av-slot { min-height: 30px; padding: 4px 6px; }
  .av-col-day { font-size: 10px; }
}

/* ── Small mobile (≤ 480px) ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .av-tab { font-size: 11px; padding: 7px 2px; }
}

/* ── FAST-ENTRY AVAILABILITY FLOW ───────────────────────────────────────── */
/* Full-screen, no-scroll, sequential confirm-as-you-go entry flow — separate
   from the per-day grid above. Sized entirely with flexbox so the 15-slot
   grid always fits the viewport without scrolling, on any screen height. */

.fe-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.fe-overlay.fe-overlay--open { display: flex; }

.fe-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  flex: none;
}
.fe-close-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 0.5px solid var(--border-strong);
  background: var(--surface);
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
}
.fe-close-btn:hover { background: var(--navy-light); }
.fe-title {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.fe-day {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fe-range {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}
.fe-header-spacer { width: 32px; flex-shrink: 0; }

.fe-progress {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 12px 8px;
  flex: none;
}
.fe-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--border-strong);
  cursor: pointer;
}
.fe-dot:disabled { cursor: default; opacity: 0.5; }
.fe-dot--confirmed { background: #86efac; }
.fe-dot--current { background: var(--navy-dark); transform: scale(1.25); }

.fe-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  margin: 0;
  padding: 0 12px 8px;
  flex: none;
}

.fe-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 8px;
  padding: 0 12px;
  touch-action: none;
}
.fe-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.fe-slot--free {
  background: #dcfce7;
  color: #166534;
}
.fe-slot--unavail {
  background: #fee2e2;
  color: #991b1b;
}
[data-theme="dark"] .fe-slot--free { background: rgba(22,163,74,0.28); color: #86efac; }
[data-theme="dark"] .fe-slot--unavail { background: rgba(239,68,68,0.26); color: #fca5a5; }

/* Final fast-entry screen — member_preferences fields, reusing the .av-pref-*
   field styling below (stepper/segmented/input look) inside this flow's
   full-screen chrome. Hidden by default; feRenderScreen() shows it in place
   of .fe-grid only while on the preferences screen. */
.fe-prefs {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 8px;
  flex-direction: column;
}
.fe-prefs .av-pref-field { margin-bottom: 12px; }

.fe-nav {
  display: flex;
  gap: 10px;
  padding: 12px;
  flex: none;
}
.fe-nav-btn {
  flex: 1;
  height: 52px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--nav-navy);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.fe-nav-btn:disabled { opacity: 0.35; cursor: default; }
.fe-nav-back { background: var(--surface); color: var(--text); border: 0.5px solid var(--border-strong); }

/* ── Desktop: wider grid so the flow doesn't look stretched-out ──────────── */
@media (min-width: 768px) {
  .fe-grid {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(3, 1fr);
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
  }
  .fe-nav {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
  }
  .fe-slot { font-size: 15px; }
  .fe-prefs {
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
  }
}

/* ── PREFERENCES PANEL ──────────────────────────────────────────────────── */

.av-layout {
  display: flex;
  flex-direction: column;
}

.av-pref-panel {
  order: -1;
  margin-bottom: 14px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
}

.av-pref-mobile-toggle {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}
.av-pref-mobile-toggle:after {
  content: '▾';
  float: right;
  color: var(--text-tertiary);
  transition: transform 0.15s;
}
.av-pref-mobile-toggle.active:after { transform: rotate(180deg); }

.av-pref-panel-inner {
  display: none;
  padding: 0 14px 14px;
}
.av-pref-panel-inner.av-pref-inner--open { display: block; }

.av-pref-caption {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  line-height: 1.4;
}

.av-pref-field { margin-bottom: 14px; }
.av-pref-field:last-of-type { margin-bottom: 8px; }

.av-pref-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.av-pref-stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}
.av-pref-step-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.av-pref-step-btn:hover:not(:disabled) { background: var(--navy-light); }
.av-pref-step-btn:disabled { opacity: 0.35; cursor: default; }
.av-pref-step-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-width: 16px;
  text-align: center;
}

.av-pref-segmented {
  display: flex;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.av-pref-erg-opt {
  flex: 1;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  background: var(--surface);
  border: none;
  border-right: 0.5px solid var(--border-strong);
  color: var(--text-secondary);
  cursor: pointer;
}
.av-pref-erg-opt:last-child { border-right: none; }
.av-pref-erg-opt:hover { background: var(--navy-light); }
.av-pref-erg-opt.active {
  background: var(--nav-navy);
  color: #fff;
  font-weight: 600;
}

.av-pref-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  font-family: inherit;
  border: 0.5px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 9px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}
.av-pref-input:focus { border-color: var(--navy-mid); }
.av-pref-textarea { resize: vertical; line-height: 1.5; }

.av-pref-save-row {
  display: flex;
  justify-content: flex-end;
}

/* ── Desktop: fixed sticky sidebar alongside the grid ────────────────────── */
@media (min-width: 900px) {
  .av-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 14px;
  }

  .av-view-port { flex: 1; min-width: 0; }

  .av-pref-panel {
    order: 0;
    width: 280px;
    flex-shrink: 0;
    margin-top: 0;
    margin-bottom: 0;
    position: sticky;
    top: 14px;
  }

  .av-pref-mobile-toggle { display: none; }

  .av-pref-panel-inner {
    display: block;
    padding: 14px;
  }
}

