/* =========================================
   1. BASE E LAYOUT PRINCIPAL
   ========================================= */
body {
    background-color: #F5F7FA;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#navbar {
    height: 70px;
    width: 100%;
    z-index: 1002;
    position: absolute;
    background-color: #FFFFFF;
    border-bottom: 3px solid #1546A0;
}

.main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 110px 0 40px;
    /* Unificado o espaçamento do topo */
}

.card-custom {
    background-color: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
    padding: 3rem;
    max-width: 900px;
    width: 90%;
    margin: auto;
    border: 1px solid #E8ECF1;
}

/* =========================================
   2. TIPOGRAFIA E TEXTOS
   ========================================= */
.title-custom {
    color: #444;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
}

.text-content p {
    color: #555;
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: justify;
    margin-bottom: 1rem;
}

.report-section-title {
    color: #1546a0;
    font-weight: 700;
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 10px;
    border-bottom: 2px solid #E6EBF2;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form-section-title {
    color: #1546a0;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.divider-text {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 2.5rem 0;
    color: #888;
    font-weight: 500;
}

.divider-text::before,
.divider-text::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #ddd;
}

.divider-text:not(:empty)::before {
    margin-right: .5em;
}

.divider-text:not(:empty)::after {
    margin-left: .5em;
}

/* =========================================
   3. BOTÕES E LINKS
   ========================================= */
.btn-custom-blue {
    background: linear-gradient(0deg, #083898 50%, #0041c2 100%);
    color: white;
    border-radius: 50px;
    box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.20);
    padding: 10px 20px;
    margin-bottom: 12px;
    font-weight: 600;
    border: none;
    width: 100%;
    transition: transform 0.2s, background-color 0.2s;
    display: block;
    text-align: center;
    text-decoration: none;
}

.btn-custom-blue:hover {
    background: linear-gradient(0deg, #073185 50%, #0041c2 100%);
    transform: translateY(-2px);
    color: white;
    text-decoration: none;
}

.nav-link-custom {
    color: #666;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-link-custom:hover {
    background-color: #f0f0f0;
    color: #1546a0;
    text-decoration: none;
}

.btn-email-action {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    background-color: #fff;
    color: #ffffff;
    border: 1px solid #ccc;
    transition: all 0.3s;
}

.btn-email-action:hover {
    transform: translateY(-2px);
    color: #073185;
}

.btn-email-icon {
    height: 20px;
    margin-right: 10px;
}

/* =========================================
   4. CARDS DE DADOS (REPORT, REVIEW, ZONEAMENTO)
   ========================================= */
.data-group {
    background-color: #FBFCFE;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #E6EBF2;
    border-left: 4px solid #1546a0;
    break-inside: avoid;
    page-break-inside: avoid;
}


.data-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6c757d;
    font-weight: 700;
    margin-bottom: 4px;
    display: block;
}

.data-group>.data-label:not(:first-child) {
    margin-top: 15px;
}

.data-group-zoned .data-label:first-child {
    margin-top: 0;
}

.data-value {
    font-size: 1rem;
    color: #212529;
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    display: block;
}

.data-group-zoned .data-value {
    font-weight: 700;
    font-size: 1.05rem;
}

/* =========================================
   5. FORMULÁRIOS E INPUTS
   ========================================= */
.form-control {
    border-radius: 8px;
    padding: 12px 15px;
    border: 1px solid #ced4da;
    height: auto;
}

.form-control:focus {
    border-color: #1546a0;
    box-shadow: 0 0 0 0.2rem rgba(21, 70, 160, 0.25);
}

.form-control:disabled {
    background-color: #e9ecef;
    opacity: 1;
    cursor: not-allowed;
    border: 1px solid #ddd;
}

.form-control:enabled {
    border: 1px solid #1546a0;
    background-color: #fff;
    box-shadow: 0 0 0 0.2rem rgba(21, 70, 160, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 200px;
}

.form-item {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.checkbox-wrapper {
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
}

.input-wrapper {
    flex-grow: 1;
}

.input-wrapper label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #6c757d;
    font-weight: 700;
    margin-bottom: 2px;
    display: block;
}

.custom-input-group {
    display: flex;
    width: 100%;
}

.custom-input-group input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 0;
    flex: 1;
}

.custom-input-group button {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    margin: 0;
    display: flex;
    align-items: center;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: #083898 !important;
}

/* Container que agrupa Input + Botão */
.form-item {
    display: flex !important;
    align-items: center !important;
    /* Centraliza verticalmente */
    gap: 10px;
    margin-bottom: 15px;
}


/* Container do botão de edição */
.edit-button-wrapper {
    display: flex;
    align-items: center;
    /* Ajuste para compensar a altura do label acima do input e centralizar com a caixa */
    margin-top: 20px;
}

/* Esconde o checkbox original */
.edit-checkbox {
    display: none;
}

.edit-label {
    width: 42px;
    height: 42px;
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0;
}

/* Estilo do Ícone (SVG) - Inativo (Cinza) */
.edit-label img {
    width: 20px;
    height: 20px;
    /* Filtro para tornar o preto em cinza médio (#6c757d) */
    filter: invert(53%) sepia(8%) saturate(297%) hue-rotate(169deg) brightness(91%) contrast(86%);
    transition: all 0.2s ease;
}

/* Quando Ativo (Checked) */
.edit-checkbox:checked+.edit-label {
    background-color: #1546a0;
    /* Azul principal */
    border-color: #1546a0;
}

/* Ícone quando Ativo (Branco) */
.edit-checkbox:checked+.edit-label img {
    filter: brightness(0) invert(1);
}

.edit-label:hover {
    border-color: #1546a0;
}

select.form-control {
    padding-right: 30px !important;
    /* Garante que o texto longo não passe por baixo da seta */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    /* O '12px' define a distância da borda direita */
    background-size: 16px 12px;
}

/* =========================================
   6. VISUALIZADORES E MAPAS
   ========================================= */
.visual-container {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(16, 24, 40, 0.05);
    border: 1px solid #E6EBF2;
    height: 400px;
    position: relative;
    background: #F0F2F5;
    break-inside: avoid;
    page-break-inside: avoid;
}

.align-map {
    width: 100%;
    height: 100%;
}

/* =========================================
   7. STATUS E ALERTAS (ZONEAMENTO)
   ========================================= */
.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0px;
}

.status-item i {
    font-size: 1.3rem;
}

.status-success {
    color: #28a745;
}

.status-warning {
    color: #ffb300;
}

.status-danger {
    color: #dc3545;
}

.icon-info-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 2px solid currentColor;
    border-radius: 50%;
    font-family: 'Times New Roman', serif;
    font-style: italic;
    font-weight: bold;
    font-size: 14px;
}

.badge-zona {
    background-color: #1546a0;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 1rem;
    margin-right: 15px;
}

.alert-mockup {
    border-radius: 12px;
    padding: 16px 20px;
    margin-top: 15px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
}

.alert-mockup-warning {
    background-color: #FFF9E6;
    border: 2px solid #F6C23E;
}

.alert-mockup-warning .alert-mockup-title,
.alert-mockup-warning .alert-mockup-body {
    color: #D39E00;
}

.alert-mockup-danger {
    background-color: #FDEAEA;
    border: 2px solid #E74A3B;
}

.alert-mockup-danger .alert-mockup-title,
.alert-mockup-danger .alert-mockup-body {
    color: #E74A3B;
}

.alert-mockup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-mockup-title {
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alert-mockup-badge {
    background: linear-gradient(to bottom, #ffffff, #f4f4f4);
    color: #444;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 4px 16px;
    border-radius: 20px;
    border: 1px solid #ddd;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 1px 2px rgba(0, 0, 0, 0.05);
}

.alert-mockup-body {
    font-size: 0.95rem;
    font-weight: 500;
    margin: 0;
}

/* =========================================
   8. COMPONENTES EXTRAS E UTILITÁRIOS
   ========================================= */
.area-diff-positive {
    color: #1546a0;
    font-weight: bold;
}

.area-diff-negative {
    color: #dc3545;
    font-weight: bold;
}

.fa-question-circle {
    color: #1546a0;
    opacity: 0.6;
    margin-left: 5px;
    font-size: 0.9em;
    cursor: help;
}

.fa-question-circle:hover {
    opacity: 1;
}

.loading-placeholder {
    text-align: center;
    padding: 20px;
    color: #999;
    font-style: italic;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
}

.loading-gif {
    width: 60px;
}

.img-iptu-guide {
    width: 100%;
    max-width: 800px;
    height: auto;
    border-radius: 10px;
    border: 1px solid #eee;
    display: block;
    margin: 15px auto;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

#list-inscricoes {
    display: none;
}

.invert-color {
    filter: invert(1);
}

.print-footer {
    display: none;
}

/* =========================================
   9. RODAPÉ
   ========================================= */
.footer-logos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
    opacity: 0.9;
}

.footer-logos img {
    height: 45px;
    width: auto;
}

.divider-vertical {
    border-left: 2px solid #5c5c5c;
    height: 40px;
    display: inline-block;
    opacity: 0.7;
}

/* =========================================
   10. MEDIA QUERIES (RESPONSIVO)
   ========================================= */
@media (max-width: 992px) {
    .main-content {
        display: block !important;
        padding-top: 130px !important;
        height: auto !important;
    }
}

@media (max-width: 768px) {
    .card-custom {
        padding: 2rem;
        width: 90%;
        margin: 0 auto;
    }

    .title-custom {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .footer-logos {
        flex-direction: column;
        gap: 15px;
    }

    .divider-vertical {
        display: none;
    }
}

@media (max-width: 576px) {
    .card-custom {
        padding: 1.5rem !important;
        width: 95% !important;
    }

    .title-custom {
        font-size: 1.3rem;
        line-height: 1.3;
    }

    .text-content p {
        text-align: left;
    }

    .btn-custom-blue {
        font-size: 0.9rem;
        padding: 12px 15px;
        white-space: normal;
        height: auto;
    }

    .footer-logos img {
        height: 35px;
    }

    .footer-logos {
        padding-bottom: 20px;
    }
}

/* =========================================
   11. CONFIGURAÇÕES DE IMPRESSÃO
   ========================================= */
@media print {

    /* 1. Limpeza de Fundo e Containers */
    body,
    .main-content,
    .card-custom {
        background-color: white !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        height: auto !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }

    .card-custom {
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }

    /* 2. Navbar e Footer */
    #navbar,
    nav,
    .navbar {
        position: static !important;
        display: flex !important;
        width: 100%;
    }

    footer {
        display: block !important;
        position: static !important;
        width: 100% !important;
        margin-top: 20px !important;
        border-top: 1px solid #ccc;
    }

    .footer-logos {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 20px !important;
    }

    .divider-vertical {
        display: block !important;
        border-left: 2px solid #5c5c5c !important;
        height: 30px !important;
    }

    /* 3. Ocultar elementos */
    .no-print,
    .btn,
    button,
    .tooltip,
    .nav-link-custom,
    .d-md-none {
        /* Esconde o HR do mobile */
        display: none !important;
    }

    .main-content {
        padding-top: 10px !important;
    }

    .title-print-space {
        margin-top: 30px !important;
    }

    .title-custom {
        margin-top: 30px !important;
        margin-bottom: 20px !important;
        font-size: 2rem;
    }

    .report-section-title {
        break-after: avoid;
        page-break-after: avoid;
        margin-bottom: 5px !important;
    }

    /* 4. GRID DE IMPRESSÃO (Força layout lado a lado) */
    .row {
        display: flex !important;
        flex-wrap: wrap !important;
    }

    /* Layout Endereço */
    #endereco-container .col-md-8 {
        flex: 0 0 66.666667% !important;
        max-width: 66.666667% !important;
    }

    #endereco-container .col-md-4 {
        flex: 0 0 33.333333% !important;
        max-width: 33.333333% !important;
    }

    /* Colunas Gerais */
    .col-lg-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        width: 50% !important;
        padding-right: 10px;
    }

    /* GARANTE QUE O QUADRO DE ÁREAS FIQUE EM COLUNAS */
    .col-md-6,
    .data-group .col-md-6,
    .col-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        width: 50% !important;
    }

    .col-12 {
        width: 100% !important;
        flex: 0 0 100% !important;
    }

    .data-group {
        border: 1px solid #ccc !important;
        border-left: 5px solid #1546a0 !important;
        background-color: #fdfdfd !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }


    #map {
        width: 100% !important;
        height: 100% !important;
    }

    .visual-container {
        width: 100% !important;
        height: 380px !important;
        /* Altura fixa para a impressão */
        overflow: hidden !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    #viewer,
    .psv-container,
    .psv-canvas-container {
        width: 100% !important;
        height: 100% !important;
        display: block !important;
    }

    #viewer canvas {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        object-fit: cover !important;
        display: block !important;
        transform: none !important;
    }

    /* ----------------------------------------------------
       EXCEÇÃO: IMPRESSÃO DO ZONEAMENTO
    ------------------------------------------------------- */
    .page-zoneamento .visual-container {
        height: auto !important;
    }

    .page-zoneamento #map {
        height: 18cm !important;
        min-height: 500px !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    /* Rodapé de impressão - aparece em todas as páginas impressas */
    .print-footer {
        display: block !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        text-align: center !important;
        font-size: 11px !important;
        color: #444 !important;
        padding: 6px 8px !important;
        background: white !important;
        border-top: 1px solid #ddd !important;
    }

    @page {
        margin: 1cm;
        size: auto;
    }
}