/* ============================================================
   ReceitaConecta - visual do sistema
   ============================================================ */
:root {
    --rc-azul: #0b3a82;
    --rc-azul-2: #1557c0;
    --rc-azul-claro: #e8f0fc;
    --rc-verde: #12a150;
    --rc-fundo: #f3f6fb;
    --rc-borda: #e1e7f0;
    --rc-texto: #16233a;
    --rc-suave: #6b7a90;
    --rc-raio: 14px;
    --rc-sombra: 0 1px 2px rgba(16, 34, 70, .06), 0 4px 16px rgba(16, 34, 70, .06);
    --bs-primary: #0b3a82;
    --bs-primary-rgb: 11, 58, 130;
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
body { background: var(--rc-fundo); color: var(--rc-texto); font-family: var(--bs-body-font-family); }
.btn-primary { --bs-btn-bg: var(--rc-azul); --bs-btn-border-color: var(--rc-azul); --bs-btn-hover-bg: #082c64; --bs-btn-hover-border-color: #082c64; --bs-btn-active-bg: #072656; }
.btn-success { --bs-btn-bg: var(--rc-verde); --bs-btn-border-color: var(--rc-verde); }
.btn-outline-primary { --bs-btn-color: var(--rc-azul); --bs-btn-border-color: #b9cbea; --bs-btn-hover-bg: var(--rc-azul); --bs-btn-hover-border-color: var(--rc-azul); --bs-btn-active-bg: var(--rc-azul); --bs-btn-active-border-color: var(--rc-azul); }
.form-check-input:checked { background-color: var(--rc-azul); border-color: var(--rc-azul); }
.swal2-styled.swal2-confirm { background-color: var(--rc-azul) !important; }
.form-control:focus, .form-select:focus { border-color: #8fb0e6; box-shadow: 0 0 0 .2rem rgba(21, 87, 192, .15); }
.text-suave { color: var(--rc-suave) !important; }
kbd { background: #eef2f8; color: var(--rc-suave); border: 1px solid var(--rc-borda); font-size: .72em; padding: .1em .4em; border-radius: 5px; box-shadow: none; }

/* ---------- Barra superior ---------- */
.rc-topo {
    position: sticky; top: 0; z-index: 1030;
    background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--rc-borda);
    height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
}
.rc-topo .rc-logo { height: 46px; width: auto; }
.rc-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; padding: 4px 10px; border-radius: 999px; background: #f1f4f9; color: var(--rc-suave); white-space: nowrap; }
.rc-chip b { color: var(--rc-texto); }
.rc-chip.ok { background: #e7f7ee; color: #0d7a3c; }
.rc-chip.alerta { background: #fff5e0; color: #9a6400; }
.rc-chip.perigo { background: #fde8e8; color: #b42318; }
.rc-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--rc-azul); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }

/* ---------- Estrutura em 3 colunas ---------- */
.rc-app { display: grid; grid-template-columns: 280px minmax(0, 1fr) minmax(0, 460px); gap: 16px; padding: 16px; max-width: 1680px; margin: 0 auto; }
.rc-card { background: #fff; border: 1px solid var(--rc-borda); border-radius: var(--rc-raio); box-shadow: var(--rc-sombra); }
.rc-lateral { position: sticky; top: 80px; height: calc(100vh - 96px); display: flex; flex-direction: column; overflow: hidden; }
.rc-lateral-scroll { overflow-y: auto; flex: 1; padding: 8px; }
.rc-sec-tit { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--rc-suave); padding: 10px 10px 6px; display: flex; justify-content: space-between; align-items: center; }
.rc-grupo-btn { width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 10px; display: flex; align-items: center; gap: 8px; color: var(--rc-texto); font-weight: 500; font-size: .92rem; }
.rc-grupo-btn:hover { background: #f2f6fc; }
.rc-grupo-btn .bi-seta { margin-left: auto; transition: transform .2s; color: var(--rc-suave); font-size: .75rem; }
.rc-grupo-btn[aria-expanded="true"] { background: var(--rc-azul-claro); color: var(--rc-azul); }
.rc-grupo-btn[aria-expanded="true"] .bi-seta { transform: rotate(90deg); }
.rc-grupo-btn .rc-conta { font-size: .72rem; color: var(--rc-suave); background: #eef2f8; border-radius: 999px; padding: 1px 8px; }
.rc-med-lista { padding: 2px 0 8px 12px; }
.rc-med-btn { width: 100%; border: 0; background: transparent; text-align: left; padding: 6px 10px; border-radius: 8px; font-size: .86rem; display: flex; align-items: center; gap: 6px; color: #2a3a55; }
.rc-med-btn:hover { background: #eaf6ef; color: #0d7a3c; }
.rc-med-btn .fa-plus { opacity: 0; font-size: .7rem; margin-left: auto; }
.rc-med-btn:hover .fa-plus { opacity: 1; }
.rc-med-btn .fa-qrcode { color: var(--rc-azul-2); font-size: .75rem; }
.rc-modelo { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.rc-modelo:hover { background: #f6f3ff; }
.rc-modelo .rc-grupo-btn:hover { background: transparent; }
.rc-modelo .rc-x { opacity: 0; border: 0; background: transparent; color: #b42318; padding: 4px 8px; }
.rc-modelo:hover .rc-x { opacity: .7; }

/* ---------- Área central ---------- */
.rc-centro { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.rc-campo-grande { border: 1px solid var(--rc-borda); border-radius: 12px; padding: 12px 14px 12px 44px; font-size: 1.05rem; width: 100%; outline: none; background: #fff; transition: border-color .15s, box-shadow .15s; }
.rc-campo-grande:focus { border-color: #8fb0e6; box-shadow: 0 0 0 .2rem rgba(21, 87, 192, .12); }
.rc-campo-wrap { position: relative; }
.rc-campo-wrap > .rc-ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--rc-suave); }
.rc-campo-wrap > kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.rc-dropdown { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 1040; background: #fff; border: 1px solid var(--rc-borda); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 34, 70, .16); max-height: 360px; overflow-y: auto; display: none; padding: 6px; }
.rc-dropdown.aberto { display: block; }
.rc-opcao { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.rc-opcao.ativa, .rc-opcao:hover { background: var(--rc-azul-claro); }
.rc-opcao .rc-opcao-tit { font-weight: 600; font-size: .93rem; }
.rc-opcao .rc-opcao-sub { font-size: .8rem; color: var(--rc-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 520px; }
.rc-opcao .rc-tag { font-size: .7rem; background: #eef2f8; color: var(--rc-suave); border-radius: 6px; padding: 1px 6px; margin-left: auto; white-space: nowrap; }
.rc-opcao mark { padding: 0; background: #fff1b8; }

.rc-editor-card { display: flex; flex-direction: column; min-height: 480px; flex: 1; }
.rc-editor-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--rc-borda); }
.rc-editor { flex: 1; border: 0; resize: none; outline: none; padding: 18px 20px; font-size: 1rem; line-height: 1.6; min-height: 380px; font-family: 'Inter', system-ui, sans-serif; border-radius: 0 0 var(--rc-raio) var(--rc-raio); }
.rc-editor::placeholder { color: #a6b1c2; }
.rc-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--rc-suave); cursor: pointer; user-select: none; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--rc-borda); }
.rc-toggle input { accent-color: var(--rc-azul); }
.rc-toggle.on { background: #fff5e0; border-color: #f3d38f; color: #8a5a00; }

.rc-acoes { display: flex; flex-wrap: wrap; gap: 8px; }
.rc-acoes .btn { border-radius: 12px; padding: .65rem 1.1rem; font-weight: 600; }
.rc-acoes .btn-imprimir { flex: 1 1 220px; font-size: 1.05rem; }

.rc-aviso { border-radius: 12px; padding: 10px 14px; font-size: .9rem; display: flex; align-items: center; gap: 10px; }
.rc-aviso.info { background: var(--rc-azul-claro); color: var(--rc-azul); }
.rc-aviso.lilas { background: #f3efff; color: #5b3fc4; }

/* ---------- Prévia ---------- */
.rc-previa-col { position: sticky; top: 80px; height: calc(100vh - 96px); display: flex; flex-direction: column; overflow: hidden; }
html, body { overflow-x: hidden; }
.rc-previa-topo { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--rc-borda); }
.rc-previa-voltar { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rc-borda); background: #fff; }
.rc-previa-voltar .btn { border-radius: 12px; padding: .75rem; font-weight: 600; }
.rc-previa-area { flex: 1; min-height: 0; overflow: auto; background: #e9eef5; padding: 16px; border-radius: 0 0 var(--rc-raio) var(--rc-raio); }
.rc-previa-escala { transform-origin: top left; }
.rc-previa-escala .rc-folha { box-shadow: 0 4px 18px rgba(0, 0, 0, .15); margin-bottom: 16px; }

/* ---------- Abas de configuração ---------- */
.rc-tabs .nav-link { color: var(--rc-suave); font-weight: 600; border-radius: 10px; }
.rc-tabs .nav-link.active { background: var(--rc-azul-claro); color: var(--rc-azul); }
.rc-opcao-modo { border: 2px solid var(--rc-borda); border-radius: 12px; padding: 12px; cursor: pointer; height: 100%; display: block; }
.rc-opcao-modo:has(input:checked) { border-color: var(--rc-azul-2); background: var(--rc-azul-claro); }
.rc-opcao-modo input { display: none; }
.rc-tabela-scroll { max-height: 360px; overflow-y: auto; border: 1px solid var(--rc-borda); border-radius: 10px; }
.rc-tabela-scroll table { margin: 0; }
.rc-tabela-scroll thead th { position: sticky; top: 0; background: #f6f8fb; z-index: 1; font-size: .78rem; text-transform: uppercase; color: var(--rc-suave); }

/* ---------- Histórico ---------- */
.rc-hist-item { border: 1px solid var(--rc-borda); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.rc-hist-item + .rc-hist-item { margin-top: 8px; }
.rc-hist-item .rc-resumo { font-size: .85rem; color: var(--rc-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-hist-item .btn { border-radius: 8px; }
.rc-stat { text-align: center; padding: 12px; }
.rc-stat b { display: block; font-size: 1.5rem; color: var(--rc-azul); }
.rc-stat span { font-size: .78rem; color: var(--rc-suave); }

/* ---------- Responsivo ---------- */
@media (max-width: 1399.98px) {
    .rc-app { grid-template-columns: 250px minmax(0, 1fr) minmax(0, 380px); }
}
@media (max-width: 1199.98px) {
    .rc-app { grid-template-columns: 250px minmax(0, 1fr); }
    .rc-previa-col { display: none; }
    .rc-previa-col.mostrar { display: flex; position: fixed; inset: 64px 0 0 0; z-index: 1035; height: auto; border-radius: 0; }
    .rc-previa-col.mostrar .rc-previa-area { border-radius: 0; }
}
@media (max-width: 767.98px) {
    .rc-app { grid-template-columns: 1fr; padding: 10px; }
    .rc-lateral { display: none; }
    .rc-topo { padding: 0 10px; }
    .rc-topo .rc-logo { height: 32px; }
    .rc-topo { gap: 6px; }
    #rc-dias { display: none !important; }
    .rc-previa-topo .fw-semibold { font-size: .95rem; }
    .rc-editor { min-height: 300px; }
}
.offcanvas .rc-lateral-scroll { padding: 0; }

/* ============================================================
   FOLHA DA RECEITA (prévia e impressão)
   ============================================================ */
.rc-folha { background: #fff; color: #111; box-sizing: border-box; display: flex; flex-direction: column; line-height: 1.45; position: relative; page-break-after: always; break-after: page; overflow: hidden; }
.rc-folha:last-child { page-break-after: auto; break-after: auto; }
.rc-folha * { box-sizing: border-box; }
.rc-paciente { font-size: 1.2em; font-weight: 700; margin-bottom: 1.6em; min-height: 1.2em; }
.rc-paciente span { font-weight: 400; color: #444; }
.rc-corpo { flex: 1; }
.rc-item { margin-bottom: 1.1em; break-inside: avoid; }
.rc-item-titulo { font-weight: 700; text-transform: uppercase; font-size: 1.07em; margin-bottom: .2em; }
.rc-item-linha { margin-bottom: .1em; }
.rc-qr-item { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.rc-qr-item svg { width: 16mm; height: 16mm; }
.rc-qr-item span { font-size: 8px; color: #555; line-height: 1.25; }
.rc-vazio { color: #9aa6b8; font-style: italic; }
.rc-final { margin-top: 1.5em; }
.rc-data { text-align: center; margin-top: 2em; }
.rc-assinatura { text-align: center; margin: 2.2em auto 0; width: 60%; font-size: .9em; }
.rc-assinatura small { color: #555; }
.rc-linha-ass { border-top: 1px solid #000; margin-bottom: 4px; }
.rc-qrs { display: flex; justify-content: space-between; gap: 12px; margin-top: 1.2em; }
.rc-qr-rodape { display: flex; align-items: center; gap: 8px; }
.rc-qr-rodape svg, .rc-qr-ph { width: 20mm; height: 20mm; flex: none; }
.rc-qr-ph { border: 2px dashed #c9d3e2; border-radius: 4px; }
.rc-qr-fantasma { opacity: .7; }
.rc-qr-rodape span { font-size: 9px; line-height: 1.3; color: #333; }

.rc-completo .rc-cab { border-bottom: 2px solid var(--rc-cor); padding-bottom: 3mm; margin-bottom: 7mm; text-align: center; }
.rc-cab-nome { font-size: 1.7em; font-weight: 700; color: var(--rc-cor); letter-spacing: .02em; }
.rc-cab-esp { font-size: 1em; color: #333; }
.rc-cab-reg { font-size: .85em; color: #555; }
.rc-rodape { border-top: 1px solid var(--rc-cor); margin-top: 5mm; padding-top: 2.5mm; text-align: center; font-size: 9px; color: #444; }
.rc-A5 .rc-qr-rodape svg, .rc-A5 .rc-qr-ph { width: 16mm; height: 16mm; }

/* Divulgação discreta no pé da folha */
.rc-marca { position: absolute; right: 6mm; bottom: 4mm; font-size: 7px; color: #9aa3ad; letter-spacing: .02em; font-family: Arial, sans-serif; }

/* Controle especial */
.rc-esp-titulo { text-align: center; font-size: 17px; font-weight: 700; text-transform: uppercase; margin: 0 0 5mm; }
.rc-esp-topo { display: flex; justify-content: space-between; gap: 6mm; margin-bottom: 5mm; }
.rc-esp-box { border: 1.5px solid #000; }
.rc-esp-emitente { width: 62%; }
.rc-esp-box-tit { border-bottom: 1.5px solid #000; text-align: center; font-weight: 700; font-size: 12px; padding: 2px 0; background: #eef3f8; }
.rc-esp-box-cont { padding: 6px 10px; font-size: 12.5px; line-height: 1.45; }
.rc-esp-emitente .rc-esp-box-cont { text-align: center; }
.rc-esp-vias { font-weight: 700; font-size: 13px; text-align: right; display: flex; flex-direction: column; justify-content: center; gap: 4px; color: #888; }
.rc-esp-vias .ativa { color: #000; border-bottom: 2px solid #000; }
.rc-esp-corpo { flex: 1; padding: 4mm 2mm; }
.rc-esp-campo { margin-bottom: 3mm; display: flex; gap: 6px; }
.rc-esp-campo span { flex: 1; border-bottom: 1px solid #999; }
.rc-esp-prescricao { margin-top: 6mm; }
.rc-esp-prescricao > b { display: block; margin-bottom: 4mm; }
.rc-esp-ass { margin-bottom: 5mm; }
.rc-esp-rodape { display: flex; gap: 4mm; }
.rc-esp-rodape .rc-esp-box { flex: 1; display: flex; flex-direction: column; }
.rc-esp-linhas div { border-bottom: 1px solid #999; padding-top: 6px; font-size: 11.5px; }
.rc-esp-forn { flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.rc-esp-forn .rc-assinatura { width: 90%; margin-top: 0; font-size: 11px; }
.rc-esp-carimbo { text-align: center; color: #aaa; font-size: 11px; padding: 18px 0; }

/* ---------- Impressão ---------- */
#rc-impressao { display: none; }
@media print {
    body { background: #fff !important; margin: 0; }
    body > *:not(#rc-impressao) { display: none !important; }
    #rc-impressao { display: block !important; }
    .rc-folha { box-shadow: none !important; margin: 0 !important; }
    .rc-esp-box-tit { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Indicador de login (verde = conectado, vermelho = desconectado) */
.rc-sessao { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid transparent; border-radius: 999px; padding: .25rem .7rem; font-size: .8rem; font-weight: 600; cursor: pointer; background: none; }
.rc-sessao.on { color: var(--rc-verde); background: #e8f7ee; border-color: #c4ead3; }
.rc-sessao.on .fa-circle { font-size: .55rem; }
.rc-sessao.off { color: #fff; background: #d63939; border-color: #d63939; animation: rc-pisca 1.4s ease-in-out infinite; }
@keyframes rc-pisca { 50% { box-shadow: 0 0 0 5px rgba(214, 57, 57, .25); } }
@media print { .rc-sessao { display: none !important; } }
