/* ================= COMPONENTS =================
   Cards, buttons, inputs, pills, role selector, bar chart,
   avatar, map, service item, toast, modal, progress ring,
   logo bubble, float bubbles, tabs, donut, live indicator,
   quick action, section title.
*/

/* Cards */
.card {
  background: linear-gradient(155deg, var(--card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
}
.card-elevated {
  background: linear-gradient(155deg, var(--card-2) 0%, var(--card) 100%);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

/* KPI cards */
.kpi {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 16px;
  background: linear-gradient(155deg, var(--card-2), var(--card));
  border: 1px solid var(--border);
}
.kpi::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-2) 0%, transparent 70%);
  opacity: 0.25;
}
.kpi-accent::before { background: radial-gradient(circle, var(--accent) 0%, transparent 70%); opacity: 0.18; }

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: #04161F;
  font-weight: 700;
  padding: 14px 20px;
  border-radius: 14px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.01em;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(0, 212, 255, 0.35); }

.btn-ghost {
  background: rgba(56, 189, 248, 0.1);
  color: var(--fg);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.btn-ghost:active { transform: scale(0.97); }

/* Inputs */
.input-field {
  width: 100%;
  background: rgba(4, 22, 31, 0.6);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px 14px 46px;
  color: var(--fg);
  font-size: 14px;
  transition: all 0.2s;
  outline: none;
}
.input-field:focus { border-color: var(--accent-2); background: rgba(56, 189, 248, 0.06); }
.input-field::placeholder { color: var(--muted); }

/* Select options: los <option> se renderizan con fondo nativo (blanco)
   al desplegar la lista, pero heredan el color claro del body.
   Forzamos color oscuro + fondo claro para que sean legibles. */
.input-field option {
  color: #04161F;
  background: #ECFEFF;
}
.input-field optgroup {
  color: #04161F;
  background: #ECFEFF;
}

/* Role selector */
.role-card {
  position: relative;
  padding: 12px;
  border-radius: 14px;
  background: rgba(12, 45, 64, 0.4);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  gap: 10px;
}
.role-card.selected {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(0, 212, 255, 0.08));
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.2);
}
.role-card.selected .role-icon {
  background: var(--accent);
  color: #04161F;
}
.role-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.25s;
}

/* Bar chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
  padding-top: 8px;
}
.bar {
  flex: 1;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  border-radius: 6px 6px 2px 2px;
  min-height: 8px;
  position: relative;
  transition: all 0.3s;
  animation: barGrow 0.8s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}
.bar.muted {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.4) 0%, rgba(56, 189, 248, 0.15) 100%);
}

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill-active { background: rgba(56, 189, 248, 0.18); color: var(--accent-2); }
.pill-progress { background: rgba(255, 184, 77, 0.18); color: var(--warning); }
.pill-idle { background: rgba(123, 168, 196, 0.18); color: var(--muted); }
.pill-offline { background: rgba(255, 90, 95, 0.18); color: var(--danger); }
.pill-accent { background: rgba(0, 212, 255, 0.18); color: var(--accent); }

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}

/* Avatar */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  display: flex; align-items: center; justify-content: center;
  color: #04161F;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  font-family: 'Space Grotesk', sans-serif;
}
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.avatar-list { display: flex; }
.avatar-list .avatar { margin-left: -10px; border: 2px solid var(--card); }
.avatar-list .avatar:first-child { margin-left: 0; }

/* Map */
.map-canvas {
  position: relative;
  height: 160px;
  border-radius: 16px;
  overflow: hidden;
  background:
    linear-gradient(135deg, #082231 0%, #103850 100%);
  border: 1px solid var(--border);
}
.map-canvas::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}
.map-pin {
  position: absolute;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #04161F;
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.3), 0 4px 12px rgba(0,0,0,0.4);
  transform: translate(-50%, -50%);
  animation: pinPulse 2s infinite;
}
.map-pin.green { background: var(--accent-2); box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.3), 0 4px 12px rgba(0,0,0,0.4); }

/* Service item */
.service-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(12, 45, 64, 0.5);
  border: 1px solid var(--border);
  transition: all 0.2s;
  cursor: pointer;
}
.service-item:active { transform: scale(0.98); }
.service-item.active {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(56, 189, 248, 0.06));
  border-color: var(--accent);
}

/* Toast — centered within phone-shell */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  max-width: 90%;
  transform: translateX(-50%) translateY(100px);
  background: var(--card-2);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  max-width: 90%;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  z-index: 150;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}
.modal-overlay.active { display: flex; }
.modal-sheet {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 32px;
  animation: sheetUp 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
}
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--muted);
  border-radius: 2px;
  margin: 0 auto 16px;
  opacity: 0.5;
}

/* Progress ring */
.progress-ring {
  position: relative;
  width: 60px; height: 60px;
}
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring circle {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}
.progress-ring .bg-circle { stroke: rgba(56, 189, 248, 0.15); }
.progress-ring .fg-circle {
  stroke: var(--accent);
  stroke-dasharray: 163;
  transition: stroke-dashoffset 0.6s ease;
}

/* Logo bubble */
.logo-bubble {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.4);
}
.logo-bubble::after {
  content: '';
  position: absolute;
  top: 8px; right: 8px;
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
}

/* Floating bubbles */
.float-bubbles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.float-bubbles span {
  position: absolute;
  bottom: -60px;
  width: 20px; height: 20px;
  background: rgba(0, 212, 255, 0.15);
  border-radius: 50%;
  animation: bubble 8s infinite ease-in;
}

/* Tabs */
.tab-row {
  display: flex;
  gap: 6px;
  background: rgba(4, 22, 31, 0.5);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  border: none;
}
.tab-btn.active {
  background: var(--accent);
  color: #04161F;
}

/* Donut chart */
.donut {
  width: 80px; height: 80px;
  position: relative;
}
.donut svg { transform: rotate(-90deg); }
.donut .track { stroke: rgba(56, 189, 248, 0.12); fill: none; stroke-width: 10; }
.donut .fill { stroke: var(--accent); fill: none; stroke-width: 10; stroke-linecap: round; }
.donut-label {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
}

/* Skeleton shimmer / live indicator */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 90, 95, 0.15);
  border-radius: 999px;
  font-size: 10px;
  color: var(--danger);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.live-indicator::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse 1.4s infinite;
}

/* Action button row */
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: 14px;
  background: rgba(12, 45, 64, 0.6);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.quick-action:active { transform: scale(0.96); }
.quick-action-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 212, 255, 0.12);
  color: var(--accent);
}

/* Section title */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 12px;
}
.section-title h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.section-title .link {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

/* ================= MAP POLYGON & ZONE ================= */
.map-polygon {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.map-polygon polygon {
  fill: rgba(0, 212, 255, 0.08);
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  animation: dash 20s linear infinite;
}
#screen-cliente .map-polygon polygon { fill: rgba(14, 165, 233, 0.08); stroke: var(--accent); }
@keyframes dash { to { stroke-dashoffset: -100; } }

/* Pin states */
.map-pin.ocupado { background: var(--warning); box-shadow: 0 0 0 4px rgba(255,184,77,0.3), 0 4px 12px rgba(0,0,0,0.4); }
.map-pin.offline { background: var(--muted); box-shadow: 0 0 0 4px rgba(123,168,196,0.2), 0 4px 12px rgba(0,0,0,0.4); animation: none; opacity: 0.6; }
.map-pin.car { background: var(--info); box-shadow: 0 0 0 4px rgba(125,211,252,0.3), 0 4px 12px rgba(0,0,0,0.4); width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
.map-pin.car i { color: #04161F; width: 14px; height: 14px; }

/* Route line */
.map-route {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.map-route line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 5 5;
  animation: dash 2s linear infinite;
}
#screen-cliente .map-route line { stroke: var(--accent); }

/* Pin label */
.map-pin-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 600;
  color: var(--fg-2);
  background: rgba(4,22,31,0.9);
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 3;
}

/* ================= NOTIFICATIONS ================= */
.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(12, 45, 64, 0.5);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}
.notification-item.unread { border-color: var(--accent); background: linear-gradient(135deg, rgba(0,212,255,0.06), rgba(56,189,248,0.04)); }
.notification-item:active { transform: scale(0.98); }
.notification-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 212, 255, 0.12);
  flex-shrink: 0;
}

/* ================= STOCK ================= */
.stock-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(56,189,248,0.15);
  overflow: hidden;
}
.stock-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.badge-stock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-stock.ok { background: rgba(56,189,248,0.18); color: var(--accent-2); }
.badge-stock.low { background: rgba(255,184,77,0.18); color: var(--warning); }
.badge-stock.crit { background: rgba(255,90,95,0.18); color: var(--danger); }

/* ================= CONSUMO ================= */
.consumo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(4,22,31,0.5);
  border: 1px solid var(--border);
}
.consumo-cant {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 14px;
  min-width: 48px;
  text-align: right;
}

/* ================= DISPONIBILIDAD EMPLEADO ================= */
.dispo-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--border);
  background: rgba(12,45,64,0.6);
  transition: all 0.25s;
  flex-shrink: 0;
}
.dispo-btn:active { transform: scale(0.94); }
/* Estado disponible (celeste) */
.dispo-btn.dispo-on {
  border-color: var(--accent-2);
  background: rgba(56,189,248,0.18);
  color: var(--accent-2);
}
.dispo-btn.dispo-on .dispo-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.25);
  animation: pulse 1.8s infinite;
}
/* Estado no disponible (gris/rojo) */
.dispo-btn.dispo-off {
  border-color: var(--danger);
  background: rgba(255,90,95,0.12);
  color: var(--danger);
}
.dispo-btn.dispo-off .dispo-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255,90,95,0.18);
}

/* Banner "No disponible" en la página Hoy */
.no-dispo-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,90,95,0.10), rgba(255,90,95,0.04));
  border: 1px solid rgba(255,90,95,0.35);
}
.no-dispo-banner .nd-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,90,95,0.18);
  color: var(--danger);
  flex-shrink: 0;
}