:root {
    --wa-color-green: #25D366;
    --wa-color-green-dark: #1EAE54;
    --wa-color-bg: #25282c;
    --wa-color-card: #1D1E22;
    --wa-color-text: #ffffff;
    --wa-color-text-muted: #888888;
    --wa-color-border: rgba(255, 255, 255, 0.05);
}

#whatsapp-float-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--wa-color-green), var(--wa-color-green-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2rem;
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.5);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-decoration: none;
}

#whatsapp-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(37, 211, 102, 0.6);
}

#whatsapp-float-btn:active {
    transform: scale(0.95);
}

.whatsapp-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
}

.whatsapp-overlay.whatsapp-hidden {
    opacity: 0;
    pointer-events: none;
}

#whatsapp-card {
    background: var(--wa-color-bg);
    border-radius: 25px;
    padding: 30px 40px 15px; /* Padding inferior reducido: el btn-close lo maneja */
    width: 90%;
    max-width: 520px;
    max-height: 95vh; /* Estandarizado al 95% del viewport */
    display: flex;
    flex-direction: column;
    overflow: visible; /* Modified to allow close button to pop out */
    position: relative;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--wa-color-border);
    transform: scale(1);
    transition: transform 0.3s ease;
}

.whatsapp-overlay.whatsapp-hidden #whatsapp-card {
    transform: scale(0.95);
}

#whatsapp-card::-webkit-scrollbar {
    width: 6px;
}

#whatsapp-card::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

#whatsapp-card::-webkit-scrollbar-thumb {
    background: var(--wa-color-green);
    border-radius: 3px;
}

.whatsapp-header {
    text-align: center;
    margin-bottom: 20px;
    flex-shrink: 0; /* La cabecera siempre visible, nunca se desplaza */
}

/* Vista de formulario: contenedor flex para aislar el scroll */
#whatsapp-form-view {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-grow: 1;
    min-height: 0; /* Necesario para que flex-grow funcione con overflow */
}

.whatsapp-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--wa-color-green), var(--wa-color-green-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 2.2rem;
    color: #fff;
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.4);
}

.whatsapp-header h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--wa-color-text);
    margin: 0 0 10px;
}

.whatsapp-header p {
    color: var(--wa-color-text-muted);
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.5;
}

#whatsapp-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;  /* Solo los campos se desplazan internamente */
    flex-grow: 1;
    min-height: 0;     /* Necesario para flex overflow correcto */
    padding-right: 5px;
    scrollbar-width: thin;
    scrollbar-color: rgba(37, 211, 102, 0.3) transparent;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-field.full-width {
    grid-column: 1 / -1;
}

.form-field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--wa-color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-field input,
.form-field select {
    width: 100%;
    padding: 14px 16px;
    background: var(--wa-color-card);
    border: 1px solid var(--wa-color-border);
    border-radius: 12px;
    color: var(--wa-color-text);
    font-size: 0.95rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
    box-shadow: inset 3px 3px 8px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}

.form-field input::placeholder {
    color: #555;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--wa-color-green);
    box-shadow: inset 3px 3px 8px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.form-field select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23888888' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.form-field select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-whatsapp-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--wa-color-green), var(--wa-color-green-dark));
    border: none;
    border-radius: 14px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.4);
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-whatsapp-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(37, 211, 102, 0.5);
}

.btn-whatsapp-submit:active {
    transform: translateY(0);
}

.btn-whatsapp-submit i {
    font-size: 1.2rem;
}

.btn-close {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--wa-color-text-muted);
    font-size: 0.9rem;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: color 0.3s ease;
    flex-shrink: 0; /* El botón cancelar siempre visible en el pie */
}

.btn-close:hover {
    color: var(--wa-color-text);
}

.whatsapp-success-view {
    text-align: center;
    padding: 20px 0;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--wa-color-green), var(--wa-color-green-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 25px;
    font-size: 2.5rem;
    color: #fff;
    box-shadow: 0 10px 30px rgba(37, 211, 102, 0.4);
}

.whatsapp-success-view h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--wa-color-text);
    margin: 0 0 12px;
}

.whatsapp-success-view p {
    color: var(--wa-color-text-muted);
    font-size: 0.95rem;
    margin: 0 0 25px;
    line-height: 1.5;
}

.whatsapp-hidden {
    display: none;
}

@media (max-width: 600px) {
    #whatsapp-card {
        padding: 25px 20px 30px;
        border-radius: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .whatsapp-icon {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }
    
    .whatsapp-header h3 {
        font-size: 1.2rem;
    }
    
    #whatsapp-float-btn {
        width: 55px;
        height: 55px;
        font-size: 1.8rem;
        bottom: 20px;
        right: 20px;
    }
}
