/* =====================================================
   assets/css/main.css — School Bus Tracker
   Dark Theme, Responsive, Mobile-First
   ===================================================== */

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

:root {
  --accent: #22d3ee;
  --accent2: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #0f172a;
  --card: #1e293b;
  --card2: #263548;
  --border: #334155;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --font: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
}

html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== TYPOGRAPHY ===== */
h1 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 700; line-height: 1.2; }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { color: var(--text2); font-size: 0.95rem; }
a { color: var(--accent); text-decoration: none; }

/* ===== LAYOUT ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.page-wrap { min-height: 100vh; display: flex; flex-direction: column; }

/* ===== NAVBAR ===== */
.navbar {
  background: rgba(30,41,59,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.navbar-brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 700; font-size: 1.1rem; color: var(--text);
}
.navbar-brand .bus-icon {
  width: 36px; height: 36px; background: var(--accent);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.navbar-right { display: flex; align-items: center; gap: 0.75rem; }
.badge-role {
  background: rgba(34,211,238,0.15); color: var(--accent);
  border: 1px solid rgba(34,211,238,0.3);
  padding: 0.2rem 0.7rem; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-role.driver { background: rgba(245,158,11,0.15); color: var(--warning); border-color: rgba(245,158,11,0.3); }
.badge-role.owner  { background: rgba(167,139,250,0.15); color: #a78bfa; border-color: rgba(167,139,250,0.3); }

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent);
}
.stat-card.warning::before { background: var(--warning); }
.stat-card.success::before { background: var(--success); }
.stat-card.danger::before  { background: var(--danger); }
.stat-value { font-size: 2rem; font-weight: 700; font-family: var(--mono); color: var(--text); }
.stat-label { font-size: 0.8rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 0.25rem; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: none; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: #0f172a;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-danger  { background: var(--danger); color: white; }
.btn-danger:hover  { filter: brightness(1.1); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(1.1); }
.btn-warning { background: var(--warning); color: #0f172a; }
.btn-outline {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: rgba(34,211,238,0.08); }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 1rem; border-radius: var(--radius); }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ===== BIG ACTION BUTTON (Driver) ===== */
.trip-btn {
  width: 160px; height: 160px;
  border-radius: 50%; border: none;
  font-family: var(--font); font-size: 1.1rem; font-weight: 700;
  cursor: pointer; transition: all 0.3s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.5rem; margin: 0 auto; box-shadow: 0 0 0 0 rgba(34,211,238,0.4);
}
.trip-btn.start {
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: #0f172a; animation: pulse-ring 2s infinite;
}
.trip-btn.stop {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white; animation: pulse-ring-red 2s infinite;
}
.trip-btn .btn-icon { font-size: 2.5rem; line-height: 1; }

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(34,211,238,0.4); }
  70%  { box-shadow: 0 0 0 20px rgba(34,211,238,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,211,238,0); }
}
@keyframes pulse-ring-red {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  70%  { box-shadow: 0 0 0 20px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text2); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.04em; }
.form-control {
  width: 100%; padding: 0.75rem 1rem;
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font); font-size: 0.95rem;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control::placeholder { color: var(--text3); }
select.form-control { cursor: pointer; }

/* ===== MAP ===== */
#map, #owner-map, #parent-map {
  width: 100%; border-radius: var(--radius);
  border: 1px solid var(--border);
  z-index: 1;
}
.leaflet-container { background: #0f1923; font-family: var(--font); }
.leaflet-popup-content-wrapper {
  background: var(--card2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.leaflet-popup-tip { background: var(--card2); }

/* ===== STATUS BADGES ===== */
.status {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.65rem; border-radius: 20px;
  font-size: 0.78rem; font-weight: 600;
}
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-live    { background: rgba(34,197,94,0.15); color: var(--success); }
.status-offline { background: rgba(100,116,139,0.15); color: var(--text3); }
.status-alert   { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-live::before { animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ===== INFO ROW ===== */
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 0; border-bottom: 1px solid var(--border);
  gap: 1rem; flex-wrap: wrap;
}
.info-row:last-child { border-bottom: none; }
.info-key { font-size: 0.82rem; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; flex-shrink: 0; }
.info-val { font-size: 0.95rem; color: var(--text); font-family: var(--mono); font-weight: 600; text-align: right; }

/* ===== SPEEDOMETER ===== */
.speedometer {
  display: flex; align-items: center; justify-content: center;
  gap: 0.4rem; font-family: var(--mono);
}
.speed-val { font-size: 2.2rem; font-weight: 700; color: var(--accent); }
.speed-unit { font-size: 0.85rem; color: var(--text3); padding-top: 1rem; }

/* ===== STOPPAGE LIST ===== */
.stop-list { list-style: none; padding: 0; }
.stop-item {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.75rem 0; border-bottom: 1px solid var(--border);
  position: relative;
}
.stop-item:last-child { border-bottom: none; }
.stop-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--border); flex-shrink: 0;
  border: 2px solid var(--text3);
}
.stop-dot.passed { background: var(--success); border-color: var(--success); }
.stop-dot.current { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(34,211,238,0.2); animation: blink 1s infinite; }
.stop-dot.next { background: var(--warning); border-color: var(--warning); }
.stop-name { font-size: 0.9rem; color: var(--text); flex: 1; }
.stop-eta { font-size: 0.8rem; color: var(--text3); font-family: var(--mono); }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at top, #1e293b 0%, #0f172a 60%);
}
.login-box {
  width: 100%; max-width: 420px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.5rem; box-shadow: var(--shadow);
}
.login-logo {
  text-align: center; margin-bottom: 2rem;
}
.login-logo .icon-wrap {
  width: 64px; height: 64px; background: var(--accent);
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; margin: 0 auto 1rem;
}
.login-logo h1 { font-size: 1.4rem; }
.login-logo p  { font-size: 0.85rem; color: var(--text3); }

/* ===== ALERT BOX ===== */
.alert {
  padding: 0.8rem 1rem; border-radius: var(--radius-sm);
  font-size: 0.9rem; margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: 0.5rem;
}
.alert-error   { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.alert-info    { background: rgba(34,211,238,0.10); border: 1px solid rgba(34,211,238,0.25); color: #67e8f9; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  background: var(--bg2); padding: 0.75rem 1rem;
  text-align: left; font-size: 0.78rem; font-weight: 600;
  color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 0.75rem 1rem; border-bottom: 1px solid rgba(51,65,85,0.5); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ===== GPS SIGNAL INDICATOR ===== */
.gps-indicator {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.82rem; color: var(--text3);
}
.gps-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text3); flex-shrink: 0;
}
.gps-dot.active { background: var(--success); animation: blink 1s infinite; }

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap;
}
.section-header h2 { font-size: 1.1rem; color: var(--text2); font-weight: 600; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  background: var(--card2); border: 1px solid var(--border);
  padding: 0.85rem 1.25rem; border-radius: var(--radius-sm);
  font-size: 0.88rem; max-width: 320px; box-shadow: var(--shadow);
  animation: slideIn 0.3s ease; display: flex; gap: 0.5rem; align-items: flex-start;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .navbar-brand span { display: none; }
  .card { padding: 1rem; }
  .login-box { padding: 1.5rem; }
  .trip-btn { width: 140px; height: 140px; }
  .stat-value { font-size: 1.6rem; }
  .card-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 400px) {
  .card-grid { grid-template-columns: 1fr; }
}

/* ===== UTILITY ===== */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.text-accent { color: var(--accent); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text3); }
.font-mono    { font-family: var(--mono); }
.hidden { display: none !important; }
