/* Informe de Historia Clínica. Todos los estilos pertenecen a este diálogo. */
.clinical-history-report {
  --chr-ink: #18375f;
  --chr-muted: #627794;
  --chr-violet: #2d7ff0;
  --chr-violet-dark: #165fc9;
  --chr-violet-soft: #eaf3ff;
  --chr-line: #d9e6f8;
  --chr-canvas: #f1f6ff;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #fff;
  color: var(--chr-ink);
  box-shadow: none;
}

.clinical-history-report::backdrop { background: rgba(21, 75, 150, .42); backdrop-filter: blur(5px); }
.clinical-history-report[open] { display: block; }
.clinical-history-report .app-icon { width: 20px; height: 20px; }
.clinical-history-report [hidden] { display: none !important; }

.clinical-history-report__shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; background: #fff; }
.clinical-history-report__header { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 28px; border-bottom: 1px solid var(--chr-line); background: linear-gradient(112deg, #fff 0%, #f4f8ff 65%, #e4efff 100%); }
.clinical-history-report__heading { display: flex; align-items: center; gap: 14px; }
.clinical-history-report__heading-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; color: #fff; background: linear-gradient(145deg, #4b9cff, #216bd5); box-shadow: 0 10px 24px rgba(33, 107, 213, .25); }
.clinical-history-report__heading-icon .app-icon { width: 26px; height: 26px; }
.clinical-history-report__heading p { margin: 0 0 2px; color: var(--chr-violet-dark); font-size: 12px; font-weight: 900; letter-spacing: .14em; }
.clinical-history-report__heading h2 { margin: 0; font-size: 28px; line-height: 1.1; }
.clinical-history-report__heading div > span { display: block; margin-top: 4px; color: var(--chr-muted); font-size: 16px; }
.clinical-history-report__header-actions { display: flex; align-items: center; gap: 12px; }
.clinical-history-report__privacy { display: flex; align-items: center; gap: 7px; padding: 9px 13px; border: 1px solid #cfe0fb; border-radius: 999px; color: #2163ba; background: #f1f6ff; font-size: 14px; font-weight: 800; }
.clinical-history-report__privacy .app-icon { width: 16px; height: 16px; }
.clinical-history-report__header-actions > button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #ded9e4; border-radius: 13px; color: #6b6574; background: rgba(255,255,255,.82); cursor: pointer; }
.clinical-history-report__header-actions > button:hover { color: #fff; border-color: #216bd5; background: #216bd5; }

.clinical-history-report__workspace { min-height: 0; display: grid; grid-template-columns: minmax(410px, 470px) minmax(680px, 1fr); }
.clinical-history-report__controls { min-height: 0; overflow: auto; padding: 22px; border-right: 1px solid var(--chr-line); background: #f8fbff; scrollbar-width: thin; scrollbar-color: #a7c5f5 transparent; }
.clinical-history-report__control-intro { padding: 16px; border: 1px solid #cfe0fb; border-radius: 18px; background: linear-gradient(135deg, #fff, #edf4ff); box-shadow: 0 8px 22px rgba(38, 101, 194, .08); }
.clinical-history-report__control-intro > div { display: flex; align-items: flex-start; gap: 11px; }
.clinical-history-report__control-intro > div > span { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; color: var(--chr-violet-dark); background: #dceaff; }
.clinical-history-report__control-intro strong { display: block; font-size: 17px; }
.clinical-history-report__control-intro small { display: block; margin-top: 3px; color: var(--chr-muted); font-size: 14px; line-height: 1.4; }
.clinical-history-report__control-intro > b { display: inline-block; margin: 11px 0 0 49px; padding: 6px 10px; border-radius: 999px; color: var(--chr-violet-dark); background: #dfebff; font-size: 13px; letter-spacing: .04em; }

.clinical-history-report__control-group { margin-top: 15px; padding: 15px; border: 1px solid #ebe7ee; border-radius: 18px; background: #fff; }
.clinical-history-report__control-group > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.clinical-history-report__control-group > header span { color: #564b61; font-size: 12px; font-weight: 900; letter-spacing: .12em; }
.clinical-history-report__control-group > header small { color: #9290a0; font-size: 12px; }
.clinical-history-report__date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.clinical-history-report__date-grid label,
.clinical-history-report__select,
.clinical-history-report__signature-settings > label { display: grid; gap: 5px; color: #615b69; font-size: 13px; font-weight: 800; }
.clinical-history-report__date-grid input,
.clinical-history-report__select select,
.clinical-history-report__signature-settings select { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #ded9e4; border-radius: 10px; color: var(--chr-ink); background: #fff; font: inherit; font-size: 14px; }
.clinical-history-report__select { margin-top: 9px; }

.clinical-history-report__switch-list { display: grid; gap: 8px; }
.clinical-history-report__switch-list > label,
.clinical-history-report__signature-toggle { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr) 44px; align-items: center; gap: 11px; min-height: 62px; padding: 10px 11px; border: 1px solid #eeebf0; border-radius: 13px; background: #fdfcfe; cursor: pointer; }
.clinical-history-report__switch-list > label:hover,
.clinical-history-report__signature-toggle:hover { border-color: #d7c5e1; background: #fcf8fe; }
.clinical-history-report__switch-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; }
.clinical-history-report__switch-icon .app-icon { width: 19px; height: 19px; }
.clinical-history-report__switch-icon.is-violet { color: #216bd5; background: #e1edff; }
.clinical-history-report__switch-icon.is-blue { color: #3767aa; background: #e9f0fb; }
.clinical-history-report__switch-icon.is-teal { color: #21786d; background: #e5f6f2; }
.clinical-history-report__switch-icon.is-slate { color: #5e6878; background: #edf0f4; }
.clinical-history-report__switch-icon.is-cyan { color: #237898; background: #e6f5fa; }
.clinical-history-report__switch-icon.is-amber { color: #a66b12; background: #fff3d9; }
.clinical-history-report__switch-icon.is-rose { color: #a34866; background: #fae8ef; }
.clinical-history-report__switch-list b,
.clinical-history-report__signature-toggle b { display: block; color: #393442; font-size: 15px; }
.clinical-history-report__switch-list small,
.clinical-history-report__signature-toggle small { display: block; margin-top: 3px; color: #858090; font-size: 13px; line-height: 1.35; }
.clinical-history-report__switch-list input,
.clinical-history-report__signature-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.clinical-history-report__switch-list label > i,
.clinical-history-report__signature-toggle > i { position: relative; width: 40px; height: 24px; border-radius: 999px; background: #d7d3db; transition: .2s ease; }
.clinical-history-report__switch-list label > i::after,
.clinical-history-report__signature-toggle > i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .2s ease; }
.clinical-history-report__switch-list input:checked + i,
.clinical-history-report__signature-toggle input:checked + i { background: linear-gradient(90deg, #4b9cff, #216bd5); }
.clinical-history-report__switch-list input:checked + i::after,
.clinical-history-report__signature-toggle input:checked + i::after { transform: translateX(16px); }
.clinical-history-report__switch-list input:focus-visible + i,
.clinical-history-report__signature-toggle input:focus-visible + i { outline: 3px solid rgba(45, 127, 240, .28); outline-offset: 2px; }
.clinical-history-report__observation { display: grid; gap: 6px; margin-top: 10px; color: #615b69; font-size: 13px; font-weight: 800; }
.clinical-history-report__observation textarea { min-height: 82px; resize: vertical; padding: 11px; border: 1px solid #ded9e4; border-radius: 11px; color: var(--chr-ink); background: #fff; font: inherit; font-size: 14px; line-height: 1.45; }

.clinical-history-report__signature-option + .clinical-history-report__signature-option { margin-top: 9px; }
.clinical-history-report__signature-settings { margin: -2px 8px 0; padding: 11px; border: 1px solid #eee8f1; border-top: 0; border-radius: 0 0 12px 12px; background: #faf8fc; }
.clinical-history-report__draw { position: relative; margin-top: 11px; overflow: hidden; border: 2px dashed #91b8ef; border-radius: 13px; background: #fff; }
.clinical-history-report__draw canvas { display: block; width: 100%; height: 180px; touch-action: none; cursor: crosshair; }
.clinical-history-report__draw button { position: absolute; right: 7px; bottom: 7px; display: flex; align-items: center; gap: 5px; padding: 7px 9px; border: 1px solid #dfd8e4; border-radius: 8px; color: #6d6373; background: rgba(255,255,255,.92); font-size: 12px; font-weight: 800; cursor: pointer; }
.clinical-history-report__draw button .app-icon { width: 13px; height: 13px; }
.clinical-history-report__safe-note { display: flex; gap: 10px; margin-top: 15px; padding: 13px; border: 1px solid #d9e6ee; border-radius: 15px; color: #365b6c; background: #f2f9fc; }
.clinical-history-report__safe-note > .app-icon { flex: 0 0 auto; width: 19px; height: 19px; }
.clinical-history-report__safe-note p { margin: 0; }
.clinical-history-report__safe-note strong { display: block; font-size: 14px; }
.clinical-history-report__safe-note span { display: block; margin-top: 3px; font-size: 13px; line-height: 1.45; }

.clinical-history-report__preview { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--chr-canvas); }
.clinical-history-report__preview-bar { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 28px; border-bottom: 1px solid #d9e6f8; color: #516d93; background: rgba(255,255,255,.82); }
.clinical-history-report__preview-bar > div { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .1em; }
.clinical-history-report__preview-bar > span { font-size: 13px; }
.clinical-history-report__live-dot { width: 9px; height: 9px; border-radius: 50%; background: #398ef4; box-shadow: 0 0 0 4px rgba(57,142,244,.14); }
.clinical-history-report__paper-stage { min-height: 0; overflow: auto; padding: 34px 42px 54px; }
.clinical-history-report__loading { width: min(760px, 100%); margin: 80px auto; padding: 32px; border-radius: 18px; color: #746d7b; background: #fff; text-align: center; box-shadow: 0 8px 30px rgba(42,37,52,.08); }
.clinical-history-report__paper { box-sizing: border-box; width: min(794px, 100%); min-height: 1123px; margin: 0 auto; padding: 46px 50px 34px; color: #202735; background: #fff; box-shadow: 0 14px 38px rgba(37,32,47,.14); }
.clinical-history-report__paper.is-pdf-exporting { width: 794px; max-width: none; min-height: 1123px; margin: 0; box-shadow: none; }
.clinical-history-report__paper-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 3px solid #2d7ff0; }
.clinical-history-report__paper-header > div:first-child { display: block; }
.clinical-history-report__paper-header strong { display: block; font-size: 19px; }
.clinical-history-report__paper-header small { display: block; margin-top: 4px; color: #526f9b; font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.clinical-history-report__paper-header > div:last-child { text-align: right; }
.clinical-history-report__paper-header > div:last-child > span { display: block; color: #8a8490; font-size: 12px; font-weight: 900; letter-spacing: .1em; }
.clinical-history-report__paper-header time { display: block; margin-top: 3px; font-size: 14px; font-weight: 800; }
.clinical-history-report__paper-header > div:last-child small { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; letter-spacing: .04em; }
.clinical-history-report__patient { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr); gap: 22px; margin-top: 22px; padding: 18px 20px; border: 1px solid #d5e4fb; border-radius: 14px; background: #f3f8ff; }
.clinical-history-report__patient small { color: #216bd5; font-size: 12px; font-weight: 900; letter-spacing: .12em; }
.clinical-history-report__patient h3 { margin: 5px 0 4px; font-size: 24px; line-height: 1.15; }
.clinical-history-report__patient > div > span { color: #6b6871; font-size: 14px; }
.clinical-history-report__patient dl { display: grid; align-content: center; gap: 7px; margin: 0; padding-left: 20px; border-left: 1px solid #ded4e4; }
.clinical-history-report__patient dl div { display: grid; grid-template-columns: 78px 1fr; gap: 8px; }
.clinical-history-report__patient dt { color: #7e7883; font-size: 12px; }
.clinical-history-report__patient dd { margin: 0; font-size: 13px; font-weight: 800; }
.clinical-history-report__scope { display: grid; grid-template-columns: 1.5fr .8fr 1fr; gap: 1px; margin: 16px 0 22px; overflow: hidden; border: 1px solid #e5e2e8; border-radius: 11px; background: #e5e2e8; }
.clinical-history-report__scope div { padding: 10px 12px; background: #fff; }
.clinical-history-report__scope span { display: block; color: #8a8590; font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.clinical-history-report__scope strong { display: block; margin-top: 3px; font-size: 13px; }
.clinical-history-report__entries { display: grid; gap: 11px; }
.clinical-history-report__entry { break-inside: avoid; padding: 14px 16px; border: 1px solid #dfe8f7; border-left: 4px solid #398ef4; border-radius: 10px; }
.clinical-history-report__entry > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.clinical-history-report__entry-date { display: flex; align-items: center; gap: 8px; }
.clinical-history-report__entry-date > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: #216bd5; background: #e8f1ff; }
.clinical-history-report__entry-date .app-icon { width: 14px; height: 14px; }
.clinical-history-report__entry-date strong { display: block; font-size: 14px; }
.clinical-history-report__entry-date small { display: block; margin-top: 2px; color: #77727d; font-size: 12px; }
.clinical-history-report__entry-professional { max-width: 260px; color: #67616c; font-size: 12px; text-align: right; }
.clinical-history-report__entry-type { display: inline-flex; margin: 0 0 7px; padding: 4px 8px; border-radius: 999px; color: #275fa8; background: #eaf3ff; font-size: 12px; font-weight: 850; }
.clinical-history-report__entry h4 { margin: 0 0 6px; color: #2a2630; font-size: 16px; }
.clinical-history-report__entry-description { color: #3e3a43; font-size: 14px; line-height: 1.55; }
.clinical-history-report__entry-description:empty { display: none; }
.clinical-history-report__entry-description p { margin: 0 0 5px; }
.clinical-history-report__entry-description p:last-child { margin-bottom: 0; }
.clinical-history-report__entry-fields { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.clinical-history-report__entry-fields span { display: inline-flex; gap: 4px; padding: 6px 8px; border-radius: 6px; color: #57515d; background: #f5f3f6; font-size: 12px; }
.clinical-history-report__entry-fields b { color: #302a35; }
.clinical-history-report__entry-medication { margin: 8px 0 0; padding: 9px 11px; border-radius: 7px; color: #2f5f57; background: #edf8f5; font-size: 13px; line-height: 1.45; }
.clinical-history-report__empty { padding: 32px; border: 1px dashed #d6cbdc; border-radius: 12px; color: #77717d; background: #fcfafc; text-align: center; font-size: 14px; }
.clinical-history-report__paper-observation { break-inside: avoid; margin-top: 20px; padding: 14px 16px; border: 1px solid #dfd8e4; border-radius: 10px; }
.clinical-history-report__paper-observation h4 { margin: 0 0 7px; color: #216bd5; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; }
.clinical-history-report__paper-observation p { min-height: 32px; margin: 0; color: #45404a; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.clinical-history-report__signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; margin-top: 38px; break-inside: avoid; }
.clinical-history-report__signatures article { text-align: center; }
.clinical-history-report__signature-space { height: 105px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px; border-bottom: 1px solid #64606a; }
.clinical-history-report__signature-space img { max-width: 230px; max-height: 96px; object-fit: contain; }
.clinical-history-report__signatures strong { display: block; margin-top: 7px; font-size: 13px; }
.clinical-history-report__signatures article > span { display: block; margin-top: 2px; color: #77717d; font-size: 12px; }
.clinical-history-report__paper-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 38px; padding-top: 10px; border-top: 1px solid #e2dfe4; color: #8a8490; font-size: 12px; }

.clinical-history-report__footer { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 20px; border-top: 1px solid var(--chr-line); background: #fff; }
.clinical-history-report__footer > p { display: flex; align-items: center; gap: 7px; margin: 0; color: #747080; font-size: 13px; }
.clinical-history-report__footer > p .app-icon { width: 16px; height: 16px; color: #216bd5; }
.clinical-history-report__footer > div { display: flex; gap: 9px; }
.clinical-history-report__footer button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 19px; border-radius: 12px; font-size: 13px; font-weight: 900; letter-spacing: .04em; cursor: pointer; }
.clinical-history-report__footer button:disabled { opacity: .5; cursor: wait; }
.clinical-history-report__close { border: 1px solid #ddd8e2; color: #6c6672; background: #fff; }
.clinical-history-report__print { border: 1px solid #abc8f3; color: #216bd5; background: #f2f7ff; }
.clinical-history-report__pdf { border: 0; color: #fff; background: linear-gradient(135deg, #4b9cff, #216bd5); box-shadow: 0 8px 20px rgba(33, 107, 213, .27); }
.clinical-history-report__footer button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(.98); }

@media (max-width: 1040px) {
  .clinical-history-report__workspace { grid-template-columns: minmax(370px, 410px) minmax(520px, 1fr); }
  .clinical-history-report__paper-stage { padding-inline: 18px; }
  .clinical-history-report__paper { padding-inline: 36px; }
}

@media (max-width: 820px) {
  .clinical-history-report { width: 100vw; height: 100vh; border-radius: 0; }
  .clinical-history-report__workspace { display: block; overflow: auto; }
  .clinical-history-report__controls { max-height: none; overflow: visible; border-right: 0; border-bottom: 1px solid var(--chr-line); }
  .clinical-history-report__preview { min-height: 760px; }
  .clinical-history-report__header { padding-inline: 14px; }
  .clinical-history-report__privacy { display: none; }
  .clinical-history-report__footer { align-items: stretch; flex-direction: column; }
  .clinical-history-report__footer > div { display: grid; grid-template-columns: 1fr 1fr; }
  .clinical-history-report__footer .clinical-history-report__close { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .clinical-history-report__heading h2 { font-size: 24px; }
  .clinical-history-report__heading-icon { width: 42px; height: 42px; }
  .clinical-history-report__date-grid { grid-template-columns: 1fr; }
  .clinical-history-report__paper-stage { padding: 12px 6px 30px; }
  .clinical-history-report__paper { min-height: 0; padding: 28px 20px; }
  .clinical-history-report__draw canvas { height: 150px; }
  .clinical-history-report__patient { grid-template-columns: 1fr; }
  .clinical-history-report__patient dl { padding: 12px 0 0; border-top: 1px solid #ded4e4; border-left: 0; }
  .clinical-history-report__scope { grid-template-columns: 1fr; }
  .clinical-history-report__signatures { grid-template-columns: 1fr; }
}

@page clinical-history-report { size: A4 portrait; margin: 12mm; }

@media print {
  body.clinical-history-report-printing > :not(.clinical-history-report) { display: none !important; }
  body.clinical-history-report-printing { background: #fff !important; }
  body.clinical-history-report-printing .clinical-history-report { position: static; display: block !important; width: auto; height: auto; margin: 0; overflow: visible; border-radius: 0; box-shadow: none; }
  body.clinical-history-report-printing .clinical-history-report::backdrop,
  body.clinical-history-report-printing .clinical-history-report__header,
  body.clinical-history-report-printing .clinical-history-report__controls,
  body.clinical-history-report-printing .clinical-history-report__preview-bar,
  body.clinical-history-report-printing .clinical-history-report__footer,
  body.clinical-history-report-printing .clinical-history-report__loading { display: none !important; }
  body.clinical-history-report-printing .clinical-history-report__shell,
  body.clinical-history-report-printing .clinical-history-report__workspace,
  body.clinical-history-report-printing .clinical-history-report__preview,
  body.clinical-history-report-printing .clinical-history-report__paper-stage { display: block; width: auto; height: auto; min-height: 0; overflow: visible; padding: 0; background: #fff; }
  body.clinical-history-report-printing .clinical-history-report__paper { page: clinical-history-report; display: block !important; width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  body.clinical-history-report-printing .clinical-history-report__entry,
  body.clinical-history-report-printing .clinical-history-report__paper-observation,
  body.clinical-history-report-printing .clinical-history-report__signatures { break-inside: avoid; page-break-inside: avoid; }
  body.clinical-history-report-printing .clinical-history-report__paper-header { break-after: avoid; page-break-after: avoid; }
  body.clinical-history-report-printing .clinical-history-report__paper-footer { break-before: avoid; page-break-before: avoid; }
}
