/* FORM MODAL STYLES - IPG INSPECÕES */
.form-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background-color: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    overflow: hidden; /* Previne scroll horizontal */
}

.form-modal.is-active {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.form-modal__content {
    background-color: var(--surface-card);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    max-width: 500px;
    width: calc(100% - 2rem); /* Previne overflow horizontal */
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-sizing: border-box; /* Garante que padding não cause overflow */
}

/* Remover scroll quando não for necessário */
.form-modal__content::-webkit-scrollbar {
    width: 6px;
}

.form-modal__content::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}

.form-modal__content::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 10px;
}

.form-modal__content::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.5);
}

.form-modal.is-active .form-modal__content {
    transform: translateY(0) scale(1);
}

.form-modal__close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    font-size: 1.25rem;
}

.form-modal__close:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
    transform: rotate(90deg);
}

.form-modal__header {
    text-align: center;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.form-modal__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-family: var(--font-heading);
}


/* FORM STYLES */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

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

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-label::after {
    content: '*';
    color: #ef4444;
    font-size: 0.875rem;
}

/* Remover asterisco apenas do label da mensagem */
.form-group-full:last-child .form-label::after {
    content: '';
}


.form-input,
.form-select,
.form-textarea {
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border-default);
    border-radius: 10px;
    background-color: var(--surface-page);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--accent-primary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-subtle);
    background-color: white;
}

.form-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.125rem center;
    background-size: 1.25rem;
    padding-right: 3.5rem;
    cursor: pointer;
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
    line-height: 1.5;
}

/* RADIO BUTTONS */
.form-radio-group {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.form-radio {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

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

.form-radio-check {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border-default);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.form-radio-check::after {
    content: '';
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background-color: var(--accent-primary);
    transform: scale(0);
    transition: transform 0.2s ease;
}

.form-radio input[type="radio"]:checked + .form-radio-check {
    border-color: var(--accent-primary);
    background-color: var(--accent-subtle);
}

.form-radio input[type="radio"]:checked + .form-radio-check::after {
    transform: scale(1);
}

.form-radio-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* SUBMIT BUTTON */
.btn-submit {
    width: 100%;
    padding: 0.875rem;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    position: relative;
    transition: all 0.2s ease;
}

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

.form-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    display: none;
}

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

.btn-submit.loading .form-spinner {
    display: block;
}

.btn-submit.loading span {
    opacity: 0.7;
}

/* FORM MESSAGE */
.form-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-button);
    font-size: 0.875rem;
    display: none;
}

.form-message.success {
    display: block;
    background-color: rgba(52, 168, 83, 0.1);
    border: 1px solid rgba(52, 168, 83, 0.2);
    color: var(--accent-secondary);
}

.form-message.error {
    display: block;
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--status-error);
}

/* CTA FIXED BUTTON */
.cta-fixed {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9998;
}

.btn-cta-fixed {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 1rem 1.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(59, 140, 199, 0.3);
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

.btn-cta-fixed:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(59, 140, 199, 0.4);
}

@keyframes pulse {
    0% { box-shadow: 0 8px 20px rgba(59, 140, 199, 0.3); }
    50% { box-shadow: 0 8px 25px rgba(59, 140, 199, 0.5); }
    100% { box-shadow: 0 8px 20px rgba(59, 140, 199, 0.3); }
}

/* RESPONSIVE */
@media (min-width: 640px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem 1.75rem; /* Ajustado para evitar overflow */
    }

    .form-modal__content {
        padding: 2rem;
        max-width: 480px; /* Um pouco menor para telas desktop */
        width: auto; /* Reset para auto em desktop */
    }

    /* Garantir que os campos tenham espaçamento consistente */
    .form-group {
        margin: 0;
        min-width: 0; /* Previne overflow de conteúdo interno */
    }

    /* Garantir que inputs não causem overflow */
    .form-input,
    .form-select,
    .form-textarea {
        max-width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    .form-modal__content {
        padding: 1.5rem;
        max-height: 95vh;
        width: calc(100% - 1rem); /* Menos padding em mobile */
    }

    .form-modal__header {
        margin-bottom: 1.25rem;
        padding-bottom: 1rem;
    }

    .form-modal__title {
        font-size: 1.25rem;
    }

    .form-grid {
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .form-input,
    .form-select,
    .form-textarea {
        padding: 0.625rem 0.875rem;
        font-size: 0.9rem;
        max-width: 100%;
        box-sizing: border-box;
    }

    .btn-submit {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .cta-fixed {
        bottom: 1rem;
        right: 1rem;
    }

    .btn-cta-fixed span {
        display: none;
    }

    .btn-cta-fixed {
        padding: 1rem;
        border-radius: 50%;
        width: 3.5rem;
        height: 3.5rem;
        justify-content: center;
    }
}

/* Ajuste para telas médias (tablets) */
@media (min-width: 481px) and (max-width: 767px) {
    .form-modal__content {
        max-width: 450px;
        padding: 1.75rem;
    }

    .form-grid {
        gap: 1.25rem 1.5rem;
    }
}

/* BODY SCROLL LOCK */
body.modal-form-active {
    overflow: hidden;
}