/* ============================================================
   Shared Styles — responsive, WCAG-oriented
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* --- Navigation --- */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand a {
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.nav-links a {
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.nav-links a:hover, .nav-links a:focus {
  background: var(--bg);
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 0.625rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  text-align: center;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--secondary);
  color: white;
}
.btn-secondary:hover { background: #475569; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Views --- */
.view { display: none; padding: 2rem; max-width: 900px; margin: 0 auto; }
.view.active { display: block; }

/* --- Hero --- */
.hero {
  text-align: center;
  padding: 2rem 0;
}
.hero h1 {
  font-size: 2rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.subtitle { color: var(--text-light); }

/* --- Forms --- */
.search-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
  background: var(--card-bg);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-light);
}

input, select, textarea {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: white;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

/* --- AI Search --- */
.ai-search {
  margin-top: 1.5rem;
}
.ai-search summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  padding: 0.5rem;
}
.ai-search-input {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.ai-search-input input { flex: 1; }
.ai-results {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* --- Trip List --- */
.trip-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.trip-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.trip-card:hover { box-shadow: var(--shadow-lg); }
.trip-card:focus-visible { outline: 2px solid var(--primary); }

.trip-info h3 { color: var(--primary); margin-bottom: 0.25rem; }
.trip-meta { display: flex; gap: 1.5rem; color: var(--text-light); font-size: 0.875rem; }
.trip-fare { text-align: right; }
.trip-fare .price { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.trip-fare .seats { font-size: 0.875rem; color: var(--text-light); }

/* --- Seat Map --- */
.seat-map {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.seat-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.seat-row .aisle { width: 2rem; }

.seat {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 6px 6px 2px 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.seat:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.seat.available {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}
.seat.available:hover { background: #bbf7d0; }

.seat.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary-dark);
}

.seat.held {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
  cursor: not-allowed;
}

.seat.booked {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
  cursor: not-allowed;
}

.seat.unavailable {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}

.seat-legend {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-item .seat {
  width: 1.5rem;
  height: 1.5rem;
  cursor: default;
}

/* --- Booking Summary --- */
.booking-summary {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin: 1rem 0;
}

.booking-summary h3 { margin-bottom: 0.5rem; }
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.summary-row:last-child { border-bottom: none; font-weight: 700; }

/* --- Ticket List --- */
.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ticket-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.ticket-card.cancelled { border-left-color: var(--danger); }

.ticket-card h3 { color: var(--primary); margin-bottom: 0.5rem; }
.ticket-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; color: var(--text-light); font-size: 0.875rem; }
.ticket-actions { margin-top: 1rem; display: flex; gap: 0.5rem; }

/* --- Banners --- */
.error-banner {
  background: #fee2e2;
  color: #991b1b;
  padding: 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
}

.success-banner {
  background: #dcfce7;
  color: #166534;
  padding: 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
}

/* --- Modal --- */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: var(--radius);
  max-width: 520px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-content h2 { margin-bottom: 1rem; }
.modal-content form { display: flex; flex-direction: column; gap: 1rem; }
.modal-content .form-group { margin-bottom: 0; }
.modal-content select { width: 100%; }
.modal-footer { margin-top: 1rem; text-align: center; font-size: 0.875rem; }

/* --- Tables (admin/operator) --- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th { background: var(--bg); font-weight: 600; color: var(--text-light); font-size: 0.875rem; }
tr:hover { background: var(--bg); }

/* --- Utilities --- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .navbar { padding: 0.75rem 1rem; }
  .nav-links { gap: 0.5rem; }
  .nav-links a { padding: 0.375rem 0.5rem; font-size: 0.875rem; }

  .search-form {
    grid-template-columns: 1fr;
  }

  .trip-card {
    grid-template-columns: 1fr;
  }
  .trip-fare { text-align: left; }

  .seat { width: 2rem; height: 2rem; font-size: 0.65rem; }

  .ticket-meta { grid-template-columns: 1fr; }

  table { font-size: 0.875rem; }
  th, td { padding: 0.5rem; }
}

@media (max-width: 480px) {
  .seat { width: 1.75rem; height: 1.75rem; font-size: 0.55rem; }
  .seat-row .aisle { width: 1rem; }
}

/* --- Print --- */
@media print {
  .navbar, .nav-links, .btn { display: none !important; }
  .view { display: block !important; }
  body { background: white; }
}

/* --- High contrast mode --- */
@media (prefers-contrast: high) {
  :root {
    --border: #000;
    --text-light: #333;
  }
  .btn { border: 2px solid currentColor; }
}
