/* ============================================
   CareRide Design System
   Premium Dark Mode Interface
   ============================================ */

:root {
  /* Color Palette */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2035;
  --bg-card-hover: #1f2847;
  --bg-input: #0f1629;
  --bg-overlay: rgba(0, 0, 0, 0.6);

  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-primary-glow: rgba(99, 102, 241, 0.3);
  --accent-success: #10b981;
  --accent-success-glow: rgba(16, 185, 129, 0.2);
  --accent-warning: #f59e0b;
  --accent-warning-glow: rgba(245, 158, 11, 0.2);
  --accent-danger: #ef4444;
  --accent-danger-glow: rgba(239, 68, 68, 0.2);
  --accent-info: #3b82f6;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0a0e1a;

  --border-color: rgba(148, 163, 184, 0.1);
  --border-active: rgba(99, 102, 241, 0.5);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-primary-glow);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Font */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* ============================================
   Layout
   ============================================ */
#app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-primary), #a855f7);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px var(--accent-primary-glow);
}

.sidebar-logo h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #f1f5f9, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.1));
  color: var(--accent-primary-hover);
  border: 1px solid var(--border-active);
}

.nav-item .nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--accent-danger);
  color: white;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-color);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-primary), #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
}

.user-details { flex: 1; }
.user-details .user-name { font-size: 0.85rem; font-weight: 600; }
.user-details .user-role { font-size: 0.7rem; color: var(--text-muted); }

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: var(--space-xl);
  min-height: 100vh;
}

.page-header {
  margin-bottom: var(--space-xl);
}

.page-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-normal);
}

.card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-glow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--stat-color, var(--accent-primary)), transparent);
}

.stat-card .stat-icon {
  font-size: 1.4rem;
  margin-bottom: var(--space-sm);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #7c3aed);
  color: white;
  box-shadow: 0 2px 10px var(--accent-primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-primary-hover), #8b5cf6);
  box-shadow: 0 4px 20px var(--accent-primary-glow);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--accent-success);
  color: white;
}

.btn-success:hover {
  background: #059669;
  box-shadow: 0 4px 20px var(--accent-success-glow);
}

.btn-danger {
  background: var(--accent-danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 20px var(--accent-danger-glow);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary-hover);
  background: rgba(99, 102, 241, 0.05);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.78rem;
}

.btn-lg {
  padding: var(--space-md) var(--space-lg);
  font-size: 1rem;
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-textarea { min-height: 80px; resize: vertical; }

/* ============================================
   Table
   ============================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* ============================================
   Status Badges
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-pending { background: rgba(245, 158, 11, 0.15); color: var(--accent-warning); }
.badge-requesting { background: rgba(59, 130, 246, 0.15); color: var(--accent-info); }
.badge-confirmed { background: rgba(16, 185, 129, 0.15); color: var(--accent-success); }
.badge-in_progress { background: rgba(99, 102, 241, 0.15); color: var(--accent-primary); }
.badge-completed { background: rgba(16, 185, 129, 0.25); color: #34d399; }
.badge-cancelled { background: rgba(239, 68, 68, 0.15); color: var(--accent-danger); }
.badge-accepted { background: rgba(16, 185, 129, 0.15); color: var(--accent-success); }
.badge-declined { background: rgba(239, 68, 68, 0.15); color: var(--accent-danger); }

/* ============================================
   Calendar
   ============================================ */
.calendar-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.calendar-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.calendar-nav { display: flex; gap: var(--space-sm); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar-day-header {
  padding: var(--space-sm);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
}

.calendar-day {
  min-height: 100px;
  padding: var(--space-xs);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.calendar-day:nth-child(7n) { border-right: none; }

.calendar-day:hover { background: var(--bg-card-hover); }

.calendar-day .day-number {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  padding: 2px 6px;
}

.calendar-day.today .day-number {
  background: var(--accent-primary);
  color: white;
  border-radius: var(--radius-full);
  display: inline-block;
}

.calendar-day.other-month { opacity: 0.3; }

.calendar-event {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.calendar-event.status-pending { background: rgba(245, 158, 11, 0.2); color: var(--accent-warning); border-left: 3px solid var(--accent-warning); }
.calendar-event.status-requesting { background: rgba(59, 130, 246, 0.2); color: var(--accent-info); border-left: 3px solid var(--accent-info); }
.calendar-event.status-confirmed { background: rgba(16, 185, 129, 0.2); color: var(--accent-success); border-left: 3px solid var(--accent-success); }
.calendar-event.status-in_progress { background: rgba(99, 102, 241, 0.2); color: var(--accent-primary); border-left: 3px solid var(--accent-primary); }
.calendar-event.status-completed { background: rgba(16, 185, 129, 0.3); color: #34d399; border-left: 3px solid #34d399; }
.calendar-event.status-cancelled { background: rgba(239, 68, 68, 0.2); color: var(--accent-danger); border-left: 3px solid var(--accent-danger); }

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: var(--space-lg); }
.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ============================================
   Login Page
   ============================================ */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #1a1f3a 0%, var(--bg-primary) 70%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-card .logo-container {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.login-card .logo-icon-lg {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent-primary), #a855f7);
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: var(--space-md);
  box-shadow: 0 0 30px var(--accent-primary-glow);
}

.login-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--space-xs);
}

.login-card .login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: var(--space-xl);
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-danger);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: var(--space-md);
  display: none;
}

/* ============================================
   Ride Detail
   ============================================ */
.ride-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.ride-info-item {
  padding: var(--space-sm) 0;
}

.ride-info-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.ride-info-value {
  font-size: 0.95rem;
  font-weight: 500;
}

.ride-route {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

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

.ride-route .route-dot.pickup { background: var(--accent-success); box-shadow: 0 0 8px var(--accent-success-glow); }
.ride-route .route-dot.dropoff { background: var(--accent-danger); box-shadow: 0 0 8px var(--accent-danger-glow); }
.ride-route .route-line {
  width: 2px;
  height: 30px;
  background: var(--border-color);
  margin: 0 4px;
}

.driver-response-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.driver-response-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border-radius: var(--radius-md);
}

.driver-response-item .driver-name { flex: 1; font-weight: 500; font-size: 0.9rem; }

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  min-width: 300px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  animation: slideIn 0.3s ease forwards;
}

.toast.toast-exit { animation: slideOut 0.3s ease forwards; }

.toast-icon { font-size: 1.2rem; }
.toast-message { flex: 1; font-size: 0.85rem; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* ============================================
   Loading Spinner
   ============================================ */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg { width: 40px; height: 40px; }
.loading-center { display: flex; justify-content: center; padding: var(--space-2xl); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .ride-detail-grid { grid-template-columns: 1fr; }
  .calendar-day { min-height: 60px; }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in { animation: fadeIn 0.4s ease forwards; }
