/* ═══════════════════════════════════════════════════════════════
   14. PESTAÑA CONEXIONES
   ═══════════════════════════════════════════════════════════════ */
.connections-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md); /* Reducido a 16px para mayor cohesión */
}

@media (max-width: 768px) {
  .connections-grid {
    grid-template-columns: 1fr;
    gap: 12px; /* Reducido en móvil */
  }
}

.connection-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px var(--space-md); /* Reducido padding interno para lucir compacto y premium */
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  transition: border-color var(--transition), background-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}

.connection-card:hover {
  border-color: var(--border-strong);
}

.connection-led {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  position: absolute;
  top: 20px;
  right: 20px;
  transition: background-color var(--motion-duration-slow) var(--motion-ease-premium),
              box-shadow var(--motion-duration-slow) var(--motion-ease-premium);
}

.connection-icon {
  width: 60px;
  height: 60px;
  background: var(--tertiary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  color: var(--text-secondary);
}

.connection-icon svg {
  width: 28px;
  height: 28px;
}

.connection-name {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.connection-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
  font-weight: 500;
}

.connection-status {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--tertiary);
}

.connection-status.connected {
  background: var(--success-bg);
  color: var(--success-text);
}

.connection-status.disconnected {
  background: var(--danger-bg);
  color: var(--danger);
}

.connection-ping {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 10px;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════
   15. PESTAÑA CLIENTES Y SERVICIOS
   ═══════════════════════════════════════════════════════════════ */
/* ─────────────────────────────────────
   15.1 Sub-tabs slider
   ───────────────────────────────────── */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  width: fit-content;
}

.sub-tab {
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-weight: 600;
  color: var(--text-secondary);
}

.sub-tab.active {
  background: var(--text-primary);
  color: var(--bg);
}

.subtab-content {
  display: none;
}

.subtab-content.active {
  display: block;
}

/* ─────────────────────────────────────
   15.2 Tablas de datos (Responsive)
   ───────────────────────────────────── */
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.table-header h3 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.table-wrapper {
  overflow-x: auto;
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 14px 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.data-table th:first-child {
  border-radius: var(--radius-xl) 0 0 0;
}

.data-table th:last-child {
  border-radius: 0 var(--radius-xl) 0 0;
}

.data-table td {
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 769px) {
  .data-table tr:last-child td {
    border-bottom: none;
  }
}

.data-table tr:hover td {
  background: var(--tertiary);
}

.table-actions {
  display: flex;
  gap: 4px;
}





/* ═══════════════════════════════════════════════════════════════

   25. CLIENTES Y SERVICIOS
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────
   25.1  Sub-tabs
   ───────────────────────────────────── */
.sub-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--item-bg);
  border-radius: var(--radius-md);
  position: relative;
  width: fit-content;
  margin-bottom: var(--space-md);
}

.sub-tab {
  position: relative;
  z-index: 1;
  padding: 7px var(--space-md);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  transition: color var(--transition);
}

.sub-tab.active {
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ─────────────────────────────────────
   25.2  Toolbar
   ───────────────────────────────────── */
.cs-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}

/* Buscador */
.cs-search-wrapper {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.cs-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.cs-search-input {
  width: 100%;
  padding: 12px 42px 12px 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1;
  color: var(--text-primary);
  transition: all var(--transition);
  outline: none;
}

.cs-search-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.cs-search-input:focus {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.12);
}

.cs-search-clear-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition);
}

.cs-search-clear-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

.cs-search-clear-btn svg {
  width: 14px;
  height: 14px;
}

/* ─────────────────────────────────────
   25.3  Pill buttons (Vista / Filtrar / Ordenar / Nuevo)
   ───────────────────────────────────── */
.cs-btn-group {
  position: relative;
  display: inline-flex;
}

/* Estilos específicos para los botones de la toolbar de Clientes y Servicios */
#cs-btn-nuevo {
  width: 180px; /* Ancho fijo para evitar saltos entre 'Nuevo Cliente' y 'Nuevo Servicio' */
  flex-shrink: 0;
  justify-content: center;
}

.cs-chevron {
  opacity: 0.55;
  transition: transform var(--transition);
}

/* Flecha gira cuando el dropdown está abierto */
/* Flecha gira cuando el dropdown está abierto */
.cs-btn-group:has(+ .cs-dropdown:not([hidden])) .cs-chevron,
.btn.active .cs-chevron,
.btn[aria-expanded="true"] .cs-chevron {
  transform: rotate(180deg);
}

/* ─────────────────────────────────────
   25.4  Badge de filtros activos
   ───────────────────────────────────── */
.cs-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--text-primary);
  color: var(--bg);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  transition: background var(--transition), color var(--transition), opacity var(--transition);
}

.cs-badge--empty {
  background: var(--border-strong);
  color: var(--text-tertiary);
  opacity: 0.5;
}

.cs-client-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.cs-client-stats .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 50%;
  padding: 0;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.cs-client-stats .badge i,
.cs-client-stats .badge svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* ─────────────────────────────────────
   25.5  Table Layout Adjustments
   ───────────────────────────────────── */
.cs-data-table th {
  white-space: nowrap;
}

.cs-data-table .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  padding: 0;
  font-size: 14px; /* Same as table text */
  font-weight: 600;
  line-height: 1;
}

.cs-data-table .table-actions {
  justify-content: flex-start;
}
.cs-chips-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
  min-height: 32px;
}

.cs-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition);
}

.cs-chip:hover {
  background: var(--item-bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.cs-chip.cs-chip--active {
  background: var(--text-primary);
  color: var(--bg);
  border-color: var(--text-primary);
}

.cs-chip-x {
  margin-left: 2px;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
}

/* ─────────────────────────────────────
   25.6  Contador de resultados
   ───────────────────────────────────── */
.cs-count-label {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-bottom: var(--space-sm);
  min-height: 16px;
}

/* ─────────────────────────────────────
   25.7  Dropdowns — Estilos de contenido interno
   (Posicionamiento y animaciones → §26 .dropdown + DropdownManager)
   ───────────────────────────────────── */

/* Padding de CS dropdown ahora es manejado por .dropdown-body */
.cs-dropdown {
  /* Se eliminó el padding para respetar la estructura del header/body/footer genérica */
}

/* El dropdown de Ordenar es un poco más ancho */
#cs-dropdown-ordenar {
  min-width: 220px;
}

.cs-dropdown-section {
  padding: var(--space-xs) 0;
}

/* Solo aplicar línea divisoria si hay una sección visible previa */
.cs-dropdown-section:not([hidden]) ~ .cs-dropdown-section:not([hidden]) {
  border-top: 1px solid var(--border);
  margin-top: var(--space-xs);
  padding-top: var(--space-sm);
}

.cs-dropdown-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px var(--space-sm) 6px;
}

.cs-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px var(--space-sm);
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.cs-dropdown-item:hover {
  background: var(--item-bg);
}

.cs-dropdown-item[aria-selected="true"] {
  font-weight: 700;
  color: var(--text-primary);
}

.cs-dropdown-item svg {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Icono check al final de la opción activa */
.cs-check-icon {
  margin-left: auto;
  opacity: 0;
  color: var(--text-primary) !important;
}

.cs-dropdown-item[aria-selected="true"] .cs-check-icon {
  opacity: 1;
}

/* Rango de filtros numéricos */
.cs-filter-range {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 var(--space-xs);
}

.cs-filter-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
  min-width: 0;
}

.cs-filter-input:focus {
  border-color: var(--border-strong);
}

.cs-filter-sep {
  font-size: 14px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* cs-dropdown-footer reemplazado por dropdown-footer */
.cs-link-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

.cs-link-btn:hover {
  color: var(--text-primary);
}

/* ─────────────────────────────────────
   25.8  Tabla (Desktop y Mobile)
   ───────────────────────────────────── */
.cs-table-wrapper {
  width: 100%;
  overflow-x: auto; /* Permite scroll horizontal */
  overflow-y: hidden; /* Evitar barra de desplazamiento vertical interna */
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card-bg);
  -webkit-overflow-scrolling: touch;
}

.cs-data-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

@media (min-width: 769px) {
  .cs-data-table th:not(:last-child),
  .cs-data-table td:not(:last-child) {
    border-right: none;
  }
}

/* Evitar colapso o solapamiento de columnas en pantallas medianas, tabletas y móviles en horizontal */
@media (min-width: 769px) {
  .cs-data-table {
    width: 100%; /* Garantizar que el ancho nunca exceda el 100% del contenedor */
  }
}

.cs-data-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  background: var(--item-bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Redondeo de esquinas superiores del header */
.cs-data-table thead tr:first-child th:first-child {
  border-top-left-radius: calc(var(--radius-md) - 1px);
}

.cs-data-table thead tr:first-child th:last-child {
  border-top-right-radius: calc(var(--radius-md) - 1px);
}

.cs-data-table thead th[data-sort-asc] {
  cursor: pointer;
  transition: color var(--transition);
}

.cs-data-table thead th[data-sort-asc]:hover {
  color: var(--text-primary);
}

.cs-data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.cs-data-table tbody tr:last-child {
  border-bottom: none;
}

.cs-data-table tbody tr:hover {
  background: var(--item-bg);
}

.cs-data-table tbody td {
  padding: 11px 14px;
  vertical-align: middle;
  color: var(--text-primary);
}

@media (min-width: 769px) {
  .cs-data-table tbody td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Footer de tabla */
.cs-table-footer td {
  padding: 10px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
  background: var(--item-bg);
  font-weight: 500;
}

/* Redondeo de esquinas inferiores del footer */
.cs-table-footer td:first-child {
  border-bottom-left-radius: calc(var(--radius-md) - 1px);
}

.cs-table-footer td:last-child {
  border-bottom-right-radius: calc(var(--radius-md) - 1px);
}

/* Columna fija sticky (Nombre) */
.cs-col-fixed {
  position: sticky;
  left: 0;
  z-index: var(--z-base);
  background: var(--card-bg); /* Fondo para celdas del body */
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
  transition: background var(--transition);
}

.cs-data-table tbody tr:hover .cs-col-fixed {
  background: var(--item-bg);
}

/* Desactivar efectos hover en filas de Clientes y Servicios para evitar confusión */
#clients-table tbody tr:hover,
#services-table tbody tr:hover {
  background: transparent;
}

#clients-table tbody tr:hover td,
#services-table tbody tr:hover td {
  background: transparent;
}

#clients-table tbody tr:hover .cs-col-fixed,
#services-table tbody tr:hover .cs-col-fixed {
  background: var(--card-bg);
}

/* El header sticky debe mantener el color del header y el redondeo */
.cs-data-table thead th.cs-col-fixed {
  background: var(--item-bg);
  z-index: 10; /* Asegurar que esté por encima de otros headers para que el resizer sea cliqueable */
  /* El radio se hereda del selector de tr:first-child anterior */
}

/* Labels de columna (visibles en mobile como etiqueta sobre el valor) */
.cs-col-label {
  display: none;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.cs-col-value {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.cs-col-badge-wrapper {
  display: inline-flex;
  justify-content: center;
  width: 100%;
}

@media (min-width: 769px) {
  .cs-col-value {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
}

/* Valor numérico destacado (citas, precio promedio) */
.cs-accent {
  color: var(--accent);
  font-weight: 700;
}





/* ─────────────────────────────────────
   25.11  Empty state
   ───────────────────────────────────── */
.cs-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
}

.cs-empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-tertiary);
  opacity: 0.6;
}

.cs-empty-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Rediseño Empty State Premium (Nuevo) ── */
.cs-premium-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  animation: cs-premium-fade-in 0.3s ease-out;
}

@keyframes cs-premium-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.cs-empty-icon-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.cs-empty-icon-container svg {
  width: 24px;
  height: 24px;
  opacity: 0.85;
}

.cs-premium-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px 0;
  letter-spacing: -0.2px;
}

.cs-premium-empty-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 var(--space-md) 0;
  line-height: 1.4;
}

/* Tarjeta del cliente/servicio matched */
.cs-premium-empty-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: var(--space-lg);
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .cs-premium-empty-card {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background: var(--tertiary);
}

/* Avatar de iniciales */
.cs-premium-empty-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.2px;
}

.cs-premium-empty-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}

.cs-premium-empty-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.cs-premium-empty-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Badge pill a la derecha */
.cs-premium-empty-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.12);
  white-space: nowrap;
}

/* Botones de acción */
.cs-premium-empty-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
}

.cs-premium-empty-actions .btn {
  flex: 1;
  justify-content: center;
  padding: 10px var(--space-md);
  font-size: 13px;
  height: 38px;
}

@media (max-width: 480px) {
  .cs-premium-empty-actions {
    flex-direction: column;
    gap: 8px;
  }
}

/* ─────────────────────────────────────
   25.13  Responsive — Mobile (≤ 640px)
   ───────────────────────────────────── */
@media (max-width: 640px) {

  /* Toolbar: apilado en 2 filas principales */
  .cs-toolbar {
    flex-wrap: wrap;
    gap: var(--space-sm); /* Un poco más de espacio para separar filas */
  }

  /* Fila 1: Buscador + Botón Nuevo */
  .cs-search-wrapper {
    flex: 1 1 auto;
    width: calc(100% - 42px - var(--space-sm));
    order: 0;
  }

  #cs-btn-nuevo {
    order: 1;
    margin-left: 0;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
  }

  /* Fila 2: Vista, Filtrar, Ordenar */
  .cs-btn-group {
    order: 2;
    flex: 1 1 30%; /* Ocupan la segunda fila al estar llena la primera */
    min-width: 0;
  }

  .cs-btn-group .btn {
    width: 100%;
    justify-content: center;
    padding: 10px 8px;
    font-size: 13px;
  }

  .cs-btn-group .btn svg {
    width: 14px;
    height: 14px;
  }

  /* Botón Nuevo: solo ícono */
  #cs-btn-nuevo-label {
    display: none;
  }

  /* Fila 3: chips con scroll horizontal sin scrollbar visible */
  .cs-chips-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
  }

  .cs-chips-row::-webkit-scrollbar {
    display: none;
  }

  /* Nota: Las reglas de la tabla móvil (.cs-table-wrapper, .cs-data-table, etc.) se han unificado en la consulta @media (max-width: 768px) para garantizar coherencia en tablets y móviles. */
}


/* ═══════════════════════════════════════════════════════════════
   26. DROPDOWN GENÉRICO (DropdownManager)
   Reglas para dropdowns gestionados por dropdown-utils.js.
   Reutiliza tokens de §25 y el sistema de diseño existente.
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────
   26.1  Base compartida (oculto por defecto)
   ───────────────────────────────────── */
.dropdown {
  /* Oculto: se muestra vía JS eliminando el atributo hidden */
  display: flex;
  flex-direction: column;

  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-family: var(--font);
  color: var(--text-primary);

  /* Evita que el contenido se desborde */
  overflow-y: auto;
  overscroll-behavior: contain;

  /* Transición suave para cambios de tema */
  transition: background var(--transition), border-color var(--transition);
}

/* Header del dropdown */
.dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-md) var(--space-sm);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: var(--space-sm);
}

.dropdown-header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.dropdown-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.dropdown-close-btn:hover {
  background: var(--tertiary);
  color: var(--text-primary);
}

.dropdown-close-btn svg {
  width: 18px;
  height: 18px;
}

/* Body del dropdown */
.dropdown-body {
  flex: 1;
  padding: var(--space-md);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Footer del dropdown */
.dropdown-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md) var(--space-md);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─────────────────────────────────────
   26.2  Escritorio (≥ 768px)
   Posicionamiento calculado por JS.
   Animación: opacidad + ligero translateY.
   ───────────────────────────────────── */

/* @keyframes */
@keyframes dm-desktop-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes dm-desktop-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}

@media (min-width: 768px) {
  .dropdown[data-dm-mode="desktop"] {
    position: fixed; /* JS lo sobreescribe con los valores exactos */
    border-radius: var(--radius-md);
    padding: 0;      /* el contenido vive en .dropdown-header/body/footer */
    min-width: 280px;
    max-width: 420px;
    max-height: 80vh;
    z-index: var(--z-modal);
  }

  /* Estado visible */
  .dropdown[data-dm-mode="desktop"].dropdown-open {
    animation: dm-desktop-in 0.18s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }

  /* Estado cerrándose */
  .dropdown[data-dm-mode="desktop"].dropdown-closing {
    animation: dm-desktop-out 0.18s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }
}

/* ─────────────────────────────────────
   26.3  Móvil (< 768px)
   Bottom-sheet: fijo en la parte inferior,
   ancho completo, bordes redondeados solo arriba.
   ───────────────────────────────────── */

/* @keyframes */
@keyframes dm-mobile-in {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dm-mobile-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(100%);
  }
}

@media (max-width: 767px) {
  .dropdown[data-dm-mode="mobile"] {
    position: fixed;
    bottom: -20px; /* Extender un poco más abajo por seguridad en Safari */
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    /* Solo redondeo en la parte superior */
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-bottom: none;
    box-shadow: 0 -6px 32px rgba(0, 0, 0, 0.18);
    max-height: calc(85vh); /* Ajustado porque se extendió hasta abajo */
    z-index: 250; /* Por encima de .mobile-nav (200) */
  }

  /* Estado visible: sube desde abajo */
  .dropdown[data-dm-mode="mobile"].dropdown-open {
    animation: dm-mobile-in 0.28s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }

  /* Estado cerrándose: baja hacia abajo */
  .dropdown[data-dm-mode="mobile"].dropdown-closing {
    animation: dm-mobile-out 0.22s cubic-bezier(0.4, 0, 0.6, 1) forwards;
  }

  /* Eliminar oscurecimiento: El usuario solicitó quitarlo */
  /* body.dm-dropdown-open::before { ... } */

  /* Sin ancho máximo en móvil */
  .dropdown[data-dm-mode="mobile"] .dropdown-body {
    max-height: unset;
  }
}

/* ─────────────────────────────────────
   26.4  Dark mode overrides
   ───────────────────────────────────── */
[data-theme="dark"] .dropdown {
  background: var(--card-bg);
  border-color: var(--border);
}

[data-theme="dark"] .dropdown-header {
  border-bottom-color: var(--border);
}

[data-theme="dark"] .dropdown-footer {
  border-top-color: var(--border);
}


/* ═══════════════════════════════════════════════════════════════

   28.1 Badge circular consistente (candados y contadores)
   ───────────────────────────────────── */
.badge-circle {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  flex-shrink: 0 !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
}

.badge-circle i,
.badge-circle svg {
  width: 14px !important;
  height: 14px !important;
  display: block !important;
}

/* ═══════════════════════════════════════════════════════════════
   HISTORIAL DE CITAS — BADGES VISUALES (espejo del calendario)
   ═══════════════════════════════════════════════════════════════ */

/* Badge de estado para la tabla del Historial (mismas variables que .event-status-icon) */
.event-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.event-status-badge .status-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: currentColor;
  flex-shrink: 0;
  display: inline-block;
}

.event-status-badge.status-scheduled {
  background: var(--ev-icon-scheduled-bg);
  color: var(--ev-icon-scheduled-color);
  border: 1px solid var(--ev-icon-scheduled-border);
}

.event-status-badge.status-completed {
  background: var(--ev-icon-completed-bg);
  color: var(--ev-icon-completed-color);
  border: 1px solid var(--ev-icon-completed-border);
}

.event-status-badge.status-no-show {
  background: var(--ev-icon-noshow-bg);
  color: var(--ev-icon-noshow-color);
  border: 1px solid var(--ev-icon-noshow-border);
}

.event-status-badge.status-cancelled {
  background: var(--ev-icon-cancelled-bg);
  color: var(--ev-icon-cancelled-color);
  border: 1px solid var(--ev-icon-cancelled-border);
}

.event-status-badge svg {
  flex-shrink: 0;
}

/* Badge de ajustado para la tabla del Historial */
.event-adjusted-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--tertiary);
  color: var(--text-secondary);
  border: 1.2px solid var(--text-secondary); /* Borde con más contraste */
  text-transform: none;
  letter-spacing: 0.3px;
}

/* Alineación visual y armonía de altos para badges del historial */
#citas-table .event-status-badge,
#citas-table .event-origin-badge,
#citas-table .event-adjusted-badge {
  height: 22px;
  box-sizing: border-box;
  padding: 0 8px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#citas-table .event-status-badge svg,
#citas-table .event-origin-badge svg,
#citas-table .event-adjusted-badge svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

/* Badges / nombres de servicio con deep-link al Historial */
.cs-historial-link {
  /* No se requiere animación de escala ni sombra */
}

.cs-historial-link:hover {
  text-decoration: underline;
}

/* Sub-tabs del panel Agente */
#agente-sub-tabs {
  margin-bottom: 20px;
}

/* Tab-datos subtab: aseguramos que Historial sea de ancho completo */
#tab-datos .subtab-content {
  display: none;
}

#tab-datos .subtab-content.active {
  display: block;
}

/* Column Resizer for Tables */
.cs-data-table th {
  position: relative;
}

.th-resizer {
  position: absolute;
  top: 0;
  right: -8px; /* Centrado en el borde de separación */
  bottom: 0;
  width: 16px; /* Área de interacción ensanchada */
  cursor: col-resize;
  z-index: 100;
  user-select: none;
}

/* Indicador visual de línea premium centrado en el área de interacción */
.th-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 7px; /* Centrado exacto (16px de ancho -> 7px left + 2px width + 7px right) */
  width: 2px;
  background: transparent;
  transition: background var(--transition);
}

.th-resizer:hover::after,
.th-resizer.resizing::after {
  background: var(--accent); /* Línea azul de foco utilizando la variable de acento del sistema */
}

/* Eliminar el cambio de ancho y color de fondo antiguo */
.th-resizer:hover,
.th-resizer.resizing {
  background: transparent;
}

.table-resizing {
  cursor: col-resize;
  user-select: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   CORRECCIÓN DE RECORTES Y CHECKBOXES DE ESTADO
   ───────────────────────────────────────────────────────────────────────────── */

/* Prevenir recortes de selectores de filtros y permitir scroll vertical controlado */
#cs-dropdown-filtrar {
  overflow: hidden !important;
}

#cs-dropdown-filtrar .dropdown-body {
  overflow-y: auto !important;
  scrollbar-gutter: stable;
}

/* Checkbox de estado con diseño premium */
.cs-status-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50% !important; /* Círculos perfectos para los checkboxes */
  background: var(--input-bg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition);
  margin-right: 8px;
  flex-shrink: 0;
}

.cs-status-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.cs-status-checkbox:checked::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid var(--white);
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg);
  position: absolute;
  top: 2px;
  left: 4.5px; /* Centrado preciso dentro del círculo de 16px */
}

[data-theme="dark"] .cs-status-checkbox:checked::after {
  border-color: var(--bg-primary);
}

/* Alinear fecha final al borde derecho */
#cs-filter-fecha-fin-container .dp-dropdown {
  left: auto !important;
  right: 0 !important;
  transform-origin: top right !important;
  animation: dpFadeInRight 0.2s ease forwards !important;
}

/* En móvil, alinear la inicial a la izquierda y la final a la derecha */
@media (max-width: 768px) {
  #cs-filter-fecha-inicio-container .dp-dropdown {
    left: 0 !important;
    transform: none !important;
    transform-origin: top left !important;
    animation: dpFadeInLeft 0.2s ease forwards !important;
  }
  #cs-filter-fecha-fin-container .dp-dropdown {
    left: auto !important;
    right: 0 !important;
    transform: none !important;
    transform-origin: top right !important;
    animation: dpFadeInRight 0.2s ease forwards !important;
  }
}

/* Animación de entrada para alineación derecha */
@keyframes dpFadeInRight {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Crecimiento dinámico del panel de filtros en móvil */
@media (max-width: 767px) {
  .dropdown[data-dm-mode="mobile"] {
    transition: min-height 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.28s ease;
  }
  /* Cuando abre el calendario de rango de fechas, crecer a 520px (optimizado para evitar espacio excesivo) */
  #cs-dropdown-filtrar.has-open-datepicker {
    min-height: 520px !important;
  }
  /* Cuando abre la lista de estados, crecer a 460px (optimizado para evitar espacio excesivo) */
  #cs-dropdown-filtrar.has-open-estatus {
    min-height: 460px !important;
  }
}

/* Animación de crecimiento y compresión del popover de filtros */
#cs-dropdown-filtrar .dropdown-body {
  transition: padding-bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Asegurar que el botón de limpiar filtros no sea tapado por la lista de estados al abrirla */
#cs-dropdown-filtrar.has-open-estatus .dropdown-body {
  padding-bottom: 220px !important;
}

/* Asegurar que el botón de limpiar filtros no sea tapado por el selector de rango de fecha al abrirlo */
#cs-dropdown-filtrar.has-open-datepicker .dropdown-body {
  padding-bottom: 255px !important;
}

/* Evitar scroll innecesario para los estados (5 opciones) en la versión de móvil */
#cs-filter-estatus-dropdown,
#select-estatus-dropdown {
  max-height: 240px;
}

/* Evitar scroll innecesario para los estados en la versión de escritorio */
@media (min-width: 768px) {
  #cs-filter-estatus-dropdown,
  #select-estatus-dropdown {
    max-height: none !important;
    overflow-y: visible !important;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   PAGINACIÓN PREMIUM (CENTRADOS Y MICRO-ANIMACIONES)
   ───────────────────────────────────────────────────────────────────────────── */
.cs-pagination-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
  padding: var(--space-sm) 0;
  flex-wrap: wrap;
  width: 100%;
}

.cs-pagination {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.cs-pagination-pages {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.cs-pagination-page,
.cs-pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  user-select: none;
  box-shadow: none !important;
}

.cs-pagination-page {
  width: 32px;
  color: var(--text-secondary);
  font-weight: 500;
}

.cs-pagination-page.active {
  font-weight: 700;
  color: var(--text-primary) !important;
  background: transparent;
  cursor: default;
}

.cs-pagination-btn {
  width: auto;
  padding: 0 8px;
  gap: 6px;
  color: var(--text-primary);
  font-weight: 600;
}

.cs-pagination-btn:disabled {
  color: var(--text-tertiary);
  opacity: 0.45;
  cursor: default;
  transform: none !important;
}

.cs-pagination-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.cs-pagination-ellipsis {
  font-size: 14px;
  color: var(--text-tertiary);
  width: 24px;
  text-align: center;
  user-select: none;
  font-weight: 500;
}

.cs-pagination-limit {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Dropdown de límite subiendo hacia arriba */
.cs-pagination-limit-select {
  position: relative;
  width: 70px;
}

.cs-pagination-limit-select .searchable-select-dropdown {
  bottom: calc(100% + 4px);
  top: auto;
  min-width: 70px;
}

.cs-pagination-select-display {
  width: 70px !important;
  padding: 6px 28px 6px 12px !important;
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px !important;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2380868B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  user-select: none;
  text-align: left;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

[data-theme="dark"] .cs-pagination-select-display {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239AA0A6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.cs-pagination-select-display:hover {
  border-color: var(--border-strong);
  background-color: var(--item-bg-hover);
}

.cs-pagination-select-display:focus {
  border-color: var(--accent);
}

.cs-pagination-limit-select .searchable-select-option.active {
  background: var(--accent);
  color: var(--white);
  font-weight: 600;
}

.cs-pagination-limit-select .searchable-select-option.active:hover {
  background: var(--accent-hover);
  color: var(--white);
}

@media (max-width: 640px) {
  .cs-pagination-container {
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
  }
}

/* Badge circular para cabeceras de tablas (ej. registros a validar) */
.cs-header-badge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
  flex-shrink: 0 !important;
  border-radius: 50% !important;
  padding: 0 !important;
  background-color: var(--accent) !important;
  color: #FFFFFF !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  aspect-ratio: 1 / 1 !important;
  box-shadow: none !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
  user-select: none !important;
  pointer-events: none !important;
}