/* =============================================================================
   FormulaFlow — receituário e documentos impressos.

   Sem dependência de biblioteca de PDF: a impressão do navegador gera o PDF.
   Em hospedagem compartilhada isso evita instalar mPDF/Dompdf e funciona
   igual no desktop e no celular do prescritor.
   ========================================================================== */

.pagina-publica { background: var(--canvas); }

.receita {
    background: #fff;
    max-width: 210mm;             /* A4 */
    min-height: 297mm;
    margin: 24px auto;
    padding: 18mm 16mm;
    box-shadow: var(--shadow);
    border-radius: 4px;
    color: #17171f;
    font-size: 11pt;
    line-height: 1.5;
}

.receita__cabecalho {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--brand-primary);
    margin-bottom: 20px;
}

.receita__logo { max-height: 64px; max-width: 190px; object-fit: contain; }

.receita__medico { flex: 1; min-width: 0; }
.receita__medico h1 { font-size: 15pt; margin: 0 0 2px; letter-spacing: -.01em; }
.receita__medico p { margin: 0; font-size: 9.5pt; color: #55556b; }

.receita__paciente {
    background: #f7f7fb;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 22px;
    font-size: 10pt;
}

.receita__titulo {
    font-size: 10pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #55556b;
    margin: 0 0 12px;
}

.formula {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px dashed #d7d7e6;
    /* Uma fórmula não deve ser partida entre duas páginas. */
    break-inside: avoid;
    page-break-inside: avoid;
}
.formula:last-child { border-bottom: 0; }

.formula__nome { font-weight: 700; font-size: 11.5pt; margin: 0 0 6px; }
.formula__linha { display: flex; justify-content: space-between; gap: 20px; padding: 1px 0; }
.formula__linha span:last-child { white-space: nowrap; color: #40405f; }
.formula__rodape { margin-top: 8px; font-size: 10pt; }
.formula__rodape strong { font-weight: 600; }

.receita__assinatura {
    margin-top: 48px;
    text-align: center;
    break-inside: avoid;
}
.receita__assinatura hr {
    width: 260px; margin: 0 auto 6px;
    border: 0; border-top: 1px solid #40405f;
}
.receita__assinatura p { margin: 0; font-size: 9.5pt; }

.receita__rodape {
    margin-top: 28px;
    padding-top: 10px;
    border-top: 1px solid #e8e8f1;
    font-size: 8.5pt;
    color: #7b7b96;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.barra-impressao {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

@media print {
    @page { size: A4; margin: 0; }

    .barra-impressao, .no-print { display: none !important; }

    body, .pagina-publica { background: #fff; }

    .receita {
        margin: 0;
        box-shadow: none;
        border-radius: 0;
        max-width: none;
        min-height: 0;
        padding: 14mm 14mm;
    }

    /* Impressoras descartam cor de fundo por padrão; sem isso a faixa do
       paciente sai branca e o layout perde a hierarquia. */
    .receita__paciente {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
