:root {
  --primary: #ff6b35;
  --primary-dark: #e5502a;
  --secondary: #1b2a4a;
  --accent: #2ec4b6;
  --bg: #f6f7fb;
  --card-bg: #ffffff;
  --text: #1b2a4a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(27, 42, 74, 0.08);
}

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- AUTH PAGES ---------- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff6b35 0%, #1b2a4a 100%);
  padding: 20px;
}

.auth-card {
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.brand { text-align: center; margin-bottom: 24px; }
.brand-icon { font-size: 42px; }
.brand h1 { font-size: 28px; color: var(--secondary); margin-top: 4px; }
.brand p { color: var(--muted); font-size: 14px; margin-top: 4px; }

.auth-form h2 { margin-bottom: 18px; font-size: 20px; color: var(--secondary); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--secondary); }
.field input, .field select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  transition: border-color 0.2s;
  background: #fff;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(255,107,53,0.35); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--secondary);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.switch-link { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.hint { text-align: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.error { color: var(--danger); font-size: 13px; margin-bottom: 8px; min-height: 16px; }

/* ---------- NAVBAR ---------- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-brand { font-size: 22px; font-weight: 700; color: var(--secondary); }
.navbar nav { display: flex; align-items: center; gap: 24px; }
.navbar nav a { color: var(--secondary); font-weight: 500; font-size: 14px; }
.navbar nav a.active { color: var(--primary); }
.user-greeting { font-size: 14px; color: var(--muted); }

/* ---------- HERO / SEARCH ---------- */
.hero {
  background: linear-gradient(135deg, #1b2a4a, #2c3e6a);
  color: white;
  text-align: center;
  padding: 50px 20px 90px;
}
.hero h1 { font-size: 32px; margin-bottom: 8px; }
.hero p { color: #c9d1e8; margin-bottom: 30px; }

.search-card {
  background: var(--card-bg);
  max-width: 950px;
  margin: 0 auto;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  gap: 16px;
  align-items: end;
  flex-wrap: wrap;
}
.search-card .field { flex: 1; min-width: 160px; margin-bottom: 0; text-align: left; }
.search-card button { width: auto; padding: 12px 30px; white-space: nowrap; }

/* ---------- RESULTS ---------- */
.results-section {
  max-width: 950px;
  margin: -50px auto 60px;
  padding: 0 20px;
}
.results-section h2 {
  background: var(--card-bg);
  padding: 20px 24px;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  font-size: 18px;
  color: var(--secondary);
}
.bus-list { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }

.bus-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  transition: transform 0.15s;
}
.bus-card:hover { transform: translateY(-3px); }

.bus-info h3 { color: var(--secondary); font-size: 17px; margin-bottom: 4px; }
.bus-info .route { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.bus-tags span {
  display: inline-block;
  background: #f0f2f7;
  color: var(--secondary);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  margin-right: 6px;
}
.bus-time { text-align: center; }
.bus-time .time { font-size: 18px; font-weight: 700; color: var(--secondary); }
.bus-time .label { font-size: 11px; color: var(--muted); }
.bus-price { text-align: right; }
.bus-price .amount { font-size: 20px; font-weight: 700; color: var(--primary); }
.bus-price .seats-left { font-size: 12px; color: var(--accent); margin-bottom: 8px; }
.bus-price button { padding: 10px 24px; width: auto; }

.empty-state { text-align: center; padding: 40px; color: var(--muted); background: var(--card-bg); border-radius: var(--radius); }

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 30px;
  max-width: 480px;
  width: 100%;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; font-size: 24px; cursor: pointer; color: var(--muted);
}
.modal h2 { color: var(--secondary); margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 13px; }

.legend { display: flex; gap: 16px; margin: 16px 0; font-size: 12px; color: var(--muted); }
.legend .dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.dot.available { background: #e5e7eb; }
.dot.selected { background: var(--primary); }
.dot.booked { background: var(--muted); }

.seat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.seat {
  padding: 10px 0;
  text-align: center;
  border-radius: 8px;
  background: #e5e7eb;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  transition: all 0.15s;
  user-select: none;
}
.seat:hover:not(.booked) { background: #d6d9e0; }
.seat.selected { background: var(--primary); color: white; }
.seat.booked { background: var(--muted); color: white; cursor: not-allowed; opacity: 0.6; }

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.modal-footer button { width: auto; padding: 12px 24px; }

/* ---------- BOOKINGS ---------- */
.bookings-section { max-width: 950px; margin: 40px auto; padding: 0 20px; }
.bookings-section h1 { color: var(--secondary); margin-bottom: 20px; }
.bookings-list { display: flex; flex-direction: column; gap: 14px; }

.booking-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.booking-card h3 { color: var(--secondary); margin-bottom: 6px; }
.booking-meta { font-size: 13px; color: var(--muted); line-height: 1.6; }
.booking-status {
  align-self: center;
  background: #dcfce7;
  color: var(--success);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.cancel-btn {
  background: none;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  align-self: center;
}
.cancel-btn:hover { background: var(--danger); color: white; }

.hidden { display: none !important; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--secondary);
  color: white;
  padding: 14px 24px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  z-index: 200;
  font-size: 14px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@media (max-width: 640px) {
  .navbar { padding: 14px 16px; flex-direction: column; gap: 10px; }
  .search-card { flex-direction: column; align-items: stretch; }
  .search-card button { width: 100%; }
  .bus-card { flex-direction: column; align-items: flex-start; }
  .seat-grid { grid-template-columns: repeat(4, 1fr); }
}
