:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;
  --border-color: #334155;
  --radius: 12px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header & Nav */
.navbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
  color: #fff;
  text-decoration: none;
}

.brand-badge {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  gap: 12px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Landing Page Cards */
.hero {
  padding: 40px 20px;
  text-align: center;
  max-width: 900px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(to right, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 30px;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.portal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.portal-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow);
}

.portal-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.portal-card h3 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.portal-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 20px;
  line-height: 1.4;
}

.portal-btn {
  background: var(--accent-blue);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  width: 100%;
}

/* Layout Split Panitia / Admin */
.dashboard-container {
  display: flex;
  height: calc(100vh - 65px);
  position: relative;
  overflow: hidden;
}

.map-container {
  flex: 1;
  position: relative;
  height: 100%;
  background: #000;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 10;
}

.sidebar-panel {
  width: 420px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
}

/* Rider Mobile App Styles */
.rider-app {
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-primary);
  overflow: hidden;
}

.rider-top-bar {
  padding: 14px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rider-status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-ready { background: #334155; color: #cbd5e1; }
.status-racing { background: #065f46; color: #34d399; }
.status-finished { background: #1e3a8a; color: #60a5fa; }
.status-offroute { background: #7f1d1d; color: #f87171; animation: blink 1s infinite alternate; }

@keyframes blink {
  from { opacity: 1; }
  to { opacity: 0.4; }
}

.rider-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-secondary);
}

.metric-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  font-family: monospace;
}

.metric-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 2px;
}

/* Off-Route Emergency Banner */
.off-route-banner {
  display: none;
  background: linear-gradient(135deg, #b91c1c, #ef4444);
  color: white;
  padding: 14px 16px;
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.5);
  animation: pulse-red 1.2s infinite;
  z-index: 100;
}

@keyframes pulse-red {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* Rider Actions Footer */
.rider-footer {
  padding: 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
}

.btn {
  padding: 12px 18px;
  border-radius: 8px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: #2563eb; }

.btn-success { background: var(--accent-green); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-warning { background: var(--accent-yellow); color: #000; }

.btn-block { width: 100%; }

/* Tab Container Panitia */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
}

.tab-content {
  display: none;
  padding: 16px;
}

.tab-content.active {
  display: block;
}

/* Leaderboard Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th, .data-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
}

.rank-badge {
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  border-radius: 50%;
  text-align: center;
  font-weight: 800;
  font-size: 0.8rem;
}

.rank-1 { background: #fbbf24; color: #78350f; }
.rank-2 { background: #94a3b8; color: #0f172a; }
.rank-3 { background: #d97706; color: #fff; }

/* Modal Styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  padding: 24px;
  position: relative;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Map Overlays & Custom Leaflet Marker */
.rider-marker-icon {
  background: #3b82f6;
  border: 2px solid #ffffff;
  color: #fff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
  transition: all 0.3s ease;
}

.rider-marker-offroute {
  background: #ef4444 !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 1) !important;
  animation: pulse-marker 0.8s infinite alternate;
}

.rider-marker-finished {
  background: #10b981 !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.8) !important;
}

@keyframes pulse-marker {
  from { transform: scale(1); }
  to { transform: scale(1.3); }
}

/* Alert Notification List */
.alert-card {
  background: rgba(239, 68, 68, 0.15);
  border-left: 4px solid var(--accent-red);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.alert-card.sos {
  background: rgba(245, 158, 11, 0.2);
  border-left-color: var(--accent-yellow);
}

/* Responsive */
@media (max-width: 900px) {
  .dashboard-container {
    flex-direction: column;
  }
  .sidebar-panel {
    width: 100%;
    height: 45vh;
  }
  .map-container {
    height: 55vh;
  }
}

.leaflet-control-layers {
  background: rgba(15, 23, 42, 0.9) !important;
  color: #fff !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 8px !important;
  padding: 6px 10px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}
.leaflet-control-layers label {
  color: #fff !important;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Custom Centered Dialog Modal */
.app-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.app-dialog-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  max-width: 440px;
  width: 100%;
  padding: 24px;
  text-align: center;
  box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.6), 0 0 20px rgba(6, 182, 212, 0.15);
  animation: scaleUp 0.2s ease-out;
}

@keyframes scaleUp {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.app-dialog-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.app-dialog-title {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.app-dialog-body {
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 22px;
  white-space: pre-line;
}

.app-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Stylish Admin User Badge & Logout Button */
.admin-user-pill {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 9999px;
  padding: 3px 4px 3px 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25), 0 0 10px rgba(56, 189, 248, 0.1);
  gap: 10px;
}

.admin-user-pill .user-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #f1f5f9;
  font-weight: 700;
}

.admin-user-pill .user-avatar {
  font-size: 1rem;
}

.admin-user-pill .user-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px #10b981;
}

.btn-logout-stylish {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-logout-stylish:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
  transform: translateY(-1px);
}

.btn-logout-stylish:active {
  transform: translateY(0);
}

/* User Management Tab Cards */
.admin-user-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.admin-user-card:hover {
  border-color: #38bdf8;
}




