:root {
  --primary: #241a6e;
  --secondary: #0784ce;
  --success: #2ecc71;
  --danger: #e74c3c;
  --light: #ecf0f1;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', sans-serif;
}
body {
  background: #f5f7fa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Contenedores */
.iframe-container,
.content-area {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  flex: 1;
}

.login-container {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 450px;
  overflow: hidden;
  margin: 2rem auto;
}

/* 💻 CORRECCIÓN DESKTOP: Container 40% width */
@media (min-width: 769px) {
  .login-container {
    width: 40%;
    max-width: none;
  }
}

.login-header {
  background: linear-gradient(to right, var(--primary), var(--secondary));
  padding: 25px;
  text-align: center;
  color: var(--light);
}

.login-header h1 {
  font-size: 1.8rem;
  margin-bottom: 5px;
  color: white; /* 💻 CORRECCIÓN: Texto blanco para mejor contraste */
}

.login-header p {
  font-size: 0.9rem;
  opacity: 0.9;
  color: white; /* 💻 CORRECCIÓN: Texto blanco para mejor contraste */
}

.login-form {
  padding: 30px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--primary);
  font-weight: 500;
  font-size: 0.9rem;
}

.form-group input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 1rem;
}

.input-icon {
  position: absolute;
  right: 15px;
  top: 42px;
  color: #aaa;
}

.toggle-password {
  position: absolute;
  right: 45px;
  top: 42px;
  cursor: pointer;
  color: #aaa;
  z-index: 10;
}

.toggle-password:hover {
  color: var(--primary);
}

.error-message {
  color: var(--danger);
  font-size: 0.85rem;
  display: none;
  margin-top: 5px;
}

.btn-login {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 5px;
  background: var(--primary);
  color: white;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-login:hover {
  background: var(--secondary);
}

/* Toggle OTP */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: 0.4s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: var(--success);
}

.switch input:checked + .slider:before {
  transform: translateX(26px);
}

.toggle-otp {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Calendar IA Notice */
.calendar-ia-notice {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  color: white;
  padding: 15px;
  text-align: center;
  font-size: 0.9rem;
}

.calendar-ia-notice i {
  margin-right: 8px;
  color: #ffd700;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s, opacity 0.3s;
}

.loading-overlay.active {
  visibility: visible;
  opacity: 1;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s ease-in-out infinite;
}

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

/* ===== AGREGAR AL FINAL DE css/login.css ===== */

/* Mensaje informativo OTP */
.otp-info-message {
  margin: 20px 0;
  padding: 20px;
  background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
  border: 1px solid #b39ddb;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(123, 31, 162, 0.1);
}

.otp-info-message.show {
  opacity: 1;
  transform: translateY(0);
}

.otp-info-content {
  display: flex;
  align-items: flex-start;
  gap: 15px;
}

.otp-info-content i {
  color: var(--primary);
  font-size: 24px;
  margin-top: 2px;
  flex-shrink: 0;
}

.otp-info-text {
  flex: 1;
}

.otp-info-text strong {
  color: var(--primary);
  font-size: 16px;
  display: block;
  margin-bottom: 5px;
}

.otp-info-text p {
  color: #6a1b9a;
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

/* Transiciones entre formularios */
.form-transition-out {
  animation: slideOutLeft 0.3s ease-in forwards;
}

.form-transition-in {
  animation: slideInRight 0.3s ease-out forwards;
}

@keyframes slideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-30px);
  }
}

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

/* Botón en modo OTP */
.btn-login.otp-mode {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  position: relative;
  overflow: hidden;
}

.btn-login.otp-mode::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn-login.otp-mode:hover::before {
  left: 100%;
}

/* Mejoras al toggle OTP existente */
.toggle-otp {
  display: flex;
  align-items: center;
  gap: 15px;
  margin: 20px 0;
  padding: 18px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 12px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  cursor: pointer;
}

.toggle-otp:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
  border-color: var(--secondary);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(7, 132, 206, 0.15);
}

.toggle-otp label[for="use_otp"] {
  margin: 0;
  color: #495057;
  font-weight: 600;
  cursor: pointer;
  font-size: 15px;
  user-select: none;
}

/* Mejoras al switch existente */
.switch {
  width: 56px;
  height: 32px;
}

.slider {
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.slider:before {
  height: 24px;
  width: 24px;
  left: 4px;
  bottom: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

input:not(:checked) + .slider {
  background-color: #94a3b8;
}

.slider:hover {
  box-shadow: 0 0 12px rgba(7, 132, 206, 0.3);
}

/* Formulario OTP */
#otp-form {
  animation: fadeIn 0.4s ease-in;
}

#otp-form h3 {
  color: var(--secondary);
  text-align: center;
  margin-bottom: 25px;
  font-size: 26px;
  font-weight: 700;
  position: relative;
}

#otp-form h3::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  border-radius: 2px;
}

#otp_code {
  text-align: center;
  font-size: 28px;
  font-weight: bold;
  letter-spacing: 12px;
  padding: 20px 15px;
  border: 3px solid #e1e8ed;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  transition: all 0.3s ease;
  width: 100%;
  box-sizing: border-box;
}

#otp_code:focus {
  border-color: var(--secondary);
  background: white;
  box-shadow: 0 0 0 4px rgba(7, 132, 206, 0.1);
  transform: scale(1.02);
  outline: none;
}

#otp_code::placeholder {
  color: #adb5bd;
  font-weight: normal;
  letter-spacing: 6px;
  font-size: 20px;
}

/* Efecto de pulsación para OTP */
.otp-pulse {
  animation: otpPulse 0.3s ease-in-out;
}

@keyframes otpPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Botón secundario */
.btn-secondary {
  background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
  color: white;
  border: none;
  padding: 14px 30px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: none;
  display: block;
  width: 100%;
  margin-top: 20px;
  position: relative;
  overflow: hidden;
}

.btn-secondary:hover {
  background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(108, 117, 125, 0.3);
}

.btn-secondary:active {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

/* Estados de countdown en botones */
.btn-countdown {
  background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%) !important;
  color: #212529 !important;
  animation: countdownPulse 2s infinite;
}

@keyframes countdownPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Alertas */
.auth-alert {
  margin-bottom: 20px;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  animation: slideDown 0.4s ease-out;
  border: none;
}

.auth-alert-content {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 15px;
  position: relative;
}

.auth-alert-success {
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
  border-left: 5px solid var(--success);
  color: #155724;
}

.auth-alert-error {
  background: linear-gradient(135deg, #f8d7da 0%, #f1b2b7 100%);
  border-left: 5px solid var(--danger);
  color: #721c24;
}

.auth-alert-info {
  background: linear-gradient(135deg, #d1ecf1 0%, #b8daff 100%);
  border-left: 5px solid var(--secondary);
  color: #0c5460;
}

.auth-alert i {
  font-size: 20px;
  flex-shrink: 0;
}

.auth-alert span {
  flex-grow: 1;
  font-weight: 500;
  line-height: 1.4;
}

.auth-alert-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s;
  opacity: 0.7;
  font-size: 14px;
}

.auth-alert-close:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.1);
  transform: scale(1.1);
}

/* Animaciones */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Responsive para OTP */
@media (max-width: 768px) {
  .otp-info-message {
    padding: 15px;
    margin: 15px 0;
  }

  .otp-info-content {
    gap: 12px;
  }

  .otp-info-content i {
    font-size: 20px;
  }

  #otp_code {
    font-size: 24px;
    letter-spacing: 8px;
    padding: 16px 12px;
  }

  #otp-form h3 {
    font-size: 22px;
    margin-bottom: 20px;
  }

  .toggle-otp {
    padding: 15px;
    gap: 12px;
  }
}

/* ===== MEJORAS CSS PARA MÓVIL - Agregar al final de login.css ===== */

/* 1. SOLUCIÓN: Responsivo sin scroll horizontal */
* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* Eliminar scroll horizontal */
}

.iframe-container,
.content-area {
  width: 100%;
  min-height: 100vh;
  padding: 10px; /* Padding mínimo en móvil */
  overflow-x: hidden;
}

/* 2. SOLUCIÓN: Icono dentro del input - Format Indicator */
.identifier-input-group {
  position: relative;
  width: 100%;
}

.identifier-input-group input {
  width: 100%;
  padding-right: 45px; /* Espacio para el icono */
  padding-left: 15px;
}

.format-indicator {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  z-index: 2;
  transition: all 0.3s ease;
}

.format-indicator.email {
  color: #3498db;
}

.format-indicator.phone {
  color: #27ae60;
}

.format-indicator.invalid {
  color: #ef4444;
}

/* Agregar icono dinámicamente basado en detección */
.email-detected + .format-indicator::before {
  content: "📧";
  font-size: 16px;
}

.phone-detected + .format-indicator::before {
  content: "📱";
  font-size: 16px;
}

.invalid-format + .format-indicator::before {
  content: "⚠️";
  font-size: 14px;
}

/* 3. SOLUCIÓN: Márgenes laterales del login-container - SOLO MÓVIL */
@media (max-width: 768px) {
  .login-container {
    margin: 1rem auto; /* Margen automático centrado */
    max-width: calc(100vw - 20px);
  }
}

/* 4. SOLUCIÓN: Mensaje de ayuda mejor posicionado */
.help-message {
  text-align: center;
  margin-top: 20px; /* Reducir margen superior */
  margin-bottom: 20px; /* Agregar margen inferior */
  padding: 15px 20px; /* Padding interno */
  border-top: 1px solid #f3f4f6;
  color: #6b7280;
  font-size: 13px;
  background: rgba(248, 250, 252, 0.5);
  border-radius: 0 0 10px 10px; /* Redondear esquinas inferiores */
}

.help-message p {
  margin: 0;
  line-height: 1.4;
}

.help-message i {
  margin-right: 5px;
  color: #3498db;
}

/* ===== RESPONSIVE DESIGN ESPECÍFICO ===== */

/* Móviles pequeños (320px - 480px) */
@media (max-width: 480px) {
  .iframe-container,
  .content-area {
    padding: 8px; /* Padding mínimo en móviles pequeños */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .login-container {
    margin: 0.5rem auto;
    max-width: calc(100vw - 16px); /* Ancho completo menos padding */
    border-radius: 8px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  }

  .login-header {
    padding: 20px 15px; /* Reducir padding */
  }

  .login-header h1 {
    font-size: 1.5rem; /* Reducir tamaño de fuente */
    margin-bottom: 3px;
  }

  .login-header p {
    font-size: 0.8rem;
  }

  .login-form,
  #otp-form {
    padding: 20px 15px; /* Reducir padding lateral */
  }

  .form-group {
    margin-bottom: 18px; /* Reducir espaciado */
  }

  .form-group label {
    font-size: 0.85rem;
    margin-bottom: 6px;
  }

  .form-group input {
    padding: 12px 40px 12px 12px; /* Ajustar padding para icono */
    font-size: 16px; /* Prevenir zoom en iOS */
    border-radius: 6px;
  }

  .format-indicator {
    right: 10px;
    font-size: 14px;
  }

  /* 📱 CORRECCIÓN MÓVIL: Toggle OTP más compacto y corregido */
  .toggle-otp {
    padding: 15px; /* Aumentar padding para mejor espaciado */
    margin: 15px 0;
    border-radius: 8px;
  }

  .toggle-otp label {
    font-size: 0.9rem;
  }

  /* 📱 CORRECCIÓN MÓVIL: Switch dimensiones corregidas */
  .switch {
    width: 54px; /* Ancho corregido */
    height: 28px; /* Altura corregida */
  }

  .slider:before {
    height: 20px; /* Altura del círculo corregida */
    width: 20px; /* Ancho del círculo corregido */
    left: 4px;
    bottom: 4px;
  }

  input:checked + .slider:before {
    transform: translateX(26px); /* Desplazamiento corregido */
  }

  /* Botones más táctiles */
  .btn-login {
    padding: 14px 12px;
    font-size: 0.95rem;
    border-radius: 8px;
    min-height: 48px; /* Altura mínima táctil */
  }

  /* Mensaje de ayuda más compacto */
  .help-message {
    margin-top: 15px;
    margin-bottom: 15px;
    padding: 12px 15px;
    font-size: 12px;
  }

  /* Auth method info más compacto */
  .auth-method-info {
    padding: 12px;
    margin: 12px 0;
    border-radius: 8px;
    font-size: 13px;
  }

  /* OTP info message más compacto */
  .otp-info-message {
    margin: 15px 0;
    padding: 15px;
    border-radius: 10px;
  }

  .otp-info-content {
    gap: 12px;
  }

  .otp-info-content i {
    font-size: 20px;
  }

  .otp-info-text strong {
    font-size: 14px;
  }

  .otp-info-text p {
    font-size: 13px;
  }

  /* Alertas más compactas */
  .auth-alert {
    margin-bottom: 15px;
    border-radius: 10px;
  }

  .auth-alert-content {
    padding: 15px 18px;
    gap: 12px;
  }

  .auth-alert i {
    font-size: 18px;
  }

  .auth-alert span {
    font-size: 14px;
  }
}

/* Móviles medianos (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  .iframe-container,
  .content-area {
    padding: 15px;
  }

  .login-container {
    margin: 1rem auto;
    max-width: 420px;
  }

  .login-header {
    padding: 22px 20px;
  }

  .login-form,
  #otp-form {
    padding: 25px 20px;
  }
}

/* Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .login-container {
    width: 50%; /* Ancho intermedio para tablets */
    max-width: none;
  }
}

/* ===== MEJORAS ESPECÍFICAS PARA EL FORMAT INDICATOR ===== */

/* Asegurar que el icono esté siempre visible */
.identifier-input-group input:focus + .format-indicator {
  color: var(--primary-color, #241a6e);
  transform: translateY(-50%) scale(1.1);
}

/* Animación suave para cambio de icono */
.format-indicator {
  transition: all 0.3s ease;
}

/* Estados del format indicator */
.format-indicator.show {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.format-indicator.hide {
  opacity: 0;
  transform: translateY(-50%) scale(0.8);
}

/* ===== MEJORAS PARA ACCESIBILIDAD TÁCTIL ===== */

/* Área táctil mínima de 44px para iOS */
@media (max-width: 768px) {
  .btn-login,
  .toggle-otp .switch,
  .auth-alert-close {
    min-height: 24px;
    min-width: 44px;
  }

  /* Input de OTP más grande para táctil */
  #otp_code {
    font-size: 24px;
    padding: 18px 15px;
    min-height: 60px;
  }
}

/* ===== PREVENCIÓN DE ZOOM EN iOS ===== */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"] {
    font-size: 16px !important; /* Prevenir zoom automático en iOS */
  }
}

/* ===== MEJORAS DE CONTRASTE Y LEGIBILIDAD ===== */
@media (max-width: 768px) {
  .identifier-hint {
    font-size: 13px;
    margin-top: 6px;
    line-height: 1.3;
  }

  .error-message {
    font-size: 13px;
    line-height: 1.3;
    margin-top: 6px;
  }

  /* Mejor contraste para hints */
  .identifier-hint.success {
    color: #059669;
    font-weight: 600;
  }

  .identifier-hint.info {
    color: #0284c7;
    font-weight: 500;
  }

  .identifier-hint.warning {
    color: #d97706;
    font-weight: 600;
  }

  .identifier-hint.error {
    color: #dc2626;
    font-weight: 600;
  }
}

/* ===== LOADING OVERLAY RESPONSIVE ===== */
@media (max-width: 768px) {
  .loading-overlay {
    padding: 20px;
  }

  .loading-spinner {
    width: 40px;
    height: 40px;
    border-width: 4px;
  }
}

/* ===== NOTIFICACIONES FLOTANTES RESPONSIVE ===== */
@media (max-width: 768px) {
  /* Ajustar notificaciones flotantes para móvil */
  .notification {
    top: 10px !important;
    right: 10px !important;
    left: 10px !important;
    max-width: none !important;
    border-radius: 8px;
    font-size: 14px;
    padding: 12px 16px;
  }
}

/* ===== MEJORAS PARA LANDSCAPE EN MÓVIL ===== */
@media (max-width: 768px) and (orientation: landscape) {
  .iframe-container,
  .content-area {
    padding: 5px 15px;
  }

  .login-container {
    margin: 0.25rem auto;
  }

  .login-header {
    padding: 15px;
  }

  .login-header h1 {
    font-size: 1.3rem;
  }

  .login-form,
  #otp-form {
    padding: 15px;
  }

  .help-message {
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 10px 15px;
  }
}


/* --- FIX ICONOS EN identifier-input-group --- */
.identifier-input-group {
  position: relative;            /* 1️⃣ Marco de referencia */
}


.identifier-input-group input {
  padding-right: 60px;         /* Espacio suficiente p/ 2 iconos */
}

/* Avatar fijo */
.identifier-input-group .input-icon {
  position: absolute;
  right: 12px;                 /* Pegado al borde derecho */
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
}

/* Indicador dinámico (email / phone / warning) */
.identifier-input-group .format-indicator {
  position: absolute;
  right: 36px;                 /* 24 px antes del avatar */
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
  opacity: 0;                  /* Oculto por defecto */
  transition: opacity .25s ease;
}

.identifier-input-group .format-indicator.show {
  opacity: 1;                  /* Se muestra cuando JS agrega .show */
}


/* 3️⃣ Solo mostrar el avatar cuando NO haya formato detectado */
.identifier-input-group.format-ok  .input-icon { display: none; }
/* 4️⃣ Ocultar el contenedor mientras no haya detección */
.format-indicator:not(.show)      { opacity: 0; }
/* 5️⃣ Transición suave */
.format-indicator.show            { opacity: 1; transition: opacity .25s ease; }
