/*
 * CDA Booking 2025 - Frontend Styles (Versión Optimizada)
 * Versión: 4.0.0 - Performance & Mobile Optimized
 * Cambios: Animaciones simplificadas, font-sizes optimizados, espacio maximizado
 */

/* ============================================================================
   VARIABLES Y ESTILOS BASE
   ============================================================================ */
:root {
  /* Colores principales */
  --cda-primary: #007cba;
  --cda-primary-dark: #005a87;
  --cda-primary-light: #4a9dcc;
  --cda-secondary: #28a745;
  --cda-accent: #ffc107;
  --cda-danger: #dc3545;
  --cda-warning: #fd7e14;
  --cda-info: #17a2b8;
  
  /* Colores de estado */
  --cda-success: #28a745;
  --cda-error: #dc3545;
  --cda-muted: #6c757d;
  
  /* Grises */
  --cda-white: #ffffff;
  --cda-light: #f8f9fa;
  --cda-light-gray: #e9ecef;
  --cda-gray: #6c757d;
  --cda-dark-gray: #495057;
  --cda-dark: #212529;
  
  /* Tipografía y espaciado */
  --cda-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --cda-font-size-base: 16px;
  --cda-spacing-md: 1rem;
  
  /* Bordes y sombras */
  --cda-border-radius: 8px;
  --cda-box-shadow-simple: 0 2px 4px rgba(0,0,0,0.1);
}

/* ============================================================================
   CONTENEDOR PRINCIPAL - ESPACIO MAXIMIZADO
   ============================================================================ */
.cda-booking-container-2025 {
  font-family: var(--cda-font-family);
  font-size: var(--cda-font-size-base);
  line-height: 1.6;
  color: var(--cda-dark);
  background: var(--cda-white);
  margin: 0 auto;
  
  /* OPTIMIZADO: Padding mínimo móvil, máximo espacio aprovechado */
  padding: 0.5rem;
  border-radius: 12px;
  box-shadow: var(--cda-box-shadow-simple);
  position: relative;
}

/* OPTIMIZADO: Espaciado progresivo más agresivo */
@media (min-width: 480px) {
  .cda-booking-container-2025 {
    padding: 0.75rem;
  }
}

@media (min-width: 768px) {
  .cda-booking-container-2025 {
    padding: 1rem;
  }
}

@media (min-width: 1024px) {
  .cda-booking-container-2025 {
    padding: 1.5rem;
  }
}

@media (min-width: 1440px) {
  .cda-booking-container-2025 {
    padding: 2rem;
  }
}

/* ============================================================================
   LÓGICA DE VISIBILIDAD DE PASOS
   ============================================================================ */
.booking-step {
  display: none;
}

.booking-step.active {
  display: block;
}

.booking-step[data-step="2"].active .datetime-selection {
    display: grid;
}

/* ============================================================================
   ESTILOS DE COMPONENTES - SIMPLIFICADOS Y OPTIMIZADOS
   ============================================================================ */

/* Header y Progreso */
.cda-booking-header { 
  text-align: center; 
  margin-bottom: 1.5rem; 
}

.cda-booking-title { 
  font-size: 28px; 
  color: var(--cda-primary); 
  margin: 0; 
}

.cda-booking-subtitle { 
  font-size: 16px; 
  color: var(--cda-gray); 
  margin: 0.5rem 0 0 0;
}

/* OPTIMIZADO: Font-sizes móvil más grandes */
@media (max-width: 479px) {
  .cda-booking-title { 
    font-size: 24px; 
  }
  .cda-booking-subtitle { 
    font-size: 15px; 
  }
}

/* OPTIMIZADO: Indicador de progreso simplificado */
.cda-progress-indicator { 
  display: flex; 
  justify-content: center; 
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
  overflow-x: auto;
}

.progress-step { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  text-align: center;
  min-width: fit-content;
}

.step-number { 
  width: 36px; 
  height: 36px; 
  border-radius: 50%; 
  background: var(--cda-light-gray); 
  color: var(--cda-gray); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-weight: 700;
  font-size: 16px;
  border: 2px solid var(--cda-light-gray);
  /* SIMPLIFICADO: Solo transición de colores */
  transition: background-color 0.2s ease, color 0.2s ease;
}

.step-label { 
  margin-top: 0.4rem; 
  font-size: 14px; 
  color: var(--cda-gray);
  white-space: nowrap;
  padding: 0 0.25rem;
}

.progress-line { 
  flex: 1; 
  height: 3px; 
  background: var(--cda-light-gray); 
  margin: 18px 0.5rem 0;
  border-radius: 2px;
  transition: background-color 0.2s ease;
}

.progress-step.active .step-number { 
  background: var(--cda-primary); 
  color: var(--cda-white);
  border-color: var(--cda-primary);
}

.progress-step.active .step-label { 
  color: var(--cda-primary); 
  font-weight: 600; 
}

.progress-step.completed .step-number { 
  background: var(--cda-success); 
  color: var(--cda-white);
  border-color: var(--cda-success);
}

.progress-step.completed .step-label { 
  color: var(--cda-success); 
}

.progress-line.completed { 
  background: var(--cda-success); 
}

/* OPTIMIZADO: Progress responsive */
@media (max-width: 479px) {
  .cda-progress-indicator {
    margin-bottom: 1rem;
    padding: 0 0.25rem;
  }
  
  .step-number {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .step-label {
    font-size: 12px;
    margin-top: 0.3rem;
  }
  
  .progress-line {
    margin-top: 16px;
    margin-left: 0.25rem;
    margin-right: 0.25rem;
  }
}

/* MEJORADO: Progress steps más grandes en PC */
@media (min-width: 768px) {
  .step-number {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  
  .step-label {
    font-size: 16px;
  }
}

/* OPTIMIZADO: Contenido de Pasos */
.step-content { 
  background: var(--cda-white); 
  border-radius: var(--cda-border-radius); 
  /* OPTIMIZADO: Padding más compacto */
  padding: 1rem;
}

@media (min-width: 768px) {
  .step-content {
    padding: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .step-content {
    padding: 2rem;
  }
}

.step-title { 
  font-size: 22px; 
  font-weight: 700; 
  color: var(--cda-primary); 
  text-align: center; 
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

@media (min-width: 768px) {
  .step-title {
    font-size: 24px;
  }
}

.step-description { 
  text-align: center; 
  color: var(--cda-gray); 
  margin-bottom: 1.25rem;
  line-height: 1.4;
  font-size: 16px;
}

@media (min-width: 768px) {
  .step-description {
    margin-bottom: 1.5rem;
    font-size: 17px;
  }
}

/* OPTIMIZADO: Selección de Vehículo */
.vehicle-selection { 
  display: grid; 
  grid-template-columns: 1fr;
  gap: 0.75rem; 
}

@media (min-width: 480px) {
  .vehicle-selection { 
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
  }
}

@media (min-width: 768px) {
  .vehicle-selection { 
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

.vehicle-option input[type="radio"] { 
  position: absolute; 
  opacity: 0; 
}

.vehicle-card { 
  background: var(--cda-white); 
  border: 2px solid var(--cda-light-gray); 
  border-radius: var(--cda-border-radius); 
  /* OPTIMIZADO: Padding más compacto para maximizar contenido */
  padding: 1.25rem 1rem; 
  text-align: center; 
  cursor: pointer; 
  /* SIMPLIFICADO: Solo transición de borde y fondo */
  transition: border-color 0.2s ease, background-color 0.2s ease;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.vehicle-option input:checked + .vehicle-card, 
.vehicle-option.selected .vehicle-card { 
  border-color: var(--cda-primary); 
  background: rgba(0, 124, 186, 0.05);
}

.vehicle-option:hover .vehicle-card { 
  border-color: var(--cda-primary-light);
}

.vehicle-icon { 
  font-size: 2.2rem; 
  margin-bottom: 0.5rem;
}

.vehicle-label { 
  /* OPTIMIZADO: Font-size más grande para mejor legibilidad */
  font-size: 18px; 
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.vehicle-description {
  font-size: 14px;
  color: var(--cda-gray);
  line-height: 1.2;
}

/* OPTIMIZADO: Cards móviles más grandes para touch */
@media (max-width: 479px) {
  .vehicle-card {
    padding: 1.5rem 1rem;
    min-height: 120px;
  }
  
  .vehicle-icon {
    font-size: 2.5rem;
  }
  
  .vehicle-label {
    font-size: 20px;
  }
  
  .vehicle-description {
    font-size: 15px;
  }
}

/* Fecha y Hora */
.datetime-selection { 
  display: none; 
  grid-template-columns: 1fr; 
  gap: 1.5rem; 
}

@media (min-width: 768px) { 
  .datetime-selection { 
    grid-template-columns: 1fr 1fr; 
  } 
}

.calendar-container { 
  background: var(--cda-white); 
  border-radius: var(--cda-border-radius); 
  box-shadow: var(--cda-box-shadow-simple);
  overflow: hidden;
}

.calendar-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  background: var(--cda-primary); 
  color: var(--cda-white); 
  padding: 0.75rem 1rem;
}

.calendar-nav { 
  background: none; 
  border: none; 
  color: var(--cda-white); 
  font-size: 1.3rem; 
  cursor: pointer;
  /* OPTIMIZADO: Touch targets sin transforms costosos */
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.calendar-nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.calendar-nav:active {
  background: rgba(255, 255, 255, 0.3);
}

.calendar-month { 
  font-size: 18px; 
  font-weight: 700;
  text-align: center;
  flex: 1;
  margin: 0 0.5rem;
}

@media (max-width: 479px) {
  .calendar-header {
    padding: 0.5rem 0.75rem;
  }
  
  .calendar-nav {
    min-width: 40px;
    min-height: 40px;
    font-size: 20px;
  }
  
  .calendar-month {
    font-size: 16px;
  }
}

.calendar-grid { 
  display: grid; 
  grid-template-columns: repeat(7, 1fr); 
  gap: 1px;
  background: var(--cda-light-gray); 
  padding: 1px;
  border-radius: var(--cda-border-radius);
}

.calendar-day-header, .calendar-day { 
  background: var(--cda-white); 
  /* OPTIMIZADO: Padding más compacto */
  padding: 0.6rem 0.4rem; 
  text-align: center; 
  font-size: 15px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: background-color 0.15s ease;
}

.calendar-day-header { 
  font-weight: 700; 
  color: var(--cda-gray);
  background: var(--cda-light);
  min-height: 32px;
}

.calendar-day.available { 
  cursor: pointer;
  position: relative;
}

.calendar-day.available:hover { 
  background: var(--cda-primary-light); 
  color: var(--cda-white);
}

.calendar-day.selected { 
  background: var(--cda-primary); 
  color: var(--cda-white); 
  font-weight: 700;
}

/* ✅ CORRECCIÓN FORZADA: Días no disponibles más claros visualmente - V3.1.1 */
.calendar-day.disabled, .calendar-day.empty { 
  background: #f1f3f4 !important; /* Fondo más claro FORZADO */
  color: #adb5bd !important; /* Texto más gris FORZADO */
  cursor: not-allowed !important;
  opacity: 0.4 !important; /* Menos opacidad para mayor contraste FORZADO */
  position: relative;
  pointer-events: none !important; /* CRÍTICO: Bloquear todos los eventos del mouse */
  /* Rayado diagonal sutil para indicar no disponible */
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(173, 181, 189, 0.3) 3px,
    rgba(173, 181, 189, 0.3) 6px
  ) !important;
}

/* ✅ CORRECCIÓN ADICIONAL: Forzar específicamente fines de semana */
.calendar-day[data-date*="-07-26"], 
.calendar-day[data-date*="-07-27"] {
  background: #e74c3c !important; /* Rojo para test temporal */
  color: white !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

/* ✅ CORRECCIÓN ESPECÍFICA V3.1.2: Forzar CSS para días deshabilitados con máxima especificidad */
.cda-booking-container-2025 .calendar-grid .calendar-day.disabled,
.cda-booking-container-2025 .calendar-day.disabled {
  background: #03284f !important;
  color: white !important;
  font-weight: bold !important;
  border: 3px solid #021e36 !important;
  opacity: 1 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

/* ✅ CORRECCIÓN ESPECÍFICA: Sobrescribir cualquier hover */
.cda-booking-container-2025 .calendar-grid .calendar-day.disabled:hover,
.cda-booking-container-2025 .calendar-day.disabled:hover {
  background: #03284f !important;
  color: white !important;
  border-color: #021e36 !important;
}

/* Hover específico para días deshabilitados - FORZADO */
.calendar-day.disabled:hover, .calendar-day.empty:hover {
  background: #03284f !important; /* Mantener azul oscuro en hover también */
  color: white !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  /* Mantener el patrón rayado en hover */
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.2) 3px,
    rgba(255, 255, 255, 0.2) 6px
  ) !important;
  /* Feedback visual de que no es clickeable */
  transform: none !important;
}

/* ✅ MEJORA 4: Día actual más visible y consistente */
.calendar-day.today { 
  font-weight: 700; 
  border: 2px solid var(--cda-accent);
  background: rgba(255, 193, 7, 0.1); /* Fondo amarillo sutil */
  position: relative;
}

/* Asegurar que today disponible mantenga su interactividad */
.calendar-day.today.available:hover {
  background: var(--cda-primary-light);
  color: var(--cda-white);
  border-color: var(--cda-primary);
}

/* Today seleccionado tiene prioridad */
.calendar-day.today.selected {
  background: var(--cda-primary);
  color: var(--cda-white);
  border-color: var(--cda-accent);
}

@media (max-width: 479px) {
  .calendar-day-header, .calendar-day {
    min-height: 44px;
    padding: 0.7rem 0.3rem;
    font-size: 16px;
  }
  
  .calendar-grid {
    gap: 2px;
    padding: 2px;
  }
}

/* ✅ MEJORA 4+: Mensajes informativos más claros */
.timeslots-container .no-selection { 
  text-align: center; 
  color: var(--cda-dark); 
  padding: 1.5rem;
  font-size: 16px;
  background: rgba(255, 193, 7, 0.08); /* Fondo amarillo sutil para alertas */
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: var(--cda-border-radius);
  margin: 0.5rem 0;
}

.timeslots-container .no-selection p:first-child {
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.timeslots-container .no-selection p:last-child {
  margin-bottom: 0;
  font-size: 14px;
  color: var(--cda-gray);
  line-height: 1.4;
}

.timeslots-grid { 
  display: grid; 
  /* OPTIMIZADO: Grid más compacto */
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); 
  gap: 0.75rem;
}

.timeslot { 
  border: 2px solid var(--cda-light-gray); 
  border-radius: var(--cda-border-radius); 
  /* OPTIMIZADO: Padding compacto con touch target adecuado */
  padding: 0.75rem 0.5rem;
  min-height: 44px;
  text-align: center; 
  font-weight: 700;
  /* SIMPLIFICADO: Solo transición de colores */
  transition: border-color 0.15s ease, background-color 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 16px;
}

.timeslot.available { 
  cursor: pointer;
  background: var(--cda-white);
}

.timeslot.available:hover { 
  border-color: var(--cda-primary-light);
  background: rgba(0, 124, 186, 0.05);
}

.timeslot.selected { 
  background: var(--cda-primary); 
  color: var(--cda-white); 
  border-color: var(--cda-primary);
}

.timeslot.unavailable { 
  background: var(--cda-light); 
  color: var(--cda-gray); 
  cursor: not-allowed; 
  text-decoration: line-through;
  opacity: 0.6;
}

@media (max-width: 479px) {
  .timeslots-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
  }
  
  .timeslot {
    min-height: 48px;
    padding: 1rem 0.5rem;
    font-size: 18px;
  }
}

/* OPTIMIZADO: Formulario */
.form-grid { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 1rem;
}

@media (min-width: 768px) { 
  .form-grid { 
    grid-template-columns: 1fr 1fr; 
    gap: 1.25rem;
  } 
}

.form-group.full-width { 
  grid-column: 1 / -1; 
}

.form-label { 
  font-weight: 700; 
  margin-bottom: 0.4rem; 
  display: block;
  color: var(--cda-dark);
  /* OPTIMIZADO: Font-size más grande para labels */
  font-size: 16px;
}

.form-input, .form-textarea { 
  width: 100%; 
  /* OPTIMIZADO: Padding para touch adecuado */
  padding: 0.8rem 1rem;
  min-height: 44px;
  border: 2px solid var(--cda-light-gray); 
  border-radius: var(--cda-border-radius);
  /* OPTIMIZADO: Font-size más grande para mejor legibilidad */
  font-size: 16px;
  line-height: 1.4;
  transition: border-color 0.15s ease;
  background: var(--cda-white);
}

.form-input:focus, .form-textarea:focus { 
  outline: none; 
  border-color: var(--cda-primary);
  background: var(--cda-white);
}

.form-input:invalid:not(:focus):not(:placeholder-shown) {
  border-color: var(--cda-danger);
  background: rgba(220, 53, 69, 0.05);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* OPTIMIZADO: Campos más grandes en móviles */
@media (max-width: 479px) {
  .form-label {
    font-size: 17px;
  }
  
  .form-input, .form-textarea {
    padding: 1rem 1.25rem;
    min-height: 48px;
    font-size: 18px;
  }
  
  .form-textarea {
    min-height: 100px;
  }
}

.required {
  color: var(--cda-danger);
  font-weight: bold;
}

.optional {
  color: var(--cda-gray);
  font-weight: normal;
  font-style: italic;
}

/* Checkbox personalizado mejorado para términos */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  line-height: 1.3;
  padding: 0.25rem;
  margin: -0.25rem;
  border-radius: var(--cda-border-radius);
  transition: background-color 0.15s ease;
  font-size: 14px;
}

.checkbox-label:hover {
  background: rgba(0, 124, 186, 0.05);
}

.checkbox-custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--cda-light-gray);
  border-radius: 4px;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  margin-top: 1px;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background: var(--cda-primary);
  border-color: var(--cda-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

/* Móvil: font más pequeño para términos */
@media (max-width: 479px) {
  .checkbox-label {
    font-size: 13px;
    gap: 0.4rem;
  }
}

/* OPTIMIZADO: Botones con font-size más grande */
.step-actions { 
  display: flex; 
  justify-content: space-between; 
  margin-top: 1.5rem; 
  padding-top: 1rem; 
  border-top: 1px solid var(--cda-light-gray);
  gap: 1rem;
}

.btn-prev, .btn-next, .btn-confirm { 
  min-height: 44px;
  padding: 0.75rem 1.5rem; 
  border: none; 
  border-radius: var(--cda-border-radius); 
  /* OPTIMIZADO: Font-size más grande para mejor legibilidad */
  font-size: 18px; 
  font-weight: 700; 
  cursor: pointer;
  /* SIMPLIFICADO: Solo transiciones de colores */
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-next, .btn-confirm { 
  background: var(--cda-primary); 
  color: var(--cda-white); 
}

.btn-next:hover:not(:disabled), .btn-confirm:hover:not(:disabled) {
  background: var(--cda-primary-dark);
}

.btn-prev { 
  background: var(--cda-light-gray); 
  color: var(--cda-dark); 
}

.btn-prev:hover {
  background: var(--cda-gray);
  color: var(--cda-white);
}

button:disabled { 
  background: var(--cda-light-gray) !important; 
  color: var(--cda-gray) !important; 
  cursor: not-allowed !important;
}

/* OPTIMIZADO: Botones móviles más grandes */
@media (max-width: 480px) {
  .step-actions {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .btn-prev, .btn-next, .btn-confirm {
    width: 100%;
    min-height: 48px;
    font-size: 20px;
    padding: 1rem 1.5rem;
  }
}

/* Spinner simplificado */
.spinner { 
  width: 16px; 
  height: 16px; 
  border: 2px solid var(--cda-light-gray); 
  border-top-color: var(--cda-white); 
  border-radius: 50%; 
  animation: spin 1s linear infinite; 
}

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

/* Otros componentes */
.booking-summary { 
  background: var(--cda-light); 
  padding: 1.25rem; 
  border-radius: var(--cda-border-radius); 
  font-size: 16px;
}

.success-step { 
  text-align: center; 
}

.checkmark { 
  width: 80px; 
  height: 80px; 
  background: var(--cda-success); 
  color: var(--cda-white); 
  border-radius: 50%; 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 2.5rem; 
  margin-bottom: 1rem;
}

/* ============================================================================
   RESPONSIVE - MÁXIMO APROVECHAMIENTO DEL ESPACIO
   ============================================================================ */

/* Pantallas muy pequeñas (320px) */
@media (max-width: 359px) {
  .cda-booking-container-2025 {
    padding: 0.25rem;
    margin: 0;
  }
  
  .step-content {
    padding: 0.75rem;
  }
}

/* Pantallas grandes (1600px+) */
@media (min-width: 1600px) {
  .cda-booking-container-2025 {
    max-width: 1200px;
    padding: 2.5rem;
  }
}