/* ==========================================================================
   SUPERVISIÓN: MATRIZ DE CONTROL DE ASISTENCIA Y SERVICIOS
   Estilos dedicados para la pestaña "Asistencia" en el Panel de Supervisión
   Réplica de la matriz de servicios con semáforo de puntualidad
   ========================================================================== */

:root {
  --sa-pink: #e84c9a;
  --sa-pink-light: #fff5f9;
  --sa-pink-border: rgba(232, 76, 154, 0.25);
  --sa-cian: #3bb6c4;
  --sa-cian-light: #ecfeff;
  --sa-slate: #0f172a;
  --sa-slate-muted: #64748b;
  --sa-border: #e2e8f0;
  --sa-border-strong: #cbd5e1;
}

.sa-container {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 8px 10px 90px 10px !important;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--sa-slate);
  animation: saFadeIn 0.3s ease-out;
}

@keyframes saFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   TOP TOOLBAR & LEYENDA DE COLORES
   ========================================================================== */
.sa-top-bar {
  background: #ffffff;
  border: 1px solid var(--sa-border);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.04);
}

.sa-top-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sa-title-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 800;
  color: var(--sa-pink);
  background: var(--sa-pink-light);
  border: 1px solid var(--sa-pink-border);
  padding: 6px 12px;
  border-radius: 10px;
}

/* Week Navigator */
.sa-week-navigator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  padding: 3px 6px;
  border-radius: 10px;
  border: 1px solid var(--sa-border);
}

.sa-nav-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--sa-border);
  background: #ffffff;
  color: var(--sa-slate);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.sa-nav-btn:hover {
  background: var(--sa-pink-light);
  color: var(--sa-pink);
  border-color: var(--sa-pink);
}

.sa-week-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--sa-slate);
  padding: 0 6px;
  min-width: 170px;
  text-align: center;
}

.sa-btn-hoy {
  padding: 5px 12px;
  background: linear-gradient(135deg, var(--sa-pink) 0%, #db2777 100%);
  border: none;
  border-radius: 8px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(232, 76, 154, 0.3);
  transition: all 0.15s;
}

.sa-btn-hoy:hover {
  transform: translateY(-1px);
}

/* Selector de Ciudad */
.sa-city-pills {
  display: inline-flex;
  align-items: center;
  background: #fdf2f8;
  border: 1px solid rgba(232, 76, 154, 0.22);
  padding: 3px;
  border-radius: 12px;
  gap: 3px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sa-city-pill {
  padding: 6px 13px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--sa-slate-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  white-space: nowrap;
}

.sa-city-pill:hover:not(.active) {
  background: rgba(232, 76, 154, 0.1);
  color: var(--sa-pink);
  transform: translateY(-0.5px);
}

.sa-city-pill.active {
  background: linear-gradient(135deg, #e84c9a 0%, #d81b60 100%) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  box-shadow: 0 2px 8px rgba(232, 76, 154, 0.38) !important;
  transform: scale(1.02);
}

.sa-top-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buscador */
.sa-search-box {
  position: relative;
  width: 250px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.sa-search-input {
  width: 100% !important;
  height: 32px !important;
  box-sizing: border-box !important;
  padding: 0 12px 0 36px !important;
  border: 1.5px solid var(--sa-border) !important;
  border-radius: 8px !important;
  background: #f8fafc !important;
  font-size: 12.5px !important;
  font-family: inherit !important;
  color: var(--sa-slate) !important;
  outline: none !important;
  line-height: normal !important;
  transition: all 0.2s ease !important;
}

.sa-search-input:focus {
  background: #ffffff !important;
  border-color: var(--sa-pink) !important;
  box-shadow: 0 0 0 3px rgba(232, 76, 154, 0.15) !important;
}

.sa-search-icon {
  position: absolute !important;
  left: 11px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  color: var(--sa-slate-muted) !important;
  font-size: 13px !important;
  line-height: 1 !important;
  pointer-events: none !important;
  z-index: 2 !important;
}

.sa-btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  background: #ffffff;
  border: 1px solid var(--sa-border);
  border-radius: 8px;
  color: var(--sa-slate);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.sa-btn-refresh:hover {
  background: var(--sa-pink-light);
  border-color: var(--sa-pink);
  color: var(--sa-pink);
}

/* ==========================================================================
   LEYENDA DE COLORES REGLA DE ASISTENCIA
   ========================================================================== */
.sa-legend-bar {
  background: #ffffff;
  border: 1px solid var(--sa-border);
  border-radius: 12px;
  padding: 8px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
}

.sa-legend-title {
  font-weight: 800;
  color: var(--sa-slate);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 4px;
}

.sa-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--sa-slate);
  padding: 3px 8px;
  border-radius: 6px;
}

.sa-legend-chip {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sa-legend-chip.verde { background: #10b981; border: 1px solid #059669; }
.sa-legend-chip.amarillo { background: #f59e0b; border: 1px solid #d97706; }
.sa-legend-chip.azul { background: #0284c7; border: 1px solid #0369a1; }
.sa-legend-chip.rojo { background: #ef4444; border: 1px solid #dc2626; }
.sa-legend-chip.pendiente { background: #f1f5f9; border: 1px solid #cbd5e1; }

/* ==========================================================================
   TABLA / MATRIZ DE SERVICIOS
   ========================================================================== */
.sa-matrix-scroll-wrapper {
  background: #ffffff;
  border: 1.5px solid var(--sa-border);
  border-radius: 14px;
  overflow-x: auto;
  overflow-y: visible;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
  position: relative;
}

.sa-matrix-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  table-layout: fixed;
  box-sizing: border-box;
}

.sa-matrix-table th,
.sa-matrix-table td {
  box-sizing: border-box !important;
}

/* ENCABEZADOS DE DÍAS */
.sa-th-day-group {
  background: #fff0f6 !important;
  color: var(--sa-pink) !important;
  font-weight: 800 !important;
  font-size: 11.5px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  text-align: center !important;
  padding: 8px 4px !important;
  border-right: 1px solid #fbcfe8 !important;
  border-bottom: 1px solid #fbcfe8 !important;
}

.sa-th-day-group.is-today {
  background: #ffe4e6 !important;
  color: #be123c !important;
  box-shadow: inset 0 -2px 0 #e11d48 !important;
}

.sa-th-sub {
  background: #f8fafc !important;
  color: var(--sa-slate-muted) !important;
  font-weight: 700 !important;
  font-size: 10px !important;
  text-transform: uppercase !important;
  text-align: center !important;
  padding: 6px 4px !important;
  border-right: 1px solid var(--sa-border) !important;
  border-bottom: 1.5px solid var(--sa-border-strong) !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.sa-th-day-group,
.sa-th-sub,
.sa-th-meta {
  position: relative !important;
  user-select: none;
  box-sizing: border-box !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

th[data-col="col_horas"] { width: 62px; }
th[data-col="col_tipo"] { width: 140px; }
th[data-col="col_email"] { width: 180px; }
th[data-col="col_cliente"] { width: 190px; }
th[data-col="col_zona"] { width: 160px; }
th[data-col="col_nanny"] { width: 190px; }
th.sa-th-sub { width: 72px; }

/* Indicador de arrastre para redimensionar (Estilo Excel / Matriz) */
.sa-col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 7px;
  height: 100%;
  cursor: col-resize !important;
  user-select: none;
  z-index: 50;
  transition: background 0.15s ease;
}

.sa-col-resizer:hover,
.sa-col-resizer.resizing {
  background: var(--sa-pink) !important;
  box-shadow: 0 0 6px rgba(232, 76, 154, 0.6);
}

body.sa-is-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.sa-is-resizing * {
  user-select: none !important;
}

/* SECCIONES Y BANNERS DE BLOQUE */
.sa-section-header-row td {
  padding: 12px 10px !important;
  background: #ffffff !important;
  border-top: 1.5px solid var(--sa-border) !important;
  border-bottom: 1.5px solid var(--sa-border) !important;
}

.sa-section-banner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.sa-section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 76, 154, 0.25), transparent);
}

.sa-section-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  background: #fff5f9;
  border: 1px solid var(--sa-pink-border);
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  color: var(--sa-pink);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sa-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--sa-pink);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

/* FILAS DE SERVICIOS */
.sa-row-item {
  transition: background 0.15s ease;
}

.sa-row-item:hover td {
  background-color: #fafafa;
}

.sa-row-item td {
  padding: 6px 6px;
  border-right: 1px solid var(--sa-border);
  border-bottom: 1px solid var(--sa-border);
  vertical-align: middle;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   CELDAS DE HORARIOS (CON PUNTUALIDAD Y SEMÁFORO)
   ========================================================================== */
.sa-cell-hour {
  text-align: center !important;
  padding: 4px 4px !important;
  min-width: 76px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.sa-cell-hour:hover {
  filter: brightness(0.96);
}

.sa-hour-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 4px;
  border-radius: 6px;
  border: 1px solid transparent;
  min-height: 38px;
}

.sa-hour-prog {
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.15;
}

.sa-hour-sub {
  font-size: 9.5px;
  font-weight: 700;
  margin-top: 2px;
  line-height: 1;
}

/* 🟢 VERDE: +- 10 min */
.sa-cell-hour.sa-verde .sa-hour-block {
  background: #d1fae5 !important;
  color: #065f46 !important;
  border-color: #6ee7b7 !important;
}
.sa-cell-hour.sa-verde .sa-hour-sub {
  color: #047857 !important;
}

/* 🟡 AMARILLO: 10 a 15 min */
.sa-cell-hour.sa-amarillo .sa-hour-block {
  background: #fef3c7 !important;
  color: #92400e !important;
  border-color: #fcd34d !important;
}
.sa-cell-hour.sa-amarillo .sa-hour-sub {
  color: #b45309 !important;
}

/* 🔵 AZUL: > 15 min */
.sa-cell-hour.sa-azul .sa-hour-block {
  background: #e0f2fe !important;
  color: #0369a1 !important;
  border-color: #7dd3fc !important;
}
.sa-cell-hour.sa-azul .sa-hour-sub {
  color: #0284c7 !important;
}

/* 🔴 ROJO: No marcado */
.sa-cell-hour.sa-rojo .sa-hour-block {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border-color: #fca5a5 !important;
}
.sa-cell-hour.sa-rojo .sa-hour-sub {
  color: #b91c1c !important;
}

/* ⚪ PENDIENTE / PROGRAMADO (Horarios en fechas u horas futuras) */
.sa-cell-hour.sa-pendiente .sa-hour-block {
  background: #f8fafc !important;
  color: #475569 !important;
  border-color: #e2e8f0 !important;
}
.sa-cell-hour.sa-pendiente .sa-hour-prog {
  color: #334155 !important;
}
.sa-cell-hour.sa-pendiente .sa-hour-sub {
  color: #94a3b8 !important;
  font-weight: 600;
}

/* Vacío */
.sa-cell-hour.sa-empty {
  color: #cbd5e1;
}

/* ==========================================================================
   PÍLDORAS Y ELEMENTOS DE METADATOS
   ========================================================================== */
/* Total horas */
.sa-badge-total-horas {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--sa-slate);
  font-size: 11.5px;
  font-weight: 800;
  text-align: center;
  min-width: 48px;
}

.sa-badge-total-horas.has-hours {
  background: var(--sa-pink-light);
  color: var(--sa-pink);
  border: 1px solid var(--sa-pink-border);
}

/* Tipo de servicio */
.sa-pill-tipo {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  text-align: center;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  box-sizing: border-box;
  background: #fdf2f8;
  color: #be185d;
  border: 1px solid #fbcfe8;
}

/* Colores corporativos idénticos a la matriz de servicios admin */
.sa-pill-tipo.svc-neuronanny {
  background: #f3e8ff !important;
  color: #6d28d9 !important;
  border: 1px solid #ddd6fe !important;
}

.sa-pill-tipo.svc-educativa {
  background: #fce7f3 !important;
  color: #be185d !important;
  border: 1px solid #fbcfe8 !important;
}

.sa-pill-tipo.svc-miss-nanny {
  background: #fff7ed !important;
  color: #c2410c !important;
  border: 1px solid #fed7aa !important;
}

.sa-pill-tipo.svc-bitacora {
  background: #e0f2fe !important;
  color: #0369a1 !important;
  border: 1px solid #bae6fd !important;
}

.sa-pill-tipo.svc-estimulacion {
  background: #d1fae5 !important;
  color: #047857 !important;
  border: 1px solid #a7f3d0 !important;
}

/* Cliente (Texto limpio sin color de fondo) */
.sa-pill-cliente {
  display: inline-block;
  padding: 2px 2px;
  color: var(--sa-slate);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  box-sizing: border-box;
}

/* Niñera (Texto limpio sin color de fondo) */
.sa-pill-nanny {
  display: inline-block;
  padding: 2px 2px;
  color: var(--sa-slate);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  box-sizing: border-box;
}

.sa-pill-nanny.sin-asignar {
  color: #94a3b8;
  font-style: italic;
  font-weight: 500;
}

/* Zona */
.sa-cell-zona {
  display: inline-block;
  font-size: 11.5px;
  color: var(--sa-slate);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  box-sizing: border-box;
}

/* Email */
.sa-cell-email {
  display: inline-block;
  font-size: 11px;
  color: var(--sa-slate-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  box-sizing: border-box;
}

/* Checkbox OK */
.sa-check-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  color: transparent;
  font-size: 11px;
  font-weight: 900;
}

.sa-check-box.checked {
  background: var(--sa-pink);
  border-color: var(--sa-pink);
  color: #ffffff;
}

/* ==========================================================================
   TOOLTIP POPUP AL CLIC EN CELDA DE ASISTENCIA
   ========================================================================== */
.sa-tooltip-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  z-index: 100000;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: saFadeIn 0.2s ease-out;
}

/* ==========================================================================
   OPTIMIZACIÓN DE ANCHO COMPLETO PARA PANEL DE SUPERVISIÓN
   Elimina márgenes laterales vacíos en pantallas grandes
   ========================================================================== */
body:has(#subvista-supervision-asistencia:not([style*="display: none"])) .container,
body:has(#subvista-supervision-asistencia[style*="display: block"]) .container,
body:has(#vista-supervision.activa) .container {
  width: 99.5% !important;
  max-width: 99.5% !important;
  padding-left: 6px !important;
  padding-right: 6px !important;
  margin: 0 auto !important;
}
