/* ELEVALOS · Asistente médico en la ficha del paciente (portal profesional, sistema Armonía). */
.care-with-assistant { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
@media (min-width: 1180px) {
  /* The panel takes the window height so the answer area gets all the remaining space. */
  .care-with-assistant { grid-template-columns: minmax(0, 1fr) minmax(420px, 520px); }
  .care-with-assistant .ma-panel { position: sticky; top: 16px; height: calc(100dvh - 72px); max-height: calc(100dvh - 72px); overflow-y: auto; }
  .care-with-assistant .ma-log { flex: 1 1 0; min-height: 240px; max-height: none; }
  .care-with-assistant:has(.ma-panel.is-expanded) { grid-template-columns: minmax(280px, 0.62fr) minmax(0, 1.38fr); }
}
@media (min-width: 1500px) {
  .care-with-assistant { grid-template-columns: minmax(0, 1fr) minmax(480px, 640px); }
}
.ma-panel {
  display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0;
  background: var(--ar-surface, #fff); color: var(--ar-text, #1D2528);
  border: 1px solid var(--ar-border, #E4DED3); border-radius: var(--ar-radius-md, 18px);
  box-shadow: var(--ar-shadow, none); padding: 18px;
}
.ma-panel [hidden] { display: none !important; }
.ma-header { flex: 0 0 auto; display: flex; align-items: center; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; border-bottom: 1px solid var(--ar-border, #E4DED3); padding-bottom: 10px; }
.ma-header h2 { display: flex; align-items: center; gap: 8px; margin: 0; font: 600 1.15rem/1.3 var(--ar-display, inherit); color: var(--ar-heading, #1F3D34); }
.ma-header svg { width: 20px; height: 20px; }
.ma-patient { margin: 0; font-weight: 600; color: var(--ar-gold-text, #836332); }
.ma-scope { flex: 0 0 auto; background: var(--ar-sage-2, #EEF2EC); border-radius: var(--ar-radius-sm, 14px); padding: 10px 12px; font-size: .88rem; }
.ma-scope-summary { display: flex; gap: 6px; align-items: flex-start; margin: 0; font-weight: 600; color: var(--ar-heading, #1F3D34); }
.ma-scope-summary svg { flex: 0 0 auto; width: 16px; height: 16px; margin-top: 2px; }
.ma-scope-details { margin-top: 6px; }
.ma-scope-details summary { cursor: pointer; color: var(--ar-text-2, #5F6865); min-height: 24px; }
.ma-scope-list { display: grid; gap: 4px; margin: 6px 0 0; }
.ma-scope-list div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; }
.ma-scope-list dt { color: var(--ar-text-2, #5F6865); font-weight: 600; }
.ma-scope-list dd { margin: 0; overflow-wrap: anywhere; }
.ma-limits { margin: 8px 0 0; font-size: .8rem; }
.ma-log { flex: 0 1 auto; min-height: 0; max-height: 70vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 2px; overscroll-behavior: contain; }
.ma-turn { display: flex; flex-direction: column; gap: 8px; }
.ma-turn.is-stale .ma-answer { border-style: dashed; }
.ma-bubble { align-self: flex-end; max-width: 92%; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--ar-green, #1F3D34); color: var(--ar-on-green, #fff); white-space: pre-wrap; overflow-wrap: anywhere; }
.ma-answer { align-self: stretch; display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 4px 16px 16px 16px; background: var(--ar-surface-2, #F8F8F5); border: 1px solid var(--ar-border, #E4DED3); }
.ma-section h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: .95rem; color: var(--ar-heading, #1F3D34); }
.ma-section h3 svg { width: 16px; height: 16px; }
.ma-evidence { border-top: 1px dashed var(--ar-border-strong, #CBC3B5); padding-top: 10px; }
.ma-body { overflow-wrap: anywhere; }
.ma-body > :first-child { margin-top: 0; }
.ma-body > :last-child { margin-bottom: 0; }
.ma-body h3, .ma-body h4 { font-size: .92rem; margin: 10px 0 4px; }
.ma-cite { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; min-height: 24px; margin: 0 2px; padding: 0 6px; border: 1px solid var(--ar-border-strong, #CBC3B5); border-radius: 999px; background: var(--ar-sand, #F4EEE3); color: var(--ar-green, #1F3D34); font: 600 .75rem/1 var(--ar-body, inherit); opacity: 1; text-decoration: none; cursor: pointer; vertical-align: baseline; }
.ma-cite:hover { background: var(--ar-gold-soft, #F1E8DA); }
.ma-sources { font-size: .85rem; }
.ma-sources ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.ma-sources .text-button { text-align: left; min-height: 32px; }
.ma-warning, .ma-stale { margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--ar-gold-soft, #F1E8DA); color: var(--ar-text, #1D2528); font-size: .85rem; }
.ma-meta, .ma-question { margin: 0; font-size: .8rem; }
.ma-progress { margin: 0; color: var(--ar-text-2, #5F6865); font-style: italic; }
.ma-status:empty, .ma-feedback:empty { display: none; }
.ma-status { margin: 0; font-size: .85rem; color: var(--ar-text-2, #5F6865); }
.ma-suggestions { display: flex; flex-direction: column; gap: 8px; }
.ma-suggestion { justify-content: flex-start; text-align: left; min-height: 44px; white-space: normal; }
.ma-error { padding: 10px 12px; border-radius: 12px; border: 1px solid #B3261E; background: #FCEEEE; color: #5C1410; }
.ma-error p { margin: 4px 0; }
html[data-theme="dark"] .ma-error { background: #3A1E1C; color: #F6D6D3; border-color: #E08A83; }
.ma-form { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--ar-border, #E4DED3); padding-top: 10px; }
.ma-form label[for="ma-input"] { font-weight: 600; }
.ma-form textarea { width: 100%; resize: vertical; min-height: 56px; }
.ma-form .check { font-size: .85rem; }
.ma-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.ma-actions button { min-height: 44px; }
@media (prefers-reduced-motion: reduce) { .ma-log { scroll-behavior: auto; } }
/* Chips compactos con área táctil ampliada (≥ 44 px) sin romper la línea de texto. */
.ma-panel .ma-cite, .layout .ma-panel .text-button.ma-cite { position: relative; width: auto; min-height: 24px; height: 24px; padding: 0 6px; line-height: 1; box-shadow: none; }
.ma-panel .ma-cite::after { content: ""; position: absolute; inset: -10px -8px; }
/* Expand toggle and Word downloads. */
.ma-header .ma-expand { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 4px; color: var(--ar-green, #1F3D34); font-weight: 500; }
.ma-header .ma-expand svg { width: 16px; height: 16px; }
.ma-meta .ma-download { display: inline-flex; align-items: center; gap: 4px; color: var(--ar-green, #1F3D34); font-weight: 500; white-space: nowrap; }
.ma-meta .ma-download svg { width: 14px; height: 14px; }
@media (max-width: 1179px) {
  .ma-log { min-height: 260px; }
  .ma-header .ma-expand { display: none; }
}
.ma-tools { flex: 0 0 auto; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin-top: -4px; }
.ma-tools .text-button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: .88rem; font-weight: 500; color: var(--ar-green, #1F3D34); }
.ma-tools .text-button svg { width: 16px; height: 16px; }
.ma-tools .text-button:disabled { opacity: .55; }
/* Compact composer: the question box and Send share one row, the evidence option below. */
.ma-panel .ma-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px 10px; }
.ma-panel .ma-form textarea { grid-column: 1; grid-row: 1; }
.ma-panel .ma-form .ma-actions { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 6px; margin: 0; }
.ma-panel .ma-form .check { grid-column: 1 / -1; grid-row: 2; margin: 0; }
.ma-panel .ma-scope { padding: 8px 12px; font-size: .84rem; }
.ma-panel .ma-scope-details { margin-top: 2px; }
.ma-panel { position: relative; }
.ma-feedback:not(:has(.ma-error)) { position: absolute; }

/* Iteración UX médico: columna asistente acotada para no recortar 1440px. */
.ma-panel { overflow-x: hidden; }
.ma-panel, .ma-panel * { min-width: 0; }
.ma-header { align-items: flex-start; }
.ma-title { overflow-wrap: anywhere; }
.ma-suggestions { grid-template-columns: 1fr; }
.ma-suggestion { white-space: normal; overflow-wrap: anywhere; }
@media (min-width: 1180px) {
  .care-with-assistant {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 380px);
    gap: clamp(14px, 1.6vw, 20px);
    align-items: start;
    justify-content: stretch;
  }
  .care-main-column { max-width: none; }
  .care-assistant-column { min-width: 0; }
  .layout .main:has(.care-with-assistant) { max-width: none; padding-left: clamp(12px, 1.4vw, 20px); padding-right: clamp(12px, 1.4vw, 20px); }
  .care-with-assistant .ma-panel { --ma-sticky-top: 18px; --ma-viewport-reserve: 180px; top: var(--ma-sticky-top); height: calc(100dvh - var(--ma-viewport-reserve)); max-height: calc(100dvh - var(--ma-viewport-reserve)); overflow: hidden; }
  .care-with-assistant .ma-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
}
@media (min-width: 1500px) {
  .care-with-assistant { grid-template-columns: minmax(0, 820px) minmax(380px, 420px); justify-content: center; }
}
@media (max-width: 767px) {
  .care-assistant-column { margin-top: 16px; }
  .ma-panel { max-height: none; }
}
.ma-suggestion {
  border: 1px solid var(--ar-border, #E4DED3);
  background: var(--ar-surface, #fff);
  color: var(--ar-green, #1F3D34);
  box-shadow: none;
}
.ma-suggestion:hover {
  border-color: var(--ar-green, #1F3D34);
  background: var(--ar-sage-2, #EEF2EC);
  color: var(--ar-heading, #1F3D34);
}
