/* ================================================================
   CNJ Processo Tracker — Relatórios
   Estilos para o modal de pré-visualização e @media print
================================================================ */

/* ── Botões de relatório ─────────────────────────────────────── */
.cnj-btn-relatorio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1.5px solid #D0D8E4;
    border-radius: 8px;
    padding: 7px 13px;
    font-family: inherit;
    font-size: .82rem;
    font-weight: 600;
    color: #1A2433;
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
    line-height: 1;
}
.cnj-btn-relatorio:hover {
    border-color: #1565A3;
    color: #1565A3;
    background: #EBF4FF;
    box-shadow: 0 2px 8px rgba(21,101,163,.08);
}
.cnj-btn-relatorio svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.cnj-rel-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 0 8px;
    border-top: 1px solid #EEF2F7;
    margin-top: 12px;
}
.cnj-rel-toolbar-label {
    font-size: .75rem;
    font-weight: 700;
    color: #5C6E82;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-right: 4px;
}

/* ── Modal de pré-visualização ───────────────────────────────── */
.cnj-rel-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,20,35,.55);
    backdrop-filter: blur(3px);
    z-index: 1000001;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.cnj-rel-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 860px;
    box-shadow: 0 24px 80px rgba(0,0,0,.22);
    display: flex;
    flex-direction: column;
    position: relative;
    margin: auto;
}

.cnj-rel-modal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #EEF2F7;
    gap: 12px;
    flex-shrink: 0;
}
.cnj-rel-modal-topbar-title {
    font-size: .92rem;
    font-weight: 700;
    color: #0B3D6B;
}
.cnj-rel-modal-topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.cnj-rel-btn-imprimir {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #1565A3, #0B3D6B);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-family: inherit;
    font-size: .83rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .15s;
}
.cnj-rel-btn-imprimir:hover { opacity: .88; }
.cnj-rel-btn-imprimir svg { width: 15px; height: 15px; }

.cnj-rel-btn-pdf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #065F46;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-family: inherit;
    font-size: .83rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .15s;
}
.cnj-rel-btn-pdf:hover { opacity: .88; }
.cnj-rel-btn-pdf svg { width: 15px; height: 15px; }

.cnj-rel-btn-fechar {
    background: none;
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    color: #5C6E82;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s;
}
.cnj-rel-btn-fechar:hover { background: #F5F7FA; color: #1A2433; }

.cnj-rel-modal-body {
    padding: 28px 32px;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

.cnj-rel-loading {
    text-align: center;
    padding: 60px 20px;
    color: #5C6E82;
    font-size: .9rem;
}
.cnj-rel-loading-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid #D0D8E4;
    border-top-color: #1565A3;
    border-radius: 50%;
    animation: cnj-spin .7s linear infinite;
    margin-bottom: 14px;
}
@keyframes cnj-spin { to { transform: rotate(360deg); } }

/* ── Conteúdo do relatório (tela e impressão) ────────────────── */
.cnj-rel-content {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 10pt;
    color: #1A2433;
    line-height: 1.5;
}

.cnj-rel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2.5px solid #0B3D6B;
    padding-bottom: 14px;
    margin-bottom: 22px;
    gap: 16px;
}
.cnj-rel-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.cnj-rel-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
}
.cnj-rel-site {
    font-size: 8pt;
    color: #5C6E82;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.cnj-rel-titulo {
    font-size: 16pt;
    font-weight: 800;
    color: #0B3D6B;
    margin: 0;
    line-height: 1.1;
}
.cnj-rel-sub {
    font-size: 9pt;
    color: #5C6E82;
    margin-top: 3px;
}
.cnj-rel-header-right {
    text-align: right;
    flex-shrink: 0;
}
.cnj-rel-data {
    font-size: 8pt;
    color: #5C6E82;
    line-height: 1.6;
}

/* Ficha */
.cnj-rel-ficha {
    margin-bottom: 28px;
}
.cnj-rel-ficha-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: #EBF4FF;
    border: 1px solid #BFDBFE;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 14px;
}
.cnj-rel-numero {
    font-family: 'Courier New', monospace;
    font-size: 12pt;
    font-weight: 700;
    color: #0B3D6B;
    display: block;
}
.cnj-rel-tribunal {
    font-size: 9pt;
    color: #5C6E82;
    margin-top: 2px;
}
.cnj-rel-sync-info {
    font-size: 8pt;
    color: #5C6E82;
    text-align: right;
}
.cnj-rel-secao-titulo {
    font-size: 10pt;
    font-weight: 700;
    color: #0B3D6B;
    border-bottom: 1px solid #D0D8E4;
    padding-bottom: 5px;
    margin: 16px 0 8px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* Tabelas */
.cnj-rel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
    margin-bottom: 8px;
}
.cnj-rel-table th {
    background: #F0F4F8;
    color: #1A2433;
    font-weight: 700;
    text-align: left;
    padding: 6px 10px;
    border: 1px solid #D0D8E4;
    font-size: 8pt;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.cnj-rel-table td {
    padding: 6px 10px;
    border: 1px solid #E5EBF0;
    vertical-align: top;
}
.cnj-rel-table-meta th { width: 120px; }
.cnj-rel-table tr:nth-child(even) td { background: #FAFBFC; }
.cnj-rel-table-sm { font-size: 8.5pt; }
.cnj-rel-table-sm th, .cnj-rel-table-sm td { padding: 4px 8px; }
.cnj-rel-table-lista th, .cnj-rel-table-lista td { font-size: 8.5pt; }

.cnj-rel-idx { width: 30px; text-align: center; color: #5C6E82; font-size: 8pt; }
.cnj-rel-numero-sm { font-family: 'Courier New', monospace; font-size: 8pt; white-space: nowrap; }
.cnj-rel-tribunal-sm { font-size: 8pt; color: #5C6E82; margin-left: 8px; }
.cnj-rel-data-mov { white-space: nowrap; font-size: 8pt; color: #5C6E82; }
.cnj-rel-compl { color: #5C6E82; font-size: 8pt; }

/* Polo badges */
.cnj-rel-polo {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 7.5pt;
    font-weight: 700;
}
.cnj-rel-polo-ativo   { background: #DBEAFE; color: #1565A3; }
.cnj-rel-polo-passivo { background: #FEE2E2; color: #991B1B; }
.cnj-rel-polo-terce,
.cnj-rel-polo-outros  { background: #F3F4F6; color: #374151; }

/* Novidades */
.cnj-rel-novidade-bloco {
    border: 1px solid #FED7AA;
    border-left: 4px solid #EA580C;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 14px;
    background: #FFF7ED;
}
.cnj-rel-novidade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
    flex-wrap: wrap;
}
.cnj-rel-badge-novo {
    display: inline-block;
    background: #EA580C;
    color: #fff;
    font-size: 7pt;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 4px;
    letter-spacing: .03em;
}
.cnj-rel-badge-novo-lg {
    display: inline-block;
    background: #EA580C;
    color: #fff;
    font-size: 8pt;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 6px;
    margin-right: 8px;
}
.cnj-rel-row-nova td { background: #FFF7ED !important; }
.cnj-rel-desde { font-size: 8pt; color: #92400E; }
.cnj-rel-note { font-size: 8.5pt; color: #5C6E82; font-style: italic; margin: 4px 0; }
.cnj-rel-empty {
    text-align: center;
    padding: 40px;
    color: #065F46;
    font-weight: 600;
    background: #D1FAE5;
    border-radius: 8px;
    margin: 20px 0;
}

/* Cliente */
.cnj-rel-cliente-bloco {
    margin-bottom: 20px;
}
.cnj-rel-cliente-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #F0F4F8;
    border-radius: 8px;
    padding: 12px 16px;
    flex-wrap: wrap;
}
.cnj-rel-cliente-nome { font-size: 11pt; color: #0B3D6B; }
.cnj-rel-cliente-login { font-size: 9pt; color: #5C6E82; margin-left: 8px; }
.cnj-rel-cliente-email { font-size: 8pt; color: #5C6E82; margin-left: 4px; }
.cnj-rel-cliente-stats { display: flex; align-items: center; gap: 10px; font-size: 9pt; }
.cnj-rel-cliente-status.ativo   { color: #065F46; font-weight: 700; }
.cnj-rel-cliente-status.inativo { color: #991B1B; font-weight: 700; }
.cnj-rel-acesso { font-size: 8pt; color: #5C6E82; padding: 4px 16px; }
.cnj-rel-sep { border-top: 1px dashed #D0D8E4; margin: 16px 0; }

/* Quebra de página e rodapé */
.cnj-rel-quebra { page-break-after: always; }
.cnj-rel-footer {
    margin-top: 32px;
    padding-top: 10px;
    border-top: 1px solid #D0D8E4;
    font-size: 7.5pt;
    color: #9CB3C9;
    text-align: center;
    display: none; /* só aparece na impressão */
}

/* ── @media print ────────────────────────────────────────────── */
@media print {
    body > *:not(#cnj-rel-print-frame) { display: none !important; }
    #cnj-rel-print-frame { display: block !important; }

    .cnj-rel-content {
        font-size: 9.5pt;
        color: #000;
    }
    .cnj-rel-footer { display: block; }
    .cnj-rel-novidade-bloco { border-color: #ccc !important; background: #fff !important; }
    .cnj-rel-ficha-header   { background: #f0f0f0 !important; border-color: #ccc !important; }
    .cnj-rel-cliente-header { background: #f0f0f0 !important; }
    .cnj-rel-table th       { background: #e8e8e8 !important; -webkit-print-color-adjust: exact; }
    .cnj-rel-polo-ativo     { background: #e0e8f8 !important; -webkit-print-color-adjust: exact; }
    .cnj-rel-polo-passivo   { background: #fde0e0 !important; -webkit-print-color-adjust: exact; }
    .cnj-rel-badge-novo,
    .cnj-rel-badge-novo-lg  { background: #888 !important; -webkit-print-color-adjust: exact; }

    @page {
        size: A4;
        margin: 15mm 12mm 18mm;
    }
}
