/* ======================================================
   MODAL DE AUTENTICACIÓN — Rediseño
   Botones: magenta para primarios, azul-oscuro para texto links
   Google: icono real con colores oficiales
   Sin magenta en textos — amarillo para acentos visuales
   ====================================================== */

/* ---- OVERLAY ---- */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 90, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  padding: 20px;
}

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

/* ---- MODAL ---- */
.auth-modal {
  background: var(--blanco);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  box-shadow:
    0 0 0 1px rgba(28, 43, 90, 0.08),
    0 24px 60px -12px rgba(28, 43, 90, 0.3);
  overflow: hidden;
  animation: authFadeUp 0.38s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  position: relative;
}

/* Barra decorativa superior: azul → magenta → amarillo */
.auth-modal::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--azul-oscuro), var(--magenta-oscuro), var(--amarillo));
  z-index: 1;
}

.auth-modal.registro-activo {
  max-width: 680px !important;
}

@keyframes authFadeUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---- TABS ---- */
.auth-tabs {
  display: flex;
  align-items: stretch;
  background: var(--bg-accent);
  border-bottom: 1px solid var(--border-light);
  padding-top: 3px;
}

.auth-tab {
  flex: 1;
  padding: 14px 20px;
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-family: "Nunito", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  transition: color 0.25s ease, background 0.25s ease;
}

.auth-tab:hover {
  color: var(--azul-oscuro);
  background: rgba(28, 43, 90, 0.04);
}

.auth-tab.active {
  color: var(--azul-oscuro);
  background: var(--blanco);
}

.auth-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--azul-oscuro);
  border-radius: 2px 2px 0 0;
}

/* ---- BOTÓN CERRAR ---- */
.auth-close {
  width: 48px;
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
  padding-top: 3px;
}

.auth-close:hover {
  color: var(--text-heading);
  background: rgba(92, 79, 86, 0.05);
}

/* ---- CONTENIDO ---- */
.auth-content {
  padding: 36px 32px 32px;
}

.auth-tab-content {
  display: none;
  animation: authTabIn 0.25s ease forwards;
}

.auth-tab-content.active {
  display: block;
}

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

/* ---- ENCABEZADO DEL TAB ---- */
.auth-titulo {
  font-family: "Philosopher", serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--azul-oscuro);
  margin-bottom: 6px;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.auth-titulo em {
  font-style: italic;
  color: var(--amarillo);
  font-weight: 400;
}

.auth-subtitle {
  font-family: "Nunito", sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-soft);
  margin-bottom: 28px;
  line-height: 1.55;
}

/* ---- FORMULARIO ---- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-family: "Nunito", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.form-input {
  padding: 11px 14px;
  background: var(--bg-accent-3);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-family: "Nunito", sans-serif;
  font-size: 15px;
  color: var(--text-heading);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  outline: none;
}

.form-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.form-input:hover {
  border-color: var(--border-dark);
}

.form-input:focus {
  border-color: var(--azul-oscuro);
  background: var(--blanco);
  box-shadow: 0 0 0 3px rgba(28, 43, 90, 0.08);
}

/* ---- CHECKBOX ---- */
.form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
}

.form-checkbox input[type="checkbox"] {
  width: 17px;
  height: 17px;
  min-width: 17px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--azul-oscuro);
  border-radius: 3px;
}

.form-checkbox label {
  font-family: "Nunito", sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-body);
  line-height: 1.5;
  cursor: pointer;
}

.form-checkbox label a {
  color: var(--azul-oscuro);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid rgba(28, 43, 90, 0.2);
  transition: border-color 0.2s, color 0.2s;
}

.form-checkbox label a:hover {
  color: var(--azul-oscuro);
  border-color: var(--azul-oscuro);
}

/* ---- BOTÓN PRIMARIO (magenta) ---- */
.auth-btn-primary {
  padding: 13px 24px;
  background: var(--magenta-oscuro);
  color: var(--blanco);
  border: none;
  border-radius: var(--radius-sm);
  font-family: "Nunito", sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s ease;
  margin-top: 4px;
  position: relative;
  overflow: hidden;
}

.auth-btn-primary:hover:not(:disabled) {
  background: var(--magenta-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(159, 39, 101, 0.3);
}

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

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

/* ---- DIVISOR ---- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.auth-divider span {
  font-family: "Nunito", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---- BOTÓN GOOGLE (icono real con colores oficiales) ---- */
.auth-btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 20px;
  background: var(--blanco);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-heading);
  font-family: "Nunito", sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-btn-google:hover {
  border-color: var(--border-dark);
  background: var(--bg-accent-3);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(92, 79, 86, 0.08);
}

/* Icono SVG de Google con colores oficiales de la marca */
.auth-btn-google .google-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
}

/* ---- LINKS SECUNDARIOS ---- */
.auth-link {
  text-align: center;
  font-family: "Nunito", sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 20px;
}

.auth-text-link {
  color: var(--azul-oscuro);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  transition: color 0.2s ease;
  border-bottom: 1px solid rgba(28, 43, 90, 0.2);
}

.auth-text-link:hover {
  color: var(--azul-oscuro);
  border-bottom-color: var(--azul-oscuro);
  opacity: 0.75;
}

/* Link "olvidé contraseña" en amarillo para distinguirlo */
.auth-text-link--forgot {
  color: var(--text-soft);
  border-bottom-color: transparent;
  font-weight: 600;
}

.auth-text-link--forgot:hover {
  color: var(--azul-oscuro);
  border-bottom-color: rgba(28, 43, 90, 0.2);
  opacity: 1;
}

/* ---- REGISTRO EN GRID (desktop) ---- */
@media (min-width: 769px) {
  .auth-overlay.active .auth-modal {
    transition: max-width 0.3s ease;
  }

  #registro-tab .auth-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
  }

  #registro-tab .auth-form .form-group:nth-child(1) { grid-column: 1; }
  #registro-tab .auth-form .form-group:nth-child(2) { grid-column: 2; }
  #registro-tab .auth-form .form-group:nth-child(3) { grid-column: 1; }
  #registro-tab .auth-form .form-group:nth-child(4) { grid-column: 2; }

  #registro-tab .auth-form .form-checkbox   { grid-column: 1 / -1; padding: 2px 0; }
  #registro-tab .auth-form .auth-btn-primary { grid-column: 1 / -1; }

  #registro-tab .auth-titulo   { font-size: 22px; }
  #registro-tab .auth-subtitle { margin-bottom: 22px; }
}

/* ======================================================
   DROPDOWN USUARIO AUTENTICADO
   ====================================================== */
.user-dropdown-authenticated {
  opacity: 1;
  visibility: visible;
}

.user-dropdown a.auth-logout {
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
  padding-top: 10px;
  color: var(--magenta-oscuro);
}

.user-dropdown a.auth-logout:hover {
  background: var(--magenta-light);
  color: var(--magenta-hover);
}

/* ======================================================
   MODAL CIERRE DE SESIÓN
   ====================================================== */
.logout-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 90, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

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

.logout-box {
  background: var(--blanco);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 36px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 24px 60px rgba(28, 43, 90, 0.2);
  animation: authFadeUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.logout-spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--border-light);
  border-top-color: var(--magenta-oscuro);
  border-radius: 50%;
  animation: spinnerGirar 0.75s linear infinite;
}

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

.logout-texto {
  font-family: "Nunito", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ======================================================
   MODAL INICIO DE SESIÓN — SPINNER
   ====================================================== */
.login-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 90, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

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

.login-loading-box {
  background: var(--blanco);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 36px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 24px 60px rgba(28, 43, 90, 0.2);
  animation: authFadeUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-loading-spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--border-light);
  border-top-color: var(--magenta-oscuro);
  border-radius: 50%;
  animation: spinnerGirar 0.75s linear infinite;
}

.login-loading-texto {
  font-family: "Nunito", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ======================================================
   MODAL OLVIDÉ MI CONTRASEÑA
   ====================================================== */
.forgot-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 90, 0.45);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 20px;
}

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

.forgot-modal {
  background: var(--blanco);
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 400px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(28, 43, 90, 0.25);
  animation: authFadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.forgot-modal::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--azul-oscuro), var(--amarillo));
  z-index: 1;
}

.forgot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 16px;
  background: var(--bg-accent);
  border-bottom: 1px solid var(--border-light);
}

.forgot-header-titulo {
  font-family: "Nunito", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--azul-oscuro);
}

.forgot-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  transition: color 0.2s ease;
  border-radius: 4px;
}

.forgot-close:hover {
  color: var(--text-heading);
  background: var(--border-light);
}

.forgot-body {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.forgot-titulo {
  font-family: "Philosopher", serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--azul-oscuro);
  letter-spacing: 0.01em;
}

.forgot-descripcion {
  font-family: "Nunito", sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-soft);
  line-height: 1.6;
  margin: 0;
}

.forgot-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.forgot-msg {
  font-family: "Nunito", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  min-height: 0;
  transition: all 0.3s ease;
}

.forgot-msg-ok {
  color: #3a9e58;
  background: rgba(58, 158, 88, 0.06);
  border: 1px solid rgba(58, 158, 88, 0.18);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
}

/* ======================================================
   RESPONSIVE — TABLET
   ====================================================== */
@media (max-width: 950px) {
  .auth-modal {
    width: 92%;
    max-width: 480px;
  }

  .auth-content {
    padding: 32px 26px 28px;
  }

  .auth-titulo { font-size: 23px; }
  .auth-subtitle { font-size: 15px; margin-bottom: 24px; }

  #registro-tab .auth-form {
    display: flex;
    flex-direction: column;
  }

  .auth-modal.registro-activo {
    max-width: 480px !important;
  }
}

/* ======================================================
   RESPONSIVE — MÓVIL GRANDE
   ====================================================== */
@media (max-width: 768px) {
  .auth-overlay { padding: 16px; }

  .auth-modal {
    width: 100%;
    max-width: 440px;
    border-radius: var(--radius-md);
    max-height: 90vh;
    overflow-y: auto;
  }

  .auth-tabs {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .auth-content { padding: 28px 22px; }

  .auth-titulo    { font-size: 22px; }
  .auth-subtitle  { font-size: 14px; margin-bottom: 22px; }
  .auth-form      { gap: 16px; }
  .auth-tab       { padding: 13px 14px; font-size: 11px; }
  .auth-close     { font-size: 16px; }
  .auth-divider   { margin: 20px 0; }
  .auth-link      { font-size: 12px; margin-top: 18px; }

  .form-label  { font-size: 11px; }
  .form-input  { padding: 11px 13px; font-size: 16px !important; }
  .form-checkbox { gap: 10px; padding: 8px 0; }

  .forgot-modal  { max-width: 420px; }
  .forgot-body   { padding: 24px 20px; gap: 14px; }
  .forgot-titulo { font-size: 17px; }
  .forgot-descripcion { font-size: 13px; }
}

/* ======================================================
   RESPONSIVE — MÓVIL PEQUEÑO — Bottom sheet
   ====================================================== */
@media (max-width: 640px) {
  .auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    z-index: 1000;
    padding: 0;
  }

  .auth-modal,
  #registro-tab .auth-modal,
  .auth-overlay.active .auth-modal:has(#registro-tab.active) {
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: authSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  @keyframes authSlideUp {
    from { transform: translateY(100%); opacity: 0.5; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  .auth-tabs {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-top: 0;
  }

  .auth-tabs::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: var(--border-medium);
    border-radius: 2px;
    z-index: 2;
    pointer-events: none;
  }

  .auth-tab   { padding: 16px 14px 14px; font-size: 11px; }
  .auth-close { font-size: 14px; width: 44px; }
  .auth-content { padding: 26px 18px 24px; }
  .auth-titulo  { font-size: 21px; text-align: center; }
  .auth-subtitle { font-size: 14px; text-align: center; margin-bottom: 20px; }

  .forgot-overlay { align-items: flex-end; padding: 0; }

  .forgot-modal {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: authSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .forgot-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-top: 20px;
  }

  .forgot-body { padding: 22px 18px; }
}

/* ======================================================
   RESPONSIVE — MÓVIL MUY PEQUEÑO
   ====================================================== */
@media (max-width: 480px) {
  .auth-content { padding: 22px 16px 20px; }
  .auth-titulo  { font-size: 20px; }
  .auth-subtitle { font-size: 13px; }
  .auth-form  { gap: 14px; }
  .auth-divider { margin: 18px 0; }
  .auth-link    { font-size: 11px; margin-top: 16px; }

  .form-label { font-size: 10px; }
  .form-input { padding: 10px 12px; border-radius: 6px; }

  .auth-btn-primary,
  .auth-btn-google { padding: 11px 16px; font-size: 12px; border-radius: 6px; }

  .logout-box,
  .login-loading-box { padding: 28px 32px; }

  .forgot-body { padding: 18px 16px; gap: 12px; }
  .forgot-titulo { font-size: 16px; }
}

/* ======================================================
   RESPONSIVE — MÍNIMO
   ====================================================== */
@media (max-width: 380px) {
  .auth-modal,
  .auth-tabs {
    border-radius: 16px 16px 0 0;
  }

  .auth-content   { padding: 18px 14px; }
  .auth-titulo    { font-size: 19px; }
  .auth-subtitle  { font-size: 13px; margin-bottom: 16px; }
  .auth-form      { gap: 12px; }
  .auth-link      { font-size: 10px; }

  .form-input { padding: 9px 11px; font-size: 15px !important; }
  .auth-btn-primary,
  .auth-btn-google { padding: 10px 14px; font-size: 12px; }

  .form-checkbox input[type="checkbox"] { width: 16px; height: 16px; min-width: 16px; }
  .form-checkbox label { font-size: 13px; }
  .form-checkbox { padding: 6px 0; }

  .forgot-modal  { border-radius: 16px 16px 0 0; }
  .forgot-header { border-radius: 16px 16px 0 0; padding: 16px 14px; }
  .forgot-body   { padding: 16px 14px; gap: 10px; }
  .forgot-titulo { font-size: 15px; }
}

/* ======================================================
   LANDSCAPE MÓVIL
   ====================================================== */
@media (max-height: 600px) and (orientation: landscape) {
  .auth-modal {
    max-height: 92vh;
    overflow-y: auto;
  }

  .auth-content { padding: 18px 22px; }
  .auth-titulo  { font-size: 17px; margin-bottom: 4px; }
  .auth-subtitle { font-size: 12px; margin-bottom: 14px; }
  .auth-form    { gap: 12px; }
  .auth-divider { margin: 14px 0; }
  .form-input   { padding: 9px 12px; }
  .auth-btn-primary,
  .auth-btn-google { padding: 9px 16px; }
}

/* ======================================================
   PREVENCIÓN BUGS MÓVIL
   ====================================================== */
@media (max-width: 768px) {
  input, textarea, select {
    font-size: 16px !important;
  }

  .auth-modal { position: fixed; }

  .auth-btn-primary,
  .auth-btn-google,
  .auth-tab {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
