/* Estilos comunes de las escalas locales (misma paleta que la presentación de geriatría) */
:root {
  --teal: #1F5460; --teal-mid: #2E7D84; --sage: #A8CBB7; --sage-light: #EAF3EE;
  --coral: #D9674A; --coral-light: #FBE7E0; --ink: #1E2A2E; --muted: #5F6E72;
  --line: #D5E3DC; --bg: #F7FAF8; --card: #FFFFFF; --chip: #E6ECEA;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--teal-mid); }
header { background: var(--teal); color: #fff; padding: 22px 24px 20px; }
header .wrap { max-width: 1180px; margin: 0 auto; }
header .back { color: var(--sage); font-size: 14px; text-decoration: none; }
header .back:hover { text-decoration: underline; }
header h1 { margin: 6px 0 4px; font: 700 28px/1.2 Cambria, Georgia, serif; }
header p { margin: 0; color: var(--sage); }
.layout { max-width: 1180px; margin: 0 auto; padding: 24px; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
section.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; margin-bottom: 20px; }
h2 { margin: 0 0 4px; font: 700 20px/1.3 Cambria, Georgia, serif; color: var(--teal); }
h3.sub { margin: 22px 0 6px; font-size: 16px; color: var(--teal-mid); }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.intro p:first-child { margin-top: 0; }
.req { color: var(--coral); }
details { font-size: 14px; color: var(--muted); }
details summary { cursor: pointer; color: var(--teal); font-weight: 600; }
details ol { padding-left: 20px; }

/* Preguntas */
.item { padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.item[hidden] { display: none !important; }
.q { font-weight: 600; margin-bottom: 8px; }
.q .ayuda { display: block; font-weight: 400; color: var(--muted); font-size: 14px; }
.nota-item { color: var(--muted); font-size: 14.5px; background: var(--sage-light); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.options { display: grid; gap: 8px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { display: grid; grid-template-columns: 26px auto; gap: 10px; align-items: start; padding: 8px 14px 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; transition: background .12s, border-color .12s; }
.options .opt { grid-template-columns: 32px 1fr auto; padding: 10px 14px; }
.opt:hover { background: var(--sage-light); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .num { width: 24px; height: 24px; border-radius: 6px; background: var(--chip); color: var(--teal);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.options .opt .num { width: 28px; height: 28px; font-size: 14px; }
.opt .stage { font-size: 12px; color: var(--muted); white-space: nowrap; padding-top: 4px; }
.opt:has(input:checked) { border-color: var(--teal); background: var(--sage-light); box-shadow: 0 0 0 1px var(--teal) inset; }
.opt:has(input:checked) .num { background: var(--teal); color: #fff; }
.opt:has(input:focus-visible) { outline: 3px solid var(--coral); outline-offset: 2px; }
.item.falta .q { color: #B23B22; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
label.f { display: block; font-size: 14px; font-weight: 600; }
label.f input, .item input[type=text], .item input[type=number], .item input[type=date], textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; font-weight: 400;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.item input[type=number] { max-width: 220px; }
textarea { min-height: 80px; resize: vertical; }
.datos-extra .item { border-top: 0; padding: 10px 0 0; }

/* Resultado */
aside { position: sticky; top: 16px; }
@media (max-width: 900px) { aside { position: static; } }
.result { background: var(--teal); color: #fff; border-radius: 12px; padding: 22px; }
.result .label { color: var(--sage); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.result .big { font: 700 52px/1 Cambria, Georgia, serif; margin: 6px 0 4px; }
.result .big small { font-size: 22px; color: var(--sage); font-weight: 400; }
.result .cat { font-size: 20px; font-weight: 700; }
.result p { margin: 10px 0 0; color: #E4EFEA; font-size: 15px; }
.result .empty { color: var(--sage); }
.result table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 14px; color: #E4EFEA; }
.result td { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.15); }
.result td:last-child { text-align: right; font-weight: 700; color: #fff; }
.pill { display: inline-block; margin-top: 12px; padding: 4px 10px; border-radius: 999px; background: var(--coral); font-size: 13px; font-weight: 600; }
.alerta { margin-top: 12px; background: var(--coral); color: #fff; border-radius: 8px; padding: 10px 12px; font-size: 14px; font-weight: 600; }
.parcial { margin-top: 12px; background: rgba(255,255,255,.12); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; color: var(--sage); }
.note { background: var(--coral-light); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; margin-top: 14px; color: var(--ink); }
.actions { display: grid; gap: 8px; margin-top: 16px; }
button { font: inherit; font-weight: 600; border-radius: 8px; padding: 10px 14px; cursor: pointer; border: 1px solid var(--teal); background: #fff; color: var(--teal); }
button.primary { background: var(--coral); border-color: var(--coral); color: #fff; }
button:hover { filter: brightness(.96); }
.msg { font-size: 14px; min-height: 1.4em; margin-top: 8px; }
.msg.err { color: #B23B22; }
.msg.ok { color: var(--teal-mid); }

/* Historial */
.table-wrap { overflow-x: auto; }
table.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
table.hist th, table.hist td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.hist th { color: var(--muted); font-weight: 600; white-space: nowrap; }
table.hist td button { padding: 4px 8px; font-size: 13px; }
.hist-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
footer { max-width: 1180px; margin: 0 auto; padding: 0 24px 32px; color: var(--muted); font-size: 13px; }

/* Índice */
.grid-escalas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.grid-escalas a { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; text-decoration: none; color: var(--ink); }
.grid-escalas a:hover { border-color: var(--teal); background: var(--sage-light); }
.grid-escalas strong { display: block; font: 700 18px/1.3 Cambria, Georgia, serif; color: var(--teal); margin-bottom: 4px; }
.grid-escalas span { color: var(--muted); font-size: 14px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-top: 10px; }
.tag.ger { background: var(--teal); color: #fff; }
.tag.otra { background: var(--chip); color: var(--muted); }

/* Láminas a pantalla completa */
button.lamina-btn { margin: 6px 6px 0 0; padding: 8px 12px; font-size: 14px; }
.lamina { position: fixed; inset: 0; z-index: 1000; background: #fff; display: flex; align-items: center; justify-content: center; padding: 56px 24px 24px; }
.lamina[hidden] { display: none !important; }
.lamina-grid { display: grid; gap: 16px 40px; width: 100%; max-width: 1500px; align-items: center; justify-items: center; }
.lamina figure { margin: 0; text-align: center; }
.lamina figcaption { font: 700 22px/1 Cambria, Georgia, serif; color: #444; margin-bottom: 10px; }
.lamina img { display: block; max-width: 100%; max-height: var(--h, 70vh); object-fit: contain; }
.lamina-cerrar { position: fixed; top: 12px; right: 12px; }

/* Impresión: solo el informe */
#print-report { display: none; }
@media print {
  body { background: #fff; }
  header, .layout, footer { display: none !important; }
  #print-report { display: block; padding: 0 8mm; font-size: 11pt; }
  #print-report h1 { font: 700 17pt Cambria, Georgia, serif; color: var(--teal); margin: 0 0 4pt; }
  #print-report h2 { font-size: 13pt; margin: 14pt 0 4pt; }
  #print-report table { width: 100%; border-collapse: collapse; }
  #print-report td, #print-report th { border-bottom: 1px solid #ccc; padding: 4pt 6pt; text-align: left; vertical-align: top; }
  #print-report tr { break-inside: avoid; }
}

/* =========================================================
   COMPONENTE DE BÚSQUEDA Y SELECCIÓN DE PACIENTES EN ESCALAS
   ========================================================= */
.card-eval-header {
  border-top: 4px solid var(--teal);
}
.patient-picker-container {
  margin-bottom: 8px;
}
.search-input-wrap {
  position: relative;
  margin-top: 6px;
}
.search-input-wrap input {
  width: 100%;
  padding: 11px 40px 11px 38px;
  font-size: 14.5px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.search-input-wrap input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(34, 112, 94, 0.15);
}
.search-input-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--muted);
  pointer-events: none;
}
.search-input-wrap .btn-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.search-input-wrap .btn-clear:hover {
  color: var(--ink);
}

.pacientes-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1.5px solid var(--teal-mid);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.15);
  max-height: 290px;
  overflow-y: auto;
  z-index: 1000;
}
.paciente-opt-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.paciente-opt-item:hover, .paciente-opt-item.active {
  background: var(--sage-light);
}
.paciente-opt-item:last-child {
  border-bottom: none;
}
.paciente-opt-name {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--teal);
}
.paciente-opt-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.paciente-no-results {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* Tarjeta de Paciente Seleccionado */
.paciente-seleccionado-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: #F4F8F6;
  border: 1.5px solid var(--teal-mid);
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 8px;
  box-shadow: 0 2px 6px rgba(34, 112, 94, 0.08);
}
.paciente-sel-info {
  display: flex;
  align-items: center;
  gap: 14px;
}
.paciente-sel-avatar {
  font-size: 28px;
  line-height: 1;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.paciente-sel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.paciente-sel-nombre {
  font-size: 16.5px;
  color: var(--teal);
  font-weight: 700;
}
.paciente-sel-meta {
  margin-top: 4px;
  font-size: 13.5px;
  color: #444;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.btn-cambiar-paciente {
  background: #fff !important;
  color: var(--teal) !important;
  border: 1.5px solid var(--teal) !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn-cambiar-paciente:hover {
  background: var(--sage-light) !important;
  transform: translateY(-1px);
}
.falta-destacada {
  border: 2px solid var(--coral) !important;
  border-radius: 8px;
  padding: 8px;
  background: #FFF8F6;
  animation: pulseHighlight 1s infinite alternate;
}
@keyframes pulseHighlight {
  0% { box-shadow: 0 0 0 0 rgba(224, 90, 71, 0.4); }
  100% { box-shadow: 0 0 0 6px rgba(224, 90, 71, 0.2); }
}

