/* =================================================================
   ANDÉN MOBILITY — Premium UX components (v1.7.0 · capa aditiva)

   Sprint 2 — UI/UX polish: componentes aditivos sobre premium.css base.
   Consume tokens.css. NO sustituye premium.css; ambos se cargan juntos.

   Componentes:
     1. Skeletons consistentes (.skeleton, .sk-card, .sk-row, .sk-text)
     2. Empty states (.empty-state-v2 con ilustración SVG inline)
     3. Loading bar top global (.anden-loadbar)
     4. Notification center panel (.notif-center)
     5. Premium tables (sort, filter chips, density, saved views)
     6. Admin mobile drawer (off-canvas pattern)
     7. Toast with actions (.toast-v2 [data-action])
     8. Trip replay timeline (.replay-bar)
     9. Driver score badges (.driver-score-*)
    10. Support chat FAB + panel (.support-chat-*)

   ---------------------------------------------------------------------
   RELACIÓN CON premium.css (auditado may-2026)
   ---------------------------------------------------------------------
   premium.css es la capa base (section-headers, hero stats, balance hero,
   trip card, filter chips, settings list, mini-sparkline, .sk-stat/.sk-tx/
   .sk-trip).  Este archivo añade los componentes del sprint v1.7.0+.

   Solape intencional en cascada: .skeleton / .sk-row / .sk-card se
   redefinen aquí con shimmer mejorado (gradient-shimmer del tokens).
   Las variantes específicas .sk-stat/.sk-tx/.sk-trip permanecen en
   premium.css por ser dependientes de los widgets de wallet/trip.

   Cargar en este orden:
       <link href="premium.css">      (1849 líneas · base)
       <link href="premium-v2.css">   (1036 líneas · aditiva v1.7.0+)
   ================================================================= */

/* =====================================================================
   1. SKELETONS — shimmer placeholders
   ===================================================================== */
@keyframes andenShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.skeleton,
.sk-card,
.sk-row,
.sk-text,
.sk-circle {
  position: relative;
  background: linear-gradient(
    90deg,
    var(--bg-2) 0%,
    color-mix(in srgb, var(--bg-3) 85%, var(--bg-4)) 50%,
    var(--bg-2) 100%
  );
  background-size: 200% 100%;
  animation: andenShimmer 1.6s var(--ease-in-out) infinite;
  border-radius: var(--r-3);
  overflow: hidden;
}
.skeleton::after,
.sk-card::after,
.sk-row::after,
.sk-text::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--gradient-shimmer);
}
.sk-card    { height: 110px; border-radius: var(--r-5); }
.sk-row     { height: 56px;  border-radius: var(--r-3); margin-bottom: var(--sp-2); }
.sk-text    { height: 14px;  border-radius: var(--r-pill); width: 100%; margin-bottom: 8px; }
.sk-text.w-80 { width: 80%; }
.sk-text.w-60 { width: 60%; }
.sk-text.w-40 { width: 40%; }
.sk-text.w-25 { width: 25%; }
.sk-circle  { height: 40px; width: 40px; border-radius: 50%; }
.sk-circle.lg { height: 64px; width: 64px; }
.sk-circle.sm { height: 28px; width: 28px; }

/* Premium KPI skeleton: 4 cards en grid */
.skeleton-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

/* Premium table skeleton: header row + N body rows */
.skeleton-table .sk-head {
  height: 40px;
  border-radius: var(--r-3) var(--r-3) 0 0;
  background: var(--bg-3);
}
.skeleton-table .sk-row { border-radius: 0; margin: 0; border-bottom: 1px solid var(--border); }

@media (prefers-reduced-motion: reduce) {
  .skeleton, .sk-card, .sk-row, .sk-text, .sk-circle { animation: none; }
}

/* =====================================================================
   2. EMPTY STATES — illustrations inline + helper text
   ===================================================================== */
.empty-state-v2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-9) var(--sp-5);
  text-align: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-5);
  background: var(--bg-1);
  min-height: 260px;
}
.empty-state-v2 .es-art {
  width: 96px;
  height: 96px;
  margin-bottom: var(--sp-4);
  opacity: 0.85;
  filter: drop-shadow(0 4px 12px color-mix(in srgb, var(--brand-500) 24%, transparent));
}
.empty-state-v2 .es-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text-0);
  margin: 0 0 var(--sp-2);
  letter-spacing: var(--tracking-tight);
}
.empty-state-v2 .es-body {
  font-size: var(--fs-sm);
  color: var(--text-2);
  max-width: 360px;
  margin: 0 0 var(--sp-4);
  line-height: var(--lh-snug);
}
.empty-state-v2 .es-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.empty-state-v2.compact {
  min-height: 160px;
  padding: var(--sp-5) var(--sp-4);
}
.empty-state-v2.compact .es-art { width: 64px; height: 64px; margin-bottom: var(--sp-3); }

/* =====================================================================
   3. LOADING BAR TOP — YouTube/GitHub style
   ===================================================================== */
.anden-loadbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: var(--z-loader);
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.anden-loadbar.is-visible { opacity: 1; }
.anden-loadbar .anden-loadbar-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-brand);
  box-shadow: 0 0 8px color-mix(in srgb, var(--brand-500) 60%, transparent);
  transition: width var(--dur-base) var(--ease-out);
}
.anden-loadbar.indeterminate .anden-loadbar-fill {
  width: 30%;
  animation: andenLoadbarSweep 1.2s var(--ease-in-out) infinite;
}
@keyframes andenLoadbarSweep {
  0%   { margin-left: -30%; }
  100% { margin-left: 100%; }
}

/* =====================================================================
   4. NOTIFICATION CENTER — unified panel with tabs
   ===================================================================== */
.notif-center {
  position: fixed;
  top: var(--shell-topbar-h);
  right: var(--sp-3);
  width: min(420px, calc(100vw - var(--sp-6)));
  max-height: min(640px, calc(100vh - var(--shell-topbar-h) - var(--sp-6)));
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-5);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-popover);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: top right;
  animation: notifPanelIn var(--dur-base) var(--ease-spring);
}
.notif-center.is-open { display: flex; }
@keyframes notifPanelIn {
  from { transform: scale(0.92) translateY(-8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.notif-center .nc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.notif-center .nc-title {
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--text-0);
}
.notif-center .nc-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.notif-center .nc-tab {
  flex: 1;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  transition: color var(--dur-fast) var(--ease-out);
}
.notif-center .nc-tab.is-active {
  color: var(--brand-500);
}
.notif-center .nc-tab.is-active::after {
  content: '';
  position: absolute; bottom: -1px; left: 16px; right: 16px;
  height: 2px;
  background: var(--brand-500);
  border-radius: 2px;
}
.notif-center .nc-tab .nc-badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
  background: var(--brand-500);
  color: var(--text-inverse);
  border-radius: var(--r-pill);
  margin-left: 4px;
}
.notif-center .nc-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.notif-center .nc-item {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  position: relative;
}
.notif-center .nc-item:hover { background: var(--bg-2); }
.notif-center .nc-item.is-unread::before {
  content: '';
  position: absolute;
  left: 6px; top: 50%;
  width: 6px; height: 6px;
  background: var(--brand-500);
  border-radius: 50%;
  transform: translateY(-50%);
}
.notif-center .nc-item .nc-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  background: var(--bg-3);
  color: var(--text-1);
}
.notif-center .nc-item.type-success .nc-icon { background: var(--success-bg); color: var(--success-text); }
.notif-center .nc-item.type-warning .nc-icon { background: var(--warning-bg); color: var(--warning-text); }
.notif-center .nc-item.type-danger  .nc-icon { background: var(--danger-bg);  color: var(--danger-text); }
.notif-center .nc-item.type-info    .nc-icon { background: var(--info-bg);    color: var(--info-text); }
.notif-center .nc-item .nc-content { flex: 1; min-width: 0; }
.notif-center .nc-item .nc-content strong {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-0);
  margin-bottom: 2px;
}
.notif-center .nc-item .nc-content .nc-body {
  font-size: var(--fs-xs);
  color: var(--text-2);
  line-height: var(--lh-snug);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
          line-clamp: 2;
  -webkit-box-orient: vertical;
}
.notif-center .nc-item .nc-content .nc-time {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}
.notif-center .nc-foot {
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-2);
}
.notif-center .nc-foot .btn { font-size: var(--fs-xs); }

/* Bell icon with unread dot in topbar */
.notif-bell {
  position: relative;
}
.notif-bell .notif-bell-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--danger);
  border: 2px solid var(--bg-0);
  border-radius: 50%;
  animation: notifDotPulse 2s var(--ease-in-out) infinite;
}
/* v1.20.0 · Counter badge (when unread > 0, replaces dot with #) */
.notif-bell .notif-bell-badge,
#notifBtn .notif-bell-badge,
#driverNotifBtn .notif-bell-badge,
#passNotifBtn .notif-bell-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  border: 2px solid var(--bg-0);
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.20);
  animation: notifBadgeIn 280ms var(--ease-spring);
  font-variant-numeric: tabular-nums;
}
@keyframes notifBadgeIn {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes notifDotPulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.25); opacity: 0.7; }
}

/* v1.20.0 · NotificationCenter additions · kind badges + row-top + live dot */
.notif-center .nc-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.notif-center .nc-kind-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.5;
}
.notif-center .nc-kind-badge.nc-kind-chat {
  background: color-mix(in srgb, var(--accent-2, var(--info)) 18%, transparent);
  color: var(--accent-2, var(--info));
}
.notif-center .nc-kind-badge.nc-kind-ticket {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  color: var(--warning-text, var(--warning));
}
.notif-center .nc-item.kind-chat .nc-icon {
  background: color-mix(in srgb, var(--accent-2, var(--info)) 18%, transparent);
  color: var(--accent-2, var(--info));
}
.notif-center .nc-item.kind-ticket .nc-icon {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  color: var(--warning-text, var(--warning));
}
.notif-center .nc-foot .nc-live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 6px;
  background: var(--success);
  border-radius: 50%;
  vertical-align: middle;
  animation: notifDotPulse 2s var(--ease-in-out) infinite;
}

/* =====================================================================
   5. PREMIUM TABLES — sort, filter chips, density, saved views
   ===================================================================== */
.ptable-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-3);
  padding: var(--sp-2);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
}
.ptable-toolbar .ptable-search {
  flex: 1; min-width: 200px;
  position: relative;
}
.ptable-toolbar .ptable-search input {
  width: 100%;
  padding: 6px 30px 6px 30px;
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  background: var(--bg-1);
  color: var(--text-0);
  font-size: var(--fs-sm);
}
.ptable-toolbar .ptable-search .bi-search {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.ptable-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
.ptable-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 12px;
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--bg-brand-soft);
  color: var(--brand-500);
  border: 1px solid var(--brand-500);
  border-radius: var(--r-pill);
  cursor: default;
  animation: chipIn 220ms var(--ease-spring);
}
@keyframes chipIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.ptable-chip .ptable-chip-close {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  line-height: 1;
  font-size: 14px;
  opacity: 0.7;
}
.ptable-chip .ptable-chip-close:hover { opacity: 1; }

/* Density toggle */
.ptable-density {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  overflow: hidden;
}
.ptable-density button {
  background: transparent;
  border: none;
  color: var(--text-2);
  padding: 4px 10px;
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.ptable-density button.is-active {
  background: var(--bg-brand-soft);
  color: var(--brand-500);
}

/* Premium table styles */
.ptable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}
.ptable thead th {
  text-align: left;
  padding: var(--sp-3) var(--sp-3);
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-2);
  background: var(--bg-2);
  border-bottom: 2px solid var(--border-strong);
  position: sticky;
  top: 0;
  z-index: 2;
  cursor: pointer;
  user-select: none;
  transition: background var(--dur-fast) var(--ease-out);
}
.ptable thead th:hover {
  background: var(--bg-3);
  color: var(--text-1);
}
.ptable thead th .ptable-sort-icon {
  margin-left: 6px;
  opacity: 0.4;
  transition: opacity var(--dur-fast);
}
.ptable thead th.is-sorted .ptable-sort-icon {
  opacity: 1;
  color: var(--brand-500);
}
.ptable thead th[data-resizable]:hover::after {
  content: '';
  position: absolute;
  right: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: var(--brand-500);
  opacity: 0.5;
  cursor: col-resize;
}
.ptable tbody td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  vertical-align: middle;
}
.ptable tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}
.ptable tbody tr:hover { background: var(--bg-2); }
.ptable tbody tr.is-selected { background: var(--bg-brand-soft); }

/* Density modifiers */
.ptable[data-density="compact"] thead th { padding: 6px 8px; }
.ptable[data-density="compact"] tbody td { padding: 6px 8px; font-size: var(--fs-xs); }
.ptable[data-density="comfortable"] thead th { padding: var(--sp-4) var(--sp-3); }
.ptable[data-density="comfortable"] tbody td { padding: var(--sp-4) var(--sp-3); }

/* Saved views dropdown */
.ptable-views {
  position: relative;
}
.ptable-views .ptable-views-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: var(--fs-xs);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  cursor: pointer;
  color: var(--text-1);
}
.ptable-views .ptable-views-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  display: none;
  z-index: var(--z-dropdown);
}
.ptable-views.is-open .ptable-views-menu { display: block; }
.ptable-views .ptable-views-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-1);
  padding: 6px 10px;
  font-size: var(--fs-xs);
  border-radius: var(--r-2);
  cursor: pointer;
}
.ptable-views .ptable-views-menu button:hover { background: var(--bg-2); }
.ptable-views .ptable-views-menu hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* =====================================================================
   6. ADMIN MOBILE DRAWER — off-canvas pattern for small screens
   ===================================================================== */
.mobile-drawer-trigger {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-1);
  padding: var(--sp-2);
  cursor: pointer;
}
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-base) var(--ease-out), visibility var(--dur-base) var(--ease-out);
  backdrop-filter: blur(4px);
}
.mobile-drawer-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 768px) {
  .mobile-drawer-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .sidebar {
    position: fixed !important;
    top: 0; bottom: 0;
    left: 0;
    width: 88vw !important;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform var(--dur-base) var(--ease-out);
    z-index: var(--z-modal);
    box-shadow: var(--shadow-2xl);
  }
  .sidebar.is-open { transform: translateX(0); }
  .shell-main, .shell-content { margin-left: 0 !important; }
}

/* =====================================================================
   7. TOAST WITH ACTIONS — premium toasts with [Undo] etc.
   ===================================================================== */
.toast-v2 {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-4);
  color: var(--text-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 480px;
  animation: toastIn var(--dur-base) var(--ease-spring);
}
@keyframes toastIn {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.toast-v2.type-success { border-left: 4px solid var(--success); }
.toast-v2.type-warning { border-left: 4px solid var(--warning); }
.toast-v2.type-danger  { border-left: 4px solid var(--danger); }
.toast-v2.type-info    { border-left: 4px solid var(--info); }
.toast-v2 .toast-icon  { font-size: 1.25rem; flex-shrink: 0; }
.toast-v2.type-success .toast-icon { color: var(--success); }
.toast-v2.type-warning .toast-icon { color: var(--warning); }
.toast-v2.type-danger  .toast-icon { color: var(--danger); }
.toast-v2.type-info    .toast-icon { color: var(--info); }
.toast-v2 .toast-body { flex: 1; font-size: var(--fs-sm); }
.toast-v2 .toast-actions {
  display: flex; gap: var(--sp-2);
  flex-shrink: 0;
}
.toast-v2 [data-action] {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-0);
  padding: 4px 10px;
  font-size: var(--fs-xs);
  font-weight: 600;
  border-radius: var(--r-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.toast-v2 [data-action]:hover { background: var(--bg-5); }
.toast-v2 [data-action="undo"] { color: var(--brand-500); border-color: var(--brand-500); }

/* =====================================================================
   8. TRIP REPLAY — timeline scrubber
   ===================================================================== */
.replay-panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-5);
  padding: var(--sp-4);
  box-shadow: var(--shadow-md);
}
.replay-bar {
  position: relative;
  height: 8px;
  background: var(--bg-3);
  border-radius: var(--r-pill);
  margin: var(--sp-4) 0 var(--sp-2);
  cursor: pointer;
}
.replay-bar .replay-bar-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: var(--gradient-brand);
  border-radius: var(--r-pill);
  transition: width var(--dur-fast) linear;
}
.replay-bar .replay-bar-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 16px; height: 16px;
  background: var(--brand-500);
  border: 3px solid var(--bg-0);
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 24%, transparent);
}
.replay-bar .replay-marker {
  position: absolute;
  top: -8px;
  width: 2px;
  height: 24px;
  background: var(--accent-violet);
  border-radius: 2px;
}
.replay-bar .replay-marker.kind-accepted { background: var(--info); }
.replay-bar .replay-marker.kind-arrived  { background: var(--warning); }
.replay-bar .replay-marker.kind-started  { background: var(--brand-500); }
.replay-bar .replay-marker.kind-ended    { background: var(--success); }
.replay-bar .replay-marker.kind-incident { background: var(--danger); }

.replay-controls {
  display: flex; align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.replay-controls .btn-play {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-500);
  color: var(--text-inverse);
  border: none;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.replay-controls .btn-play:hover { transform: scale(1.08); }
.replay-controls .replay-time {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.replay-controls .replay-speed select {
  background: var(--bg-3);
  color: var(--text-0);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: var(--r-2);
  font-size: var(--fs-xs);
}

/* =====================================================================
   9. DRIVER SCORE — badges + meter
   ===================================================================== */
.driver-score {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.driver-score-platinum { background: linear-gradient(135deg, #c4b5fd, #a78bfa); color: #1e1b4b; }
.driver-score-gold     { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #451a03; }
.driver-score-silver   { background: linear-gradient(135deg, #e5e7eb, #9ca3af); color: #111827; }
.driver-score-bronze   { background: linear-gradient(135deg, #fbbf24, #b45309); color: #fff7ed; }
.driver-score-flagged  { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }

.score-meter {
  display: flex;
  gap: 2px;
  align-items: center;
}
.score-meter .seg {
  flex: 1;
  height: 6px;
  background: var(--bg-3);
  border-radius: var(--r-pill);
  min-width: 8px;
}
.score-meter .seg.is-active { background: var(--brand-500); }
.score-meter .seg.is-active.warn   { background: var(--warning); }
.score-meter .seg.is-active.danger { background: var(--danger); }

/* =====================================================================
  10. SUPPORT CHAT FAB + PANEL
   ===================================================================== */
.support-fab {
  position: fixed;
  right: var(--sp-4);
  bottom: calc(var(--sp-4) + var(--safe-bottom));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: var(--text-inverse);
  border: none;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center; justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: var(--z-fixed);
  transition: transform var(--dur-fast) var(--ease-spring);
}
.support-fab:hover { transform: scale(1.08); }
.support-fab .support-fab-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 12px; height: 12px;
  background: var(--danger);
  border: 2px solid var(--bg-1);
  border-radius: 50%;
}
.support-fab[hidden] { display: none; }

.support-chat-panel {
  position: fixed;
  right: var(--sp-4);
  bottom: calc(var(--sp-4) + 72px + var(--safe-bottom));
  width: min(380px, calc(100vw - var(--sp-6)));
  height: min(560px, calc(100vh - 160px));
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-5);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-fixed);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: chatPanelIn var(--dur-base) var(--ease-spring);
}
.support-chat-panel.is-open { display: flex; }
@keyframes chatPanelIn {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.support-chat-panel .scp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  background: var(--gradient-brand);
  color: var(--text-inverse);
}
.support-chat-panel .scp-head strong { font-weight: 700; }
.support-chat-panel .scp-head .scp-close {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1.2rem;
  opacity: 0.85;
}
.support-chat-panel .scp-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-3);
  background: var(--bg-0);
  display: flex; flex-direction: column;
  gap: var(--sp-2);
}
.support-chat-panel .scp-msg {
  max-width: 80%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-4);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  word-wrap: break-word;
}
.support-chat-panel .scp-msg.from-user {
  align-self: flex-end;
  background: var(--brand-500);
  color: var(--text-inverse);
  border-bottom-right-radius: var(--r-1);
}
.support-chat-panel .scp-msg.from-agent {
  align-self: flex-start;
  background: var(--bg-3);
  color: var(--text-0);
  border-bottom-left-radius: var(--r-1);
}
.support-chat-panel .scp-msg.from-bot {
  align-self: flex-start;
  background: var(--bg-2);
  color: var(--text-1);
  border-bottom-left-radius: var(--r-1);
  border: 1px dashed var(--border-strong);
}
.support-chat-panel .scp-time {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
}
.support-chat-panel .scp-foot {
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--sp-2);
  background: var(--bg-1);
}
.support-chat-panel .scp-foot input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  background: var(--bg-2);
  color: var(--text-0);
  font-size: var(--fs-sm);
}
.support-chat-panel .scp-suggestion {
  display: inline-flex;
  font-size: var(--fs-xs);
  padding: 6px 10px;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  color: var(--text-1);
  cursor: pointer;
  border: 1px solid var(--border);
  margin: 2px;
}
.support-chat-panel .scp-suggestion:hover {
  background: var(--bg-brand-soft);
  border-color: var(--brand-500);
}
.support-chat-panel .scp-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--sp-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
}
.support-chat-panel .scp-typing .dot {
  width: 6px; height: 6px;
  background: var(--text-2);
  border-radius: 50%;
  animation: chatTyping 1.2s var(--ease-in-out) infinite;
}
.support-chat-panel .scp-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.support-chat-panel .scp-typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatTyping {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50%      { transform: translateY(-4px); opacity: 1; }
}

/* =====================================================================
   2FA setup modal styling helpers (S2.SEC1)
   ===================================================================== */
.twofa-setup {
  text-align: center;
  padding: var(--sp-3);
}
.twofa-qr {
  display: inline-block;
  padding: var(--sp-3);
  background: white;
  border-radius: var(--r-4);
  margin: var(--sp-3) 0;
}
.twofa-qr img { display: block; width: 200px; height: 200px; }
.twofa-secret {
  display: inline-block;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-3);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  letter-spacing: 2px;
  user-select: all;
  margin: var(--sp-2) 0;
}
.twofa-code-input {
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
  margin: var(--sp-4) 0;
}
.twofa-code-input input {
  width: 44px; height: 56px;
  text-align: center;
  font-size: var(--fs-2xl);
  font-family: var(--font-mono);
  font-weight: 700;
  background: var(--bg-3);
  border: 2px solid var(--border-strong);
  border-radius: var(--r-3);
  color: var(--text-0);
  caret-color: var(--brand-500);
  transition: all var(--dur-fast) var(--ease-out);
}
.twofa-code-input input:focus {
  outline: none;
  border-color: var(--brand-500);
  background: var(--bg-2);
  box-shadow: var(--shadow-focus);
}
.twofa-code-input input.is-error {
  border-color: var(--danger);
  animation: shake 0.4s var(--ease-out);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.twofa-recovery-list {
  background: var(--bg-3);
  border: 1px dashed var(--warning);
  border-radius: var(--r-3);
  padding: var(--sp-3);
  margin: var(--sp-3) 0;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  text-align: left;
  columns: 2;
  column-gap: var(--sp-3);
}
.twofa-recovery-list .code {
  display: block;
  user-select: all;
  margin-bottom: 4px;
}

/* =====================================================================
   Inline form validation (premium error states)
   ===================================================================== */
.field-v2 {
  margin-bottom: var(--sp-3);
}
.field-v2 label.label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.field-v2 .input,
.field-v2 .field-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-3);
  color: var(--text-0);
  border: 1.5px solid var(--border);
  border-radius: var(--r-3);
  font-size: var(--fs-sm);
  transition: all var(--dur-fast) var(--ease-out);
}
.field-v2 .input:focus,
.field-v2 .field-input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--shadow-focus);
}
.field-v2.has-error .input,
.field-v2.has-error .field-input {
  border-color: var(--danger);
  animation: shake 0.4s var(--ease-out);
}
.field-v2 .field-error {
  display: none;
  font-size: var(--fs-xs);
  color: var(--danger-text);
  margin-top: 4px;
}
.field-v2.has-error .field-error { display: block; }
.field-v2 .field-helper {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 4px;
}

/* =====================================================================
   Light theme overrides
   ===================================================================== */
:root[data-theme="light"] .empty-state-v2 {
  border-color: var(--border-strong);
}
:root[data-theme="light"] .twofa-qr {
  background: var(--bg-2);
  border: 1px solid var(--border);
}
