/* =========================
   AUTH BASE
========================= */

.auth-wrapper {
  max-width: 420px;
  margin: 60px auto;
  padding: 32px 28px;
  background: var(--ba-bg-white);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.08);
  font-family: var(--ba-font-family, 'Nunito', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

/* =========================
   TABS LOGIN / REGISTER
========================= */

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.auth-tabs .tab {
  flex: 1;
  padding: 10px 0;
  border-radius: 8px;
  background: var(--ba-bg-section);
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.auth-tabs .tab.active {
  background: var(--ba-primary);
  color: var(--ba-text-on-dark);
}

/* =========================
   ROLE SWITCH (COMPRADOR / VENDEDOR)
========================= */

.role-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-radius: 14px;
  background-color: #E4E4E7;
  padding: 8px;
}

.role-switch .role {
  flex: 1;
  padding: 10px;
  border-radius: 14px;
  background: #E4E4E7;
  color: #3F3F46;
  cursor: pointer;
  font-weight: 500;
}

.role-switch .role.active {
  background: var(--ba-bg-white);
  color: #3F3F46;
}

/* =========================
   INPUTS
========================= */

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 8px;
  border: 1px solid var(--ba-border);
  font-size: 14px;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--ba-primary);
}

/* =========================
   LOGIN MODAL (custom-login-form)
   Compatible con Figma, layout en columna
========================= */
#login-section,
#register-section {
  padding: 40px;
}

/* Forzar columna: el JS pone display:flex; aquí anulamos dirección para que no quede en fila */
#custom-login-form {
  display: flex !important;
  flex-direction: column !important;
  max-width: 100%;
  gap: 0;
}

#custom-login-form .auth-modal-title,
#custom-login-form h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--ba-primary);
  margin: 0 0 20px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ba-bg-section);
  text-align: center;
}

#login-section .login-role-switch {
  margin-bottom: 24px;
}

#login-section .login-role-switch .role {
  flex: 1;
  padding: 10px 16px;
  border-radius: 14px;
  background: #E4E4E7;
  color: #3F3F46;
  font-weight: 500;
  border: none;
  cursor: pointer;
}

#login-section .login-role-switch .role.active {
  background: var(--ba-bg-white);
  color: var(--ba-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#custom-login-form .form-group {
  margin-bottom: 18px;
}

#custom-login-form .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

#custom-login-form .form-group input[type="text"],
#custom-login-form .form-group input[type="password"],
#custom-login-form .form-group input[type="email"] {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 15px;
  background: #f8fafc;
  color: #334155;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#custom-login-form .form-group input:focus {
  outline: none;
  border-color: var(--ba-primary);
  box-shadow: 0 0 0 3px rgba(31, 191, 117, 0.15);
  background: var(--ba-bg-white);
}

#custom-login-form .form-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

#custom-login-form .form-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #475569;
  cursor: pointer;
  margin: 0;
}

#custom-login-form .form-options input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--ba-primary);
}

#custom-login-form .form-options a {
  font-size: 14px;
  color: var(--ba-primary);
  font-weight: 600;
  text-decoration: none;
}

#custom-login-form .form-options a:hover {
  text-decoration: underline;
}

#custom-login-form .btn-submit {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  background: #107241;
  color: var(--ba-text-on-dark);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#custom-login-form .btn-submit:hover {
  background: #0d5f34;
}

#custom-login-form .btn-submit:active {
  transform: scale(0.98);
}

#custom-login-form .auth-switch {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  font-size: 14px;
  color: #475569;
  text-align: center;
}

#custom-login-form .auth-switch a {
  color: var(--ba-primary);
  font-weight: 600;
  text-decoration: none;
}

#custom-login-form .auth-switch a:hover {
  text-decoration: underline;
}

/* Contraseña con botón mostrar/ocultar */
#custom-login-form .input-wrap-password {
  position: relative;
  display: flex;
  align-items: center;
}

#custom-login-form .input-wrap-password input {
  padding-right: 44px;
  flex: 1;
}

#custom-login-form .input-wrap-password .toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #64748b;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#custom-login-form .input-wrap-password .toggle-password:hover {
  color: var(--ba-primary);
}

#custom-login-form .input-wrap-password .ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#custom-login-form .input-wrap-password .ico svg {
  display: block;
}

/* =========================
   VENDOR ONLY
========================= */

/* Cambia .vendor-only por .vendor-only-section */
.vendor-only-section {
  display: none; /* Oculta por defecto los campos largos de vendedor */
  margin-bottom: 14px;
}

/* Muestra los campos solo cuando el JS añade la clase is-vendor */
.is-vendor .vendor-only-section {
  display: block;
}
.vendor-type {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.vendor-type button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--ba-border);
  background: var(--ba-bg-white);
  cursor: pointer;
}

.vendor-type button.active {
  background: var(--ba-primary);
  color: #3F3F46;
  border-color: var(--ba-primary);
  
}
/* Contenedor de los selectores Persona/Empresa */
.vendor-type-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

/* Estado base de los botones */
.v-type {
    flex: 1;
    display: flex;
    flex-direction: column; /* Icono arriba, texto abajo */
    align-items: center;
    justify-content: center;
    padding: 20px 10px;
    background: var(--ba-bg-white);
    border: 1.5px solid #ddd;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #444;
    font-weight: 500;
}

.v-type img {
   width: 15px !important;  /* Tamaño fijo */
    height: 15px !important; /* Tamaño fijo */
    object-fit: contain;     /* Evita deformación */
    flex-shrink: 0;
    margin-bottom: 2px;
}

/* Estado ACTIVO (Cuando se hace clic) */
.v-type.active {
    background: #f0faf5; /* Fondo verde muy claro */
    border-color: var(--ba-primary); /* Borde verde fuerte */
    color: #444;
}

.v-type.active img {
    filter: none; /* Recupera color original del icono */
    opacity: 1;
}

/* Estilo para etiquetas de campo */
.field-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    color: #333;
}

/* =========================
   REMEMBER
========================= */

.remember {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 18px;
}

/* =========================
   BUTTON
========================= */

.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  background: #107241 !important;
  color: var(--ba-text-on-dark);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.btn-primary:active {
  background: #148a54;
  transform: scale(0.98);
}
/* =========================
   LINKS
========================= */

.switch-link {
  text-align: center;
  font-size: 14px;
  margin-top: 16px;
}

.switch-link a {
  color: var(--ba-primary);
  font-weight: 600;
  text-decoration: none;
}

/* Sincronizar con el HTML del partial */
.vendor-only-section {
    display: none;
}

.is-vendor .vendor-only-section {
    display: block;
}
/* =========================
   RESPONSIVE
========================= */
/* =========================
   MODAL OVERLAY (EL FONDO OSCURO)
========================= */
.auth-overlay {
  display: none; /* Oculto por defecto */
  position: fixed; /* Lo saca del flujo y lo fija a la pantalla */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7); /* Fondo oscuro con transparencia */
  z-index: 99999; /* Por encima de todo el contenido de Astra o Yotako */
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px); /* Efecto desenfoque como en la imagen */
}

/* Esta clase la activa tu auth.js al hacer clic en el header */
.auth-overlay.is-visible {
  display: flex;
}

/* =========================
   MODAL CARD (LA TARJETA BLANCA)
========================= */
/* FUERZA EL COMPORTAMIENTO DE MODAL */
#auth-modal-overlay.auth-overlay {
    display: none !important; /* Oculto por defecto */
    position: fixed !important; /* No se queda en el footer, flota en la pantalla */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8) !important; /* Fondo oscuro */
    z-index: 999999 !important; /* Por encima de todo el contenido */
    justify-content: center;
    align-items: center;
}

/* Solo se muestra cuando el JS añade esta clase */
#auth-modal-overlay.is-visible {
    display: flex !important;
}

/* OCULTA LAS SECCIONES QUE NO ESTÁN ACTIVAS */
.auth-section {
    display: none !important;
}

.auth-section.active {
    display: block !important;
}
.auth-modal-card {
  background: var(--ba-bg-white);
  width: 90%;
  max-width: 480px; /* Ajustado a tu maqueta image_3b39a2.png */
  max-height: 90vh; /* Para que no se salga en pantallas pequeñas */
  padding: 40px;
  border-radius: 20px;
  position: relative;
  overflow-y: auto; /* Permite scroll interno si el registro es largo */
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

/* Botón de cerrar (X) */
.modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #999;
  line-height: 1;
}

.contact-notice {
    font-size: 14px;
    color: #444;
    margin: 20px 0;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px;
    border: 1px solid #eef0f2;
    border-radius: 12px;
    margin-bottom: 12px;
    background: var(--ba-bg-white);
}

/* Mismo estilo que producto/store/footer: cuadro verde claro + icono blanco */
.contact-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: var(--ba-radius-lg, 12px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.email-bg,
.whatsapp-bg {
    background: var(--ba-primary-light, #e9f7ef);
}

.contact-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.contact-info .label {
    display: block;
    font-size: 12px;
    color: #888;
}

.contact-info .value {
    color: var(--ba-primary);
    font-weight: 700;
    text-decoration: none;
    font-size: 15px;
}

.contact-footer-text {
    text-align: center;
    font-size: 12px;
    color: #aaa;
    margin-top: 15px;
}

/* =========================
   REGISTER MODAL
========================= */
#custom-register-form {
  display: flex !important;
  flex-direction: column !important;
  max-width: 100%;
}

#custom-register-form .auth-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--ba-primary);
  margin: 0 0 20px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ba-bg-section);
  text-align: center;
}

#custom-register-form .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

#custom-register-form .form-group input,
#custom-register-form .form-group select {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 15px;
  background: #f8fafc;
  color: #334155;
}

/* Región y Comuna: evitar que el texto se corte a la mitad en el select */
#custom-register-form .form-group select,
#chile-regions,
#chile-communes {
  min-height: 48px;
  line-height: 1.5;
  appearance: auto;
  -webkit-appearance: menulist;
  -moz-appearance: menulist;
}

#custom-register-form .form-group input:focus,
#custom-register-form .form-group select:focus {
  outline: none;
  border-color: var(--ba-primary);
  box-shadow: 0 0 0 3px rgba(31, 191, 117, 0.15);
  background: var(--ba-bg-white);
}

/* Contenedor de campos: siempre columna para evitar layout roto */
#registration-fields-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

#custom-register-form .form-group {
  margin-bottom: 16px;
}

#custom-register-form .form-row {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  direction: ltr;
}

#custom-register-form .form-row .form-group {
  margin-bottom: 0;
}

#custom-register-form .form-row-rut {
  display: flex;
  align-items: center;
  gap: 8px;
}

#custom-register-form .form-row-rut input:first-child {
  flex: 1;
}

#custom-register-form .form-row-rut input:last-child {
  width: 60px;
  text-align: center;
}

#custom-register-form .rut-sep {
  color: #64748b;
  font-weight: 600;
}

#custom-register-form .empresa-placeholder .empresa-msg {
  font-size: 15px;
  color: #475569;
  margin-bottom: 20px;
}

#custom-register-form .switch-link {
  text-align: center;
  font-size: 14px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

#custom-register-form .switch-link a {
  color: var(--ba-primary);
  font-weight: 600;
  text-decoration: none;
}

#custom-register-form .input-wrap-password {
  position: relative;
  display: flex;
  align-items: center;
}

#custom-register-form .input-wrap-password input {
  padding-right: 44px;
  flex: 1;
}

#custom-register-form .input-wrap-password .toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #64748b;
}

#custom-register-form .input-wrap-password .toggle-password:hover {
  color: var(--ba-primary);
}

@media (max-width: 480px) {
  .auth-wrapper {
    margin: 30px 16px;
    padding: 24px 20px;
  }
  #custom-register-form .form-row {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  #custom-register-form .form-row .form-group {
    margin-bottom: 16px;
  }
  #custom-register-form .form-row .form-group:last-child {
    margin-bottom: 0;
  }
}
