/* On Time Transportation — Main Stylesheet */
/* Clean, high-contrast, large-font design optimized for dispatch readability */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --sidebar-bg: #1B2A4A;
  --sidebar-hover: #243556;
  --sidebar-active: #2d4270;
  --sidebar-text: #c8d6e5;
  --sidebar-text-active: #ffffff;
  --sidebar-width: 240px;

  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #636e72;
  --border: #dfe6e9;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #6366f1;
  --info-bg: #e0e7ff;
  --purple: #8b5cf6;
  --teal: #14b8a6;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 150ms ease;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

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

/* ========== Sidebar ========== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.sidebar-brand small {
  font-size: 0.75rem;
  opacity: 0.6;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--primary);
}

.sidebar-nav .nav-section {
  padding: 16px 20px 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  opacity: 0.5;
  font-weight: 600;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
}

.sidebar-user .user-name {
  color: #fff;
  font-weight: 600;
}

.sidebar-user .user-role {
  opacity: 0.6;
  font-size: 0.75rem;
  text-transform: capitalize;
}

/* ========== Main Content ========== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px 32px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

/* ========== Cards & Panels ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ========== Stats Grid ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card.stat-primary .stat-value { color: var(--primary); }
.stat-card.stat-success .stat-value { color: var(--success); }
.stat-card.stat-warning .stat-value { color: var(--warning); }
.stat-card.stat-danger .stat-value { color: var(--danger); }
.stat-card.stat-info .stat-value { color: var(--info); }

/* ========== Tables ========== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: #f8f9fa;
}

tr:hover td {
  background: #f8f9fa;
}

/* ========== Status Badges ========== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-pending { background: var(--warning-bg); color: #92400e; }
.badge-dispatched { background: var(--info-bg); color: #3730a3; }
.badge-en_route, .badge-en-route { background: #ede9fe; color: #6d28d9; }
.badge-arrived { background: var(--success-bg); color: #065f46; }
.badge-in_progress, .badge-in-progress { background: #ccfbf1; color: #0f766e; }
.badge-completed { background: #e5e7eb; color: #374151; }
.badge-cancelled { background: var(--danger-bg); color: #991b1b; }
.badge-no_show, .badge-no-show { background: #fde8e8; color: #9b2c2c; }

.badge-available { background: var(--success-bg); color: #065f46; }
.badge-on_ride, .badge-on-ride { background: var(--info-bg); color: #3730a3; }
.badge-off_duty, .badge-off-duty { background: #e5e7eb; color: #374151; }
.badge-break { background: var(--warning-bg); color: #92400e; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover { text-decoration: none; opacity: 0.9; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ========== Forms ========== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color var(--transition);
  background: #fff;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23636e72' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ========== Alerts ========== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-danger { background: var(--danger-bg); color: #991b1b; }
.alert-success { background: var(--success-bg); color: #065f46; }
.alert-warning { background: var(--warning-bg); color: #92400e; }
.alert-info { background: var(--info-bg); color: #3730a3; }

/* ========== Dispatch Board ========== */
.dispatch-board {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

.dispatch-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.dispatch-column {
  background: #f8f9fa;
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
}

.dispatch-column-header {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dispatch-column-header .count {
  background: rgba(0,0,0,0.1);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
}

.col-pending .dispatch-column-header { background: var(--warning-bg); color: #92400e; }
.col-dispatched .dispatch-column-header { background: var(--info-bg); color: #3730a3; }
.col-en_route .dispatch-column-header { background: #ede9fe; color: #6d28d9; }
.col-arrived .dispatch-column-header { background: var(--success-bg); color: #065f46; }
.col-in_progress .dispatch-column-header { background: #ccfbf1; color: #0f766e; }

.ride-card {
  background: var(--bg-card);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  cursor: pointer;
  transition: box-shadow var(--transition);
}

.ride-card:hover {
  box-shadow: var(--shadow-md);
}

.ride-card.status-pending { border-left-color: var(--warning); }
.ride-card.status-dispatched { border-left-color: var(--info); }
.ride-card.status-en_route { border-left-color: var(--purple); }
.ride-card.status-arrived { border-left-color: var(--success); }
.ride-card.status-in_progress { border-left-color: var(--teal); }

.ride-card .ride-id {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ride-card .ride-customer {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 4px 0;
}

.ride-card .ride-address {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ride-card .ride-driver {
  font-size: 0.8rem;
  color: var(--info);
  margin-top: 6px;
}

.ride-card .ride-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.ride-card .ride-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

/* ========== Driver Panel (sidebar of dispatch board) ========== */
.driver-panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.driver-panel h3 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.driver-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.driver-item:last-child { border-bottom: none; }

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

.driver-dot.available { background: var(--success); }
.driver-dot.on_ride { background: var(--info); }
.driver-dot.off_duty { background: #9ca3af; }
.driver-dot.break { background: var(--warning); }

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

.driver-item .driver-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ========== Map ========== */
.map-container {
  height: 500px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

/* ========== Status Timeline ========== */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-card);
}

.timeline-item .timeline-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.timeline-item .timeline-status {
  font-weight: 600;
  text-transform: capitalize;
}

.timeline-item .timeline-user {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ========== Search/Filter Bar ========== */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-bar .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 150px;
}

.filter-bar .btn {
  flex-shrink: 0;
}

/* ========== Login Page ========== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #2d4270 100%);
}

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

.login-box h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 8px;
}

.login-box .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.9rem;
}

/* ========== Pagination ========== */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 20px;
}

.pagination a, .pagination span {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

.pagination a:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  text-decoration: none;
}

.pagination .active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ========== Utility ========== */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.hidden { display: none; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .dispatch-board { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ========== Notification Sound ========== */
.notification-dot {
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* ========== Toast Notifications ========== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--bg-card);
  border-left: 4px solid var(--primary);
  padding: 14px 20px;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 9999;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  max-width: 350px;
  font-size: 0.9rem;
}
.toast.show { transform: translateX(0); }

/* ========== Dispatch Board ========== */
.dispatch-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.board-column { background: var(--bg); border-radius: 8px; min-height: 200px; }
.column-header {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 8px 8px 0 0;
}
.column-pending { background: #fff3cd; color: #856404; }
.column-dispatched { background: #cce5ff; color: #004085; }
.column-enroute { background: #d4edda; color: #155724; }
.column-inprogress { background: #d1ecf1; color: #0c5460; }

.ride-card {
  background: var(--bg-card);
  margin: 8px;
  padding: 12px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.ride-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

/* ========== Driver Panel ========== */
.driver-panel { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px; }
.driver-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 4px solid var(--border);
  min-width: 150px;
}
.driver-available { border-left-color: var(--success); }
.driver-on_ride { border-left-color: var(--info); }
.driver-busy { border-left-color: var(--warning); }
.driver-offline { border-left-color: var(--text-muted); }

/* ========== Detail Grid ========== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
dl { padding: 16px; }
dt { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); margin-top: 12px; }
dt:first-child { margin-top: 0; }
dd { margin-top: 2px; font-size: 1rem; }

/* ========== Status Timeline ========== */
.status-timeline { padding: 16px; }
.timeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-left: 2px solid var(--border);
  padding-left: 16px;
  margin-left: 12px;
  position: relative;
}
.timeline-item::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  position: absolute;
  left: -6px;
}

/* ========== Responsive Board ========== */
@media (max-width: 1200px) {
  .dispatch-board { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .dispatch-board { grid-template-columns: 1fr; }
}
