/* ============================================================
   ExamiNáutica — Asistente IA (chatbot)
   Público: azul marino/cian. Zona de usuario: verde agua (otro color).
   ============================================================ */
.cbot-fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 58;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--cyan-600); color: #fff; border: none;
  box-shadow: var(--sh-lg); display: grid; place-items: center; cursor: pointer;
  transition: transform .15s, background .2s;
}
.cbot-fab:hover { transform: translateY(-2px); }
.cbot-fab svg { width: 26px; height: 26px; }
.cbot-fab:focus-visible { outline: 3px solid var(--cyan-300); outline-offset: 3px; }
.cbot--app .cbot-fab { background: var(--sea-600); }
.cbot--app .cbot-fab:focus-visible { outline-color: var(--sea-500); }
@media (max-width: 900px) { body:has(.bottomnav) .cbot-fab { bottom: 80px; } }

.cbot-panel {
  position: fixed; right: 16px; bottom: 84px; z-index: 59;
  width: 380px; max-width: calc(100vw - 24px); height: 560px; max-height: calc(100vh - 120px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-lg); display: flex; flex-direction: column; overflow: hidden;
}
.cbot-panel[hidden] { display: none; }
@media (max-width: 900px) { body:has(.bottomnav) .cbot-panel { bottom: 146px; } }
@media (max-width: 480px) { .cbot-panel { right: 8px; left: 8px; width: auto; height: calc(100vh - 150px); } }

.cbot-head {
  background: var(--navy-900); color: #fff; padding: 13px 15px;
  display: flex; align-items: center; gap: 10px;
}
.cbot--app .cbot-head { background: var(--sea-700); }
.cbot-head__ic { width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,.14); display: grid; place-items: center; flex-shrink: 0; }
.cbot-head__ic svg { width: 19px; height: 19px; }
.cbot-head__t { font-size: 14.5px; font-weight: 700; line-height: 1.1; }
.cbot-head__s { font-size: 11.5px; opacity: .8; }
.cbot-head__sp { margin-left: auto; display: flex; gap: 4px; }
.cbot-head button { background: rgba(255,255,255,.12); border: none; color: #fff; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.cbot-head button[aria-pressed="true"] { background: var(--cyan-500); }
.cbot--app .cbot-head button[aria-pressed="true"] { background: var(--sea-500); }
.cbot-head button svg { width: 17px; height: 17px; }

.cbot-msgs { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.cbot-msg { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
/* El bot ocupa todo el ancho disponible (lleva párrafos/listas); el usuario, burbuja a la derecha. */
.cbot-msg--bot { background: var(--surface); border: 1px solid var(--line); align-self: stretch; max-width: 100%; border-bottom-left-radius: 4px; }
.cbot-msg--me { background: var(--cyan-600); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.cbot--app .cbot-msg--me { background: var(--sea-600); }
/* markdown del bot (negritas, cursivas, listas, código) */
.cbot-msg--bot { white-space: normal; }
.cbot-msg--bot p { margin: 0 0 8px; }
.cbot-msg--bot p:last-child, .cbot-msg--bot ul:last-child, .cbot-msg--bot ol:last-child { margin-bottom: 0; }
.cbot-msg--bot strong { font-weight: 700; }
.cbot-msg--bot em { font-style: italic; }
.cbot-msg--bot ul, .cbot-msg--bot ol { margin: 4px 0 8px; padding-left: 20px; }
.cbot-msg--bot li { margin: 2px 0; }
.cbot-msg--bot code { background: var(--bg-2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.cbot-msg--bot a { color: var(--cyan-700); font-weight: 600; }
.cbot--app .cbot-msg--bot a { color: var(--sea-700); }
/* panel de historial de conversaciones */
.cbot-histpanel { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
/* el atributo `hidden` debe ganar al display:flex; si no, ocupa la mitad del alto del chat */
.cbot-histpanel[hidden] { display: none; }
.cbot-histback { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; padding: 4px; }
.cbot-histback svg { width: 16px; height: 16px; }
.cbot-hist__empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 30px 16px; }
.cbot-hist__item { display: flex; flex-direction: column; gap: 2px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; transition: border-color .12s; }
.cbot-hist__item:hover { border-color: var(--cyan-400); }
.cbot-hist__t { font-size: 13.5px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbot-hist__d { font-size: 11.5px; color: var(--muted); }
.cbot-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 11px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.cbot-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: cbot-bounce 1.2s infinite; }
.cbot-typing span:nth-child(2) { animation-delay: .2s; } .cbot-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cbot-bounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.cbot-sugg { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; background: var(--bg); }
.cbot-sugg button { font-size: 12.5px; font-weight: 600; padding: 6px 10px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); cursor: pointer; }
.cbot-sugg button:hover { border-color: var(--cyan-400); }

.cbot-input { display: flex; align-items: flex-end; gap: 7px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface); }
.cbot-input textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: var(--r-md); padding: 9px 11px; font: inherit; font-size: 14px; max-height: 96px; min-height: 40px; color: var(--ink); background: var(--bg); }
.cbot-input textarea:focus { outline: 2px solid var(--cyan-400); border-color: var(--cyan-400); }
.cbot-btn { width: 40px; height: 40px; border-radius: 10px; border: none; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.cbot-btn svg { width: 19px; height: 19px; }
.cbot-mic { background: var(--bg-2); color: var(--ink-soft); border: 1px solid var(--line); }
.cbot-mic.rec { background: var(--coral-500); color: #fff; border-color: var(--coral-500); animation: cbot-pulse 1.2s infinite; }
@keyframes cbot-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(232,95,84,.5); } 50% { box-shadow: 0 0 0 7px rgba(232,95,84,0); } }
.cbot-send { background: var(--cyan-600); color: #fff; }
.cbot--app .cbot-send { background: var(--sea-600); }
.cbot-send:disabled { opacity: .5; cursor: default; }
.cbot-hint { font-size: 11px; color: var(--muted); text-align: center; padding: 0 14px 8px; background: var(--surface); }
.cbot-foot { font-size: 10.5px; color: var(--muted); text-align: center; padding: 6px; background: var(--surface); border-top: 1px solid var(--line-soft); }

/* Fuente de la teoría citada por el tutor (RAG) */
.cbot-src { align-self: flex-start; font-size: 11.5px; color: var(--muted); background: var(--bg-2); border-radius: 8px; padding: 5px 10px; margin-top: -4px; max-width: 85%; }
.cbot--app .cbot-src { color: var(--sea-700); }
