/* ============================================================
   ws-coach.css — §11 Coach chat (workstream E)
   Chat con Atlas: burbujas, composer fijo sobre la tabbar,
   typing dots, chips sugeridos, toggle Profundo.
   Solo tokens de app.css → hereda light/dark automáticamente.
   ============================================================ */

/* ---------- hilo ---------- */
.coach-thread {
  display: flex; flex-direction: column; gap: 12px;
  padding: 10px 0 148px; /* colchón para el composer fijo (chips + input) */
}
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.me    { align-self: flex-end;   align-items: flex-end; }
.msg.atlas { align-self: flex-start; align-items: flex-start; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px; line-height: 1.45;
  box-shadow: var(--shadow-sm);
  word-break: break-word;
  animation: msg-in .22s var(--ease) both;
}
.msg.me .msg-bubble {
  background: var(--accent); color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.atlas .msg-bubble {
  background: var(--card); color: var(--text);
  border-bottom-left-radius: 6px;
}
.msg-bubble p { margin: 0; }
.msg-bubble p + p, .msg-bubble p + ul, .msg-bubble ul + p { margin-top: 8px; }
.msg-bubble ul { margin: 4px 0 0; padding-left: 18px; list-style: disc; }
.msg-bubble li { margin: 3px 0; }
.msg-bubble li::marker { color: var(--text-3); }
.msg.me .msg-bubble li::marker { color: rgba(255, 255, 255, .7); }
.msg-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; background: rgba(127, 127, 127, .16);
  padding: 1px 5px; border-radius: 6px;
}
.msg-bubble .md-num b { font-variant-numeric: tabular-nums; }
.msg-meta { font-size: 11px; font-weight: 600; color: var(--text-3); margin-top: 4px; padding: 0 6px; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- typing indicator (3 puntos) ---------- */
.msg-typing { display: inline-flex; align-items: center; gap: 4px; min-width: 46px; min-height: 20px; }
.tdot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3); display: inline-block;
  animation: coach-blink 1.2s infinite both;
}
.tdot:nth-child(2) { animation-delay: .15s; }
.tdot:nth-child(3) { animation-delay: .3s; }
@keyframes coach-blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40%           { opacity: 1;   transform: translateY(-3px); }
}

/* ---------- composer fijo (encima de la tabbar, safe-area) ---------- */
.coach-composer {
  position: fixed; left: 0; right: 0; z-index: 35;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--hair);
  padding: 8px 12px 10px;
}
.coach-composer-inner { max-width: var(--maxw); margin: 0 auto; }

.composer-row { display: flex; align-items: flex-end; gap: 8px; }

.coach-input {
  flex: 1; min-width: 0;
  min-height: 44px; max-height: 120px;
  resize: none; border: 1px solid var(--hair);
  border-radius: 22px;
  background: var(--card);
  padding: 11px 16px;
  font-size: 16px; /* ≥16px: iOS no hace zoom al enfocar */
  line-height: 1.35;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.coach-input:focus { outline: none; border-color: var(--accent); }
.coach-input::placeholder { color: var(--text-3); }

.coach-send {
  flex: none; width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: opacity .15s var(--ease), transform .1s var(--ease);
}
.coach-send:active { transform: scale(.92); }
.coach-send:disabled { opacity: .35; cursor: default; }

/* toggle Profundo (agente completo) */
.deep-toggle {
  flex: none; min-height: 44px;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 0 13px;
  border-radius: var(--r-pill);
  background: var(--card); color: var(--text-2);
  border: 1px solid var(--hair);
  box-shadow: var(--shadow-sm);
  font-size: 13px; font-weight: 700;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.deep-toggle .ic { width: 15px; height: 15px; }
.deep-toggle.on { background: var(--purple); border-color: transparent; color: #fff; }

/* ---------- chips sugeridos ---------- */
.coach-chips {
  display: flex; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 0 2px 8px;
  scrollbar-width: none;
}
.coach-chips::-webkit-scrollbar { display: none; }
.coach-chips.busy { opacity: .4; pointer-events: none; }
.coach-chip {
  flex: none; min-height: 40px;
  padding: 9px 15px;
  border-radius: var(--r-pill);
  background: var(--card); color: var(--accent);
  border: 1px solid var(--hair);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap;
  transition: transform .1s var(--ease), background .15s var(--ease);
}
.coach-chip:active { transform: scale(.95); background: var(--accent-soft); }

/* ---------- desktop ≥900px (tabbar = sidebar izquierda) ---------- */
@media (min-width: 900px) {
  .coach-composer {
    left: var(--sidebar-w); bottom: 0;
    padding: 10px 32px 16px;
  }
  .coach-composer-inner { max-width: calc(var(--content-maxw) - 64px); margin: 0; }
  .coach-thread { padding-bottom: 160px; }
  .msg { max-width: 70%; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .msg-bubble { animation: none; }
  .tdot { animation: none; opacity: .6; }
}
