/* ==========================================
   CALENDAR GRID
   ========================================== */

.calendar-grid {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  gap: 0;
  background: var(--surface);
  border-radius: 0;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  width: 100%;
  min-width: 100%;
}

.cell {
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 12px;
  min-height: 100px;
  /* Aumentado de 72px */
  transition: all 0.2s ease;
}

.cell:nth-child(8n+1) {
  border-left: 1px solid var(--border-color);
}

.time {
  background: #f8f9fa;
  font-weight: 500;
  text-align: center;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border-left: 1px solid var(--border-color);
}

.day-header {
  background: var(--primary-color);
  color: white;
  font-weight: 500;
  text-align: center;
  padding: 6px 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-top: 1px solid var(--border-color);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.day-header.today {
  background: var(--success-color);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}

/* ==========================================
   CELDAS DE CITAS
   ========================================== */

.free {
  background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.free .time-label {
  font-size: 11px;
  color: var(--success-dark);
  font-weight: 500;
  opacity: 0.6;
  transition: all 0.3s ease;
}

.free:hover {
  background: linear-gradient(135deg, #c8e6c9 0%, #dcedc8 100%);
  box-shadow: inset 0 0 0 2px var(--success-color), var(--shadow-md);
  transform: scale(1.02);
}

.free:hover .time-label {
  opacity: 0.4;
}

.free::after {
  content: '+';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  color: #a5d6a7;
  opacity: 0;
  transition: opacity 0.2s;
}

.free:hover::after {
  opacity: 1;
  color: var(--success-color);
}

.busy {
  cursor: grab;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

/* Solo aplicar padding si NO es una cita única que llena el slot */
.cell.busy:not(.single-appointment) {
  padding-left: 16px;
}

.busy:hover {
  background: linear-gradient(135deg, #ffcdd2 0%, #f8bbd0 100%);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.busy.dragging {
  opacity: 0.5;
  cursor: grabbing;
  transform: rotate(2deg);
}

.busy strong {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.busy span {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.drop-target {
  background: #c8e6c9 !important;
  box-shadow: inset 0 0 0 2px var(--success-color) !important;
}

/* ==========================================
   MULTI-SLOT SUPPORT (N citas por hora)
   ========================================== */

.multi-slot-cell {
  padding: 2px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
}

.sub-slot {
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  transition: all 0.2s ease;
  min-height: 40px;
  /* Ajustado a 40px por petición */
  display: flex;
  flex-direction: column;
}

.sub-slot.free {
  background: rgba(232, 245, 233, 0.5);
  border: 1px dashed #a5d6a7;
  justify-content: center;
  align-items: center;
}

.sub-slot.free:hover {
  background: #c8e6c9;
  border-style: solid;
}

.sub-slot-label {
  font-size: 10px;
  color: var(--success-dark);
  opacity: 0.7;
  font-weight: 500;
}

.cita-item.busy {
  flex: 1;
  margin: 0;
  padding: 8px;
  border-left: 4px solid var(--error-color);
  background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Para citas únicas en el slot, quitamos el fondo del item (ya lo tiene el padre) */
.single-appointment .cita-item {
  background: transparent !important;
  border-left: none !important;
  padding: 12px 16px !important;
}

.cita-item.busy:hover {
  background: linear-gradient(135deg, #ffcdd2 0%, #f8bbd0 100%);
}

.multi-slot-cell .cita-content strong {
  font-size: 12px;
  margin-bottom: 2px;
}

/* Colores por servicio */
.service-neumaticos {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
  border-left: 4px solid #1976d2 !important;
}

.service-neumaticos:hover {
  background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%) !important;
}

.service-alineacion {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%) !important;
  border-left: 4px solid #f57c00 !important;
}

.service-alineacion:hover {
  background: linear-gradient(135deg, #ffe0b2 0%, #ffcc80 100%) !important;
}

.service-completo {
  background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%) !important;
  border-left: 4px solid #9c27b0 !important;
}

.service-completo:hover {
  background: linear-gradient(135deg, #e1bee7 0%, #ce93d8 100%) !important;
}

.multi-slot-cell .cita-content span {
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multi-slot-cell .matricula {
  font-size: 9px !important;
  opacity: 0.8;
}

/* Soporte táctil para drag and drop */
.cell.busy[draggable="true"] {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.02);
  }
}

.cell.busy:active {
  animation: pulse 0.5s ease-in-out;
}

/* ==========================================
   MINI CALENDARIO
   ========================================== */

.mini-calendar {
  background: transparent;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  margin-bottom: 24px;
}

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

.mini-calendar-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: capitalize;
}

.mini-calendar-nav {
  display: flex;
  gap: 4px;
}

.mini-calendar-nav button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: all 0.2s;
}

.mini-calendar-nav button:hover {
  background: var(--bg-gray-50);
  border-color: var(--text-secondary);
}

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

.mini-calendar-day-header {
  text-align: center;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 0;
  font-size: 11px;
}

.mini-calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-white);
  color: var(--text-primary);
}

.mini-calendar-day:hover:not(.other-month):not(.weekend) {
  background: var(--bg-gray-50);
  border-color: var(--text-secondary);
}

.mini-calendar-day.other-month {
  color: var(--text-secondary);
  opacity: 0.4;
}

.mini-calendar-day.today {
  background: var(--accent-blue-light);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
  font-weight: 600;
}

.mini-calendar-day.selected {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

.mini-calendar-day.weekend {
  opacity: 0.5;
}

/* Días sin slots disponibles - tono apagado */
.mini-calendar-day.no-slots {
  opacity: 0.4;
  color: var(--text-secondary);
}

/* ==========================================
   ESTADÍSTICAS
   ========================================== */

.stats {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.stats h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.stats-section {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.stats-section h4 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.stat-badge.success {
  background: var(--success-light);
  color: var(--success-dark);
}

.stat-badge.warning {
  background: var(--warning-light);
  color: #e65100;
}

.stat-badge.error {
  background: var(--error-light);
  color: #c62828;
}

/* ==========================================
   SLOTS VIEW
   ========================================== */

.slots-view {
  padding: 20px;
  background: var(--background);
  overflow-y: auto;
}

.slots-header {
  margin-bottom: 24px;
  text-align: center;
}

.slots-header h3 {
  font-size: 24px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.slots-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Grid de columnas - horizontal en desktop */
.slots-grid-columnas {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 16px 0;
  scroll-snap-type: x mandatory;
  max-width: 1400px;
  margin: 0 auto;
}

/* Columna de día */
.dia-slots-columna {
  min-width: 140px;
  flex-shrink: 0;
  scroll-snap-align: start;
  background: transparent;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.dia-slots-header {
  padding: 12px 8px 8px 8px;
  text-align: center;
  border-bottom: none;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dia-nombre-corto {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

/* Línea separadora entre header y slots */
.dia-slots-separator {
  height: 1px;
  background: var(--border-color);
  margin: 8px 8px 12px 8px;
}

/* Botón copiar horarios */
.btn-copiar-horarios {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-copiar-horarios .material-icons {
  font-size: 18px;
  color: var(--text-secondary);
}

.btn-copiar-horarios:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  transform: scale(1.05);
}

.btn-copiar-horarios:hover .material-icons {
  color: white;
}

.btn-copiar-horarios.copiado {
  background: #4caf50;
  border-color: #4caf50;
}

.btn-copiar-horarios.copiado .material-icons {
  color: white;
}

/* Lista vertical de slots dentro de cada columna */
.slots-list-vertical {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 8px;
}

.slot-btn-columna {
  width: 100%;
  padding: 14px 12px;
  background: var(--bg-white);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Roboto', sans-serif;
  text-align: center;
}

.slot-btn-columna:hover {
  border-color: var(--primary-color);
  background: var(--accent-blue-light);
  color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.slot-btn-columna:active {
  transform: translateY(0);
}

.loading-slots,
.error-slots {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.error-slots button {
  margin-top: 16px;
  padding: 10px 20px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
}

.error-slots button:hover {
  background: var(--primary-dark);
}

.no-disponibles {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.no-disponibles svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.no-disponibles h3 {
  color: var(--text-primary);
  margin-bottom: 8px;
}