/* ========================================
   CVGHR - CSS de Impressão Otimizado
   Versão modular e otimizada
   ======================================== */

/* ============== CONFIGURAÇÕES BASE ============== */
@media print {
    /* Reset completo para impressão */
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-sizing: border-box !important;
    }

    /* Configuração da página A4 */
    @page {
        size: A4;
        margin: 20mm 15mm 20mm 15mm;
        orphans: 3;
        widows: 3;
    }

    /* Corpo da página */
    body {
        font-family: 'Times New Roman', Times, serif !important;
        font-size: 11pt !important;
        line-height: 1.4 !important;
        color: #000 !important;
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ============== ELEMENTOS A OCULTAR ============== */
    .no-print,
    .navbar, .nav, .sidebar,
    .btn, .button, .btn-group, .dropdown,
    .pagination, .breadcrumb, .alert, .toast,
    footer:not(.document-footer),
    .admin-panel, .debug-info,
    .fas, .fa, .far, .fab, .bi,
    .modal, .tooltip, .popover,
    .badge, .progress, .spinner-border {
        display: none !important;
    }

    /* ============== CONTAINERS DE DOCUMENTOS ============== */
    .payslip-container,
    .certificate-container,
    .contract-container,
    .document-container,
    .print-content {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 15pt !important;
        border: 1pt solid #000 !important;
        background: #fff !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }

    /* ============== CABEÇALHOS ============== */
    .header,
    .document-header,
    .certificate-header,
    .contract-header {
        border-bottom: 2pt solid #000 !important;
        padding-bottom: 10pt !important;
        margin-bottom: 15pt !important;
        page-break-after: avoid;
    }

    .certificate-header h2,
    .contract-header h2 {
        font-size: 16pt !important;
        font-weight: bold !important;
        text-transform: uppercase !important;
        text-align: center !important;
        margin: 5pt 0 !important;
        color: #000 !important;
    }

    /* Logo posicionado */
    .certificate-header img,
    .contract-header img {
        display: block !important;
        position: absolute !important;
        top: 5pt !important;
        left: 5pt !important;
        width: 60pt !important;
        height: 60pt !important;
        border: 1pt solid #ccc !important;
        background: white !important;
        z-index: 2000 !important;
    }

    /* ============== TÍTULOS ============== */
    .payslip-title,
    .certificate-title,
    .contract-title,
    .document-title {
        font-size: 18pt !important;
        font-weight: bold !important;
        text-transform: uppercase !important;
        text-align: center !important;
        margin: 20pt 0 !important;
        color: #000 !important;
        text-decoration: underline !important;
    }

    /* ============== TABELAS ============== */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin: 10pt 0 !important;
        page-break-inside: auto;
    }

    th, td {
        border: 1pt solid #000 !important;
        padding: 6pt !important;
        text-align: left !important;
        font-size: 11pt !important;
    }

    th {
        background: #f0f0f0 !important;
        font-weight: bold !important;
        text-align: center !important;
    }

    .text-end,
    .text-right {
        text-align: right !important;
    }

    /* ============== INFORMAÇÕES DO FUNCIONÁRIO ============== */
    .employee-info,
    .period-info {
        background: #f9f9f9 !important;
        border: 1pt solid #ccc !important;
        padding: 10pt !important;
        margin: 10pt 0 !important;
        page-break-inside: avoid;
    }

    /* ============== TOTAIS E VALORES ============== */
    .totals,
    .net-salary {
        border-top: 2pt solid #000 !important;
        padding-top: 10pt !important;
        margin-top: 15pt !important;
        font-weight: bold !important;
        page-break-inside: avoid;
    }

    .totals-row {
        display: flex !important;
        justify-content: space-between !important;
        margin-bottom: 5pt !important;
    }

    .net-salary {
        font-size: 14pt !important;
        text-align: center !important;
    }

    /* ============== RODAPÉ ============== */
    .document-footer,
    .certificate-footer {
        margin-top: 20pt !important;
        font-size: 10pt !important;
        text-align: center !important;
        color: #666 !important;
        border-top: 1pt solid #ccc !important;
        padding-top: 10pt !important;
    }

    /* ============== ASSINATURAS ============== */
    .signature-line {
        width: 80% !important;
        border-top: 1pt solid #000 !important;
        margin: 0 auto 8pt auto !important;
        height: 30pt !important;
    }

    .signature-line p {
        font-size: 9pt !important;
        margin: 5pt 0 0 0 !important;
        text-align: center !important;
        color: #000 !important;
    }

    /* ============== QUEBRAS DE PÁGINA ============== */
    .page-break {
        page-break-before: always !important;
    }

    .no-break {
        page-break-inside: avoid !important;
    }

    /* ============== OTIMIZAÇÕES ESPECÍFICAS ============== */
    .row {
        display: block !important;
        width: 100% !important;
    }

    .col-md-6,
    .col-lg-6 {
        width: 48% !important;
        float: left !important;
        margin-right: 2% !important;
    }

    .col-md-12,
    .col-lg-12 {
        width: 100% !important;
        float: none !important;
    }

    /* Limpar floats */
    .clearfix::after {
        content: "";
        display: table;
        clear: both;
    }

    /* ============== REFERÊNCIAS ============== */
    .reference-number {
        position: absolute !important;
        top: 10pt !important;
        right: 10pt !important;
        font-size: 9pt !important;
        color: #666 !important;
        font-style: italic !important;
    }
}

/* ============== ESTILOS PARA PREVIEW ============== */
.print-preview {
    background: #f5f5f5;
    padding: 20px;
    border: 1px solid #ddd;
    margin: 20px 0;
}

.print-preview .payslip-container,
.print-preview .certificate-container {
    background: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* ============== INDICADORES DE IMPRESSÃO ============== */
.printing {
    overflow: hidden;
}

.printing * {
    -webkit-print-color-adjust: exact !important;
    color-adjust: exact !important;
    print-color-adjust: exact !important;
}
