/* Historia clínica de Fichas. Todo selector queda contenido en la vista del paciente. */
.legacy-record-view .legacy-record-grid:not(.is-history-editing) .legacy-module-tabs:has(> button[data-module="history"].is-active) {
  position: relative;
  z-index: 2;
  margin-bottom: -14px;
  border-radius: 8px 8px 0 0;
}

.legacy-record-view .legacy-record-grid:not(.is-history-editing) .legacy-module-tabs:has(> button[data-module="history"].is-active) + #historyPanel:not([hidden]) {
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.legacy-record-view #historyPanel:not(.is-creating) {
  container-type: inline-size;
  border-color: #d7e2f0;
  background: #f8faff;
  box-shadow: 0 18px 38px rgba(29, 57, 99, .13);
}

.legacy-record-view #historyPanel:not(.is-creating) .history-card-controls {
  min-height: 76px;
  margin-bottom: 0;
  padding-top: 15px;
  padding-bottom: 15px;
  border-bottom-color: #dce5ef;
  box-shadow: 0 4px 12px rgba(32, 59, 104, .06);
}

.legacy-record-view #historyPanel .history-report-button,
.legacy-record-view #historyPanel .history-new-button {
  transition: color .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.legacy-record-view #historyPanel .history-report-button {
  border-color: #b9d1fa;
  color: #225fbf;
  background: #edf4ff;
  box-shadow: 0 5px 14px rgba(33, 107, 213, .12);
}

.legacy-record-view #historyPanel .history-report-button:hover:not(:disabled) {
  border-color: #216bd5;
  color: #fff;
  background: #2f75e8;
  box-shadow: 0 8px 18px rgba(33, 107, 213, .24);
  transform: translateY(-2px);
}

.legacy-record-view #historyPanel .history-report-button:hover:not(:disabled) > small {
  color: #225fbf;
  background: #fff;
}

.legacy-record-view #historyPanel .history-new-button {
  min-height: 46px;
  border: 1px solid rgba(61, 45, 181, .72);
  color: #fff;
  background: linear-gradient(115deg, #2f75e8 0%, #4f61e5 48%, #7438df 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .30), 0 0 0 3px rgba(94, 72, 218, .09), 0 8px 18px rgba(62, 48, 177, .26);
  cursor: pointer;
}

.legacy-record-view #historyPanel .history-new-button:hover {
  border-color: rgba(65, 42, 190, .82);
  color: #fff;
  background: linear-gradient(115deg, #2684f5 0%, #584ee2 46%, #8135e2 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .34), 0 0 0 4px rgba(94, 72, 218, .11), 0 11px 22px rgba(62, 48, 177, .31);
  transform: translateY(-2px);
}

.legacy-record-view #historyPanel .history-report-button:active:not(:disabled),
.legacy-record-view #historyPanel .history-new-button:active:not(:disabled) {
  box-shadow: 0 3px 9px rgba(42, 47, 118, .20);
  transform: translateY(1px) scale(.985);
  transition-duration: .06s;
}

.legacy-record-view #historyPanel .history-report-button:focus-visible,
.legacy-record-view #historyPanel .history-new-button:focus-visible {
  outline: 3px solid rgba(47, 117, 232, .26);
  outline-offset: 3px;
}

.legacy-record-view #historyPanel .legacy-timeline {
  max-height: 650px;
  padding: 29px 22px 31px 62px;
  color: #203b68;
  background: radial-gradient(circle at 100% 0, rgba(47, 117, 232, .07), transparent 31%), #f8faff;
  scrollbar-color: #8eaae0 #eef3f9;
}

.legacy-record-view #historyPanel .history-entry {
  --history-entry-accent: #718096;
  --history-entry-ink: #475569;
  --history-entry-soft: #f1f5f9;
  margin-bottom: 19px;
  padding: 18px 20px;
  border: 1px solid #dbe4ef;
  border-left: 5px solid var(--history-entry-accent);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 7px 18px rgba(32, 59, 104, .07);
  container-type: inline-size;
  transition: box-shadow .18s ease, transform .18s ease;
}

.legacy-record-view #historyPanel .history-entry[data-attention-color="VIOLET"] {
  --history-entry-accent: #6d52e8;
  --history-entry-ink: #4936aa;
  --history-entry-soft: #f0edff;
}

.legacy-record-view #historyPanel .history-entry[data-attention-color="TEAL"] {
  --history-entry-accent: #00a9d2;
  --history-entry-ink: #00657c;
  --history-entry-soft: #e7faff;
}

.legacy-record-view #historyPanel .history-entry[data-attention-color="AMBER"] {
  --history-entry-accent: #f2ad2e;
  --history-entry-ink: #865800;
  --history-entry-soft: #fff7e6;
}

.legacy-record-view #historyPanel .history-entry[data-attention-color="RED"] {
  --history-entry-accent: #eb4d6d;
  --history-entry-ink: #a32143;
  --history-entry-soft: #fff0f4;
}

.legacy-record-view #historyPanel .history-entry[data-attention-color="GREEN"] {
  --history-entry-accent: #57b83b;
  --history-entry-ink: #35771f;
  --history-entry-soft: #effae9;
}

.legacy-record-view #historyPanel .history-entry[data-attention-color="BLUE"] {
  --history-entry-accent: #2788ef;
  --history-entry-ink: #145baa;
  --history-entry-soft: #eaf4ff;
}

.legacy-record-view #historyPanel .history-entry[data-attention-color="INDIGO"] {
  --history-entry-accent: #4f68dd;
  --history-entry-ink: #3349a4;
  --history-entry-soft: #edf0ff;
}

.legacy-record-view #historyPanel .history-entry[data-attention-color="EMERALD"] {
  --history-entry-accent: #00715c;
  --history-entry-ink: #005244;
  --history-entry-soft: #e5f5f1;
}

.legacy-record-view #historyPanel .history-entry:hover {
  box-shadow: 0 12px 24px rgba(32, 59, 104, .12);
  transform: translateY(-2px);
}

.legacy-record-view #historyPanel .history-entry:last-child {
  margin-bottom: 0;
}

.legacy-record-view #historyPanel .history-entry::before {
  top: -22px;
  bottom: -22px;
  left: -35px;
  width: 3px;
  border-radius: 999px;
  background: var(--history-entry-accent);
  transform: translateX(-50%);
}

.legacy-record-view #historyPanel .history-entry:first-child::before {
  top: 50%;
}

.legacy-record-view #historyPanel .history-entry:last-child::before {
  bottom: 50%;
}

.legacy-record-view #historyPanel .history-entry-dot {
  top: 50%;
  left: -35px;
  width: 19px;
  height: 19px;
  border: 4px solid #fff;
  background: var(--history-entry-accent);
  box-shadow: 0 0 0 3px var(--history-entry-accent), 0 4px 10px rgba(32, 59, 104, .18);
  transform: translate(-50%, -50%);
}

.legacy-record-view #historyPanel .history-entry > header {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  min-height: 36px;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.legacy-record-view #historyPanel .history-entry time {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--history-entry-ink);
  background: var(--history-entry-soft);
  font-size: 13px;
}

.legacy-record-view #historyPanel .history-entry-heading-end {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 13px;
}

.legacy-record-view #historyPanel .history-entry-professional {
  min-width: 0;
  color: #6b7788;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: break-word;
  text-align: right;
}

.legacy-record-view #historyPanel .history-entry-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  margin-top: 15px;
}

.legacy-record-view #historyPanel .history-entry-type {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 999px;
  color: var(--history-entry-ink);
  background: var(--history-entry-soft);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.legacy-record-view #historyPanel .history-entry-title-row h3 {
  min-width: 0;
  margin: 0;
  color: #203b68;
  font-size: 20px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.legacy-record-view #historyPanel .history-entry-summary {
  display: -webkit-box;
  margin: 12px 0 0;
  padding: 0;
  overflow: hidden;
  color: #53647a;
  background: transparent;
  font-size: 15px;
  line-height: 1.55;
  text-align: left;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.legacy-record-view #historyPanel .history-entry.is-unclassified .history-entry-type {
  letter-spacing: 0;
  text-transform: none;
}

@container (max-width: 720px) {
  .legacy-record-view #historyPanel:not(.is-creating) .history-card-controls {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 8px;
  }

  .legacy-record-view #historyPanel .history-report-button,
  .legacy-record-view #historyPanel .history-new-button {
    width: 100%;
    justify-self: stretch;
  }

  .legacy-record-view #historyPanel .history-report-button {
    justify-content: flex-start;
  }

  .legacy-record-view #historyPanel .history-report-button > span {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
}

@container (min-width: 560px) {
  .legacy-record-view #historyPanel .history-entry-title-row {
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    gap: 12px;
  }
}

@container (max-width: 420px) {
  .legacy-record-view #historyPanel .history-entry > header {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .legacy-record-view #historyPanel .history-entry-heading-end {
    justify-content: space-between;
  }

  .legacy-record-view #historyPanel .history-entry-professional {
    text-align: left;
  }
}

.legacy-record-view #historyPanel .history-attention-type-card {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
  padding: 18px;
  border: 1px solid #d9e2ef;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff, #f7f9ff);
  box-shadow: 0 5px 15px rgba(32, 59, 104, .06);
}

.legacy-record-view #historyPanel .history-attention-type-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #253b60;
  font-size: 15px;
}

.legacy-record-view #historyPanel .history-attention-type-heading strong {
  font-size: 15px;
  font-weight: 900;
}

.legacy-record-view #historyPanel .history-attention-type-heading > b {
  color: #d83d68;
  font-size: 17px;
  line-height: 1;
}

.legacy-record-view #historyPanel .history-attention-type-heading .app-icon {
  width: 19px;
  height: 19px;
  color: #5b5edc;
}

.legacy-record-view #historyPanel .history-attention-type-card > p,
.legacy-record-view #historyPanel .history-attention-type-card > small {
  margin: 0;
  color: #68778c;
  font-size: 13px;
  line-height: 1.5;
}

.legacy-record-view #historyPanel .history-attention-type-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.legacy-record-view #historyPanel .history-attention-type-option {
  --attention-option-accent: #718096;
  --attention-option-ink: #475569;
  --attention-option-soft: #f1f5f9;
  min-width: 0;
  cursor: pointer;
}

.legacy-record-view #historyPanel .history-attention-type-option[data-attention-color="VIOLET"] {
  --attention-option-accent: #6d52e8;
  --attention-option-ink: #4936aa;
  --attention-option-soft: #f0edff;
}

.legacy-record-view #historyPanel .history-attention-type-option[data-attention-color="TEAL"] {
  --attention-option-accent: #00a9d2;
  --attention-option-ink: #00657c;
  --attention-option-soft: #e7faff;
}

.legacy-record-view #historyPanel .history-attention-type-option[data-attention-color="AMBER"] {
  --attention-option-accent: #f2ad2e;
  --attention-option-ink: #865800;
  --attention-option-soft: #fff7e6;
}

.legacy-record-view #historyPanel .history-attention-type-option[data-attention-color="RED"] {
  --attention-option-accent: #eb4d6d;
  --attention-option-ink: #a32143;
  --attention-option-soft: #fff0f4;
}

.legacy-record-view #historyPanel .history-attention-type-option[data-attention-color="GREEN"] {
  --attention-option-accent: #57b83b;
  --attention-option-ink: #35771f;
  --attention-option-soft: #effae9;
}

.legacy-record-view #historyPanel .history-attention-type-option[data-attention-color="BLUE"] {
  --attention-option-accent: #2788ef;
  --attention-option-ink: #145baa;
  --attention-option-soft: #eaf4ff;
}

.legacy-record-view #historyPanel .history-attention-type-option[data-attention-color="INDIGO"] {
  --attention-option-accent: #4f68dd;
  --attention-option-ink: #3349a4;
  --attention-option-soft: #edf0ff;
}

.legacy-record-view #historyPanel .history-attention-type-option[data-attention-color="EMERALD"] {
  --attention-option-accent: #00715c;
  --attention-option-ink: #005244;
  --attention-option-soft: #e5f5f1;
}

.legacy-record-view #historyPanel .history-attention-type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.legacy-record-view #historyPanel .history-attention-type-option > span {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid #dce3ed;
  border-radius: 10px;
  color: #536276;
  background: #fff;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}

.legacy-record-view #historyPanel .history-attention-type-option i {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
  background: var(--attention-option-accent);
  box-shadow: 0 0 0 4px var(--attention-option-soft);
}

.legacy-record-view #historyPanel .history-attention-type-option strong {
  color: #34455e;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
}

.legacy-record-view #historyPanel .history-attention-type-option:hover > span {
  border-color: var(--attention-option-accent);
  transform: translateY(-1px);
}

.legacy-record-view #historyPanel .history-attention-type-option input:checked + span {
  border-color: var(--attention-option-accent);
  color: var(--attention-option-ink);
  background: var(--attention-option-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--attention-option-accent) 16%, transparent);
}

.legacy-record-view #historyPanel .history-attention-type-option input:checked + span strong {
  color: var(--attention-option-ink);
}

.legacy-record-view #historyPanel .history-attention-type-option input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--attention-option-accent) 24%, transparent);
  outline-offset: 2px;
}

.legacy-record-view #historyPanel .history-entry-edit {
  color: #6557e8;
}

.legacy-record-view #historyPanel .history-entry-edit:hover,
.legacy-record-view #historyPanel .history-entry-edit:focus-visible {
  color: #fff;
  background: #6557e8;
}

@media (max-width: 620px) {
  .legacy-record-view #historyPanel .legacy-timeline {
    padding-right: 12px;
    padding-left: 47px;
  }

  .legacy-record-view #historyPanel .history-entry {
    padding: 16px 14px;
  }

  .legacy-record-view #historyPanel .history-entry::before,
  .legacy-record-view #historyPanel .history-entry-dot {
    left: -27px;
  }

  .legacy-record-view #historyPanel .history-entry > header,
  .legacy-record-view #historyPanel .history-entry-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .legacy-record-view #historyPanel .history-entry-heading-end {
    width: 100%;
    justify-content: space-between;
  }

  .legacy-record-view #historyPanel .history-attention-type-options {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 621px) and (max-width: 980px) {
  .legacy-record-view #historyPanel .history-attention-type-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .legacy-record-view #historyPanel .history-entry,
  .legacy-record-view #historyPanel .history-report-button,
  .legacy-record-view #historyPanel .history-new-button {
    transition: none;
  }
}
