/* Reset e Variáveis CSS */
:root {
    --primary-color: #2563eb;
    --primary-color-hover: #1d4ed8;
    --error-color: #dc2626;
    --success-color: #16a34a;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #d1d5db;
    --border-focus: #2563eb;
    --background-color: transparent;
    --input-background: #ffffff;
    --spacing-xs: 0.25rem;  /* 4px */
    --spacing-sm: 0.375rem; /* 6px */
    --spacing-md: 1rem;     /* 16px */
    --spacing-lg: 1rem;      /* 16px - reduzido de 24px */
    --spacing-xl: 1.25rem;   /* 20px - reduzido de 32px */
    --border-radius: 0.5rem;
    --transition: all 0.2s ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--background-color);
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Container do Formulário */
.form-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* Estados do Formulário */
.state {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.state.active {
    display: block;
}

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

/* Formulário */
form {
    width: 100%;
}

.form-group {
    margin-bottom: 0.875rem; /* 14px - espaçamento equilibrado entre campos */
}

.form-group:last-of-type {
    margin-bottom: 1.25rem; /* 20px antes do botão */
}

label {
    display: block;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-color);
    margin-bottom: 0.375rem; /* 6px - espaçamento entre label e campo */
}

.required {
    color: var(--error-color);
    margin-left: 2px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
select {
    width: 100%;
    padding: 10px 14px;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--input-background);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    transition: var(--transition);
    outline: none;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23374151' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="tel"]:hover,
select:hover {
    border-color: #9ca3af;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    outline: none;
}

input[type="text"].error,
input[type="email"].error,
input[type="tel"].error,
select.error {
    border-color: var(--error-color);
}

input[type="text"].error:focus,
input[type="email"].error:focus,
input[type="tel"].error:focus,
select.error:focus {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.error-message {
    display: block;
    color: var(--error-color);
    font-size: 13px;
    margin-top: 0.375rem; /* 6px - espaçamento após campo */
    min-height: 18px;
    opacity: 0;
    transform: translateY(-5px);
    transition: var(--transition);
}

.error-message.show {
    opacity: 1;
    transform: translateY(0);
}

/* Botão de Submit */
.submit-button {
    width: 100%;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background-color: var(--primary-color);
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    min-height: 44px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.submit-button:hover {
    background-color: var(--primary-color-hover);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

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

.submit-button:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Estado de Loading */
.loading-content {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 400px;
    margin: 0 auto;
}

.loading-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.1);
}

.spinner-container {
    position: relative;
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
}

.spinner {
    width: 64px;
    height: 64px;
    border: 4px solid rgba(37, 99, 235, 0.1);
    border-top-color: var(--primary-color);
    border-right-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    position: absolute;
    top: 0;
    left: 0;
}

.spinner-inner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(37, 99, 235, 0.15);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.6s cubic-bezier(0.5, 0, 0.5, 1) infinite reverse;
    position: absolute;
    top: 8px;
    left: 8px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loading-message {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

.loading-dots {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    margin-top: 0.5rem;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary-color);
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) {
    animation-delay: 0s;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.loading-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 1rem;
    font-weight: 400;
}

/* Estado de Sucesso */
.success-content {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 400px;
    margin: 0 auto;
}

.success-card {
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(22, 163, 74, 0.2);
}

/* Estado de Erro (Amigável) */
.error-content {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 400px;
    margin: 0 auto;
}

.error-card {
    background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.error-icon-container {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1d4ed8 100%);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    position: relative;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.error-icon-ring {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 3px solid rgba(37, 99, 235, 0.2);
    border-radius: 50%;
    animation: ringPulse 2s ease-out infinite;
}

.error-message-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

.error-message-text {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
    font-weight: 400;
}

.error-message-subtitle {
    font-size: 15px;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    font-weight: 500;
    line-height: 1.5;
}

.whatsapp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    text-decoration: none;
    min-height: 48px;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    margin-bottom: 0.75rem;
}

.whatsapp-button:hover {
    background: linear-gradient(135deg, #20BA5A 0%, #0F7A6D 100%);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
    transform: translateY(-2px);
}

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

.whatsapp-button:focus {
    outline: 2px solid #25D366;
    outline-offset: 2px;
}

.whatsapp-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.whatsapp-phone {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 0.5rem;
}

.success-icon-container {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--success-color) 0%, #15803d 100%);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    position: relative;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-icon-ring {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 3px solid rgba(22, 163, 74, 0.2);
    border-radius: 50%;
    animation: ringPulse 2s ease-out infinite;
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes ringPulse {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

.success-message {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.success-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 500;
}

.redirect-countdown {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.redirect-button {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    background-color: var(--primary-color);
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    outline: none;
    min-height: 44px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    width: 100%;
    display: none; /* Escondido por padrão */
    opacity: 0;
    transform: translateY(10px);
}

.redirect-button.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.redirect-button:hover {
    background-color: #1d4ed8;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.redirect-button:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.redirect-button:active {
    transform: translateY(0);
}

/* Responsividade */
@media (max-width: 640px) {
    body {
        padding: var(--spacing-xs);
    }

    .form-container {
        max-width: 100%;
    }

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    select {
        font-size: 16px; /* Evita zoom no iOS */
        padding: 10px 14px;
    }
    
    select {
        padding-right: 40px;
    }

    .submit-button {
        font-size: 16px;
        padding: 12px 16px;
    }

    .loading-content {
        padding: 2rem 1rem;
    }

    .loading-card {
        padding: 2rem 1.5rem;
    }

    .spinner-container {
        width: 56px;
        height: 56px;
    }

    .spinner {
        width: 56px;
        height: 56px;
    }

    .spinner-inner {
        width: 40px;
        height: 40px;
        top: 8px;
        left: 8px;
    }

    .loading-message {
        font-size: 16px;
    }

    .success-content {
        padding: 2rem 1rem;
    }

    .success-card {
        padding: 2rem 1.5rem;
    }

    .success-icon-container {
        width: 72px;
        height: 72px;
    }

    .success-icon {
        width: 56px;
        height: 56px;
        font-size: 28px;
    }

    .success-icon-ring {
        width: 72px;
        height: 72px;
    }

    .success-message {
        font-size: 18px;
    }

    .success-subtitle {
        font-size: 15px;
    }

    .error-content {
        padding: 2rem 1rem;
    }

    .error-card {
        padding: 2rem 1.5rem;
    }

    .error-icon-container {
        width: 72px;
        height: 72px;
    }

    .error-icon {
        width: 56px;
        height: 56px;
        font-size: 28px;
    }

    .error-icon-ring {
        width: 72px;
        height: 72px;
    }

    .error-message-title {
        font-size: 18px;
    }

    .error-message-text {
        font-size: 14px;
    }

    .error-message-subtitle {
        font-size: 14px;
    }

    .whatsapp-button {
        font-size: 15px;
        padding: 12px 20px;
    }
}

/* Acessibilidade - Foco visível */
*:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* Fundo branco quando transparent=false */
body.bg-white {
    --background-color: #ffffff;
    --input-background: #ffffff;
}

