/* Asistente IA (rediseño 2026-10-27): hoja flotante a la derecha, tarjetas de inicio por categoría, conversación en burbujas
   y tarjeta de confirmación que lista TODOS los pasos. Mismos id y botones de siempre. Quitar este <link> y ia-b.js lo deja sin estilo nuevo. */
#copilotDrawer.ia { --ia-bg: #F3F5FA; --ia-card: #fff; --ia-ink: #0F172A; --ia-mut: #5A6580; --ia-line: rgba(15, 23, 42, .08); --ia-field: #F1F5F9; --ia-soft: #F6F8FB; --ia-blue: #0284C7;
  position: fixed; top: 12px; right: 12px; bottom: 12px; left: auto; width: min(540px, calc(100vw - 24px)); max-width: none; height: auto; border-radius: 24px; border: 0; background: var(--ia-bg); color: var(--ia-ink);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28), 0 0 0 1px var(--ia-line); display: flex; flex-direction: column; overflow: hidden; font-size: 15px; z-index: 10001; }
#copilotDrawer.ia.hidden { transform: translateX(115%); }
:root[data-theme="dark"] #copilotDrawer.ia { --ia-bg: #0B0B0C; --ia-card: #1A1A1C; --ia-ink: #F1F5F9; --ia-mut: #A1A1A6; --ia-line: rgba(255, 255, 255, .1); --ia-field: #1A1A1C; --ia-soft: #242427; }
#copilotDrawer.ia * { box-sizing: border-box; }
#copilotDrawer.ia button { font-family: inherit; cursor: pointer; text-transform: none; letter-spacing: 0; }
#copilotDrawer.ia h2, #copilotDrawer.ia h3, #copilotDrawer.ia h5, #copilotDrawer.ia h6 { font-family: inherit; color: var(--ia-ink); text-transform: none; letter-spacing: inherit; margin: 0; }
#copilotDrawer.ia svg { flex: none; }

/* cabecera */
#copilotDrawer .ia-h { display: flex; align-items: center; gap: 12px; padding: 16px 18px 14px; background: var(--ia-card); border-bottom: 1px solid var(--ia-line); }
#copilotDrawer .ia-badge { width: 42px; height: 42px; border-radius: 13px; background: rgba(2, 132, 199, .14); color: var(--ia-blue); display: grid; place-items: center; flex: none; }
#copilotDrawer .ia-badge svg { width: 22px; height: 22px; }
#copilotDrawer .ia-title { font-size: 20px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
#copilotDrawer .ia-sub { display: flex; align-items: center; gap: 6px; color: var(--ia-mut); font-size: 13.5px; font-weight: 600; }
#copilotDrawer .ia-dot { width: 8px; height: 8px; border-radius: 50%; background: #0F9D58; display: inline-block; }
#copilotDrawer .ia-tools { margin-left: auto; display: flex; gap: 4px; }
#copilotDrawer .ia-ib { width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--ia-ink); display: grid; place-items: center; padding: 0; }
#copilotDrawer .ia-ib:hover { background: var(--ia-field); }
#copilotDrawer .ia-ib svg { width: 20px; height: 20px; }

/* zona de conversación */
#copilotDrawer .copilot-chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; background: var(--ia-bg); display: flex; flex-direction: column; gap: 14px; }
#copilotDrawer #copilotSuggestionsBox { display: flex; flex-direction: column; gap: 14px; background: transparent; border: 0; padding: 0; margin: 0; }
#copilotDrawer #copilotSuggestionsBox[style*="display: none"] { display: none !important; }
#copilotDrawer .ia-hi { margin: 2px 2px 0; }
#copilotDrawer .ia-hi h2 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
#copilotDrawer .ia-hi p { margin: 6px 0 0; color: var(--ia-mut); font-size: 15px; line-height: 1.4; }
#copilotDrawer .ia-cats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
#copilotDrawer .ia-cat { white-space: normal; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; padding: 14px; min-height: 112px; border-radius: 18px; border: 1px solid var(--ia-line); background: var(--ia-card); color: var(--ia-ink); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
#copilotDrawer .ia-cat:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, .12); }
#copilotDrawer .ia-chip { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; }
#copilotDrawer .ia-chip svg { width: 20px; height: 20px; }
#copilotDrawer .ia-cat b { font-size: 15.5px; line-height: 1.2; font-weight: 700; }
#copilotDrawer .ia-cat .e { font-size: 13px; color: var(--ia-mut); line-height: 1.3; font-weight: 500; }
#copilotDrawer .ia-sec { margin: 4px 2px -4px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ia-mut); }
#copilotDrawer .ia-qs { display: flex; flex-wrap: wrap; gap: 8px; }
#copilotDrawer .ia-q { min-height: 44px; padding: 0 16px; border-radius: 99px; border: 1px solid var(--ia-line); background: var(--ia-card); font-weight: 600; font-size: 14.5px; color: var(--ia-ink); display: inline-flex; align-items: center; }
#copilotDrawer .ia-q:hover { background: var(--ia-field); }
#copilotDrawer .ia-help { border-radius: 18px; background: var(--ia-card); border: 1px solid var(--ia-line); overflow: hidden; }
#copilotDrawer .ia-help > button { width: 100%; min-height: 50px; padding: 0 14px; border: 0; background: transparent; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: var(--ia-ink); text-align: left; }
#copilotDrawer .ia-help > button svg { width: 20px; height: 20px; color: var(--ia-blue); }
#copilotDrawer .ia-help > button .ch { margin-left: auto; color: #94A3B8; width: 18px; height: 18px; }
#copilotDrawer .ia-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-top: 1px solid var(--ia-line); }
#copilotDrawer .ia-cols > div { padding: 12px 14px; }
#copilotDrawer .ia-cols > div + div { border-left: 1px solid var(--ia-line); }
#copilotDrawer .ia-cols h6 { margin: 0 0 6px; font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
#copilotDrawer .ia-cols h6 svg { width: 16px; height: 16px; }
#copilotDrawer .ia-cols ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
#copilotDrawer .ia-cols li { font-size: 13px; line-height: 1.3; color: var(--ia-ink); opacity: .85; display: flex; gap: 6px; }
#copilotDrawer .ia-cols li::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; margin-top: 6px; background: #C2C9D6; }
#copilotDrawer .ia-yes li::before { background: #0F9D58; }
#copilotDrawer .ia-perm { border-top: 1px solid var(--ia-line); padding: 11px 14px; background: #FFF4D6; color: #7A5A00; font-size: 13px; font-weight: 600; line-height: 1.35; display: flex; gap: 8px; }
#copilotDrawer .ia-perm svg { width: 18px; height: 18px; margin-top: 1px; }

/* mensajes */
#copilotDrawer #copilotLiveMessages { display: flex; flex-direction: column; gap: 12px; }
#copilotDrawer .copilot-msg { display: flex; flex-direction: column; max-width: 100%; margin: 0; padding: 0; background: none; border: 0; }
#copilotDrawer .copilot-msg .copilot-msg-avatar { display: none; }
#copilotDrawer .copilot-msg.user { align-self: flex-end; align-items: flex-end; max-width: 86%; }
#copilotDrawer .copilot-msg.user .copilot-msg-bubble { background: var(--ia-blue); color: #fff; border-radius: 20px 20px 6px 20px; padding: 11px 15px; font-size: 15px; line-height: 1.35; border: 0; }
#copilotDrawer .copilot-msg.bot { align-self: flex-start; max-width: 94%; }
#copilotDrawer .copilot-msg.bot .copilot-msg-bubble { background: var(--ia-card); color: var(--ia-ink); border: 1px solid var(--ia-line); border-radius: 20px 20px 20px 6px; padding: 12px 15px; font-size: 15px; line-height: 1.4; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
#copilotDrawer .copilot-msg.bot .copilot-msg-bubble p, #copilotDrawer .copilot-msg.bot .copilot-msg-bubble li { font-size: 14.5px !important; }
#copilotDrawer .copilot-msg .copilot-disambig-btn { min-height: 52px; border-radius: 14px; width: 100%; text-align: left; margin-top: 6px; }
#copilotDrawer .copilot-typing { display: flex; align-items: center; gap: 6px; color: var(--ia-mut); font-size: 14px; font-weight: 600; padding: 4px 6px; }
#copilotDrawer .copilot-typing.hidden { display: none; }

/* tarjeta de confirmación */
#copilotDrawer .ia-card { background: var(--ia-card); border: 1px solid var(--ia-line); border-radius: 20px; padding: 14px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
#copilotDrawer .ia-card h5 { font-size: 15.5px; font-weight: 800; display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
#copilotDrawer .ia-card h5 svg { width: 18px; height: 18px; color: var(--ia-blue); }
#copilotDrawer .ia-card h5 small { margin-left: auto; font-weight: 600; color: var(--ia-mut); font-size: 13px; }
#copilotDrawer .ia-op { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 14px; background: var(--ia-soft); }
#copilotDrawer .ia-op + .ia-op { margin-top: 8px; }
#copilotDrawer .ia-op .ia-chip { width: 34px; height: 34px; border-radius: 10px; flex: none; }
#copilotDrawer .ia-op b { display: block; font-size: 14.5px; font-weight: 700; }
#copilotDrawer .ia-op .e { display: block; font-size: 13.5px; color: var(--ia-mut); margin-top: 1px; overflow-wrap: anywhere; }
#copilotDrawer .ia-warn { margin-top: 10px; display: flex; gap: 8px; align-items: flex-start; background: #FDECEC; color: #8E1B1B; border-radius: 12px; padding: 9px 11px; font-size: 13.5px; font-weight: 600; }
#copilotDrawer .ia-warn svg { width: 18px; height: 18px; margin-top: 1px; }
#copilotDrawer .ia-note { margin-top: 10px; display: flex; gap: 8px; align-items: flex-start; background: #FFF4D6; color: #7A5A00; border-radius: 12px; padding: 9px 11px; font-size: 13.5px; font-weight: 600; }
#copilotDrawer .ia-note svg { width: 18px; height: 18px; margin-top: 1px; }
#copilotDrawer .ia-btns { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; margin-top: 12px; }
#copilotDrawer .ia-btn { min-height: 48px; border-radius: 14px; border: 1px solid var(--ia-line); background: var(--ia-card); font-weight: 700; font-size: 15.5px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ia-ink); }
#copilotDrawer .ia-btn.p { background: var(--ia-blue); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(2, 132, 199, .28); }
#copilotDrawer .ia-btn svg { width: 18px; height: 18px; }
#copilotDrawer .ia-swap { margin-top: 4px; width: 100%; min-height: 44px; border: 0; background: transparent; color: var(--ia-blue); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 6px; }
#copilotDrawer .ia-done { display: flex; align-items: center; gap: 8px; background: #E6F6EC; color: #0B7A43; border-radius: 14px; padding: 11px 14px; font-weight: 700; font-size: 14.5px; }
#copilotDrawer .ia-done.x { background: var(--ia-soft); color: var(--ia-mut); }
#copilotDrawer .ia-done svg { width: 20px; height: 20px; }
#copilotDrawer .ia-res { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13.5px; font-weight: 600; }

/* barra de entrada */
#copilotDrawer .copilot-input-area { padding: 12px 16px 16px; background: var(--ia-card); border-top: 1px solid var(--ia-line); }
#copilotDrawer .copilot-input-wrapper { display: flex; align-items: flex-end; gap: 8px; background: var(--ia-field); border: 1px solid var(--ia-line); border-radius: 26px; padding: 6px 6px 6px 18px; }
#copilotDrawer .copilot-input-wrapper:focus-within { box-shadow: none; border-color: var(--ia-mut); }
/* apple-movil.css da borde y halo azul con !important a todo textarea:focus: aquí el marco es solo el de la caja */
html body #copilotDrawer #copilotInputText:focus, html body #copilotDrawer #copilotInputText:focus-visible { border: 0 !important; box-shadow: none !important; outline: 0 !important; -webkit-appearance: none; appearance: none; }
#copilotDrawer #copilotInputText { flex: 1; min-width: 0; border: 0; background: transparent; box-shadow: none; outline: 0; resize: none; font: inherit; font-size: 15.5px; line-height: 1.3; padding: 10px 0; min-height: 44px; max-height: 120px; color: var(--ia-ink); }
#copilotDrawer .copilot-input-actions { display: flex; gap: 8px; flex: none; }
#copilotDrawer .copilot-voice-btn, #copilotDrawer .copilot-send-btn { width: 44px; height: 44px; min-height: 44px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
#copilotDrawer .copilot-voice-btn { border: 0; background: var(--ia-card); color: var(--ia-blue); box-shadow: 0 0 0 1px var(--ia-line); }
#copilotDrawer .copilot-voice-btn.listening { background: #FDECEC; color: #DC2626; }
#copilotDrawer .copilot-send-btn { border: 0; background: var(--ia-blue); color: #fff; box-shadow: 0 4px 12px rgba(2, 132, 199, .35); }
#copilotDrawer .copilot-voice-btn svg, #copilotDrawer .copilot-send-btn svg { width: 20px; height: 20px; }
#copilotDrawer .copilot-input-footer { margin: 8px 6px 0; font-size: 12.5px; color: var(--ia-mut); text-align: center; }

@media (max-width: 834px) {
  #copilotDrawer.ia { top: 0; right: 0; bottom: 0; width: 100vw; border-radius: 0; }
  #copilotDrawer .ia-cats { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { #copilotDrawer.ia { transition: none; } }

/* Caja de escribir más baja: los botones no heredan márgenes de otras hojas y todo se alinea al centro */
#copilotDrawer .copilot-input-wrapper { align-items: center; }
#copilotDrawer .copilot-input-actions { align-items: center; margin: 0; }
#copilotDrawer .copilot-voice-btn, #copilotDrawer .copilot-send-btn { margin: 0; }

/* Historial de Odi y dictado en vivo (2026-11-05) */
#copilotDrawer .ia-ib { position: relative; }
#copilotDrawer .ia-ib.is-active { background: rgba(2, 132, 199, .14); color: var(--ia-blue); }
#copilotDrawer .ia-h-cnt { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--ia-blue); color: #fff; font-size: 10px; font-weight: 800; line-height: 16px; text-align: center; pointer-events: none; }
#copilotDrawer .ia-h-cnt.hidden { display: none !important; }
#copilotDrawer #copilotHistoryBox { display: flex; flex-direction: column; gap: 10px; }
#copilotDrawer #copilotHistoryBox.hidden { display: none !important; }
#copilotDrawer .ia-hist-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 2px 4px; }
#copilotDrawer .ia-hist-top h4 { margin: 0; font-size: 17px; font-weight: 800; color: var(--ia-ink); display: flex; align-items: center; gap: 7px; }
#copilotDrawer .ia-hist-top h4 svg { width: 18px; height: 18px; color: var(--ia-blue); }
#copilotDrawer .ia-hist-acts { display: flex; align-items: center; gap: 6px; }
#copilotDrawer .ia-hist-btn { min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--ia-line); background: var(--ia-card); color: var(--ia-ink); font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
#copilotDrawer .ia-hist-btn:hover { background: var(--ia-field); }
#copilotDrawer .ia-hist-btn svg { width: 15px; height: 15px; }
#copilotDrawer .ia-hist-empty { background: var(--ia-card); border: 1px solid var(--ia-line); border-radius: 16px; padding: 22px 16px; text-align: center; color: var(--ia-mut); font-size: 14px; font-weight: 600; }
#copilotDrawer .ia-hist-item { background: var(--ia-card); border: 1px solid var(--ia-line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
#copilotDrawer .ia-hist-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#copilotDrawer .ia-hist-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 800; color: #0B7A43; background: #E6F6EC; padding: 3px 9px; border-radius: 99px; }
#copilotDrawer .ia-hist-tag.warn { color: #7A5A00; background: #FFF4D6; }
#copilotDrawer .ia-hist-tag.info { color: var(--ia-blue); background: rgba(2, 132, 199, .12); }
#copilotDrawer .ia-hist-tag svg { width: 13px; height: 13px; }
#copilotDrawer .ia-hist-time { font-size: 12px; font-weight: 600; color: var(--ia-mut); font-variant-numeric: tabular-nums; }
#copilotDrawer .ia-hist-q { font-size: 14px; font-weight: 700; color: var(--ia-ink); line-height: 1.3; overflow-wrap: anywhere; }
#copilotDrawer .ia-hist-a { font-size: 13px; font-weight: 500; color: var(--ia-mut); line-height: 1.35; overflow-wrap: anywhere; }
#copilotDrawer .ia-hist-open { align-self: flex-start; min-height: 36px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--ia-line); background: var(--ia-soft); color: var(--ia-blue); font-size: 12.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; margin-top: 2px; }
#copilotDrawer .copilot-voice-btn.listening { box-shadow: 0 0 0 3px rgba(220, 38, 38, .22); }


/* Varios pacientes coinciden: los botones se leen completos (nombre arriba, datos abajo) y no se salen de la tarjeta */
#copilotDrawer .copilot-msg:has(.copilot-disambig-btn) .copilot-msg-bubble { max-width: 100% !important; min-width: 0 !important; width: 100%; }
#copilotDrawer .copilot-msg .copilot-disambig-btn { display: flex !important; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; height: auto !important; min-height: 58px !important; white-space: normal; text-align: left; padding: 10px 14px !important; overflow: hidden; line-height: 1.3; }
#copilotDrawer .copilot-disambig-btn br { display: none; }
#copilotDrawer .copilot-disambig-btn strong { font-size: 15px; overflow-wrap: anywhere; }
#copilotDrawer .copilot-disambig-btn small { display: block; font-size: 13px !important; color: var(--ia-mut); overflow-wrap: anywhere; }
