/* ═══════════════════════════════════════
   TRAVEL WALLET — CSS
   Dark-first, mobile-first, no frameworks
═══════════════════════════════════════ */

:root {
  --bg-0: #0f172a;
  --bg-1: #1e293b;
  --bg-2: #334155;
  --bg-3: #475569;
  --text-1: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --accent: #3b82f6;
  --accent-dim: rgba(59,130,246,0.15);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: rgba(255,255,255,0.08);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --header-h: 56px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  /* transport colors */
  --train: #3b82f6;
  --plane: #8b5cf6;
  --bus: #6b7280;
  --car: #ec4899;
  --bike: #f59e0b;
  --walk: #10b981;
  --metro: #14b8a6;
  --ferry: #0ea5e9;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-0: #f8fafc;
    --bg-1: #ffffff;
    --bg-2: #e2e8f0;
    --bg-3: #cbd5e1;
    --text-1: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    --border: rgba(0,0,0,0.08);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-0);
  color: var(--text-1);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bot);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ── HEADER ── */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  background: var(--bg-0);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
  position: relative;
}
.header-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.3px;
}
.icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text-1); }

/* ── MAIN ── */
#main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  padding-bottom: 80px;
}
.view.active {
  opacity: 1;
  pointer-events: all;
  transform: translateX(0);
}
.view.slide-out {
  opacity: 0;
  transform: translateX(-20px);
}

/* ── HERO ── */
.view-hero {
  padding: 28px 20px 16px;
}
.hero-sub {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.hero-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.5px;
}

/* ── TRIP CARDS ── */
.trips-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trip-card {
  background: var(--bg-1);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.trip-card:active { transform: scale(0.98); }
.trip-card-accent {
  height: 4px;
  background: var(--accent);
}
.trip-card-body {
  padding: 16px 18px;
}
.trip-card-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}
.trip-card-meta {
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.trip-card-meta i { font-size: 14px; }
.trip-card-segments {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 18px 14px;
  flex-wrap: wrap;
}
.seg-icon-mini {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.seg-arrow { color: var(--text-3); font-size: 12px; }
.trip-card-actions {
  position: absolute;
  top: 14px; right: 14px;
  display: flex; gap: 4px;
}
.trip-action-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: none;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.trip-card:hover .trip-action-btn { opacity: 1; }
.trip-action-btn:hover { background: var(--bg-3); color: var(--text-1); }

/* ── TRIP DETAIL ── */
.trip-header {
  padding: 20px 20px 12px;
}
.trip-detail-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}
.trip-detail-meta {
  font-size: 13px;
  color: var(--text-2);
}

/* ── SEGMENTS ── */
.segments-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
}

.seg-connector {
  width: 2px;
  height: 20px;
  background: var(--border);
  margin-left: 31px;
}

.segment-card {
  background: var(--bg-1);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
}
.segment-card:active { transform: scale(0.99); }

.seg-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.seg-type-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  color: white;
}
.seg-info { flex: 1; min-width: 0; }
.seg-route {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg-company {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 1px;
}
.seg-times-col {
  text-align: right;
  flex-shrink: 0;
}
.seg-time-dep {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}
.seg-time-arr {
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.seg-times-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 12px;
  margin-left: 48px;
}
.seg-time-label { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.seg-line { flex: 1; height: 1px; background: var(--border); }
.seg-duration { font-size: 11px; color: var(--text-3); white-space: nowrap; }

.seg-body-collapsed {
  padding: 0 16px 12px;
  margin-left: 48px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.seg-badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--bg-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.seg-badge i { font-size: 12px; }
.seg-badge.accent { background: var(--accent-dim); color: var(--accent); }

/* transport colors */
.ic-train { background: var(--train); }
.ic-plane { background: var(--plane); }
.ic-bus   { background: var(--bus); }
.ic-car   { background: var(--car); }
.ic-bike  { background: var(--bike); }
.ic-walk  { background: var(--walk); }
.ic-metro { background: var(--metro); }
.ic-ferry { background: var(--ferry); }
.color-train { color: var(--train); }
.color-plane { color: var(--plane); }
.color-bus   { color: var(--bus); }
.color-car   { color: var(--car); }
.color-bike  { color: var(--bike); }
.color-walk  { color: var(--walk); }
.color-metro { color: var(--metro); }
.color-ferry { color: var(--ferry); }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px + var(--safe-bot));
  right: max(16px, calc(50% - 240px + 16px));
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(59,130,246,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 20;
}
.fab:active { transform: scale(0.93); box-shadow: 0 2px 8px rgba(59,130,246,0.3); }

/* ── BOTTOM NAV ── */
.bottom-nav {
  height: var(--nav-h);
  display: flex;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 10px;
  font-family: var(--font);
  cursor: pointer;
  transition: color 0.15s;
  padding: 6px 0;
}
.nav-item i { font-size: 22px; }
.nav-item.active { color: var(--accent); }
.nav-item span { font-size: 10px; font-weight: 500; }

/* ── FORMS ── */
.form-container {
  padding: 20px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.form-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.3px;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field-input {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 15px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  width: 100%;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: var(--text-3); }
.field-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

.fields-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.transport-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.tp-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-1);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.tp-btn i { font-size: 20px; }
.tp-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.tp-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.doc-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-1);
  cursor: pointer;
  padding: 4px 0;
}
.doc-check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Dynamic transport fields */
.detail-field {
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.detail-row-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}
.btn-primary, .btn-secondary, .btn-danger {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--bg-2); color: var(--text-1); }
.btn-secondary:hover { background: var(--bg-3); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }

/* ── MODAL ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.modal {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  width: 100%;
  max-width: 480px;
  background: var(--bg-1);
  border-radius: 24px 24px 0 0;
  z-index: 50;
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--border);
}
.modal::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  margin: 10px auto 0;
}
.modal-header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  gap: 10px;
}
.modal-header h3 {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-1);
}
.modal-body {
  padding: 0 20px 20px;
}
.modal-footer {
  display: flex;
  gap: 10px;
  padding: 0 20px 20px;
}

/* ── MODAL DETAIL ROWS ── */
.modal-seg-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  margin: 0 -20px;
  background: var(--bg-2);
  margin-bottom: 16px;
}
.modal-seg-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  color: white;
  flex-shrink: 0;
}
.modal-seg-route { font-size: 16px; font-weight: 600; color: var(--text-1); }
.modal-seg-company { font-size: 13px; color: var(--text-2); margin-top: 2px; }

.modal-times {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--bg-2);
  border-radius: var(--radius-md);
}
.modal-time-block { text-align: center; }
.modal-time-h { font-size: 22px; font-weight: 700; color: var(--text-1); font-variant-numeric: tabular-nums; }
.modal-time-city { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.modal-time-line { flex: 1; height: 1px; background: var(--border); }
.modal-duration { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.detail-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.detail-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
}
.detail-item-icon { font-size: 18px; color: var(--text-2); flex-shrink: 0; margin-top: 1px; }
.detail-item-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; }
.detail-item-val { font-size: 14px; color: var(--text-1); font-weight: 500; margin-top: 2px; }

.docs-title { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.docs-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.doc-pill {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 5px 10px;
  border-radius: 20px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.2);
}
.doc-pill i { font-size: 13px; }

.notes-box {
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  white-space: pre-wrap;
  margin-bottom: 16px;
}

/* ── SETTINGS ── */
.settings-section { margin-bottom: 20px; }
.settings-title { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.settings-btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.15s;
}
.settings-btn i { font-size: 18px; color: var(--text-2); }
.settings-btn:hover { background: var(--bg-3); }
.settings-btn.danger { color: var(--danger); }
.settings-btn.danger i { color: var(--danger); }
.settings-info-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.settings-info-row i { font-size: 16px; }

/* ── DOCS OVERVIEW ── */
.docs-trip-section { margin-bottom: 20px; }
.docs-trip-name { font-size: 15px; font-weight: 600; color: var(--text-1); margin-bottom: 10px; }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 32px;
  text-align: center;
  gap: 8px;
}
.empty-icon {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-1); }
.empty-sub { font-size: 13px; color: var(--text-2); line-height: 1.5; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--bg-2);
  color: var(--text-1);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  z-index: 100;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 40px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── INSTALL BANNER ── */
.install-banner {
  position: fixed;
  top: calc(var(--safe-top) + var(--header-h));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  z-index: 30;
  box-shadow: 0 4px 20px rgba(59,130,246,0.4);
}
.install-banner span { flex: 1; font-weight: 500; }
.install-banner button {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  padding: 5px 12px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
#install-close {
  background: none;
  border: none;
  font-size: 18px;
  padding: 2px 6px;
}

/* ── OFFLINE BAR ── */
.offline-bar {
  background: var(--warning);
  color: #000;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ── UTILS ── */
.hidden { display: none !important; }
