/**
 * coach.css — v171. Estilos del Coach IA: vista #/coach, chat compartido,
 * botón flotante con la mascota y sus reacciones (animaciones por ánimo).
 */

/* ============ avatar de la mascota + ánimo ============ */
.coach-pet {
  position: relative;
  display: inline-block;
  flex: none;
}
.coach-pet img {
  display: block;
  object-fit: cover;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 3px solid var(--bg-elevated);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.coach-pet .coach-mood-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  font-size: 0.42em;
  line-height: 1;
  background: var(--bg-surface);
  border-radius: 50%;
  padding: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
/* el tamaño se hereda: el badge escala con el font-size del contenedor */
.coach-pet { font-size: 64px; }
.coach-pet.coach-pet-sm { font-size: 40px; }
.coach-pet.coach-pet-lg { font-size: 104px; }
.coach-pet img { width: 1em; height: 1em; }

/* ánimo: idle flotante */
.coach-pet .coach-pet-imgwrap { animation: coach-float 3.2s ease-in-out infinite; display: block; width: 1em; height: 1em; }
.coach-pet[data-mood="alegre"] .coach-pet-imgwrap { animation: coach-bounce 1.6s ease-in-out infinite; }
.coach-pet[data-mood="triste"] .coach-pet-imgwrap { animation: coach-sad 3.6s ease-in-out infinite; }
.coach-pet[data-mood="triste"] img { filter: saturate(0.75); }
.coach-pet[data-mood="pensando"] .coach-pet-imgwrap { animation: coach-thinking 1.1s ease-in-out infinite; }

@keyframes coach-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes coach-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-10px) scale(1.04); }
  50% { transform: translateY(0) scale(1); }
  75% { transform: translateY(-5px) scale(1.02); }
}
@keyframes coach-sad {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(4px) rotate(-2deg); }
}
@keyframes coach-thinking {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.07); opacity: 0.88; }
}

/* ============ chat ============ */
.coach-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.coach-msgs {
  overflow-y: auto;
  padding: 6px 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
}
.coach-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
}
.coach-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.coach-msg .burbuja {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.coach-msg.coach .burbuja {
  background: var(--bg-elevated);
  border-bottom-left-radius: 6px;
}
.coach-msg.user .burbuja {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.coach-msg .hora {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
}
.coach-escribiendo {
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
}
.coach-escribiendo span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: coach-typing 1.2s infinite;
}
.coach-escribiendo span:nth-child(2) { animation-delay: 0.15s; }
.coach-escribiendo span:nth-child(3) { animation-delay: 0.3s; }
@keyframes coach-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}
.coach-inputrow {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  background: var(--bg-elevated);
  border-radius: 99px;
  padding: 5px 5px 5px 16px;
  flex: none;
}
.coach-inputrow .input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 9px 0;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}
.coach-inputrow .input::placeholder { color: var(--text-muted); }
.coach-inputrow .input:disabled { opacity: 0.6; }
.coach-inputrow .btn {
  border-radius: 50%;
  width: 38px;
  height: 38px;
  padding: 0;
  flex: none;
  font-size: 15px;
  line-height: 1;
}
/* v188: el wrap del dictado ocupa el lugar del input dentro de la píldora. */
.coach-inputrow .dictado-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
}
.coach-inputrow .dictado-wrap .input {
  flex: 1;
  min-width: 0;
}
.coach-vacio {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 18px 8px;
}

/* ============ botón flotante ============ */
#coach-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-height, 66px) + var(--safe-bottom, 0px) + 14px);
  z-index: 150;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: transparent;
  transition: transform 0.15s ease;
}
#coach-fab:active { transform: scale(0.93); }
#coach-fab .coach-pet { font-size: 62px; }
#coach-fab.has-nuevo { animation: coach-ring 1.8s ease-out infinite; }
/* v214: antes animaba filter: drop-shadow(), que en Edge/Chromium vibra sobre
   elementos fixed. box-shadow da el mismo pulso sin el tartamudeo. */
@keyframes coach-ring {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 14px 3px var(--accent); }
}
#coach-fab .coach-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 22px;
  height: 22px;
  border-radius: 99px;
  background: var(--danger, #e5484d);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
}

/* ============ drawer del widget: panel lateral derecho flotante ============ */
#coach-drawer {
  position: fixed;
  z-index: 151;
  right: 16px;
  top: calc(var(--header-height, 64px) + var(--safe-top, 0px) + 10px);
  bottom: calc(var(--nav-height, 66px) + var(--safe-bottom, 0px) + 96px);
  width: 400px;
  max-width: calc(100vw - 32px);
  background: var(--bg-surface);
  border-radius: 20px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: coach-drawer-in 0.22s ease-out;
}
@keyframes coach-drawer-in {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
@media (max-width: 719px) {
  #coach-drawer {
    top: auto;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    bottom: calc(var(--nav-height, 66px) + var(--safe-bottom, 0px) + 88px);
    height: 62dvh;
  }
}
.coach-drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.coach-drawer-head .t { flex: 1; min-width: 0; }
.coach-drawer-head .t strong { font-size: 14px; display: block; }
.coach-drawer-head .t span { font-size: 12px; color: var(--text-secondary); }
.coach-drawer-head button {
  border: 0;
  background: var(--bg-elevated);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  flex: none;
}
.coach-drawer-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 12px 0;
  flex: none;
  border-bottom: 1px solid var(--border);
}
.coach-drawer-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 9px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.coach-drawer-tabs button.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}
@media (max-width: 719px) {
  .coach-drawer-tabs button { font-size: 19px; padding: 10px 4px; }
  .coach-drawer-tabs button .tab-label { display: none; }
}
.coach-drawer-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 14px;
  overflow: hidden;
}
.coach-drawer-body [data-wpanel="chat"] {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.coach-drawer-body [data-wpanel="chat"][hidden] { display: none; }
.coach-drawer-body [data-wpanel="rutinas"],
.coach-drawer-body [data-wpanel="memoria"] {
  overflow-y: auto;
  min-height: 0;
}
.coach-drawer-body .coach-chat { flex: 1; min-height: 0; }
.coach-drawer-body .coach-msgs { flex: 1; }

/* ============ listas (rutinas / memoria) ============ */
.coach-lista .fila {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.coach-lista .fila:last-child { border-bottom: 0; }
.coach-tag {
  font-size: 11px;
  background: var(--bg-elevated);
  border-radius: 99px;
  padding: 2px 8px;
  margin-right: 6px;
  white-space: nowrap;
}
.coach-addrow {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.coach-addrow .input-nombre { flex: 2; min-width: 140px; }
.coach-addrow .input-hora { flex: 1; min-width: 90px; }
.coach-dias {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* v203 (Parte 4): selector de skills por conversación. */
.coach-skills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 10px;
  scrollbar-width: none;
}
.coach-skills::-webkit-scrollbar { display: none; }
.coach-skill-chip {
  flex: 0 0 auto;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.coach-skill-chip.active {
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--accent);
}
.coach-skill-lock { opacity: 0.65; }
/* v205 (Fase 5): el toggle de Modo Profundo reusa los chips; activo se
   distingue con un fondo tenuemente acentuado (vars de ambos temas). */
.coach-skill-chip[data-profundo].active {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-elevated));
}
/* v208: tarjeta de aprobación de acciones del coach (crear tarea/hábito/nota).
   Usa solo vars de tema: se ve bien en claro y oscuro. */
.coach-accion {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.45;
  max-width: 92%;
  word-break: break-word;
}
.coach-accion-t { font-weight: 700; margin-bottom: 4px; }
.coach-accion-d { color: var(--text-secondary); margin-bottom: 4px; }
.coach-accion-m { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.coach-accion-btns { display: flex; gap: 8px; margin-top: 8px; }
.coach-accion-ok { color: var(--success); font-weight: 600; }
.coach-accion.bloqueada { opacity: 0.8; }
.coach-accion.hecha { border-color: var(--success); }
