/* ============================================================
   TO Easy Ferry — Styles
   Mobile-first, single-page app layout
   ============================================================ */

:root {
  --primary:        #0d3b6e;
  --primary-light:  #1565c0;
  --accent:         #f0a500;
  --bg:             #eef2f7;
  --card:           #ffffff;
  --text:           #1a2733;
  --text-muted:     #64748b;
  --border:         #e2e8f0;

  --color-ward:     #1565c0;
  --color-hanlan:   #2e7d32;
  --color-centre:   #e65100;

  --radius-sm:  8px;
  --radius:     14px;
  --shadow:     0 2px 10px rgba(0, 0, 0, 0.08);
  --shadow-lg:  0 4px 20px rgba(0, 0, 0, 0.12);

  --header-h:  58px;
  --nav-h:     62px;
}

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

html { height: 100%; }

body {
  height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a { color: var(--primary-light); }
button { font-family: inherit; }

/* ===== Offline Banner ===== */
.offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: #d97706;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 1rem;
  flex-shrink: 0;
}
.offline-banner svg { width: 14px; height: 14px; flex-shrink: 0; }
body.is-offline .offline-banner { display: flex; }

/* ===== Header ===== */
.app-header {
  flex-shrink: 0;
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  position: relative;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
}

.header-brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.accent { color: var(--accent); }

.header-time {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

/* ===== Main + Panels ===== */
.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.tab-panel.active {
  opacity: 1;
  pointer-events: auto;
}

.panel-scroll {
  padding: 1rem 1rem calc(var(--nav-h) + 1.25rem + env(safe-area-inset-bottom));
}

/* ===== Direction Toggle (Next tab) ===== */
.direction-toggle {
  display: flex;
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.dir-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s;
}

.dir-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.dir-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* ===== Route Card (Next tab) ===== */
.route-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.route-card-header {
  padding: 0.9rem 1rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.route-card-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
}

.route-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.route-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 2px 9px;
  border-radius: 100px;
  text-transform: uppercase;
}

.route-badge.open     { background: #dcfce7; color: #166534; }
.route-badge.seasonal { background: #fef3c7; color: #92400e; }
.route-badge.done     { background: #f1f5f9; color: #64748b; }

.route-card-body {
  padding: 0.4rem 1rem 1rem;
}

.departure-main {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
}

.departure-countdown {
  font-size: 2.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1.5px;
  line-height: 1.1;
}

.departure-countdown.urgent { color: #dc2626; }
.departure-countdown.soon   { color: #d97706; }
.departure-countdown.ok     { color: #16a34a; }
.departure-countdown.board  { color: var(--primary-light); }

.departure-time {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.upcoming-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.upcoming-chip {
  background: var(--bg);
  border-radius: 100px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.no-service-msg {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  padding: 0.5rem 0 0.25rem;
}

/* ===== Schedule Tab ===== */

/* Controls (route + direction) stay fixed at top; only the list scrolls */
#panel-schedule {
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
}

.sched-controls {
  flex-shrink: 0;
  padding: 0.75rem 1rem 0.5rem;
  background: var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  z-index: 2;
}

#panel-schedule .panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding-top: 0.75rem;
}

.route-selector {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.route-tab {
  flex: 1;
  padding: 0.55rem 0.4rem;
  border: 2px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.route-tab[data-route="ward"].active   { border-color: var(--color-ward);   background: var(--color-ward);   color: #fff; }
.route-tab[data-route="hanlan"].active { border-color: var(--color-hanlan); background: var(--color-hanlan); color: #fff; }
.route-tab[data-route="centre"].active { border-color: var(--color-centre); background: var(--color-centre); color: #fff; }

.sched-dir-selector {
  display: flex;
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow);
  gap: 2px;
  margin-bottom: 0.75rem;
}

.sched-dir-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s;
}

.sched-dir-btn svg { width: 16px; height: 16px; }

.sched-dir-btn.active {
  background: var(--primary);
  color: #fff;
}

.schedule-list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.schedule-item {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.schedule-item:last-child { border-bottom: none; }

.schedule-item.past { opacity: 0.38; }

.schedule-item.is-next {
  background: #fff9e6;
}

.schedule-item.is-next .s-time {
  font-weight: 700;
  color: #d97706;
}

.s-num {
  width: 1.6rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.s-time {
  font-size: 1.05rem;
  font-weight: 500;
  flex: 1;
}

.s-next-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #d97706;
  background: #fef3c7;
  padding: 2px 9px;
  border-radius: 100px;
}

.seasonal-notice {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 1rem;
  color: #92400e;
  font-size: 0.9rem;
  line-height: 1.5;
}

.seasonal-notice strong { display: block; margin-bottom: 0.25rem; }

/* ===== Info Tab ===== */
.info-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.info-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.info-card-year {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.fare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.fare-table th {
  text-align: left;
  padding: 0.3rem 0.4rem;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.fare-table th:not(:first-child),
.fare-table td:not(:first-child) { text-align: right; }

.fare-table td {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--bg);
  line-height: 1.4;
}

.fare-table tr:last-child td { border-bottom: none; }
.fare-table td small { color: var(--text-muted); font-size: 0.78rem; }
.fare-table .free { color: #16a34a; font-weight: 600; }

.info-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  line-height: 1.5;
}

.terminal-info { display: flex; flex-direction: column; gap: 0.85rem; }

.info-row { display: flex; gap: 0.75rem; align-items: flex-start; }

.info-icon {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--primary-light);
}

.info-icon svg { width: 18px; height: 18px; display: block; }

.info-row > div {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
}

.info-row > div strong { color: var(--primary); }

.routes-info { display: flex; flex-direction: column; gap: 0.6rem; }

.route-info-item {
  padding: 0.7rem 0.75rem;
  border-left: 4px solid var(--route-color);
  background: var(--bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

.route-info-item strong { display: block; margin-bottom: 0.2rem; color: var(--text); }
.route-info-item p      { color: var(--text-muted); }
.route-info-item .route-meta { font-size: 0.8rem; margin-top: 0.2rem; }

/* ===== Install Button ===== */
.install-wrap {
  margin-bottom: 0.75rem;
}

.install-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.15s, opacity 0.15s;
}

.install-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.install-btn:not(:disabled):active { background: var(--primary-light); }

.install-btn:disabled {
  background: var(--text-muted);
  opacity: 0.55;
  cursor: default;
}

.info-disclaimer {
  text-align: center;
  padding: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== Alerts ===== */
.alert {
  padding: 0.8rem 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
}

.alert.warning { background: #fef3c7; border-left: 4px solid #f59e0b; color: #78350f; }
.alert.info    { background: #dbeafe; border-left: 4px solid #3b82f6; color: #1e3a8a; }
.alert.danger  { background: #fee2e2; border-left: 4px solid #ef4444; color: #7f1d1d; }

.alert-title { font-weight: 700; margin-bottom: 0.2rem; }

/* ===== Schedule Note ===== */
.schedule-note {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 1rem;
  line-height: 1.5;
}

/* ===== Bottom Tab Nav ===== */
.tab-nav {
  flex-shrink: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.07);
  position: relative;
  z-index: 10;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0.55rem 0.5rem;
  min-height: var(--nav-h);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
  position: relative;
}

.tab-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 24px;
  height: 2px;
  background: var(--primary);
  border-radius: 0 0 2px 2px;
  transition: transform 0.18s ease;
}

.tab-btn.active { color: var(--primary); }
.tab-btn.active::after { transform: translateX(-50%) scaleX(1); }

.tab-icon { display: block; }
.tab-icon svg { width: 1.3rem; height: 1.3rem; display: block; }
.tab-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.2px; }

/* ===== No-schedule empty state ===== */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
