/* css/print.css */

@page { size: A4 landscape; margin: 0; }

@media print {
    body { margin: 0; -webkit-print-color-adjust: exact; }
    .sheet { page-break-after: always; }
    .sheet:last-child { page-break-after: auto; }
}

* { box-sizing: border-box; }

body {
    font-family: 'Arial', sans-serif;
    background: #eee;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

@media print {
    body { background: white; }
    .sheet { margin: 0; box-shadow: none; }
}

.sheet {
    background: white;
    width: 297mm;
    height: 210mm;
    display: flex;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* --- ESTRUTURA DA VIA --- */
.via {
    width: 50%;
    height: 100%;
    padding: 10mm 15mm;
    display: flex;
    flex-direction: column;
    position: relative;
    border-right: 1px dashed #ccc;
}
.via:last-child { border-right: none; }

/* --- CABEÇALHO --- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
    height: 90px;
}

.logo { width: 70px; height: 70px; object-fit: contain; }

.header-text { text-align: center; flex-grow: 1; margin: 0 10px; }
.h-mantenedora { font-size: 10px; text-transform: uppercase; color: #555; }
.h-intermediario { font-size: 10px; margin-top: 2px; font-weight: bold; }
.h-instituicao { font-size: 15px; font-weight: bold; margin-top: 4px; text-transform: uppercase; color: #000; }

/* --- SEÇÕES DE DADOS --- */
.section-box { margin-bottom: 10px; font-size: 11px; }
.label { font-weight: bold; color: #444; font-size: 9px; text-transform: uppercase; border-bottom: 1px solid #ddd; margin-bottom: 2px; }

.doctor-info { display: flex; justify-content: space-between; padding-bottom: 2px; }

.patient-row { display: flex; gap: 15px; margin-bottom: 2px; }
.patient-name { font-weight: bold; font-size: 13px; width: 100%; text-transform: uppercase; }
.patient-address { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-style: italic; color: #555; }

/* --- TÍTULO --- */
.rx-title {
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    margin: 10px 0;
    border: 1px solid #000;
    padding: 5px;
    background: #f0f0f0;
    text-transform: uppercase;
}

/* --- LISTA --- */
.med-list { flex-grow: 1; }

.med-box {
    border: 1px solid #999;
    border-radius: 4px;
    margin-bottom: 8px;
    overflow: hidden;
}
.med-header {
    background: #f5f5f5;
    border-bottom: 1px dotted #999;
    padding: 4px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.med-name { font-weight: bold; font-size: 12px; }
.med-qty { font-weight: bold; font-size: 11px; background: #fff; padding: 0 4px; border-radius: 3px; border: 1px solid #ccc; }
.med-body { padding: 6px 8px; font-size: 11px; }
.med-usage { white-space: pre-wrap; line-height: 1.3; }

/* --- RODAPÉS --- */
.general-footer {
    text-align: center;
    font-size: 9px;
    color: #555;
    border-top: 1px solid #ccc;
    padding-top: 5px;
    margin-top: 5px;
}

.special-footer { display: flex; border: 1px solid #000; margin-top: auto; margin-bottom: 10px; font-size: 9px; height: 130px; }
.sf-col { width: 50%; padding: 5px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid #000; }
.sf-col:last-child { border-right: none; }
.sf-title { font-weight: bold; text-align: center; background: #ddd; display: block; margin-bottom: 5px; }
.sf-line { border-bottom: 1px solid #ccc; height: 14px; margin-bottom: 5px; display: flex; align-items: flex-end; }
.sf-label { margin-right: 5px; font-weight: bold; }

.simple-spacer { flex-grow: 1; }

.page-number { position: absolute; bottom: 5mm; left: 5mm; font-size: 9px; color: #666; }
.via-label { position: absolute; bottom: 5mm; right: 5mm; font-size: 9px; font-weight: bold; border: 1px solid #000; padding: 2px 6px; }