/* ==========================================================
   Cita Express - Estilos de Login y Layout Responsivo
   Diseñado para Móviles, Tabletas y Escritorio
   ========================================================== */

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

body {
  font-family: var(--font-sans);
  background-color: var(--sand-50);
  background-image: 
    radial-gradient(at 0% 0%, rgba(255, 230, 224, 0.6) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(254, 243, 199, 0.45) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(255, 255, 255, 0.8) 0px, transparent 80%);
  color: var(--sand-900);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
}

/* Decoraciones de Fondo Ambientales */
.ambient-glow {
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
}

.ambient-glow-1 {
  top: -120px;
  left: -100px;
  background: radial-gradient(circle, #FFA07A 0%, rgba(244, 124, 98, 0.1) 70%);
}

.ambient-glow-2 {
  bottom: -150px;
  right: -120px;
  background: radial-gradient(circle, #FCD34D 0%, rgba(245, 158, 11, 0.05) 70%);
}

/* Contenedor Principal Split */
.login-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1220px;
  min-height: 90vh;
  margin: 24px auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  background: var(--grad-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  overflow: hidden;
}

/* ==========================================================
   PANEL IZQUIERDO: Presentación de Marca e Identidad
   ========================================================== */
.brand-showcase {
  background: linear-gradient(145deg, #FFF9F6 0%, #FFF2EC 60%, #FFE9E1 100%);
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  border-right: 1px solid rgba(224, 93, 64, 0.1);
}

.brand-showcase::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(224, 93, 64, 0.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.brand-header {
  position: relative;
  z-index: 2;
}

.brand-logo-container {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.main-brand-logo {
  height: 64px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(136, 43, 23, 0.08));
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-100);
  color: var(--primary-700);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(224, 93, 64, 0.2);
  margin-bottom: 20px;
}

.brand-badge span.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary-500);
  box-shadow: 0 0 0 0 rgba(224, 93, 64, 0.6);
  animation: pulse-ring 2s infinite cubic-bezier(0.45, 0, 0.2, 1);
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(224, 93, 64, 0.6); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(224, 93, 64, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(224, 93, 64, 0); }
}

.brand-title {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--sand-900);
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}

.brand-title .text-gradient {
  background: var(--grad-warm-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-description {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--sand-500);
  max-width: 440px;
}

/* Tarjetas flotantes de características */
.feature-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 36px 0;
  position: relative;
  z-index: 2;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(224, 93, 64, 0.12);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--trans-normal), box-shadow var(--trans-normal), background var(--trans-normal);
}

.feature-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-md);
}

.feature-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--primary-100);
  color: var(--primary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.feature-info h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--sand-900);
  margin-bottom: 3px;
}

.feature-info p {
  font-size: 0.82rem;
  color: var(--sand-500);
}

.brand-footer {
  font-size: 0.8rem;
  color: var(--sand-400);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.brand-footer a {
  color: var(--primary-600);
  text-decoration: none;
  font-weight: 600;
}

.brand-footer a:hover {
  text-decoration: underline;
}

/* ==========================================================
   PANEL DERECHO: Formulario de Autenticación
   ========================================================== */
.auth-panel {
  padding: 56px 52px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
}

.auth-mobile-header {
  display: none;
  text-align: center;
  margin-bottom: 24px;
}

.auth-mobile-header .mobile-logo {
  height: 52px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  margin-bottom: 12px;
}

.auth-header {
  margin-bottom: 32px;
}

.auth-header h2 {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--sand-900);
  letter-spacing: -0.4px;
  margin-bottom: 8px;
}

.auth-header p {
  font-size: 0.95rem;
  color: var(--sand-500);
}

/* Formulario */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--sand-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-type-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--sand-100);
  color: var(--sand-500);
  transition: all var(--trans-fast);
}

.auth-type-pill.is-email {
  background: var(--info-light);
  color: var(--info);
}

.auth-type-pill.is-username {
  background: var(--primary-100);
  color: var(--primary-600);
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-leading {
  position: absolute;
  left: 16px;
  font-size: 1.15rem;
  color: var(--sand-400);
  pointer-events: none;
  transition: color var(--trans-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-control {
  width: 100%;
  height: 52px;
  padding: 0 46px 0 48px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--sand-900);
  background: #FFFFFF;
  border: 1.5px solid var(--sand-200);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast), background var(--trans-fast);
}

.form-control::placeholder {
  color: var(--sand-300);
  font-weight: 400;
}

.form-control:hover {
  border-color: var(--sand-300);
}

.form-control:focus {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-input-focus);
  background: #FFFFFF;
}

.form-control:focus ~ .input-icon-leading {
  color: var(--primary-500);
}

/* Indicador de error / validación */
.form-control.is-invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.field-feedback {
  font-size: 0.8rem;
  margin-top: 6px;
  display: none;
  align-items: center;
  gap: 5px;
}

.field-feedback.error {
  color: var(--error);
  display: flex;
}

/* Botón para alternar visibilidad de contraseña */
.btn-toggle-password {
  position: absolute;
  right: 14px;
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--sand-400);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--trans-fast), background var(--trans-fast);
}

.btn-toggle-password:hover {
  color: var(--sand-700);
  background: var(--sand-100);
}

/* Opciones: Recordarme y Olvidé Contraseña */
.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
  font-size: 0.86rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  color: var(--sand-700);
}

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

.forgot-password-link {
  color: var(--primary-600);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--trans-fast);
}

.forgot-password-link:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

/* Botón Principal de Acción */
.btn-submit-login {
  width: 100%;
  height: 52px;
  background: var(--grad-warm-hero);
  border: none;
  border-radius: var(--radius-md);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 10px 22px -5px rgba(224, 93, 64, 0.42);
  transition: transform var(--trans-fast), box-shadow var(--trans-fast), opacity var(--trans-fast);
}

.btn-submit-login:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 14px 26px -4px rgba(224, 93, 64, 0.5);
}

.btn-submit-login:active {
  transform: translateY(0);
}

.btn-submit-login:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Spinner dentro del botón */
.spinner-loader {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  border-top-color: #FFFFFF;
  animation: spin 0.8s linear infinite;
  display: none;
}

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

/* ==========================================================
   SELECTOR RÁPIDO DE ROLES PARA PRUEBAS (DEMO BADGES)
   ========================================================== */
.demo-role-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px dashed var(--sand-200);
}

.demo-role-header {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--sand-400);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
  text-align: center;
}

.role-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.role-chip {
  background: var(--sand-100);
  border: 1px solid var(--sand-200);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sand-700);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--trans-fast);
}

.role-chip:hover {
  background: var(--primary-50);
  border-color: var(--primary-300);
  color: var(--primary-700);
  transform: translateY(-1px);
}

.role-chip .chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sand-400);
}

.role-chip:hover .chip-dot {
  background: var(--primary-500);
}

/* ==========================================================
   MODAL DE RECUPERACIÓN DE CONTRASEÑA
   ========================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 23, 18, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--trans-normal);
}

.modal-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 100%;
  max-width: 440px;
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-xl);
  position: relative;
  transform: translateY(20px) scale(0.96);
  transition: transform var(--trans-smooth);
}

.modal-overlay.is-active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  background: var(--sand-100);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sand-600);
  transition: background var(--trans-fast);
}

.modal-close-btn:hover {
  background: var(--sand-200);
  color: var(--sand-900);
}

.modal-header {
  margin-bottom: 18px;
}

.modal-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--amber-100);
  color: var(--amber-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--sand-900);
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 0.88rem;
  color: var(--sand-500);
  line-height: 1.5;
}

/* ==========================================================
   SISTEMA DE NOTIFICACIONES TOAST
   ========================================================== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 300px;
  max-width: 420px;
  background: #FFFFFF;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary-500);
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  transform: translateX(120%);
  transition: transform var(--trans-smooth);
}

.toast.show {
  transform: translateX(0);
}

.toast-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.toast-body {
  flex-grow: 1;
}

.toast-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--sand-900);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.8rem;
  color: var(--sand-500);
  line-height: 1.4;
}

.toast.success { border-left-color: var(--success); }
.toast.success .toast-icon { color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.error .toast-icon { color: var(--error); }
.toast.info { border-left-color: var(--primary-500); }
.toast.info .toast-icon { color: var(--primary-500); }

/* ==========================================================
   RESPONSIVIDAD (Móviles, Tabletas y Escritorio)
   ========================================================== */

/* Tabletas (Pantallas medianas: 768px a 1024px) */
@media (max-width: 1024px) {
  .login-card {
    grid-template-columns: 1fr;
    max-width: 540px;
    margin: auto;
  }

  .brand-showcase {
    display: none; /* En tabletas y móviles priorizamos la tarjeta limpia */
  }

  .auth-mobile-header {
    display: block;
  }

  .auth-panel {
    padding: 44px 40px;
  }
}

/* Celulares / Smartphones (< 768px) */
@media (max-width: 640px) {
  body {
    background: #FFFFFF;
    align-items: flex-start;
    padding: 0;
  }

  .ambient-glow {
    display: none;
  }

  .login-wrapper {
    margin: 0;
    padding: 0;
    min-height: 100vh;
  }

  .login-card {
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .auth-panel {
    padding: 32px 20px 40px 20px;
    background: transparent;
  }

  .auth-header h2 {
    font-size: 1.6rem;
  }

  .form-control {
    height: 50px;
    font-size: 16px; /* Evita auto-zoom en Safari iOS */
  }

  .btn-submit-login {
    height: 50px;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    top: 16px;
  }

  .toast {
    min-width: unset;
    width: 100%;
  }

  .role-pill-group {
    justify-content: flex-start;
  }
}
