/* ============================================================
   FleetFixer Race Log — Light Mode Mobile-first (375px)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f0f4f8;
  --bg-elevated: #ffffff;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --border:      rgba(0,0,0,.08);
  --border-hi:   rgba(0,0,0,.12);
  --text:        #0b2545;
  --text-2:      #506070;
  --text-3:      #94a3b8;
  --accent:      #6366f1;
  --accent-soft: rgba(99,102,241,.08);
  --accent-glow: rgba(99,102,241,.18);
  --green:       #10b981;
  --green-soft:  rgba(16,185,129,.08);
  --yellow:      #f59e0b;
  --yellow-soft: rgba(245,158,11,.08);
  --red:         #ef4444;
  --red-soft:    rgba(239,68,68,.08);
  --star:        #e2e8f0;
  --star-active: #f59e0b;
  --radius:      14px;
  --radius-sm:   10px;
  --radius-xs:   6px;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg:   0 4px 24px rgba(0,0,0,.08);
  --transition:  .18s cubic-bezier(.4,0,.2,1);
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Progress bar ─────────────────────────────────────────── */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  border-radius: 0 2px 2px 0;
  transition: width .4s cubic-bezier(.4,0,.2,1);
  z-index: 100;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  animation: fadeIn .25s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen-inner {
  flex: 1;
  padding: 16px 16px 110px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.screen-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 80px;
}

/* ── Logo mark ────────────────────────────────────────────── */
.logo-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px var(--accent-glow);
}

/* ── Typography ───────────────────────────────────────────── */
h1 {
  font-size: 1.75rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  color: var(--text);
}

h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.subtitle {
  text-align: center;
  color: var(--text-3);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* ── Header ───────────────────────────────────────────────── */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 4px 0;
}
.screen-header h2 { flex: 1; }

.header-title { flex: 1; display: flex; align-items: center; gap: 10px; }

.header-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* ── Field labels ─────────────────────────────────────────── */
.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.field-label:not(:first-child) { margin-top: 18px; }
.field-label i { font-size: 0.7rem; opacity: .7; }

.label-hint {
  font-weight: 400;
  text-transform: none;
  color: var(--text-3);
  letter-spacing: 0;
}

/* ── Inputs ───────────────────────────────────────────────── */
.input-wrap {
  position: relative;
}
.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 0.85rem;
  pointer-events: none;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 13px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrap input {
  padding-left: 40px;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }

/* ── Searchable Dropdown ──────────────────────────────────── */
.dropdown {
  position: relative;
}
.dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.dropdown-trigger:hover, .dropdown.open .dropdown-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.dropdown-icon { color: var(--text-3); font-size: 0.85rem; }
.dropdown-placeholder { flex: 1; color: var(--text-3); font-size: 0.95rem; }
.dropdown-value { flex: 1; color: var(--text); font-size: 0.95rem; font-weight: 500; }
.dropdown-arrow {
  color: var(--text-3);
  font-size: 0.7rem;
  transition: transform var(--transition);
}
.dropdown.open .dropdown-arrow { transform: rotate(180deg); }

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  overflow: hidden;
  animation: slideDown .15s ease;
}
.dropdown.open .dropdown-menu { display: block; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-search {
  width: 100%;
  background: var(--surface-2);
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
}
.dropdown-search:focus {
  box-shadow: none;
}

.dropdown-items {
  max-height: 200px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.95rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover, .dropdown-item:active {
  background: var(--accent-soft);
  color: var(--text);
}
.dropdown-item i {
  width: 20px;
  text-align: center;
  color: var(--accent);
  font-size: 0.85rem;
}
.dropdown-item-create {
  color: var(--accent);
  font-weight: 500;
}

/* ── Chip row ─────────────────────────────────────────────── */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-row-equal {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.chip-row-equal:has(.chip:nth-child(4)) {
  grid-template-columns: repeat(4, 1fr);
}

/* ── Chips ────────────────────────────────────────────────── */
.chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 11px 14px;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}
.chip i { font-size: 0.75rem; opacity: .7; }
.chip:active { transform: scale(0.96); }
.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.chip.selected i { opacity: 1; }

/* Semantic chip colors when selected */
.chip-green.selected {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 2px 12px rgba(16,185,129,.18);
}
.chip-yellow.selected {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #000;
  box-shadow: 0 2px 12px rgba(245,158,11,.18);
}
.chip-red.selected {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 2px 12px rgba(239,68,68,.18);
}

/* ── Star rating row ─────────────────────────────────────── */
.star-row {
  display: flex;
  gap: 6px;
}
.star-btn {
  width: 48px;
  height: 48px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--star);
  transition: color var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.star-btn:active { transform: scale(0.9); }
.star-btn.lit {
  color: var(--star-active);
  filter: drop-shadow(0 2px 6px rgba(245,158,11,.35));
}

/* ── Rating row (1–5) — kept for boat handling ───────────── */
.rating-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.rating-btn {
  aspect-ratio: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}
.rating-btn:active { transform: scale(0.93); }
.rating-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* ── Slider ───────────────────────────────────────────────── */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.slider-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 52px;
}
.slider-label:last-child { text-align: right; }
.slider-track { flex: 1; }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--border-hi);
  border: none;
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--accent-glow);
}
input[type="range"]:focus { box-shadow: none; }

/* ── Stepper ──────────────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper-btn {
  width: 52px;
  height: 52px;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  color: var(--accent);
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.stepper-btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.stepper-btn:active { background: var(--bg); }
.stepper-value {
  width: 72px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-top: 1px solid var(--border-hi);
  border-bottom: 1px solid var(--border-hi);
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-icon {
  width: 38px;
  height: 38px;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-icon:active { background: var(--bg); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  transition: background var(--transition);
}
.btn-ghost:active { background: var(--accent-soft); }

.btn-outline-accent {
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(99,102,241,.15);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition);
}
.btn-outline-accent:active {
  background: rgba(99,102,241,.14);
}
.badge-sm {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
}

/* ── Sticky bottom nav ────────────────────────────────────── */
.sticky-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 40%);
  z-index: 40;
}

.btn-primary, .btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 15px;
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-submit {
  background: linear-gradient(135deg, var(--green), #34d399);
  box-shadow: 0 4px 16px rgba(16,185,129,.18);
}
.btn-submit:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(16,185,129,.18);
}

.btn-primary:disabled, .btn-submit:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Collapsible card ─────────────────────────────────────── */
.card-collapsible { padding: 0; overflow: hidden; }
.collapse-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 16px 18px;
  cursor: pointer;
  text-align: left;
}
.collapse-trigger span:first-child { flex: 1; }
.collapse-trigger i:first-child { color: var(--accent); }
.collapse-arrow {
  font-size: 0.65rem;
  transition: transform var(--transition);
}
.card-collapsible.open .collapse-arrow { transform: rotate(180deg); }
.collapse-body {
  display: none;
  padding: 0 18px 18px;
}
.card-collapsible.open .collapse-body { display: block; }

/* ── Voice input ──────────────────────────────────────────── */
.voice-field {
  position: relative;
}
.voice-field textarea {
  padding-right: 48px;
}
.btn-mic {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 36px;
  height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-3);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-mic:active { background: var(--accent-soft); color: var(--accent); }
.btn-mic.recording {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

body.no-speech .btn-mic { display: none; }
body.no-speech .voice-field textarea { padding-right: 14px; }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--green);
  color: var(--green);
  padding: 13px 24px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  z-index: 200;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Login card ───────────────────────────────────────────── */
.login-card {
  width: 100%;
  max-width: 340px;
}
.login-card .field-label { margin-top: 14px; }
.login-card .field-label:first-of-type { margin-top: 0; }
.login-card .btn-primary { margin-top: 18px; }

.login-error {
  background: var(--red-soft);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
}
.login-error[hidden] { display: none; }

/* ── Sailor info card ────────────────────────────────────── */
.sailor-info-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sailor-info-icon {
  font-size: 24px;
  color: var(--accent);
  flex-shrink: 0;
}
.sailor-info-name {
  font-weight: 700;
  font-size: 14px;
}
.sailor-info-meta {
  font-size: 11px;
  color: var(--text-3);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (min-width: 500px) {
  .screen-inner { padding-left: 24px; padding-right: 24px; }
}

@media (max-width: 380px) {
  .screen-inner { padding: 12px 12px 100px; }
  .screen-center { padding-top: 48px; }
  .logo-mark { width: 52px; height: 52px; font-size: 1.2rem; margin-bottom: 14px; }
  h1 { font-size: 1.4rem; }
  .subtitle { font-size: 0.8rem; margin-bottom: 20px; }
  .card { padding: 14px; }
  .chip { padding: 9px 10px; font-size: 0.78rem; }
  .star-btn { width: 40px; height: 40px; font-size: 1.25rem; }
  .btn-primary, .btn-submit { padding: 13px; font-size: 0.9rem; }
  .field-label { font-size: 0.7rem; }
  .sticky-nav { padding: 10px 12px; }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sticky-nav { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
