/* =========================================================================
 * FoloApp — Global Design System
 * File: foloapp.css
 *
 * Loads AFTER the Tailwind CDN. Provides theme tokens + custom component
 * classes ONLY. Deliberately contains ZERO Tailwind-duplicate utilities
 * (.hidden, .flex-*, .text-center, .mt-*, .w-full, .truncate, etc.) —
 * shadowing those silently breaks responsive variants in the markup.
 * ========================================================================= */

/* -------------------------------------------------------------------------
 * 1. THEME TOKENS
 * ------------------------------------------------------------------------- */
:root {
  --folo-yellow:       #FFD600;
  --folo-navy:         #0C2340;
  --folo-navy-dark:    #0E2A4E;
  --folo-amber:        #FFD60A;
  --folo-green:        #14B87A;
  --folo-red:          #EF4A5C;
  --folo-whatsapp:     #25D366;
  --folo-blue:         #1E4A8A;

  --folo-navy-03:  rgba(12, 35, 64, 0.03);
  --folo-navy-08:  rgba(12, 35, 64, 0.08);
  --folo-navy-10:  rgba(12, 35, 64, 0.10);
  --folo-navy-15:  rgba(12, 35, 64, 0.15);
  --folo-navy-30:  rgba(12, 35, 64, 0.30);
  --folo-navy-50:  rgba(12, 35, 64, 0.50);
  --folo-navy-70:  rgba(12, 35, 64, 0.70);
  --folo-green-10: rgba(20, 184, 122, 0.10);
  --folo-green-30: rgba(20, 184, 122, 0.30);
  --folo-red-10:   rgba(239, 74, 92, 0.10);
  --folo-amber-20: rgba(255, 214, 10, 0.20);

  --folo-surface:     #FFFFFF;
  --folo-surface-alt: #F7F9FC;
  --folo-text:        var(--folo-navy);
  --folo-text-muted:  var(--folo-navy-70);
  --folo-text-faint:  var(--folo-navy-50);

  --folo-shadow-sm:   0 1px 2px rgba(12, 35, 64, 0.06);
  --folo-shadow-card: 0 8px 24px rgba(12, 35, 64, 0.10);
  --folo-shadow-lg:   0 18px 40px rgba(12, 35, 64, 0.28);
  --folo-shadow-btn:  0 2px 0 rgba(0, 0, 0, 0.15);

  --folo-r-sm:   8px;
  --folo-r:      10px;
  --folo-r-card: 12px;
  --folo-r-lg:   16px;
  --folo-r-pill: 999px;

  --folo-ease-fast:   0.15s ease;
  --folo-ease:        0.25s ease;
  --folo-ease-out:    cubic-bezier(0.4, 0, 0.2, 1);

  --folo-container:        1180px;
  --folo-container-wide:   1400px;
  --folo-container-narrow: 820px;

  --folo-font-sans:  'Poppins', 'Inter', system-ui, -apple-system, sans-serif;
  --folo-font-serif: 'Fraunces', Georgia, serif;
  --folo-font-mono:  'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
}

/* -------------------------------------------------------------------------
 * 2. BASE
 * ------------------------------------------------------------------------- */
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--folo-yellow);
  color: var(--folo-text);
  font-family: var(--folo-font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
*, *::before, *::after { box-sizing: border-box; }
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; }

/* -------------------------------------------------------------------------
 * 3. TYPOGRAPHY
 * ------------------------------------------------------------------------- */
.display {
  font-family: var(--folo-font-serif);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--folo-navy);
}
.stat-num {
  font-family: var(--folo-font-serif);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--folo-navy);
  line-height: 1;
}
.mono { font-family: var(--folo-font-mono); font-size: 0.9em; }

/* -------------------------------------------------------------------------
 * 4. LAYOUT PRIMITIVES
 * ------------------------------------------------------------------------- */
.page-wrap {
  max-width: var(--folo-container);
  margin: 0 auto;
  padding: 32px 20px;
}
@media (min-width: 768px) { .page-wrap { padding: 32px 32px; } }
.page-wrap-wide   { max-width: var(--folo-container-wide);   margin: 0 auto; padding: 32px 20px; }
.page-wrap-narrow { max-width: var(--folo-container-narrow); margin: 0 auto; padding: 32px 20px; }

.grid-cards { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 768px)  { .grid-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) {
  .grid-cards-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-cards-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-cards-6 { grid-template-columns: repeat(6, 1fr); }
}

/* -------------------------------------------------------------------------
 * 5. CARDS
 * ------------------------------------------------------------------------- */
.card {
  background: var(--folo-surface);
  border-radius: var(--folo-r-card);
  padding: 20px;
  box-shadow: var(--folo-shadow-card);
}
.card-tight { padding: 16px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--folo-navy-10);
  margin-bottom: 16px;
}
.card-header-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--folo-navy);
}
.card-footer {
  padding-top: 12px;
  border-top: 1px solid var(--folo-navy-10);
  margin-top: 16px;
}
.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--folo-navy-08);
}
.card-row:last-child  { border-bottom: 0; padding-bottom: 0; }
.card-row:first-child { padding-top: 0; }

/* -------------------------------------------------------------------------
 * 6. BUTTONS — .btn owns ONLY hover / active / focus / disabled.
 *    Sizing, colour, radius, font-weight come from Tailwind utilities
 *    applied alongside (as old-index.php did). Variants below provide
 *    colour-only shortcuts when a caller prefers them.
 * ------------------------------------------------------------------------- */
.btn {
  cursor: pointer;
  transition: filter var(--folo-ease-fast), transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--folo-blue); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-gold    { background: var(--folo-amber);    color: var(--folo-navy); font-weight: 700; box-shadow: var(--folo-shadow-btn); }
.btn-gold:hover    { filter: brightness(1.08); }
.btn-navy    { background: var(--folo-navy);     color: #fff; }
.btn-navy:hover    { background: var(--folo-navy-dark); }
.btn-outline { background: transparent; color: var(--folo-navy); border: 1px solid var(--folo-navy-30); }
.btn-outline:hover { background: var(--folo-navy-03); }
.btn-ghost   { background: var(--folo-navy-08);  color: var(--folo-navy); }
.btn-ghost:hover   { background: var(--folo-navy-15); }
.btn-danger  { background: var(--folo-red-10);   color: var(--folo-red); }
.btn-danger:hover  { background: rgba(239, 74, 92, 0.18); }
.btn-whatsapp{ background: var(--folo-whatsapp); color: #fff; font-weight: 700; }
.btn-whatsapp:hover{ filter: brightness(0.95); }

/* -------------------------------------------------------------------------
 * 7. BADGES & PILLS
 * ------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--folo-r-pill);
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-verified { background: var(--folo-green); color: #fff; }
.badge-live     { background: var(--folo-green-10); color: var(--folo-green); }
.badge-offline  { background: var(--folo-red-10);   color: var(--folo-red); }
.badge-pending  { background: var(--folo-amber-20); color: var(--folo-navy); }
.badge-failed   { background: #FEE2E2; color: #B91C1C; }
.badge-queued   { background: var(--folo-navy-08);  color: var(--folo-text-muted); }
.badge-navy     { background: var(--folo-navy-10);  color: var(--folo-navy); }

.badge-role-parent       { background: var(--folo-navy-10);     color: var(--folo-navy); }
.badge-role-driver       { background: var(--folo-green-10);    color: var(--folo-green); }
.badge-role-school_admin { background: rgba(30, 74, 138, 0.10); color: var(--folo-blue); }
.badge-role-super_admin  { background: var(--folo-amber);       color: var(--folo-navy); }

.wa-badge {
  background: var(--folo-whatsapp);
  color: #fff;
  border-radius: var(--folo-r-pill);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  transition: filter var(--folo-ease-fast);
}
.wa-badge:hover { filter: brightness(0.95); }

/* -------------------------------------------------------------------------
 * 8. ALERTS
 * ------------------------------------------------------------------------- */
.alert {
  border-radius: var(--folo-r-card);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
}
.alert-icon {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
}
.alert-success { background: var(--folo-green-10); border: 1px solid var(--folo-green-30); color: var(--folo-navy); }
.alert-danger  { background: var(--folo-red-10);   border: 1px solid rgba(239, 74, 92, 0.3); color: var(--folo-navy); }
.alert-warning { background: var(--folo-amber-20); border: 1px solid rgba(255, 214, 10, 0.4); color: var(--folo-navy); }
.alert-info    { background: var(--folo-navy); color: #fff; }
.alert-info .alert-icon { background: var(--folo-amber); color: var(--folo-navy); }

/* -------------------------------------------------------------------------
 * 9. HEADER
 * ------------------------------------------------------------------------- */
.folo-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--folo-navy-dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.folo-header-inner {
  max-width: var(--folo-container-wide);
  margin: 0 auto;
  height: 68px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
@media (min-width: 768px) { .folo-header-inner { padding: 0 32px; } }
.folo-logo-tile {
  width: 42px;
  height: 42px;
  border-radius: var(--folo-r);
  background: var(--folo-amber);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--folo-shadow-sm);
}

/* -------------------------------------------------------------------------
 * 10. DRAWER (Z-Index elevated above maps)
 * ------------------------------------------------------------------------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(12, 35, 64, 0.60);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--folo-ease);
}
.drawer-backdrop[data-open="true"] { opacity: 1; pointer-events: auto; }

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1045;
  height: 100%;
  width: 86%;
  max-width: 380px;
  background: var(--folo-navy-dark);
  box-shadow: -12px 0 40px rgba(12, 35, 64, 0.28);
  transform: translateX(100%);
  transition: transform 0.3s var(--folo-ease-out);
}
.drawer-panel[data-open="true"] { transform: translateX(0); }

/* -------------------------------------------------------------------------
 * 11. FOOTER
 * ------------------------------------------------------------------------- */
.folo-footer {
  background: var(--folo-navy);
  color: rgba(255, 255, 255, 0.8);
  padding: 32px 20px;
  margin-top: 48px;
}
.folo-footer-inner {
  max-width: var(--folo-container);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
@media (min-width: 768px) {
  .folo-footer-inner { flex-direction: row; align-items: center; justify-content: space-between; }
}
.folo-footer-bottom {
  max-width: var(--folo-container);
  margin: 24px auto 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

/* -------------------------------------------------------------------------
 * 12. STAT CARDS
 * ------------------------------------------------------------------------- */
.stat-card {
  background: var(--folo-surface);
  border-radius: var(--folo-r-card);
  padding: 16px;
  box-shadow: var(--folo-shadow-card);
}
.stat-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--folo-text-muted);
}
.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--folo-navy);
  line-height: 1.1;
  margin-top: 8px;
}

/* -------------------------------------------------------------------------
 * 13. TIMELINE
 * ------------------------------------------------------------------------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--folo-navy-15);
}
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute;
  left: -22px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--folo-navy);
}
.tl-item.school .tl-dot { background: var(--folo-navy); border-color: var(--folo-navy); }
.tl-item.depot  .tl-dot { background: var(--folo-amber); border-color: var(--folo-navy); }

/* -------------------------------------------------------------------------
 * 14. FLEET LIST
 * ------------------------------------------------------------------------- */
.fleet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--folo-r);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--folo-ease-fast), border-color var(--folo-ease-fast);
}
.fleet-row:hover    { background: var(--folo-navy-03); }
.fleet-row.selected { background: rgba(255, 214, 10, 0.18); border-color: rgba(12, 35, 64, 0.35); }
.fleet-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--folo-r);
  background: var(--folo-navy);
  color: var(--folo-amber);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}
.fleet-row.selected .fleet-avatar { background: var(--folo-amber); color: var(--folo-navy); }
.fleet-scroll { max-height: 600px; overflow-y: auto; padding: 8px; }
.fleet-scroll::-webkit-scrollbar { width: 6px; }
.fleet-scroll::-webkit-scrollbar-thumb { background: var(--folo-navy-15); border-radius: 3px; }

/* -------------------------------------------------------------------------
 * 15. MAP MARKERS (Leaflet divIcon)
 * ------------------------------------------------------------------------- */
.bus-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(12, 35, 64, 0.55);
  color: var(--folo-amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  cursor: pointer;
  position: relative;
  transition: transform var(--folo-ease-fast), background var(--folo-ease-fast);
}
.bus-marker:hover { transform: scale(1.15); background: rgba(12, 35, 64, 0.85); }
.bus-marker.selected {
  width: 36px;
  height: 36px;
  font-size: 12px;
  background: var(--folo-amber);
  color: var(--folo-navy);
  border-color: var(--folo-navy);
  box-shadow: 0 6px 22px rgba(12, 35, 64, 0.35);
}
.bus-marker.selected::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 214, 10, 0.7);
  animation: folo-pulse 2s ease-out infinite;
}
.trail-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.trail-dot.start { background: var(--folo-green); }
.trail-dot.end   { background: var(--folo-red); }

/* -------------------------------------------------------------------------
 * 16. LIVE DOT
 * ------------------------------------------------------------------------- */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--folo-green);
  box-shadow: 0 0 0 0 rgba(20, 184, 122, 0.7);
  animation: folo-live 1.6s infinite;
}

/* -------------------------------------------------------------------------
 * 17. SPEED GAUGE
 * ------------------------------------------------------------------------- */
.gauge {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: conic-gradient(var(--folo-navy) var(--p, 0%), var(--folo-navy-08) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.gauge::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: #fff;
}
.gauge-inner { position: relative; text-align: center; }

/* -------------------------------------------------------------------------
 * 18. TOAST (Z-Index elevated above maps)
 * ------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  padding: 10px 16px;
  border-radius: var(--folo-r-pill);
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: var(--folo-navy);
  box-shadow: var(--folo-shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--folo-ease);
}
.toast.show       { opacity: 1; }
.toast-success    { background: var(--folo-navy); color: var(--folo-amber); }
.toast-error      { background: #DC2626; color: #fff; }

/* -------------------------------------------------------------------------
 * 19. MODAL (Z-Index elevated above maps)
 * ------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 35, 64, 0.70);
  backdrop-filter: blur(3px);
}
.modal {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--folo-r-lg);
  padding: 24px;
  box-shadow: var(--folo-shadow-lg);
  animation: folo-fade-in 0.25s var(--folo-ease-out);
}

/* -------------------------------------------------------------------------
 * 20. TABLES
 * ------------------------------------------------------------------------- */
.folo-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.folo-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--folo-text-faint);
  padding: 10px 12px;
  border-bottom: 1px solid var(--folo-navy-10);
}
.folo-table td {
  padding: 12px;
  border-bottom: 1px solid var(--folo-navy-08);
  color: var(--folo-navy);
}
.folo-table tr:last-child td { border-bottom: 0; }
.folo-table tr:hover td      { background: var(--folo-navy-03); }

/* -------------------------------------------------------------------------
 * 21. EMPTY STATE / SKELETON
 * ------------------------------------------------------------------------- */
.empty-state { padding: 40px 20px; text-align: center; color: var(--folo-text-muted); font-size: 13px; }
.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--folo-amber-20);
  color: var(--folo-navy);
  margin-bottom: 12px;
}
.skeleton {
  background: linear-gradient(90deg, var(--folo-navy-08) 25%, var(--folo-navy-03) 37%, var(--folo-navy-08) 63%);
  background-size: 400% 100%;
  border-radius: var(--folo-r-sm);
  animation: folo-shimmer 1.4s ease-in-out infinite;
  height: 1em;
}

/* -------------------------------------------------------------------------
 * 22. ANIMATIONS
 * ------------------------------------------------------------------------- */
.fade-in { animation: folo-fade-in 0.25s var(--folo-ease-out); }

@keyframes folo-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
@keyframes folo-live {
  0%   { box-shadow: 0 0 0 0    rgba(20, 184, 122, 0.6); }
  70%  { box-shadow: 0 0 0 10px rgba(20, 184, 122, 0); }
  100% { box-shadow: 0 0 0 0    rgba(20, 184, 122, 0); }
}
@keyframes folo-pulse {
  0%   { transform: scale(0.85); opacity: 0.9; }
  100% { transform: scale(1.6);  opacity: 0; }
}
@keyframes folo-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* -------------------------------------------------------------------------
 * 23. REDUCED MOTION
 * ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* -------------------------------------------------------------------------
 * 24. PRINT
 * ------------------------------------------------------------------------- */
@media print {
  body { background: #fff; }
  .folo-header, .drawer-panel, .drawer-backdrop, .toast { display: none !important; }
  .card { box-shadow: none; border: 1px solid var(--folo-navy-10); }
}