/* ============================================================
   Claire's Driving Log — styles
   ============================================================ */

:root {
  --c-bg: #FAFAF7;
  --c-surface: #FFFFFF;
  --c-surface-2: #F1EFE8;
  --c-border: #E5E3DA;
  --c-border-strong: #C9C7BD;
  --c-text: #2C2C2A;
  --c-text-muted: #5F5E5A;
  --c-text-faint: #8B8A82;
  --c-accent: #1F4E78;
  --c-accent-hover: #163955;
  --c-success: #3B6D11;
  --c-success-bg: #EAF3DE;
  --c-warn: #854F0B;
  --c-warn-bg: #FAEEDA;
  --c-danger: #A32D2D;
  --c-danger-bg: #FCEBEB;
  --c-info-bg: #E6F1FB;
  --c-info: #185FA5;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

/* ============ GATE ============ */
.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
  padding: 20px;
}
.gate-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.gate-card h1 { margin: 0 0 8px; font-size: 22px; }
.gate-card p { margin: 0 0 20px; color: var(--c-text-muted); }
.gate-card form { display: flex; flex-direction: column; gap: 12px; }
.gate-error { color: var(--c-danger); font-size: 14px; margin-top: 12px !important; }

/* ============ HEADER ============ */
.app-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 20px;
}
.header-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.app-title {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  color: var(--c-accent);
}
.app-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -20px;
  padding: 0 20px;
}
.nav-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  color: var(--c-text-muted);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.nav-btn.active {
  background: var(--c-accent);
  color: white;
}
#btn-quick-quiz {
  background: var(--c-accent);
  color: white;
  font-size: 16px;
}
#btn-quick-quiz:hover { background: var(--c-accent-hover); }
#btn-quick-quiz:disabled { opacity: 0.45; cursor: not-allowed; }

/* ============ MAIN ============ */
.app-main {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: 80px;
}
.view { display: none; }
.view.active { display: block; }

.section-h {
  font-size: 16px;
  font-weight: 500;
  margin: 24px 0 12px;
  color: var(--c-text);
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ============ FORM ELEMENTS ============ */
input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  background: var(--c-surface);
  color: var(--c-text);
}
textarea { resize: vertical; }
label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--c-text-muted);
}
label input, label select, label textarea {
  margin-top: 4px;
  font-size: 15px;
  color: var(--c-text);
}
fieldset {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
legend { font-size: 13px; color: var(--c-text-muted); padding: 0 6px; }

button {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-text);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
button:hover { background: var(--c-surface-2); }
.btn-primary {
  background: var(--c-accent);
  color: white;
  border-color: var(--c-accent);
}
.btn-primary:hover { background: var(--c-accent-hover); border-color: var(--c-accent-hover); }
.btn-secondary { background: var(--c-surface); }
.btn-danger {
  background: var(--c-surface);
  color: var(--c-danger);
  border-color: var(--c-danger);
}
.btn-danger:hover { background: var(--c-danger-bg); }
.btn-large {
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 500;
  width: 100%;
  margin-top: 16px;
}

/* ============ METRICS ============ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}
.metric {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.metric-label { font-size: 12px; color: var(--c-text-muted); margin: 0 0 4px; }
.metric-val { font-size: 24px; font-weight: 500; margin: 0; }
.metric-sub { font-size: 11px; color: var(--c-text-faint); margin: 6px 0 0; }
.req-bar {
  height: 5px;
  background: var(--c-surface-2);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}
.req-fill {
  height: 100%;
  background: var(--c-success);
  border-radius: 3px;
  transition: width 0.3s;
}

@media (max-width: 600px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric:last-child { grid-column: span 2; }
  .metric-val { font-size: 22px; }
}

/* ============ SKILL / DRIVE LISTS ============ */
.skill-list, .drive-list {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  transition: background 0.1s;
}
.list-row:hover { background: var(--c-surface-2); }
.list-row:last-child { border-bottom: none; }
.list-row-main { flex: 1; min-width: 0; }
.list-row-name { font-size: 14px; margin: 0 0 2px; }
.list-row-meta { font-size: 12px; color: var(--c-text-faint); margin: 0; }
.list-row-rating {
  font-size: 13px;
  font-weight: 500;
  margin-left: 12px;
  flex-shrink: 0;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.dot-low { background: #E24B4A; }
.dot-mid { background: #EF9F27; }
.dot-high { background: #639922; }
.dot-none { background: #C9C7BD; }
.empty {
  padding: 24px;
  text-align: center;
  color: var(--c-text-faint);
  font-size: 14px;
}

/* ============ PLANS ============ */
.plan-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.plan-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 12px;
}
.plan-card-title { font-size: 15px; font-weight: 500; margin: 0; }
.plan-card-meta { font-size: 12px; color: var(--c-text-faint); margin: 2px 0 0; }
.plan-card-route { font-size: 14px; color: var(--c-text-muted); margin: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
}
.chip-skill { background: #EEEDFE; color: #3C3489; }
.chip-situation { background: var(--c-info-bg); color: var(--c-info); }
.status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  flex-shrink: 0;
}
.status-Planned { background: var(--c-info-bg); color: var(--c-info); }
.status-Completed { background: var(--c-success-bg); color: var(--c-success); }
.status-Skipped { background: var(--c-surface-2); color: var(--c-text-muted); }
.status-Rescheduled { background: var(--c-warn-bg); color: var(--c-warn); }

/* ============ FORM CARD ============ */
.form-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.form-card h3 { margin: 0 0 16px; font-size: 16px; font-weight: 500; }

/* ============ DRIVE ============ */
.drive-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--c-accent);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.drive-id-label { font-size: 12px; margin: 0; opacity: 0.85; }
.drive-elapsed { font-size: 22px; font-weight: 500; margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.drive-status-buttons { display: flex; gap: 8px; }
.drive-status-bar button {
  background: rgba(255,255,255,0.15);
  color: white;
  border-color: rgba(255,255,255,0.3);
}
.drive-status-bar button:hover { background: rgba(255,255,255,0.25); }
#map {
  width: 100%;
  height: 280px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
  margin-bottom: 16px;
}

.skill-rate-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.skill-rate-name { font-size: 14px; font-weight: 500; margin: 0 0 8px; }
.skill-rate-id { color: var(--c-text-faint); font-weight: 400; }
.rating-row { display: flex; gap: 6px; }
.rating-btn {
  flex: 1;
  padding: 12px 0;
  font-size: 16px;
  font-weight: 500;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  border-radius: var(--radius);
  cursor: pointer;
}
.rating-btn:hover { background: var(--c-surface-2); }
.rating-btn.r-1, .rating-btn.r-2 {
  background: var(--c-danger-bg) !important;
  border-color: var(--c-danger) !important;
  color: var(--c-danger) !important;
}
.rating-btn.r-3 {
  background: var(--c-warn-bg) !important;
  border-color: var(--c-warn) !important;
  color: var(--c-warn) !important;
}
.rating-btn.r-4, .rating-btn.r-5 {
  background: var(--c-success-bg) !important;
  border-color: var(--c-success) !important;
  color: var(--c-success) !important;
}
.skill-notes-input {
  margin-top: 8px;
  font-size: 13px;
  padding: 6px 10px;
}
.skill-remove {
  font-size: 11px;
  color: var(--c-text-faint);
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  float: right;
  margin-top: -4px;
}
.skill-remove:hover { color: var(--c-danger); background: transparent; }

/* ============ REFERENCE ============ */
.ref-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 0;
}
.ref-tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.ref-tab {
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.ref-tab.active {
  background: var(--c-accent);
  color: white;
  border-color: var(--c-accent);
}
.ref-item {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 6px;
}
.ref-item-id {
  font-size: 11px;
  color: var(--c-text-faint);
  font-weight: 500;
}
.ref-item-name { font-size: 14px; margin: 2px 0; }
.ref-item-meta { font-size: 12px; color: var(--c-text-muted); }
.ref-item-actions { display: flex; gap: 6px; margin-top: 8px; }
.ref-item-editing {
  border: 1px solid var(--c-accent);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--c-surface);
  margin-bottom: 8px;
}

/* ============ MODAL ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close {
  font-size: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
}
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
}
.quiz-option--correct { background: #d1fae5; border-color: #10b981; color: #065f46; }
.quiz-option--wrong   { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
.quiz-option:disabled { cursor: default; opacity: 1; }

#picker-list {
  flex: 1;
  overflow-y: auto;
  margin: 12px -8px;
}
.picker-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.picker-item:hover { background: var(--c-surface-2); }
.picker-item.selected { background: var(--c-info-bg); }
.picker-item-id { font-size: 11px; color: var(--c-text-faint); min-width: 38px; }
.picker-item input[type="checkbox"] { width: auto; margin: 0; }

/* picker as inline list inside plan form */
.picker {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 4px;
  background: var(--c-bg);
}
.picker-cat-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-text-faint);
  padding: 8px 10px 4px;
  font-weight: 500;
}

/* ============ WAYPOINTS ============ */
.waypoints-section { margin-bottom: 16px; }
.waypoint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  position: relative;
}
.waypoint-input { flex: 1; }
.waypoint-remove {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--c-text-muted);
  padding: 0;
}
.waypoint-remove:hover { background: var(--c-danger-bg); color: var(--c-danger); border-color: var(--c-danger); }
.waypoint-label {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.waypoint-label--start { background: var(--c-success-bg); color: var(--c-success); border: 1px solid var(--c-success); }
.waypoint-label--end   { background: var(--c-info-bg);    color: var(--c-info);    border: 1px solid var(--c-info); }
.waypoint-label--mid   { background: var(--c-surface-2);  color: var(--c-text-faint); border: 1px solid var(--c-border); font-size: 16px; }
.waypoint-drag-handle {
  flex-shrink: 0;
  cursor: grab;
  color: var(--c-text-faint);
  font-size: 16px;
  padding: 0 2px;
  user-select: none;
  line-height: 1;
}
.waypoint-drag-handle:active { cursor: grabbing; }
.waypoint-dragging { opacity: 0.35; }
.waypoint-row--corridor { padding-left: 28px; }
.waypoint-row--corridor .waypoint-label--mid { color: var(--c-text-faint); font-size: 14px; }
.waypoint-row--corridor-group { padding-left: 28px; align-items: center; }
.corridor-group-label { flex: 1; font-size: 13px; color: var(--c-text-muted); font-style: italic; }
.geocode-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 40px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}
.geocode-result {
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--c-border);
  line-height: 1.3;
}
.geocode-result:last-child { border-bottom: none; }
.geocode-result:hover { background: var(--c-info-bg); }

.wp-option--selected {
  border-color: var(--c-accent) !important;
  background: color-mix(in srgb, var(--c-accent) 10%, var(--c-bg)) !important;
}
.wp-option:hover { background: var(--c-surface-2) !important; }
.waypoint-marker {
  width: 24px;
  height: 24px;
  background: var(--c-warn);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  cursor: default;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-text);
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ============ HISTORY ============ */
.history-row {
  cursor: pointer;
}
.history-detail-map {
  width: 100%;
  height: 320px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
  margin-bottom: 16px;
}

/* ============ DASHBOARD PERIOD FILTER + QUIZ RESULTS ============ */
.section-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.section-header-row .section-h { margin-bottom: 8px; }

.period-select {
  font-size: 13px;
  padding: 3px 8px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: var(--c-bg);
  color: var(--c-text-muted);
  width: auto;
  flex-shrink: 0;
}

.quiz-overall {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--c-border);
  border-radius: 8px 8px 0 0;
  background: var(--c-surface);
}
.quiz-overall-pct { font-size: 28px; font-weight: 500; }
.quiz-overall-label { font-size: 13px; color: var(--c-text-muted); }

.quiz-categories {
  border: 1px solid var(--c-border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  margin-bottom: 24px;
}
.quiz-cat-row {
  display: grid;
  grid-template-columns: 1fr 90px 44px;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--c-border);
  font-size: 13px;
}
.quiz-cat-row:last-child { border-bottom: none; }
.quiz-cat-name { color: var(--c-text); }
.quiz-cat-bar-wrap { background: var(--c-border); border-radius: 3px; height: 8px; }
.quiz-cat-bar { background: var(--c-accent); border-radius: 3px; height: 8px; min-width: 4px; }
.quiz-cat-pct { text-align: right; font-weight: 500; }

/* ============ QUICK QUIZ ============ */
.quiz-session-summary {
  font-size: 13px;
  color: var(--c-text-muted);
  text-align: center;
  margin: 8px 0 0;
}
