
/* =========================
   BACKDROP
========================= */
#bibuaranModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 999999;
    justify-content: center;
    align-items: center;
    padding: 16px;
    box-sizing: border-box;
    overflow: hidden;
    backdrop-filter: blur(4px);
}

#bibuaranModal.active {
    display: flex;
}

/* Evita que la pagina de fondo se desplace mientras el modal esta abierto */
body:has(#bibuaranModal.active) {
    overflow: hidden;
}

#bibuaranModal,
#bibuaranModal *,
#bibuaranModal *::before,
#bibuaranModal *::after {
    box-sizing: border-box;
}

/* =========================
   BOX
========================= */
#bibuaranModal .bibuaran-box {
    background: #fff;
    width: 100%;
    max-width: 480px;
    border-radius: 16px;
    padding: 24px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    /* CLAVE: nunca mas alto que la pantalla; si el contenido no cabe,
       el scroll es DENTRO de la caja (no se corta ni arriba ni abajo). */
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* =========================
   TITULO
========================= */
#bibuaranModal h3 {
    margin: 0 0 14px;
    padding: 0 44px;
    font-size: 19px;
    font-weight: 600;
    text-align:center;
    color:#222;
}

/* =========================
   INPUTS
========================= */
#bibuaranModal input,
#bibuaranModal textarea,
#bibuaranModal select {
    width:100%;
    padding:10px 12px;
    margin-bottom:10px;
    border:1px solid #e5e5e5;
    border-radius:10px;
    font-size:14px;
}

#bibuaranModal textarea {
    min-height: 76px;
    max-height: 140px;
    resize: vertical;
}

/* focus */
#bibuaranModal input:focus,
#bibuaranModal textarea:focus,
#bibuaranModal select:focus {
    border-color:#000;
    outline:none;
}

/* =========================
   BOTON ENVIAR
========================= */
#bibuaranModal button {
    width:100%;
    padding:12px;
    background:#000;
    color:#fff;
    border:none;
    border-radius:10px;
    font-weight:600;
    cursor:pointer !important;
    transition:all 0.2s ease;
}

#bibuaranModal button:hover {
    background:#222;
}

/* =========================
   X CERRAR (VISIBLE + NEGRA)
========================= */
#bibuaranModal .bibuaran-close {
    position:sticky;
    top:0;
    margin:-12px -12px -34px auto;
    width:40px;
    height:40px;
    flex-shrink:0;
    background:#000 !important;
    color:#fff !important;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:24px;
    font-weight:bold;
    cursor:pointer !important;
    z-index:5;
    transition:all 0.2s ease;
}

/* hover X */
#bibuaranModal .bibuaran-close:hover {
    background:#e60000 !important;
    transform: scale(1.1);
}

/* =========================
   ANTI-SPAM: HONEYPOT (invisible para humanos)
========================= */
#bibuaranModal .bib-hp {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* =========================
   ANTI-SPAM: CAPTCHA + TERMINOS Y CONDICIONES
========================= */
#bibuaranModal .bib-captcha label {
    display: block;
    font-size: 13px;
    color: #444;
    margin-bottom: 6px;
}
#bibuaranModal .bib-terms {
    margin-bottom: 14px;
    text-align: center;
}
#bibuaranModal .bib-terms-link {
    display: inline-block;
    font-size: 13.5px;
    font-weight: 600;
    color: #000;
    text-decoration: underline;
    cursor: pointer;
}
#bibuaranModal .bib-terms-link:hover { color: #444; }

/* Boton "Enviar" deshabilitado hasta que se pulse el enlace de arriba */
#bibuaranModal button:disabled {
    background: #ccc;
    cursor: not-allowed !important;
}
#bibuaranModal button:disabled:hover { background: #ccc; }

/* =========================
   VENTANA DE TERMINOS Y CONDICIONES (iframe)
========================= */
#bibuaranTermsModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 1000000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
#bibuaranTermsModal.active { display: flex; }
#bibuaranTermsModal .bib-terms-modal-box {
    background: #fff;
    width: 100%;
    max-width: 720px;
    height: 80vh;
    border-radius: 14px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    overflow: hidden;
}
#bibuaranTermsModal iframe {
    width: 100%;
    height: 100%;
    border: none;
}
#bibuaranTermsModal .bib-terms-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: #000;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2;
}
#bibuaranTermsModal .bib-terms-modal-close:hover { background: #e60000; }

/* =========================
   SUCCESS
========================= */
#bibuaran-success {
    display:none;
    color:#0a8f3c;
    text-align:center;
    margin-top:10px;
    font-weight:500;
}

/* =========================
   DATOS DEL PROFESIONAL/EMPRESA
========================= */
#bibuaranModal .bib-seller-box {
    margin: 0 0 14px;
    padding: 12px 14px;
    background: #f7f8fa;
    border: 1px solid #eceef0;
    border-radius: 12px;
    font-size: 13px;
    color: #3d4451;
    line-height: 1.55;
}
#bibuaranModal .bib-seller-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6c6f75;
    margin-bottom: 6px;
}
#bibuaranModal .bib-seller-row { display: flex; gap: 8px; align-items: flex-start; }
#bibuaranModal .bib-seller-row + .bib-seller-row { margin-top: 4px; }
#bibuaranModal .bib-seller-row a { color: #136436; font-weight: 600; text-decoration: none; }
#bibuaranModal .bib-seller-label { color: #8a8f98; font-size: 12px; }


/* =========================
   reCAPTCHA (304px fijos) + RESPONSIVE
========================= */
#bibuaranModal .bib-recaptcha {
    margin-bottom: 10px;
    max-width: 100%;
    overflow: hidden;
}

#bibuaranModal .bib-terms { margin-bottom: 10px; }
#bibuaranModal .bib-terms-link { font-size: 13px; }

@media (max-width: 575px) {
    #bibuaranModal { padding: 10px; }
    #bibuaranModal .bibuaran-box {
        padding: 18px 16px;
        border-radius: 14px;
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
    }
    #bibuaranModal h3 { font-size: 17px; margin-bottom: 10px; }
    /* 16px evita el zoom automatico de iOS al enfocar un campo */
    #bibuaranModal input,
    #bibuaranModal textarea,
    #bibuaranModal select {
        font-size: 16px;
        padding: 9px 12px;
        margin-bottom: 8px;
    }
    #bibuaranModal textarea { min-height: 64px; }
    #bibuaranModal .bib-seller-box { padding: 10px 12px; margin-bottom: 10px; font-size: 12.5px; }
    #bibuaranTermsModal { padding: 10px; }
    #bibuaranTermsModal .bib-terms-modal-box { height: 88vh; height: 88dvh; }
}

/* Pantallas muy estrechas: el reCAPTCHA (304px) no cabe, se reduce */
@media (max-width: 360px) {
    #bibuaranModal .bib-recaptcha .g-recaptcha {
        transform: scale(.86);
        transform-origin: 0 0;
        height: 68px;
    }
}

/* Pantallas bajas (moviles en horizontal, portatiles pequenos) */
@media (max-height: 700px) and (min-width: 576px) {
    #bibuaranModal .bibuaran-box { padding: 18px 22px; }
    #bibuaranModal input,
    #bibuaranModal select { padding: 8px 12px; margin-bottom: 8px; }
    #bibuaranModal textarea { min-height: 60px; }
}
