/* ==========================================================================
   Variables y Reset Base
   ========================================================================== */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-text: #ffffff;
  
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-surface: #ffffff;
  --bg-slot-hover: #f1f5f9;
  --bg-slot-drop-target: #e0e7ff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-light: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-hour: #cbd5e1;
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: #fef2f2;

  /* Categorías */
  --cat-trabajo: #3b82f6;
  --cat-trabajo-bg: #eff6ff;
  --cat-trabajo-border: #60a5fa;

  --cat-reunion: #8b5cf6;
  --cat-reunion-bg: #f5f3ff;
  --cat-reunion-border: #a78bfa;

  --cat-personal: #10b981;
  --cat-personal-bg: #ecfdf5;
  --cat-personal-border: #34d399;

  --cat-salud: #f59e0b;
  --cat-salud-bg: #fffbeb;
  --cat-salud-border: #fbbf24;

  --cat-urgente: #ef4444;
  --cat-urgente-bg: #fef2f2;
  --cat-urgente-border: #f87171;

  /* Dimensiones del horario de 15 minutos */
  --slot-height: 24px;
  --hour-height: calc(var(--slot-height) * 4); /* 96px */
  --sidebar-width: 280px;
  --header-height: 64px;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-event: 0 2px 5px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Layout Principal
   ========================================================================== */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   Barra Lateral (Menú Izquierdo)
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s ease, transform 0.25s ease;
  z-index: 30;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  transform: translateX(-100%);
  overflow: hidden;
  border-right-color: transparent;
  pointer-events: none;
}

/* Botón de alternar menú lateral en la cabecera */
.header-sidebar-toggle {
  display: none;
}

/* En desktop, cuando la barra lateral está colapsada, mostrar el botón en la cabecera para poder reabrirlo */
.sidebar.collapsed ~ .main-content .header-sidebar-toggle {
  display: inline-flex;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary);
}

.brand-logo {
  width: 64px;
  height: 64px;
  max-width: 64px;
  max-height: 64px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand-icon {
  width: 26px;
  height: 26px;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  padding-left: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

.nav-item:hover:not(.disabled) {
  background-color: var(--primary-light);
  color: var(--primary);
}

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-item .badge {
  margin-left: auto;
  background-color: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

/* Mini Calendario */
.mini-calendar-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.mini-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.mini-month-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  text-transform: capitalize;
}

.mini-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: bold;
}

.mini-nav-btn:hover {
  background-color: var(--border-light);
  color: var(--text-main);
}

.mini-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 0.4rem;
}

.mini-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mini-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  transition: all 0.15s ease;
  position: relative;
}

.mini-day:hover {
  background-color: var(--border-light);
}

.mini-day.other-month {
  color: var(--text-light);
  opacity: 0.45;
}

/* Escala de Densidad en Tonos Rosa */
/* Menos de 10 citas (< 10): rosa casi transparente */
.mini-day.density-low {
  background-color: rgba(244, 63, 94, 0.18);
  border-color: rgba(244, 63, 94, 0.32);
  color: #9f1239;
  font-weight: 600;
}

.mini-day.density-low:hover {
  background-color: rgba(244, 63, 94, 0.28);
}

/* De 10 a 15 citas: rosa medio transparente */
.mini-day.density-medium {
  background-color: rgba(244, 63, 94, 0.52);
  border-color: rgba(244, 63, 94, 0.68);
  color: #ffffff;
  font-weight: 700;
}

.mini-day.density-medium:hover {
  background-color: rgba(244, 63, 94, 0.65);
}

/* Más de 15 citas: rosa sin transparencias (100% opaco) */
.mini-day.density-high {
  background-color: #f43f5e;
  border-color: #f43f5e;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(244, 63, 94, 0.4);
}

.mini-day.density-high:hover {
  background-color: #e11d48;
}

.mini-day.today {
  box-shadow: 0 0 0 1.5px var(--primary);
  font-weight: 700;
}

.mini-day.selected {
  background-color: var(--primary) !important;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 3.5px var(--primary) !important;
}

/* Leyenda de Densidad del Calendario Mensual */
.mini-calendar-legend {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.legend-scale-item {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  cursor: default;
}

.legend-dot {
  width: 8.5px;
  height: 8.5px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.density-low {
  background-color: rgba(244, 63, 94, 0.22);
  border: 1px solid rgba(244, 63, 94, 0.45);
}

.legend-dot.density-medium {
  background-color: rgba(244, 63, 94, 0.55);
  border: 1px solid rgba(244, 63, 94, 0.75);
}

.legend-dot.density-high {
  background-color: #f43f5e;
}

/* Categorías */
.categories-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
}

.category-item input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
}

.category-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Footer de la Barra Lateral */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.footer-action-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.footer-action-btn svg {
  width: 16px;
  height: 16px;
}

.footer-action-btn:hover {
  background-color: var(--border-light);
  color: var(--text-main);
}

.footer-action-btn.text-danger:hover {
  background-color: var(--danger-light);
  color: var(--danger);
}

/* ==========================================================================
   Contenido Principal
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  background-color: var(--bg-app);
}

/* Header */
.main-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.date-navigation {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.nav-arrows {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.current-date-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin: 0;
  text-transform: capitalize;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.view-tag {
  background-color: var(--primary-light);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
}

/* Banner de ayuda */
.instruction-banner {
  background-color: #f1f5f9;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.5rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

/* ==========================================================================
   Rejilla del Calendario (15 minutos)
   ========================================================================== */
.calendar-viewport {
  flex: 1;
  overflow-y: scroll;
  overflow-x: auto;
  position: relative;
  background-color: var(--bg-surface);
  scroll-behavior: smooth;
}

.calendar-container {
  display: flex;
  min-width: 650px;
  height: calc(var(--slot-height) * 96); /* 96 slots de 15 min = 24 horas = 2304px */
  position: relative;
}

/* Columna de Horas */
.time-gutter {
  width: 75px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  user-select: none;
}

.time-slot-label {
  height: var(--slot-height);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px dotted var(--border-light);
}

.time-slot-label.hour-mark {
  border-bottom: 1px solid var(--border-hour);
  font-weight: 600;
  color: var(--text-main);
}

.time-slot-label.half-hour-mark {
  border-bottom: 1px dashed var(--border-subtle);
  color: var(--text-light);
  font-size: 0.7rem;
}

.time-slot-label.quarter-hour-mark {
  color: transparent; /* Solo visible en hover para mantener limpieza */
  font-size: 0.65rem;
}

.time-slot-label.quarter-hour-mark:hover {
  color: var(--text-light);
}

/* Rejilla de Día */
.day-grid {
  flex: 1;
  position: relative;
  background-color: var(--bg-surface);
}

/* Capa de Ranuras de 15 min */
.slots-container {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.slot-row {
  height: var(--slot-height);
  border-bottom: 1px dotted #f1f5f9;
  position: relative;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.slot-row:hover {
  background-color: var(--bg-slot-hover);
}

.slot-row.hour-row {
  border-bottom: 1px solid var(--border-hour);
}

.slot-row.half-hour-row {
  border-bottom: 1px dashed var(--border-subtle);
}

/* Drop target highlight */
.slot-row.drag-over {
  background-color: var(--bg-slot-drop-target) !important;
  border-top: 2px solid var(--primary) !important;
}

/* Capa de Eventos */
.events-container {
  position: absolute;
  inset: 0;
  pointer-events: none; /* Los clicks pasan a través salvo en los elementos de evento */
}

/* Tarjeta de Evento */
.event-card {
  position: absolute;
  left: 10px;
  right: 15px;
  background-color: #ffffff;
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  pointer-events: auto;
  cursor: grab;
  user-select: none;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
  z-index: 10;
  opacity: 1;
}

.event-card:active {
  cursor: grabbing;
}

.event-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 20;
}

.event-card.dragging {
  opacity: 0.45;
  box-shadow: var(--shadow-lg);
  cursor: grabbing;
}

/* Estilos de colores por categoría */
.event-card.category-trabajo {
  background-color: var(--cat-trabajo-bg);
  border-left-color: var(--cat-trabajo);
  color: #1e3a8a;
}
.event-card.category-reunion {
  background-color: var(--cat-reunion-bg);
  border-left-color: var(--cat-reunion);
  color: #4c1d95;
}
.event-card.category-personal {
  background-color: var(--cat-personal-bg);
  border-left-color: var(--cat-personal);
  color: #064e3b;
}
.event-card.category-salud {
  background-color: var(--cat-salud-bg);
  border-left-color: var(--cat-salud);
  color: #78350f;
}
.event-card.category-urgente {
  background-color: var(--cat-urgente-bg);
  border-left-color: var(--cat-urgente);
  color: #7f1d1d;
}

.event-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.25;
  width: 100%;
}

.event-header-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-header-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.event-time {
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.event-client-service {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-title {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-description {
  font-size: 0.72rem;
  opacity: 0.85;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tirador para redimensionar duración (15 min) */
.event-resize-handle {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  cursor: ns-resize;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.event-resize-handle::after {
  content: '';
  width: 24px;
  height: 2px;
  background-color: rgba(0, 0, 0, 0.25);
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.event-card:hover .event-resize-handle::after {
  opacity: 1;
}

/* Indicador de Hora Actual */
.current-time-indicator {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background-color: #ef4444;
  z-index: 20;
  pointer-events: none;
}

.time-dot {
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  background-color: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

.time-label {
  position: absolute;
  left: 10px;
  top: -10px;
  background-color: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}

/* ==========================================================================
   Botones y Componentes Comunes
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-text);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #ffffff;
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--border-light);
  border-color: var(--border-hour);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background-color: var(--border-light);
  color: var(--text-main);
}

.btn-danger {
  background-color: var(--danger-light);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background-color: var(--danger);
  color: #ffffff;
}

.btn-warning {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.btn-warning:hover {
  background-color: #fde68a;
  border-color: #fcd34d;
}

.mode-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.78rem;
}

.online-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  font-size: 0.78rem;
  font-weight: 600;
}

.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.mode-dot.amber {
  background-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

.mode-dot.green {
  background-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-icon {
  width: 16px;
  height: 16px;
}

.icon-btn {
  background: none;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.icon-btn:hover {
  background-color: var(--border-light);
  color: var(--text-main);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.mobile-only {
  display: none;
}

/* Colores de Categorías para badges */
.color-trabajo { background-color: var(--cat-trabajo); }
.color-reunion { background-color: var(--cat-reunion); }
.color-personal { background-color: var(--cat-personal); }
.color-salud { background-color: var(--cat-salud); }
.color-urgente { background-color: var(--cat-urgente); }

/* ==========================================================================
   Modal Dialog
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: #ffffff;
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-form {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-group label .required {
  color: var(--danger);
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  background-color: #fff;
  transition: var(--transition);
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.category-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-radio {
  cursor: pointer;
}

.category-radio input[type="radio"] {
  display: none;
}

.radio-badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  opacity: 0.45;
  transition: var(--transition);
  border: 2px solid transparent;
}

.category-radio input[type="radio"]:checked + .radio-badge {
  opacity: 1;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary);
  transform: translateY(-1px);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.modal-actions-right {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

/* ==========================================================================
   Toast Notificaciones
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--text-main);
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Gestión de Usuario, Perfil y Seguridad
   ========================================================================== */
.user-profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  margin-bottom: 0.4rem;
}

.user-profile-card:hover {
  background-color: var(--primary-light);
  border-color: #cbd5e1;
}

.user-avatar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
  background-color: var(--primary);
  transition: background-color 0.2s ease;
}

.user-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #10b981;
  border: 2px solid #ffffff;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-action-arrow {
  color: var(--text-light);
  display: flex;
  align-items: center;
}

.user-action-arrow svg {
  width: 16px;
  height: 16px;
}

/* Botón de Perfil en Header */
.header-user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.65rem 0.3rem 0.35rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  cursor: pointer;
  transition: var(--transition);
}

.header-user-btn:hover {
  background-color: var(--border-light);
  border-color: var(--border-hour);
}

.user-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  color: #ffffff;
  background-color: var(--primary);
}

.header-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal Extendido y Pestañas */
.modal-dialog-lg {
  max-width: 580px;
}

.modal-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  background-color: #f1f5f9;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.modal-tab-btn,
.tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.modal-tab-btn:hover,
.tab-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.6);
}

.modal-tab-btn.active,
.tab-btn.active {
  color: var(--primary);
  font-weight: 600;
  background-color: #ffffff;
  border-color: rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.tab-icon {
  width: 16px;
  height: 16px;
}

.modal-tab-contents {
  padding: 1.5rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* Editor de Avatar */
.avatar-editor-section {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 0.5rem;
}

.user-avatar-large {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  background-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.2s ease;
}

.avatar-colors-picker {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label-sm {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.color-options-row {
  display: flex;
  gap: 0.5rem;
}

.avatar-color-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.avatar-color-circle:hover {
  transform: scale(1.1);
}

.avatar-color-circle.active {
  box-shadow: 0 0 0 2px var(--primary);
  transform: scale(1.15);
}

.color-opt-indigo { background-color: #4f46e5; }
.color-opt-emerald { background-color: #059669; }
.color-opt-violet { background-color: #7c3aed; }
.color-opt-amber { background-color: #d97706; }
.color-opt-rose { background-color: #e11d48; }
.color-opt-sky { background-color: #0284c7; }

/* Seguridad y Medidor de Contraseña */
.security-intro-box {
  display: flex;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  margin-bottom: 0.25rem;
}

.shield-icon {
  width: 24px;
  height: 24px;
  color: #2563eb;
  flex-shrink: 0;
  margin-top: 2px;
}

.security-intro-box h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e3a8a;
  margin-bottom: 2px;
}

.security-intro-box p {
  font-size: 0.78rem;
  color: #1e40af;
  line-height: 1.35;
}

.password-meter-wrap {
  margin-top: 0.25rem;
}

.meter-bar-container {
  height: 6px;
  width: 100%;
  background-color: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.meter-bar {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.meter-bar.weak { width: 33%; background-color: #ef4444; }
.meter-bar.medium { width: 66%; background-color: #f59e0b; }
.meter-bar.strong { width: 100%; background-color: #10b981; }

.meter-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.helper-text {
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.helper-text code {
  background-color: #f1f5f9;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-weight: 600;
  color: var(--primary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.user-status-text {
  font-size: 0.78rem;
  color: #059669;
  font-weight: 600;
}

/* ==========================================================================
   Pantalla de Login Online
   ========================================================================== */
.login-screen-backdrop {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}

.login-card {
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border-subtle);
  padding: 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
}

.login-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.login-brand {
  justify-content: center;
  font-size: 1.35rem;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.25rem;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-light);
  pointer-events: none;
}

.input-with-icon input {
  width: 100%;
  padding-left: 2.45rem !important;
  padding-right: 2.45rem !important;
}

.btn-toggle-password {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-toggle-password:hover {
  color: var(--text-main);
}

.btn-toggle-password svg {
  width: 18px;
  height: 18px;
}

.login-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
}

/* Alertas */
.alert {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  line-height: 1.35;
}

.alert-danger {
  background-color: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.alert-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Spinner de Carga */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Vistas y Sección de Clientes
   ========================================================================== */
.app-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#view-clients {
  overflow-y: auto;
  background-color: var(--bg-app);
  padding: 1.5rem;
  gap: 1.25rem;
}

.clients-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.clients-view-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.clients-view-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.clients-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.clients-search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 280px;
}

.clients-search-box .search-icon {
  position: absolute;
  left: 0.75rem;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.clients-search-box input {
  width: 100%;
  padding: 0.55rem 2rem 0.55rem 2.25rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background-color: #fff;
  transition: var(--transition);
}

.clients-search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.clear-search-btn {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.clear-search-btn:hover {
  color: var(--text-main);
}

/* Tarjeta y Tabla de Clientes */
.clients-content-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.clients-table-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.clients-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.clients-table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.clients-table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

.clients-table tr:last-child td {
  border-bottom: none;
}

.clients-table tr:hover td {
  background-color: #f8fafc;
}

.client-cell-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.client-avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.client-info-names {
  display: flex;
  flex-direction: column;
}

.client-full-name {
  font-weight: 600;
  color: var(--text-main);
}

.client-telegram-tag {
  font-size: 0.75rem;
  color: #0284c7;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.client-doc-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}

.client-contact-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.client-contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.85rem;
}

.client-contact-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.client-contact-link svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.client-actions-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

.client-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: #fff;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.client-action-btn svg {
  width: 15px;
  height: 15px;
}

.client-action-btn:hover {
  background-color: var(--border-light);
  color: var(--text-main);
}

.client-action-btn.delete-btn:hover {
  background-color: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}

.clients-table-footer {
  padding: 0.85rem 1.25rem;
  background-color: #f8fafc;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.84rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: #ffffff;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-page:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background-color: var(--primary-light);
}

.btn-page.active {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 600;
}

.btn-page:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-ellipsis {
  padding: 0 0.25rem;
  color: var(--text-light);
  font-size: 0.85rem;
}

/* Empty State */
.clients-empty-state {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3.5rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.empty-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: #f1f5f9;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.empty-icon-wrap svg {
  width: 32px;
  height: 32px;
}

.clients-empty-state h3 {
  font-size: 1.15rem;
  color: var(--text-main);
  font-weight: 700;
}

.clients-empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 400px;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.modal-dialog-sm {
  max-width: 440px;
}

/* ==========================================================================
   Estilos específicos de Servicios
   ========================================================================== */
#view-services {
  overflow-y: auto;
  background-color: var(--bg-app);
  padding: 1.5rem;
  gap: 1.25rem;
}

.service-color-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.8rem;
  font-family: monospace;
}

.service-color-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #cbd5e1;
  flex-shrink: 0;
}

.service-color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.color-picker-input {
  width: 44px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #fff;
}

.color-palette-presets {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.color-preset-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-preset-btn:hover {
  transform: scale(1.15);
}

.color-preset-btn.active {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary);
}

/* ==========================================================================
   Botones de Servicios en el Modal de Citas
   ========================================================================== */
.services-button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.service-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: #fff;
  color: var(--text-main);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.service-pill-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.service-pill-btn.active {
  font-weight: 600;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.service-pill-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease;
}

.service-pill-btn.active .service-pill-dot {
  transform: scale(1.25);
  box-shadow: 0 0 0 2px #fff;
}

/* ==========================================================================
   Selector de Cliente con Buscador Integrado (Combobox)
   ========================================================================== */
.client-picker-group {
  position: relative;
}

.client-picker-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.client-picker-row .client-picker {
  flex: 1;
}

.btn-picker-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.85rem;
  min-height: 42px;
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.25);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-picker-add:hover {
  background-color: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.client-picker {
  position: relative;
  width: 100%;
}

.client-picker-trigger {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: #fff;
  display: flex;
  align-items: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.client-picker-trigger:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.client-picker-search-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.picker-search-icon {
  position: absolute;
  left: 0.75rem;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.client-picker-search-wrap input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.6rem 0.75rem 0.6rem 2.25rem;
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
}

.client-picker-selected {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.4rem 0.65rem;
  background-color: #f8fafc;
  border-radius: calc(var(--radius-sm) - 1px);
}

.client-picker-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.client-picker-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color 0.15s ease;
}

.client-picker-name:hover {
  color: var(--primary);
  text-decoration: underline;
}

.client-picker-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.4rem;
  border-radius: 4px;
}

.client-picker-clear-btn:hover {
  color: #ef4444;
  background-color: #fee2e2;
}

/* Desplegable de opciones filtradas */
.client-picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background-color: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  max-height: 230px;
  overflow-y: auto;
  z-index: 100;
}

.client-picker-option {
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.1s ease;
}

.client-picker-option:last-child {
  border-bottom: none;
}

.client-picker-option:hover,
.client-picker-option.highlighted {
  background-color: #f1f5f9;
}

.client-picker-option-info {
  display: flex;
  flex-direction: column;
}

.client-picker-option-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.client-picker-option-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
}

.client-picker-empty-opt {
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Historia y Métricas de Citas del Cliente
   ========================================================================== */
.client-history-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.5rem 0;
}

.client-history-table-wrap {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: #fff;
}

.client-history-table th {
  position: sticky;
  top: 0;
  z-index: 5;
  background-color: #f8fafc;
}

.client-history-metrics-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
  background-color: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.metric-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.metric-value.text-success {
  color: #15803d;
}

.metric-value.text-danger {
  color: #b91c1c;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-width) !important;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    z-index: 50;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .sidebar.mobile-open ~ .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .header-sidebar-toggle,
  .mobile-only {
    display: inline-flex;
  }
}

/* ==========================================================================
   Configuración de Disponibilidad Horaria por Agenda
   ========================================================================== */
.agenda-days-schedule-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.day-schedule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.85rem;
  background: #ffffff;
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 8px;
  gap: 12px;
  transition: all 0.15s ease;
}

.day-schedule-row.disabled {
  background: var(--bg-hover, #f8fafc);
  opacity: 0.65;
}

.day-schedule-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
}

.day-schedule-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.day-schedule-hours {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.day-schedule-hours input[type="time"] {
  padding: 4px 8px;
  border: 1px solid var(--border-subtle, #cbd5e1);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-main);
  background: #ffffff;
}

.day-schedule-hours input[type="time"]:disabled {
  background: #f1f5f9;
  cursor: not-allowed;
  color: #94a3b8;
}

/* Estilos para Gestión de Usuarios y Roles */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.role-badge.role-admin {
  background-color: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.role-badge.role-operador {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-pill.active {
  background-color: #dcfce7;
  color: #15803d;
}

.status-pill.inactive {
  background-color: #fee2e2;
  color: #b91c1c;
}

/* ==========================================================================
   Comunicaciones con Clientes (Telegram)
   ========================================================================== */
.comms-panel-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  padding: 0.25rem 0;
  max-height: 520px;
  overflow-y: auto;
}

.comms-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border-subtle, #cbd5e1);
  background-color: #f8fafc;
}

.comms-status-card.linked {
  background-color: #f0fdf4;
  border-color: #bbf7d0;
}

.comms-status-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.comms-telegram-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0284c7;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.comms-status-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
}

.comms-status-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.comms-status-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.comms-send-box {
  background: #ffffff;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.comms-send-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.comms-quick-templates {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.quick-tmpl-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-quick-tmpl {
  font-size: 0.74rem;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  border: 1px solid var(--border-subtle, #cbd5e1);
  background-color: #f1f5f9;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-quick-tmpl:hover {
  background-color: #e2e8f0;
  border-color: #94a3b8;
}

.comms-input-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
}

.comms-textarea {
  flex-grow: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-sm, 6px);
  font-family: inherit;
  font-size: 0.88rem;
  resize: vertical;
  min-height: 48px;
  line-height: 1.4;
  outline: none;
}

.comms-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.comms-alert-error {
  margin-top: 0.5rem;
  padding: 0.45rem 0.75rem;
  background-color: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 6px;
  font-size: 0.78rem;
}

.comms-history-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.comms-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle, #e2e8f0);
}

.comms-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.45rem;
  background-color: #e2e8f0;
  color: #475569;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

.btn-text-sm {
  background: none;
  border: none;
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
  color: var(--primary);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 4px;
}

.btn-text-sm:hover {
  background-color: #e0e7ff;
}

.comms-list-container {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.25rem;
}

.comms-msg-card {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border-color, #e2e8f0);
  font-size: 0.85rem;
  line-height: 1.45;
}

.comms-msg-card.outbound {
  background-color: #f0f9ff;
  border-color: #bae6fd;
  align-self: flex-end;
  max-width: 88%;
}

.comms-msg-card.inbound {
  background-color: #ffffff;
  border-color: #e2e8f0;
  align-self: flex-start;
  max-width: 88%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.comms-msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.comms-channel-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #0284c7;
  background-color: #e0f2fe;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.comms-dir-badge {
  font-size: 0.7rem;
  font-weight: 600;
}

.comms-msg-text {
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   Campanita de Notificaciones de Mensajes (Header)
   ========================================================================== */
.notifications-wrapper {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background-color: #ef4444;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 0 0 2px #ffffff;
  animation: pulseNotif 2s infinite;
  pointer-events: none;
}

@keyframes pulseNotif {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.notifications-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.notifications-dropdown.open {
  display: flex !important;
}

.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle, #e2e8f0);
  background-color: var(--bg-surface, #f8fafc);
}

.notif-dropdown-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.notif-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle, #f1f5f9);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.notif-item:hover {
  background-color: #f0f9ff;
}

.notif-item-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e0f2fe;
  color: #0284c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.notif-item-content {
  flex-grow: 1;
  min-width: 0;
}

.notif-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 2px;
}

.notif-item-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.notif-item-msg {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


