/* HopOn Transit */

/* Design Tokens */
:root {
  --primary:        #2563eb;
  --primary-hover:  #1d4ed8;
  --primary-light:  #eff6ff;
  --danger:         #ef4444;
  --danger-hover:   #b91c1c;
  --success:        #16a34a;
  --warning:        #d97706;
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --text:           #0f172a;
  --text-muted:     #64748b;
  --border:         #e2e8f0;
  --shadow:         0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --radius:         8px;
  --radius-sm:      5px;
  --transition:     0.18s ease;
}

/* Dark Mode Overrides */
body.dark {
  --primary:       #3b82f6;
  --primary-light: #1e3a5f;
  --bg:            #0f172a;
  --surface:       #1e293b;
  --text:          #f1f5f9;
  --text-muted:    #94a3b8;
  --border:        #334155;
  --shadow:        0 1px 3px rgba(0,0,0,0.4);
}

body.dark input[type="text"],
body.dark select {
  background-color: #0f172a;
  color: var(--text);
  border-color: var(--border);
}

body.dark .leaflet-popup-content-wrapper,
body.dark .leaflet-popup-tip {
  background: var(--surface);
  color: var(--text);
}

body.dark .leaflet-container {
  filter: brightness(0.88) saturate(0.95);
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  transition: background-color var(--transition), color var(--transition);
}

/* Layout */
.layout { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px;
  min-width: 240px;
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition), border-color var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.brand-icon { font-size: 1.4rem; }

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
}

nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  padding: 0.85rem 1.25rem;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  border-right: 3px solid transparent;
}

.nav-btn:hover { background-color: var(--bg); color: var(--text); }

.nav-btn.active {
  color: var(--primary);
  background-color: var(--primary-light);
  border-right-color: var(--primary);
}

.nav-icon { font-size: 1rem; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.btn-theme {
  width: 100%;
  padding: 0.6rem 1rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  text-align: left;
}

.btn-theme:hover { background-color: var(--bg); color: var(--text); }

/* Main Content */
.content {
  flex: 1;
  padding: 2rem 2.5rem;
  overflow-y: auto;
}

header { margin-bottom: 2rem; }
header h1 { font-size: 1.7rem; font-weight: 600; }
header p  { color: var(--text-muted); margin-top: 0.4rem; font-size: 0.95rem; }

.view         { display: none; }
.view.active  { display: block; }

/* Card */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: background-color var(--transition), border-color var(--transition);
}

.bg-light { background-color: var(--bg); }

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.stat-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.stat-card h3 { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card p  { font-size: 2.25rem; font-weight: 700; margin-top: 0.4rem; color: var(--primary); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* Occupancy Chips */
.occ-chip {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
}

.occ-empty    { background-color: #dcfce7; color: #15803d; }
.occ-moderate { background-color: #fef9c3; color: #92400e; }
.occ-full     { background-color: #fee2e2; color: #b91c1c; }

body.dark .occ-empty    { background-color: #14532d; color: #86efac; }
body.dark .occ-moderate { background-color: #451a03; color: #fcd34d; }
body.dark .occ-full     { background-color: #450a0a; color: #fca5a5; }

/* Form Inputs */
.input-group { margin-bottom: 1.25rem; }
.input-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 0.45rem;
  color: var(--text);
}

input[type="text"], select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.93rem;
  background-color: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
  appearance: none;
}

input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.help-text {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

/* Map */
.map-container {
  height: 380px;
  background-color: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Stop Preview List */
.stops-preview {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stop-preview-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.stop-index-badge {
  width: 22px;
  height: 22px;
  min-width: 22px;
  background-color: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stop-item-name {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 500;
}

/* Leaflet Stop Popup */
.stop-popup {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.25rem 0;
  min-width: 190px;
}

.popup-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.popup-input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
}

.popup-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  border: none;
  transition: background-color var(--transition), opacity var(--transition);
}

.btn.primary   { background-color: var(--primary); color: white; }
.btn.primary:hover  { background-color: var(--primary-hover); }
.btn.secondary { background-color: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background-color: var(--border); }
.btn.danger    { background-color: var(--danger); color: white; }
.btn.danger:hover   { background-color: var(--danger-hover); }

.btn.small      { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn.large-btn  { padding: 0.9rem 1.4rem; font-size: 1rem; }
.w-100          { width: 100%; }
.btn:disabled   { opacity: 0.45; cursor: not-allowed; }

/* Occupancy button */
.occ-btn {
  padding: 0.55rem 1.1rem;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all var(--transition);
}

.occ-btn.occ-empty    { border-color: #86efac; color: #15803d; }
.occ-btn.occ-moderate { border-color: #fcd34d; color: #92400e; }
.occ-btn.occ-full     { border-color: #fca5a5; color: #b91c1c; }

/* Status Banners */
.status-banner {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.status-banner.info {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: #bfdbfe;
}

/* Admin List */
.admin-list { list-style: none; }

.admin-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.admin-list li:last-child { border-bottom: none; }

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.5rem 0 !important;
  border: none !important;
  font-style: italic;
}

/* Driver Timeline */
.section-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.driver-timeline {
  display: flex;
  flex-direction: column;
}

.tl-stop {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tl-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  border: 2px solid var(--border);
  background-color: var(--surface);
  color: var(--text-muted);
}

.tl-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.tl-stop.done .tl-icon  { background-color: var(--success); border-color: var(--success); color: white; }
.tl-stop.done .tl-label { color: var(--text-muted); text-decoration: line-through; }

.tl-stop.current .tl-icon  { background-color: var(--primary); border-color: var(--primary); color: white; }
.tl-stop.current .tl-label { color: var(--primary); font-weight: 600; }

.tl-line {
  width: 2px;
  height: 20px;
  background-color: var(--border);
  margin-left: 13px;
}

/* Passenger ETA Cards */
.eta-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  background-color: var(--surface);
}

.eta-bus-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.bus-badge {
  font-weight: 700;
  font-size: 0.95rem;
}

.eta-current-stop {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.eta-stops-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
}

.eta-stop-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.eta-stop-row.eta-next {
  background-color: var(--primary-light);
  font-weight: 600;
}

.eta-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  background-color: var(--border);
}

.eta-dot.eta-dot-next { background-color: var(--primary); }

.eta-stop-name { flex: 1; }

.eta-time {
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  font-size: 0.85rem;
}

.eta-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* Bus Map Marker */
.bus-map-marker {
  width: 16px;
  height: 16px;
  background-color: var(--danger);
  border-radius: 50%;
  display: block;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  animation: bus-pulse 2s ease-in-out infinite;
}

@keyframes bus-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  max-width: 320px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast.show { opacity: 1; transform: translateY(0); }

.toast-info    { background-color: var(--primary); color: white; }
.toast-success { background-color: var(--success);  color: white; }
.toast-error   { background-color: var(--danger);   color: white; }

/* Form Actions */
.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Progression Panel */
.progression-panel {
  border-radius: var(--radius-sm);
}

/* Utility Classes */
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* Mobile Responsive */
@media (max-width: 768px) {
  body { overflow: auto; height: auto; }

  .layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .hamburger { display: block; }

  nav {
    display: none;
    flex-direction: column;
    border-top: 1px solid var(--border);
  }

  nav.open { display: flex; }

  .nav-btn {
    border-right: none;
    border-left: 3px solid transparent;
  }

  .nav-btn.active {
    border-right: none;
    border-left: 3px solid var(--primary);
  }

  .sidebar-footer { display: none; }

  .content { padding: 1.25rem; }

  .map-container { height: 280px; }

  .stat-card p { font-size: 1.75rem; }

  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }

  #toast-container {
    bottom: 1rem;
    right: 0.75rem;
    left: 0.75rem;
  }

  .toast { max-width: 100%; }
}