/**
 * IPA Afiliação Form - Estilos Públicos
 * Version: 2.7.0
 */

/* Reset e Base */
.ipa-form-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
}

.ipa-form-container * {
    box-sizing: border-box;
}

/* Formulário */
.ipa-form {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

/* Introdução */
.ipa-form-intro {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 4px solid var(--ipa-cor-primaria, #e02b20);
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 0 8px 8px 0;
}

.ipa-form-intro p {
    margin: 0 0 10px;
    font-weight: 500;
}

.ipa-form-intro ul {
    margin: 0;
    padding-left: 20px;
}

.ipa-form-intro li {
    margin-bottom: 5px;
    color: #555;
}

/* Seções */
.ipa-form-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.ipa-form-section:last-of-type {
    border-bottom: none;
}

.ipa-section-title {
    color: var(--ipa-cor-primaria, #e02b20);
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--ipa-cor-primaria, #e02b20);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ipa-section-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

/* Container de campos */
.ipa-form-fields {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
    width: calc(100% + 20px);
}

/* Títulos de Seção Manuais */
.ipa-form-section-title {
    padding: 0 10px;
    margin-bottom: 20px;
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
}

.ipa-form-section-title .ipa-section-title {
    color: var(--ipa-cor-primaria, #e02b20);
    font-size: 18px;
    font-weight: 600;
    margin: 20px 0 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--ipa-cor-primaria, #e02b20);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ipa-form-section-title:first-child .ipa-section-title {
    margin-top: 0;
}

.ipa-form-section-title .ipa-section-description {
    color: #666;
    font-size: 14px;
    margin: 0 0 10px;
}

/* HTML Personalizado */
.ipa-form-html {
    padding: 0 10px;
    margin-bottom: 20px;
}

/* Grid - Sistema de Colunas Corrigido */
.ipa-form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
    width: calc(100% + 20px);
}

.ipa-form-group {
    padding: 0 10px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

/* Classes de largura baseadas em porcentagem */
.ipa-col-20 { width: 20%; flex: 0 0 20%; max-width: 20%; }
.ipa-col-25 { width: 25%; flex: 0 0 25%; max-width: 25%; }
.ipa-col-33 { width: 33.333%; flex: 0 0 33.333%; max-width: 33.333%; }
.ipa-col-40 { width: 40%; flex: 0 0 40%; max-width: 40%; }
.ipa-col-50 { width: 50%; flex: 0 0 50%; max-width: 50%; }
.ipa-col-60 { width: 60%; flex: 0 0 60%; max-width: 60%; }
.ipa-col-67 { width: 66.666%; flex: 0 0 66.666%; max-width: 66.666%; }
.ipa-col-75 { width: 75%; flex: 0 0 75%; max-width: 75%; }
.ipa-col-80 { width: 80%; flex: 0 0 80%; max-width: 80%; }
.ipa-col-100 { width: 100%; flex: 0 0 100%; max-width: 100%; }

/* Labels */
.ipa-form-group > label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.ipa-form-group .required {
    color: var(--ipa-cor-primaria, #e02b20);
}

.ipa-field-hint {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 5px;
}

.ipa-field-error {
    display: none;
    font-size: 12px;
    color: #dc3545;
    margin-top: 5px;
}

.ipa-form-group.has-error .ipa-field-error {
    display: block;
}

/* Inputs */
.ipa-form input[type="text"],
.ipa-form input[type="email"],
.ipa-form input[type="tel"],
.ipa-form input[type="number"],
.ipa-form select,
.ipa-form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #fff;
}

.ipa-form input:focus,
.ipa-form select:focus,
.ipa-form textarea:focus {
    outline: none;
    border-color: var(--ipa-cor-primaria, #e02b20);
    box-shadow: 0 0 0 3px rgba(224, 43, 32, 0.1);
}

.ipa-form input.error,
.ipa-form select.error,
.ipa-form textarea.error,
.ipa-form-group.has-error input,
.ipa-form-group.has-error select,
.ipa-form-group.has-error textarea {
    border-color: #dc3545;
    background: #fff5f5;
}

.ipa-form textarea {
    resize: vertical;
    min-height: 100px;
}

/* CEP Loading e Error */
.ipa-cep-loading {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.ipa-spinner-small {
    animation: rotate 2s linear infinite;
    width: 14px;
    height: 14px;
    margin-right: 6px;
}

.ipa-spinner-small .path {
    stroke: var(--ipa-cor-primaria, #e02b20);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

.ipa-cep-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
}

.ipa-cep-success {
    color: #28a745;
    font-size: 12px;
    margin-top: 5px;
}

/* Alerta de Estado */
.ipa-estado-warning {
    display: none;
    align-items: flex-start;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.ipa-estado-warning.show {
    display: flex;
}

.ipa-warning-icon {
    font-size: 28px;
    margin-right: 15px;
    flex-shrink: 0;
}

.ipa-warning-text {
    color: #856404;
    font-size: 14px;
    line-height: 1.6;
}

.ipa-warning-text strong {
    color: #664d03;
    display: block;
    margin-bottom: 5px;
    font-size: 16px;
}

/* Radio Buttons */
.ipa-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ipa-radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    transition: all 0.3s ease;
    flex: 1 1 calc(50% - 10px);
    min-width: 200px;
}

.ipa-radio-label:hover {
    border-color: var(--ipa-cor-primaria, #e02b20);
    background: #fef5f5;
}

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

.ipa-radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 50%;
    margin-right: 10px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.ipa-radio-label input[type="radio"]:checked + .ipa-radio-custom {
    border-color: var(--ipa-cor-primaria, #e02b20);
}

.ipa-radio-label input[type="radio"]:checked + .ipa-radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--ipa-cor-primaria, #e02b20);
    border-radius: 50%;
}

/* Radio Compact - para instituições */
.ipa-radio-compact .ipa-radio-label {
    flex: 1 1 calc(50% - 10px);
    min-width: 280px;
}

.ipa-radio-compact .ipa-radio-text {
    font-size: 13px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Checkboxes */
.ipa-checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.ipa-checkbox-label:hover {
    background: #e9ecef;
}

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

.ipa-checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid #ddd;
    border-radius: 4px;
    margin-right: 12px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
    margin-top: 2px;
}

.ipa-checkbox-label input[type="checkbox"]:checked + .ipa-checkbox-custom {
    background: var(--ipa-cor-primaria, #e02b20);
    border-color: var(--ipa-cor-primaria, #e02b20);
}

.ipa-checkbox-label input[type="checkbox"]:checked + .ipa-checkbox-custom::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 7px;
    width: 6px;
    height: 12px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.ipa-checkbox-label.error {
    background: #fff5f5;
    border: 1px solid #dc3545;
}

.ipa-checkbox-text {
    font-size: 14px;
    line-height: 1.5;
    color: #555;
}

.ipa-checkbox-text strong {
    color: #333;
    display: block;
    margin-bottom: 3px;
}

/* Termos Section - Melhorado */
.ipa-terms-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border-radius: 8px;
    padding: 25px;
    margin-top: 10px;
}

.ipa-terms-container {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.ipa-term-item {
    border-bottom: 1px solid #e9ecef;
}

.ipa-term-item:last-child {
    border-bottom: none;
}

.ipa-term-item .ipa-checkbox-label {
    margin-bottom: 0;
    border-radius: 0;
    background: #fff;
    padding: 18px 20px;
}

.ipa-term-item .ipa-checkbox-label:hover {
    background: #f8f9fa;
}

.ipa-term-item .ipa-checkbox-text {
    font-size: 13px;
}

.ipa-term-item .ipa-checkbox-text strong {
    color: var(--ipa-cor-primaria, #e02b20);
    font-size: 14px;
}

/* File Upload */
.ipa-file-upload {
    position: relative;
}

.ipa-file-upload input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.ipa-file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: #f8f9fa;
    transition: all 0.3s ease;
    text-align: center;
}

.ipa-file-upload:hover .ipa-file-upload-label,
.ipa-file-upload.dragover .ipa-file-upload-label {
    border-color: var(--ipa-cor-primaria, #e02b20);
    background: #fef5f5;
}

.ipa-file-upload.has-file .ipa-file-upload-label {
    border-color: #28a745;
    background: #f0fff4;
}

.ipa-file-upload.error .ipa-file-upload-label {
    border-color: #dc3545;
    background: #fff5f5;
}

.ipa-file-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.ipa-file-text {
    color: #666;
    font-size: 14px;
}

.ipa-file-name {
    display: none;
    color: #28a745;
    font-weight: 600;
    margin-top: 10px;
}

.ipa-file-upload.has-file .ipa-file-text {
    display: none;
}

.ipa-file-upload.has-file .ipa-file-name {
    display: block;
}

/* Botão de Envio */
.ipa-form-submit {
    margin-top: 30px;
    text-align: center;
}

.ipa-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 15px 50px;
    background: var(--ipa-cor-botao, #2ea3f2);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 250px;
}

.ipa-submit-btn:hover {
    background: var(--ipa-cor-primaria, #e02b20);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.ipa-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Spinner */
.ipa-spinner {
    animation: rotate 2s linear infinite;
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

.ipa-spinner .path {
    stroke: #fff;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

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

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* Mensagens de Erro */
.ipa-form-errors {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 15px 20px;
    margin-top: 20px;
    color: #721c24;
}

.ipa-form-errors ul {
    margin: 0;
    padding-left: 20px;
}

.ipa-form-errors li {
    margin-bottom: 5px;
}

/* Mensagem de Sucesso */
.ipa-success-message {
    text-align: center;
    padding: 50px 30px;
    background: linear-gradient(135deg, #f0fff4 0%, #d4edda 100%);
    border-radius: 8px;
}

.ipa-success-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 30px;
}

.ipa-success-icon svg {
    width: 100%;
    height: 100%;
}

.ipa-checkmark-circle {
    stroke: #28a745;
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.ipa-checkmark-check {
    stroke: #28a745;
    stroke-width: 3;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

.ipa-success-message h2 {
    color: #155724;
    font-size: 28px;
    margin: 0 0 15px;
}

.ipa-success-message p {
    color: #155724;
    font-size: 16px;
    margin: 0;
    max-width: 500px;
    margin: 0 auto;
}

/* Mensagem de Erro Geral */
.ipa-error-message {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.ipa-error-message p {
    margin: 0;
    color: #856404;
}

.ipa-error-message p:first-child {
    margin-bottom: 10px;
}

/* Campos Condicionais */
.ipa-conditional-field {
    transition: all 0.3s ease;
}

.ipa-conditional-field[style*="display: none"] {
    opacity: 0;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Responsivo */
@media (max-width: 768px) {
    .ipa-form-container {
        padding: 10px;
    }
    
    .ipa-form {
        padding: 20px 15px;
    }
    
    .ipa-form-row {
        margin: 0 -5px;
        width: calc(100% + 10px);
    }
    
    .ipa-form-group {
        padding: 0 5px;
    }
    
    /* Em mobile, todos os campos ocupam 100% */
    .ipa-col-20,
    .ipa-col-25,
    .ipa-col-33,
    .ipa-col-40,
    .ipa-col-50,
    .ipa-col-60,
    .ipa-col-67,
    .ipa-col-75,
    .ipa-col-80,
    .ipa-col-100 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .ipa-radio-label {
        flex: 1 1 100%;
        min-width: 100%;
    }
    
    .ipa-radio-compact .ipa-radio-label {
        flex: 1 1 100%;
        min-width: 100%;
    }
    
    .ipa-submit-btn {
        width: 100%;
        min-width: auto;
    }
    
    .ipa-section-title {
        font-size: 16px;
    }
}

@media (max-width: 576px) {
    .ipa-form {
        padding: 15px 10px;
    }
    
    .ipa-checkbox-label {
        padding: 12px;
    }
    
    .ipa-file-upload-label {
        padding: 20px 15px;
    }
    
    .ipa-success-icon {
        width: 80px;
        height: 80px;
    }
    
    .ipa-success-message h2 {
        font-size: 22px;
    }
}
