/* ==========================
   SISTEMA DE MODALES
   Modales responsive para el sistema
========================== */

/* Contenedor principal del modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 200ms ease-in-out;
}

/* Overlay oscuro con blur */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

/* Contenido del modal */
.modal-content {
  position: relative;
  background: var(--bg-card, #ffffff);
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
  max-width: 700px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 300ms ease-out;
  z-index: 10000;
}

/* Header del modal */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 2px solid var(--bg-main, #f8fafc);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}

/* Botón de cerrar */
.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary, #64748b);
  transition: all var(--transition-fast, 150ms);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm, 6px);
  padding: 0;
}

.modal-close:hover {
  background: var(--bg-main, #f8fafc);
  color: var(--danger, #ef4444);
  transform: scale(1.1);
}

/* Body del modal */
.modal-body {
  padding: 24px;
}

/* Estado de loading en modal */
.modal-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary, #64748b);
}

.modal-loading .loading-spinner {
  margin: 0 auto 16px auto;
}

.modal-loading p {
  margin: 0;
  font-size: 0.95rem;
}

/* Footer del modal (opcional) */
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--bg-main, #f8fafc);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================
   VARIANTES DE TAMAÑO
========================== */

/* Modal pequeño */
.modal-content.modal-sm {
  max-width: 400px;
}

/* Modal mediano (default) */
.modal-content.modal-md {
  max-width: 700px;
}

/* Modal grande */
.modal-content.modal-lg {
  max-width: 900px;
}

/* Modal extra grande */
.modal-content.modal-xl {
  max-width: 1200px;
}

/* Modal pantalla completa */
.modal-content.modal-fullscreen {
  max-width: 100%;
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  margin: 0;
}

/* ==========================
   ANIMACIONES
========================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* ==========================
   RESPONSIVE
========================== */

@media screen and (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-height: 95vh;
    max-width: 95%;
  }
  
  .modal-header {
    padding: 16px;
  }
  
  .modal-header h3 {
    font-size: 1.25rem;
  }
  
  .modal-body {
    padding: 16px;
  }
  
  .modal-footer {
    padding: 12px 16px;
    flex-direction: column;
  }
  
  .modal-footer .btn {
    width: 100%;
  }
  
  /* En móvil, los modales grandes ocupan toda la pantalla */
  .modal-content.modal-lg,
  .modal-content.modal-xl {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}

/* ==========================
   ACCESIBILIDAD
========================== */

/* Focus visible en botón de cerrar */
.modal-close:focus {
  outline: 2px solid var(--primary, #6366f1);
  outline-offset: 2px;
}

/* Scroll suave en contenido del modal */
.modal-content {
  scroll-behavior: smooth;
}

/* Evitar selección de texto en overlay */
.modal-overlay {
  user-select: none;
}

/* ==========================
   UTILIDADES PARA MODALES
========================== */

/* Título del modal con icono */
.modal-title-with-icon {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title-with-icon .icon {
  font-size: 1.75rem;
  line-height: 1;
}

/* Separador en body del modal */
.modal-divider {
  height: 1px;
  background: var(--bg-main, #f8fafc);
  margin: 20px 0;
}

/* Sección en modal con título */
.modal-section {
  margin-bottom: 24px;
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
  margin-bottom: 12px;
}

/* Alert dentro de modal */
.modal-body .alert {
  margin-bottom: 0;
}

.modal-body .alert:not(:last-child) {
  margin-bottom: 16px;
}