/* ==========================================================================
   AI-CEPH - Estilos de Autenticación, Cuenta de Usuario y Turnstile
   ========================================================================== */

/* --- Cabecera: Menú Desplegable y Chip de Usuario --- */
.nav-user-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: all 0.2s ease;
}

.site-nav-header.header-on-light .nav-user-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}

.site-nav-header.header-on-dark .nav-user-btn {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.nav-user-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.nav-user-avatar-initials {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0b5cab 0%, #0284c7 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(11, 92, 171, 0.35);
  flex-shrink: 0;
}

.nav-user-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid #0b5cab;
}

.nav-user-name-short {
  font-size: 0.88rem;
  font-weight: 600;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-user-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
}

.nav-user-btn[aria-expanded="true"] .nav-user-chevron {
  transform: rotate(180deg);
}

/* Menú flotante del usuario */
.nav-user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 260px;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16), 0 4px 12px rgba(15, 23, 42, 0.06);
  padding: 8px 0;
  z-index: 9999;
  display: none;
  animation: navDropdownFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.nav-user-dropdown.is-open {
  display: block;
}

@keyframes navDropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.nav-user-dropdown-header {
  padding: 12px 18px 10px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-user-dropdown-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-user-dropdown-email {
  font-size: 0.8rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-user-dropdown-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #0b5cab;
  background: #eff6ff;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  width: fit-content;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #334155;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: inherit;
}

.nav-dropdown-item:hover {
  background: #f8fafc;
  color: #0b5cab;
}

.nav-dropdown-item svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
}

.nav-dropdown-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 6px 0;
}

.nav-dropdown-item.logout-item {
  color: #dc2626;
}

.nav-dropdown-item.logout-item:hover {
  background: #fef2f2;
  color: #b91c1c;
}

/* --- Página de Autenticación (login.html) --- */
.auth-page-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  background-image: 
    radial-gradient(circle at 50% 10%, rgba(11, 92, 171, 0.28) 0%, transparent 60%),
    radial-gradient(circle at 10% 90%, rgba(2, 132, 199, 0.15) 0%, transparent 45%);
  background-attachment: fixed;
  color: #1e293b;
}

.auth-viewport-wrapper {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 5vw, 48px) 16px;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 38px 36px;
  position: relative;
  box-sizing: border-box;
}

@media (max-width: 520px) {
  .auth-card {
    padding: 28px 20px;
    border-radius: 20px;
  }
}

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

.auth-card-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(11, 92, 171, 0.1) 0%, rgba(3, 105, 161, 0.18) 100%);
  color: #0b5cab;
  margin-bottom: 14px;
}

.auth-card-badge svg {
  width: 26px;
  height: 26px;
}

.auth-card-title {
  font-size: 1.55rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.4px;
  margin-bottom: 6px;
}

.auth-card-subtitle {
  font-size: 0.92rem;
  color: #64748b;
  line-height: 1.45;
}

/* Selector de Pestañas (Tabs) */
.auth-tabs-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 14px;
  gap: 4px;
  margin-bottom: 24px;
}

.auth-tab-btn {
  background: transparent;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  color: #64748b;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.auth-tab-btn:hover {
  color: #0f172a;
}

.auth-tab-btn.active {
  background: #ffffff;
  color: #0b5cab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Formularios */
.auth-form-view {
  display: none;
}

.auth-form-view.active {
  display: block;
  animation: authFormSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.auth-form-group {
  margin-bottom: 16px;
  text-align: left;
}

.auth-form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

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

.auth-input-icon {
  position: absolute;
  left: 14px;
  color: #94a3b8;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-input-icon svg {
  width: 19px;
  height: 19px;
}

.auth-text-input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  font-size: 0.95rem;
  color: #0f172a;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  font-family: inherit;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.auth-text-input:focus {
  outline: none;
  background: #ffffff;
  border-color: #0b5cab;
  box-shadow: 0 0 0 3px rgba(11, 92, 171, 0.16);
}

.auth-text-input::placeholder {
  color: #94a3b8;
}

/* Botón Mostrar/Ocultar Contraseña */
.auth-password-toggle {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s ease;
}

.auth-password-toggle:hover {
  color: #0f172a;
}

.auth-password-toggle svg {
  width: 19px;
  height: 19px;
}

/* Enlace Olvidé mi Contraseña */
.auth-forgot-link-wrapper {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.auth-text-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: #0b5cab;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  font-family: inherit;
  transition: color 0.15s ease;
}

.auth-text-link:hover {
  color: #0369a1;
  text-decoration: underline;
}

/* Checkbox Legal (Ley N° 21.719) */
.auth-legal-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0 16px;
  font-size: 0.82rem;
  color: #475569;
  line-height: 1.45;
  cursor: pointer;
}

.auth-legal-checkbox input[type="checkbox"] {
  margin-top: 2px;
  width: 17px;
  height: 17px;
  accent-color: #0b5cab;
  cursor: pointer;
  flex-shrink: 0;
}

.auth-legal-checkbox a {
  color: #0b5cab;
  text-decoration: underline;
  font-weight: 600;
}

/* Slot para Cloudflare Turnstile */
.auth-turnstile-wrapper {
  margin: 18px 0 16px;
  min-height: 65px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.auth-turnstile-slot {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Botones de Envío */
.auth-primary-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 20px;
  background: linear-gradient(135deg, #0b5cab 0%, #0369a1 100%);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 6px 18px rgba(11, 92, 171, 0.32);
  font-family: inherit;
}

.auth-primary-btn:hover:not(:disabled) {
  transform: translateY(-1.5px);
  box-shadow: 0 8px 24px rgba(11, 92, 171, 0.42);
}

.auth-primary-btn:active:not(:disabled) {
  transform: translateY(0);
}

.auth-primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* Divisor O Continúa Con */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0 18px;
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

/* Botón Google Sign-In */
.auth-google-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 18px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  color: #1e293b;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.auth-google-btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.auth-google-btn:active:not(:disabled) {
  transform: scale(0.99);
}

.auth-google-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.auth-google-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Enlaces Secundarios al Pie */
.auth-footer-prompt {
  margin-top: 22px;
  text-align: center;
  font-size: 0.88rem;
  color: #64748b;
}

.auth-footer-prompt button,
.auth-footer-prompt a {
  color: #0b5cab;
  font-weight: 700;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  margin-left: 4px;
}

.auth-footer-prompt button:hover,
.auth-footer-prompt a:hover {
  text-decoration: underline;
}

/* Alertas de Error y Éxito */
.auth-alert-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.86rem;
  line-height: 1.45;
  margin-bottom: 20px;
  animation: authAlertFadeIn 0.2s ease;
}

@keyframes authAlertFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-alert-box.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.auth-alert-box.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.auth-alert-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.auth-alert-icon svg {
  width: 18px;
  height: 18px;
}

/* Spinner Animado */
.auth-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: authSpin 0.75s linear infinite;
  display: inline-block;
}

.auth-spinner.dark {
  border: 2px solid rgba(15, 23, 42, 0.2);
  border-top-color: #0f172a;
}

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

/* Estado de Sesión Ya Activa */
.auth-active-session-card {
  text-align: center;
  padding: 10px 0;
}

.auth-session-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #0b5cab 0%, #0284c7 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(11, 92, 171, 0.35);
  object-fit: cover;
}

.auth-session-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.auth-session-email {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 24px;
}

.auth-session-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Ventana Modal Universal de Autenticación (Emergente en Index y Analizador) --- */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 32px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

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

.auth-modal-dialog {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 36px 32px;
  position: relative;
  box-sizing: border-box;
  transform: translateY(12px) scale(0.96);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.auth-modal-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f1f5f9;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  cursor: pointer;
  transition: all 0.18s ease;
  z-index: 10;
}

.auth-modal-close-btn:hover {
  background: #fee2e2;
  color: #ef4444;
  transform: scale(1.08);
}

.auth-modal-close-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.2;
}
