/**
 * Gatekeeper Modal - WhatsApp Lead Capture
 * Modal responsivo para captura de leads antes do redirecionamento para WhatsApp
 */

/* Overlay/Backdrop do modal */
.gatekeeper-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
}

/* Estado ativo do modal */
.gatekeeper-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Container do modal */
.gatekeeper-modal {
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Header do modal */
.gatekeeper-header {
    background: linear-gradient(135deg, #0c6d40 0%, #00a85a 100%);
    color: white;
    padding: 24px 24px 20px 24px;
    border-radius: 16px 16px 0 0;
    position: relative;
}

.gatekeeper-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
    padding-right: 40px;
}

.gatekeeper-header p {
    margin: 8px 0 0 0;
    font-size: 14px;
    opacity: 0.95;
}

/* Botão de fechar (X) */
.gatekeeper-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.gatekeeper-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.gatekeeper-close:active {
    transform: scale(0.95);
}

/* Corpo do modal */
.gatekeeper-body {
    padding: 24px;
}

/* Estilo dos campos do formulário */
.gatekeeper-field {
    margin-bottom: 20px;
}

.gatekeeper-field label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #374151;
    margin-bottom: 8px;
}

.gatekeeper-field input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-family: inherit;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.gatekeeper-field input:focus {
    outline: none;
    border-color: #00a85a;
    box-shadow: 0 0 0 3px rgba(0, 168, 90, 0.1);
}

.gatekeeper-field input::placeholder {
    color: #9ca3af;
}

/* Validação de campos */
.gatekeeper-field input:invalid:not(:placeholder-shown) {
    border-color: #ef4444;
}

.gatekeeper-field input:valid:not(:placeholder-shown) {
    border-color: #10b981;
}

/* Mensagem de erro */
.gatekeeper-error {
    color: #ef4444;
    font-size: 13px;
    margin-top: 6px;
    display: none;
}

.gatekeeper-field.has-error .gatekeeper-error {
    display: block;
}

.gatekeeper-field.has-error input {
    border-color: #ef4444;
}

/* Botão de submit */
.gatekeeper-submit {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #0c6d40 0%, #00a85a 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.gatekeeper-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 168, 90, 0.4);
}

.gatekeeper-submit:active {
    transform: translateY(0);
}

.gatekeeper-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Spinner de loading */
.gatekeeper-submit .spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.gatekeeper-submit.loading .spinner {
    display: inline-block;
}

.gatekeeper-submit.loading .submit-text {
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Footer do modal */
.gatekeeper-footer {
    padding: 16px 24px;
    background-color: #f9fafb;
    border-radius: 0 0 16px 16px;
    text-align: center;
}

.gatekeeper-footer p {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
}

/* Container do texto e ícone do botão */
.gatekeeper-submit .submit-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Ícone do WhatsApp */
.gatekeeper-whatsapp-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
    flex-shrink: 0;
}

/* Responsividade para mobile */
@media (max-width: 640px) {
    .gatekeeper-overlay {
        padding: 12px;
    }

    .gatekeeper-modal {
        max-height: 95vh;
    }

    .gatekeeper-header {
        padding: 20px 20px 16px 20px;
    }

    .gatekeeper-header h2 {
        font-size: 20px;
    }

    .gatekeeper-close {
        width: 40px;
        height: 40px;
        font-size: 26px;
        top: 12px;
        right: 12px;
    }

    .gatekeeper-body {
        padding: 20px;
    }

    .gatekeeper-field input {
        padding: 14px 16px;
        font-size: 16px; /* Mantém 16px para evitar zoom no iOS */
    }

    .gatekeeper-submit {
        padding: 16px 24px;
        font-size: 16px;
    }

    .gatekeeper-footer {
        padding: 12px 20px;
    }
}

/* Otimização para telas muito pequenas */
@media (max-height: 600px) and (orientation: landscape) {
    .gatekeeper-modal {
        max-height: 100vh;
        max-width: 400px;
    }

    .gatekeeper-header h2 {
        font-size: 18px;
    }

    .gatekeeper-body {
        padding: 16px;
    }

    .gatekeeper-field {
        margin-bottom: 16px;
    }
}

/* Acessibilidade: foco visível */
.gatekeeper-close:focus,
.gatekeeper-submit:focus,
.gatekeeper-field input:focus {
    outline: 2px solid #00a85a;
    outline-offset: 2px;
}

/* Suporte a reduce-motion */
@media (prefers-reduced-motion: reduce) {
    .gatekeeper-overlay,
    .gatekeeper-modal,
    .gatekeeper-submit {
        animation: none;
        transition: none;
    }
}

/* Scrollbar customizada para o modal */
.gatekeeper-modal::-webkit-scrollbar {
    width: 8px;
}

.gatekeeper-modal::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 0 16px 16px;
}

.gatekeeper-modal::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.gatekeeper-modal::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
