/**
 * CSS de Impressão para Relatórios PDF
 * Estilos específicos para impressão via navegador
 */

/* No modo tela, ocultar #print-report */
#print-report,
#print-report-consolidated,
#print-compare-report {
    display: none;
}

/* Estilos de impressão */
/* Ocultar calendário no print */
@media print {
    #calendar-panel,
    #exception-modal {
        display: none !important;
    }
    /* Ocultar elementos do site */
    header,
    footer,
    nav,
    .no-print,
    button,
    input,
    select,
    textarea,
    #skeleton-loading,
    #mobile-cta,
    .faq-item,
    .step-indicator,
    .step-line,
    #btn-calcular,
    #btn-copiar-resumo,
    #btn-gerar-relatorio,
    .hero,
    .bg-gradient-to-r {
        display: none !important;
    }

    /* Mostrar apenas o relatório */
    #print-report,
    #print-report-consolidated,
    #print-compare-report {
        display: block !important;
    }

    /* Configuração da página A4 */
    @page {
        size: A4;
        margin: 12mm;
    }

    /* Resetar estilos para impressão */
    body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
        margin: 0;
        padding: 0;
    }

    /* Container do relatório */
    .print-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
        background: #fff;
    }

    /* Cabeçalho do relatório */
    .print-header {
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 2px solid #333;
    }

    .print-logo-container {
        margin-bottom: 10px;
    }

    .print-logo {
        height: 28px;
        max-height: 28px;
        width: auto;
        display: block;
    }

    .print-logo-fallback {
        font-size: 24pt;
        font-weight: bold;
        color: #2563eb;
        display: none;
    }

    .print-subtitle {
        font-size: 16pt;
        font-weight: 600;
        color: #333;
        margin-bottom: 10px;
    }

    .print-meta {
        font-size: 10pt;
        color: #666;
        margin-top: 10px;
    }

    .print-meta-item {
        margin-bottom: 5px;
    }

    .print-date {
        font-size: 10pt;
        color: #666;
        margin-top: 10px;
    }

    .print-subsection {
        margin-top: 15px;
        margin-bottom: 15px;
    }

    .print-subsection-title {
        font-size: 12pt;
        font-weight: 600;
        color: #333;
        margin-bottom: 10px;
        padding-bottom: 5px;
        border-bottom: 1px solid #ddd;
    }

    .print-qr-container {
        margin-top: 20px;
        padding: 15px;
        text-align: center;
        border-top: 1px solid #ddd;
    }

    .print-qr-text {
        font-size: 10pt;
        color: #666;
        margin-bottom: 10px;
    }

    .print-qr-code {
        display: inline-block;
        padding: 10px;
        border: 1px solid #ddd;
        background-color: #f9f9f9;
        font-size: 9pt;
        color: #999;
    }

    .print-footer-text {
        font-size: 10pt;
        color: #666;
        margin-bottom: 15px;
    }

    /* Blocos de conteúdo */
    .print-section {
        margin-bottom: 20px;
        page-break-inside: avoid;
    }

    .print-section-title {
        font-size: 14pt;
        font-weight: 600;
        color: #333;
        margin-bottom: 10px;
        padding-bottom: 5px;
        border-bottom: 1px solid #ccc;
    }

    /* Tabelas */
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 15px;
        font-size: 11pt;
    }

    .print-table th,
    .print-table td {
        padding: 8px;
        text-align: left;
        border: 1px solid #ddd;
    }

    .print-table th {
        background-color: #f5f5f5;
        font-weight: 600;
        color: #333;
    }

    .print-table tr:nth-child(even) {
        background-color: #f9f9f9;
    }

    .print-table .total-row {
        background-color: #e5e7eb !important;
        font-weight: bold;
        font-size: 12pt;
    }

    .print-table .label-cell {
        width: 60%;
        font-weight: 500;
    }

    .print-table .value-cell {
        width: 40%;
        text-align: right;
        font-family: 'Courier New', monospace;
    }

    /* Breakdown detalhado */
    .print-breakdown {
        margin-top: 10px;
    }

    .print-breakdown-item {
        margin-bottom: 8px;
        padding: 8px;
        border-left: 3px solid #2563eb;
        background-color: #f9fafb;
    }

    .print-breakdown-label {
        font-weight: 600;
        color: #333;
        margin-bottom: 5px;
    }

    .print-breakdown-details {
        font-size: 10pt;
        color: #666;
        margin-left: 15px;
        margin-top: 5px;
    }

    .print-breakdown-details-item {
        margin-bottom: 3px;
    }

    /* Avisos/Observações */
    .print-warnings {
        margin-top: 20px;
        padding: 15px;
        background-color: #fef3c7;
        border: 1px solid #fbbf24;
        border-radius: 4px;
    }

    .print-warnings-title {
        font-weight: 600;
        color: #92400e;
        margin-bottom: 10px;
    }

    .print-warnings-list {
        list-style: disc;
        margin-left: 20px;
        color: #78350f;
    }

    .print-warnings-list li {
        margin-bottom: 5px;
    }

    /* Rodapé do relatório */
    .print-footer {
        margin-top: 30px;
        padding-top: 20px;
        border-top: 2px solid #333;
        font-size: 10pt;
        color: #666;
    }

    .print-footer-company {
        font-weight: 600;
        color: #333;
        margin-bottom: 10px;
    }

    .print-footer-cta {
        margin: 15px 0;
        padding: 10px;
        background-color: #eff6ff;
        border-left: 3px solid #2563eb;
    }

    .print-footer-qr {
        margin: 15px 0;
        padding: 10px;
        text-align: center;
    }

    .print-footer-qr img {
        display: block;
        margin: 10px auto;
        width: 140px;
        height: 140px;
    }

    .print-footer-qr-link {
        color: #2563eb;
        text-decoration: underline;
    }

    .print-footer-note {
        margin-top: 15px;
        font-style: italic;
        color: #666;
    }

    /* Rodapé fixo com numeração de páginas */
    .print-page-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        font-size: 9pt;
        color: #666;
        text-align: center;
        padding: 8px 0;
        border-top: 1px solid #ddd;
        background: #fff;
    }

    .print-page-footer-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 12mm;
    }

    .print-page-footer-left {
        text-align: left;
    }

    .print-page-footer-right {
        text-align: right;
    }

    .print-page-info {
        font-size: 9pt;
        color: #666;
    }

    /* Counter para numeração de páginas (suportado em alguns navegadores) */
    @page {
        counter-increment: page;
    }

    .page-number::before {
        content: counter(page);
    }

    /* Fallback: JavaScript irá preencher se counter não funcionar */

    /* Evitar quebra de página em elementos importantes */
    .print-section,
    .print-header {
        page-break-inside: avoid;
    }

    .print-table .total-row {
        page-break-inside: avoid;
    }

    /* Espaçamento inferior para acomodar rodapé fixo */
    .print-container {
        padding-bottom: 50px;
    }

    /* Cores para impressão (garantir contraste) */
    .print-value-positive {
        color: #000;
    }

    .print-value-negative {
        color: #000;
    }

    /* Espaçamento */
    .print-spacer {
        margin-bottom: 15px;
    }

    /* Listas */
    .print-list {
        list-style: disc;
        margin-left: 20px;
        margin-bottom: 15px;
    }

    .print-list li {
        margin-bottom: 5px;
    }

    /* Estilos específicos para Cartão Ponto / Folha de Ponto */
    .timesheet-page {
        width: 210mm;
        min-height: 297mm;
        box-sizing: border-box;
        page-break-after: always;
        break-after: page;
        margin: 0;
        padding: 0;
    }

    .timesheet-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    .timesheet {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        font-size: 11pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }

    .timesheet-header {
        text-align: center;
        margin-bottom: 20px;
    }

    .timesheet-title {
        font-size: 20pt;
        font-weight: bold;
        margin-bottom: 10px;
        text-transform: uppercase;
    }

    .timesheet-separator {
        border-bottom: 2px solid #000;
        margin: 10px 0;
    }

    .timesheet-info {
        display: flex;
        justify-content: space-between;
        margin-bottom: 15px;
        font-size: 10pt;
    }

    .timesheet-info-left {
        flex: 1;
    }

    .timesheet-info-right {
        text-align: right;
    }

    .timesheet-info-item {
        margin-bottom: 5px;
    }

    .timesheet-colaborador {
        margin-bottom: 15px;
        font-size: 10pt;
        border: 1px solid #000;
        padding: 8px;
    }

    .timesheet-colaborador-line {
        margin-bottom: 5px;
    }

    .timesheet-colaborador-line:last-child {
        margin-bottom: 0;
    }

    .timesheet-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 20px;
        font-size: 10pt;
    }

    .timesheet-table thead {
        display: table-header-group;
    }

    .timesheet-table tbody {
        display: table-row-group;
    }

    .timesheet-table th {
        background-color: #f0f0f0;
        border: 1px solid #000;
        padding: 8px 4px;
        text-align: center;
        font-weight: bold;
        font-size: 9pt;
        page-break-inside: avoid;
        break-inside: avoid;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    .timesheet-table td {
        border: 1px solid #000;
        padding: 10px 4px;
        text-align: center;
        vertical-align: middle;
        min-height: 30px;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .timesheet-table tbody tr {
        min-height: 35px;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .timesheet-table tbody tr.is-offday {
        background-color: #e5e5e5;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    .timesheet-table tbody tr.is-offday td {
        background-color: #e5e5e5;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    .timesheet-table th {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    .timesheet-table td:first-child {
        font-weight: 500;
        width: 10%;
    }

    .timesheet-table td:nth-child(2),
    .timesheet-table td:nth-child(3),
    .timesheet-table td:nth-child(4),
    .timesheet-table td:nth-child(5) {
        width: 15%;
    }

    .timesheet-table td:last-child {
        width: 30%;
        text-align: left;
        padding-left: 8px;
    }

    .timesheet-footer {
        margin-top: 30px;
        text-align: right;
    }

    .timesheet-responsavel {
        display: inline-block;
        width: 300px;
        text-align: right;
    }

    .timesheet-responsavel-line {
        border-bottom: 1px solid #000;
        height: 40px;
        margin-bottom: 5px;
    }

    .timesheet-responsavel-label {
        font-size: 9pt;
        font-weight: bold;
        text-transform: uppercase;
    }

    /* Preview na tela (não impressão) */
    .timesheet-preview {
        font-size: 10pt;
        max-width: 100%;
        overflow-x: auto;
    }

    .timesheet-preview .timesheet-title {
        font-size: 18pt;
    }

    .timesheet-preview .timesheet-table {
        font-size: 9pt;
    }

    .timesheet-preview .timesheet-table th,
    .timesheet-preview .timesheet-table td {
        padding: 6px 3px;
    }

    /* Estilos específicos para Holerite / Recibo de Pagamento */
    .payslip {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        font-size: 11pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
        padding: 0;
        margin: 0;
    }

    .payslip-header {
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 2px solid #333;
    }

    .payslip-title {
        font-size: 20pt;
        font-weight: bold;
        margin-bottom: 15px;
        text-align: center;
        text-transform: uppercase;
    }

    .payslip-company {
        font-size: 10pt;
        line-height: 1.6;
    }

    .payslip-company-name {
        font-weight: bold;
        font-size: 12pt;
        margin-bottom: 5px;
    }

    .payslip-meta {
        display: flex;
        justify-content: space-between;
        margin-bottom: 15px;
        padding: 10px;
        background-color: #f5f5f5;
        border: 1px solid #ddd;
        font-size: 10pt;
    }

    .payslip-employee {
        margin-bottom: 15px;
        padding: 10px;
        border: 1px solid #ddd;
        font-size: 10pt;
        line-height: 1.8;
    }

    .payslip-employee > div {
        margin-bottom: 5px;
    }

    .payslip-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 20px;
        font-size: 10pt;
    }

    .payslip-table thead {
        display: table-header-group;
    }

    .payslip-table tbody {
        display: table-row-group;
    }

    .payslip-table th {
        background-color: #f0f0f0;
        border: 1px solid #000;
        padding: 8px 6px;
        text-align: left;
        font-weight: bold;
        font-size: 9pt;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .payslip-table td {
        border: 1px solid #000;
        padding: 8px 6px;
        text-align: left;
        vertical-align: top;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .payslip-table .text-right {
        text-align: right;
    }

    .payslip-table tbody tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .payslip-totals {
        background-color: #e5e5e5 !important;
        font-weight: bold;
        font-size: 11pt;
    }

    .payslip-totals td {
        background-color: #e5e5e5 !important;
    }

    .payslip-liquido {
        margin-bottom: 20px;
        padding: 15px;
        border: 2px solid #333;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 14pt;
        font-weight: bold;
    }

    .payslip-liquido-value {
        font-size: 16pt;
        color: #000;
    }

    .payslip-signatures {
        display: flex;
        justify-content: space-between;
        margin-top: 40px;
        margin-bottom: 20px;
        gap: 40px;
    }

    .payslip-signature-line {
        border-bottom: 1px solid #000;
        height: 50px;
        margin-bottom: 5px;
    }

    .payslip-signature-label {
        text-align: center;
        font-size: 9pt;
        font-weight: bold;
        text-transform: uppercase;
    }

    .payslip-note {
        margin-top: 30px;
        padding-top: 15px;
        border-top: 1px solid #ccc;
        font-size: 9pt;
        font-style: italic;
        color: #666;
        text-align: center;
    }

    /* Preview na tela (não impressão) */
    .payslip-preview {
        font-size: 11pt;
        max-width: 100%;
    }

    .payslip-preview-container {
        font-size: 12pt;
    }

    .payslip-preview-container .payslip-header {
        border-bottom: 1px solid #ddd;
    }

    .payslip-preview-container table {
        font-size: 11pt;
    }

    .payslip-preview-container .payslip-table th,
    .payslip-preview-container .payslip-table td {
        padding: 6px 4px;
    }

    /* Estilos específicos para RPA (Recibo de Pagamento a Autônomo) */
    .rpa-doc {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        font-size: 11pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }

    .rpa-header {
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 2px solid #333;
    }

    .rpa-title {
        font-size: 18pt;
        font-weight: bold;
        margin-bottom: 15px;
        text-align: center;
        text-transform: uppercase;
    }

    .rpa-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        margin-bottom: 20px;
    }

    .rpa-block {
        margin-bottom: 20px;
        page-break-inside: avoid;
    }

    .rpa-block h3 {
        font-size: 12pt;
        font-weight: bold;
        margin-bottom: 10px;
        padding-bottom: 5px;
        border-bottom: 1px solid #ccc;
        text-transform: uppercase;
    }

    .rpa-content {
        font-size: 10pt;
        line-height: 1.6;
    }

    .rpa-content > div {
        margin-bottom: 5px;
    }

    .rpa-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 20px;
        font-size: 10pt;
    }

    .rpa-table thead {
        display: table-header-group;
    }

    .rpa-table tbody {
        display: table-row-group;
    }

    .rpa-table th,
    .rpa-table td {
        border: 1px solid #000;
        padding: 8px 6px;
        text-align: left;
    }

    .rpa-table .rpa-label {
        font-weight: 500;
    }

    .rpa-table .rpa-value {
        text-align: right;
        font-family: 'Courier New', monospace;
    }

    .rpa-table tbody tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .rpa-totals {
        background-color: #e5e5e5 !important;
        font-weight: bold;
        font-size: 11pt;
    }

    .rpa-totals td {
        background-color: #e5e5e5 !important;
    }

    .rpa-liquido {
        background-color: #dbeafe !important;
    }

    .rpa-liquido .rpa-value {
        font-size: 13pt;
        font-weight: bold;
        color: #000;
    }

    .rpa-declaration {
        font-size: 10pt;
        font-style: italic;
        margin: 20px 0;
        padding: 10px;
        background-color: #f9fafb;
        border-left: 3px solid #333;
    }

    .rpa-signatures {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 40px;
        margin-top: 40px;
        margin-bottom: 20px;
    }

    .rpa-signature {
        text-align: center;
    }

    .rpa-signature-line {
        border-bottom: 1px solid #000;
        height: 50px;
        margin-bottom: 10px;
    }

    .rpa-signature-name {
        font-size: 9pt;
        line-height: 1.4;
    }

    .rpa-observations {
        margin-top: 20px;
        padding: 10px;
        background-color: #fef3c7;
        border: 1px solid #fbbf24;
        font-size: 9pt;
        font-style: italic;
    }

    .rpa-observations p {
        margin: 0;
        color: #78350f;
    }

    /* Preview na tela (não impressão) */
    .rpa-preview {
        font-size: 11pt;
        max-width: 100%;
    }

    .rpa-preview-container {
        font-size: 12pt;
    }

    .rpa-preview-container .rpa-header {
        border-bottom: 1px solid #ddd;
    }

    .rpa-preview-container .rpa-section {
        margin-bottom: 15px;
        padding-bottom: 15px;
        border-bottom: 1px solid #ddd;
    }

    .rpa-preview-container table {
        font-size: 11pt;
    }

    .rpa-preview-container table th,
    .rpa-preview-container table td {
        padding: 6px 4px;
    }

    /* Ocultar print-rpa no modo tela */
    #print-rpa {
        display: none;
    }

    /* Mostrar print-rpa apenas no print */
    @media print {
        #print-rpa {
            display: block !important;
        }
    }
}
