/* Form Styles - Mobile Optimized */

/* Form Section */
.form-section {
    padding: 2rem 0 3rem;
    background: var(--gray-50);
    min-height: calc(100vh - 200px);
}

.form-card {
    background: var(--white);
    border-radius: var(--radius-2xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    margin: 0 auto;
}

.form-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--gray-500);
    font-size: 0.875rem;
    text-decoration: none;
    margin-bottom: 1rem;
    transition: color var(--transition);
}

.back-btn:hover {
    color: var(--primary-500);
}

.back-btn svg {
    width: 20px;
    height: 20px;
}

.form-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.form-header > p {
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Simulation Summary */
.simulacao-resumo {
    background: var(--primary-100);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.simulacao-resumo .resumo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.simulacao-resumo .resumo-item:first-child {
    border-bottom: 1px solid var(--primary-200);
}

.simulacao-resumo .resumo-item:last-child {
    border-top: 1px solid var(--primary-200);
    margin-top: 0.5rem;
    padding-top: 1rem;
}

.simulacao-resumo .label {
    color: var(--primary-700);
    font-size: 0.875rem;
}

.simulacao-resumo .value {
    font-weight: 600;
    color: var(--gray-800);
}

.simulacao-resumo .value.highlight {
    color: var(--primary-600);
    font-size: 1.125rem;
}

/* Form Fields */
.form-field {
    margin-bottom: 1.25rem;
}

.form-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-field input {
    width: 100%;
    padding: 1rem 1rem;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 16px; /* Prevent iOS zoom */
    font-family: inherit;
    transition: all var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-field input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-field input::placeholder {
    color: var(--gray-400);
}

.form-field input:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

/* Form Row 2 columns */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* CEP Input Wrapper */
.cep-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.cep-input-wrapper input {
    flex: 1;
    min-width: 0;
}

.cep-busca {
    padding: 1rem 0.75rem;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius);
    white-space: nowrap;
    transition: all var(--transition);
    display: flex;
    align-items: center;
}

.cep-busca:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

/* Checkbox Terms */
.termos-field {
    margin-bottom: 1.5rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--gray-600);
    line-height: 1.5;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 22px;
    height: 22px;
    min-width: 22px;
    background: var(--white);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    margin-top: 1px;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-500);
    border-color: var(--primary-500);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.checkbox-label a {
    color: var(--primary-500);
    text-decoration: none;
}

.checkbox-label a:hover {
    text-decoration: underline;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.125rem 1.5rem;
    background: var(--primary-500);
    color: var(--white);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.submit-btn:hover {
    background: var(--primary-600);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.submit-btn:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
    transform: none;
}

.submit-btn svg {
    width: 20px;
    height: 20px;
    transition: transform var(--transition);
}

.submit-btn:hover svg {
    transform: translateX(4px);
}

/* Loading Spinner */
.submit-btn.loading .btn-text {
    opacity: 0;
}

.submit-btn.loading::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Success State */
.submit-btn.success {
    background: var(--primary-500);
}

.submit-btn.success svg {
    width: 24px;
    height: 24px;
}

/* Form Footer */
.form-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    color: var(--gray-500);
    font-size: 0.75rem;
}

.form-footer svg {
    width: 16px;
    height: 16px;
    color: var(--primary-500);
    flex-shrink: 0;
}

/* Input with icon */
.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper input {
    padding-left: 3rem;
}

.input-icon-wrapper .input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--gray-400);
    pointer-events: none;
}

/* Validation States */
.form-field input.error {
    border-color: var(--error);
}

.form-field input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.error-message {
    color: var(--error);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
}

.form-field input.error + .error-message {
    display: block;
}

/* Responsive Styles */
@media (min-width: 640px) {
    .form-card {
        padding: 2rem;
    }
    
    .form-header h2 {
        font-size: 1.75rem;
    }
}

@media (min-width: 1024px) {
    .form-section {
        padding: 3rem 0 4rem;
    }
    
    .form-card {
        padding: 2.5rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .form-field input {
        padding: 1.125rem 1rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .submit-btn {
        padding: 1.25rem 1.5rem;
    }
    
    .cep-busca {
        padding: 1rem 1rem;
    }
    
    .checkbox-label {
        padding: 0.5rem 0;
    }
}

/* Small screens */
@media (max-width: 360px) {
    .form-card {
        padding: 1.25rem;
        border-radius: var(--radius-xl);
    }
    
    .form-row-2 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .cep-input-wrapper {
        flex-direction: column;
    }
    
    .cep-busca {
        justify-content: center;
        padding: 0.75rem;
    }
    
    .checkbox-label {
        font-size: 0.75rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-field input {
        border-width: 3px;
    }
    
    .checkmark {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .submit-btn,
    .form-field input,
    .back-btn,
    .cep-busca,
    .checkbox-label .checkmark {
        transition: none;
    }
    
    @keyframes spin {
        from, to {
            transform: rotate(0deg);
        }
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .form-section {
        background: var(--gray-900);
    }
    
    .form-card {
        background: var(--gray-800);
    }
    
    .form-header h2 {
        color: var(--white);
    }
    
    .form-header > p {
        color: var(--gray-400);
    }
    
    .form-field label {
        color: var(--gray-300);
    }
    
    .form-field input {
        background: var(--gray-700);
        border-color: var(--gray-600);
        color: var(--white);
    }
    
    .form-field input::placeholder {
        color: var(--gray-500);
    }
    
    .form-field input:focus {
        border-color: var(--primary-500);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
    }
    
    .simulacao-resumo {
        background: rgba(37, 99, 235, 0.15);
    }
    
    .simulacao-resumo .label {
        color: var(--primary-300);
    }
    
    .simulacao-resumo .value {
        color: var(--white);
    }
    
    .cep-busca {
        background: var(--gray-700);
        color: var(--gray-300);
    }
    
    .cep-busca:hover {
        background: var(--gray-600);
    }
    
    .checkmark {
        background: var(--gray-700);
        border-color: var(--gray-500);
    }
    
    .checkbox-label {
        color: var(--gray-300);
    }
    
    .form-footer {
        color: var(--gray-400);
    }
}

/* Loading Overlay Styles */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-card {
    text-align: center;
    padding: 2rem;
    max-width: 320px;
    background: var(--white);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
}

.loading-spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
}

.loading-spinner svg {
    width: 100%;
    height: 100%;
}

.loading-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.loading-card p {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

/* Loading Progress Bar */
.loading-progress {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.loading-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-500), var(--primary-400));
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 5s linear;
}

.loading-overlay.active .loading-bar {
    width: 100%;
}

/* Dark mode for loading overlay */
@media (prefers-color-scheme: dark) {
    .loading-overlay {
        background: rgba(17, 24, 39, 0.98);
    }
    
    .loading-card {
        background: var(--gray-800);
    }
    
    .loading-card h3 {
        color: var(--white);
    }
    
    .loading-card p {
        color: var(--gray-400);
    }
}
