/* ============================================
   Consultores del Sur — Asistente IA
   Usa los tokens definidos en landing.css
   ============================================ */

.cb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.cb-launcher {
  position: fixed;
  right: 24px;
  bottom: 96px;               /* encima del botón de WhatsApp */
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-white);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(10, 37, 64, 0.35);
  z-index: 55;
  transition: var(--transition);
}
.cb-launcher:hover { background: var(--color-accent); transform: translateY(-2px); }
.cb-launcher:focus-visible { outline: 3px solid var(--color-accent-2); outline-offset: 3px; }
.cb-ico-close { display: none; }
.cb.is-open .cb-ico-open { display: none; }
.cb.is-open .cb-ico-close { display: block; }

.cb-panel {
  position: fixed;
  right: 24px;
  bottom: 164px;
  width: 380px;
  height: min(600px, calc(100vh - 200px));
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 70;
  animation: cbIn 0.22s ease-out;
}
.cb-panel[hidden] { display: none; }
@keyframes cbIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.cb-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 14px 18px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-2) 100%);
  color: var(--color-white);
}
.cb-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--color-white); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; flex-shrink: 0;
}
.cb-head-text { flex: 1; min-width: 0; }
.cb-head h2 { color: var(--color-white); font-size: 0.98rem; margin: 0; letter-spacing: 0; }
.cb-head p { color: rgba(255,255,255,0.78); font-size: 0.76rem; margin: 0; display: flex; align-items: center; gap: 6px; }
.cb-online { width: 7px; height: 7px; border-radius: 50%; background: var(--color-success); display: inline-block; }
.cb-icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  color: rgba(255,255,255,0.85);
  display: flex; align-items: center; justify-content: center;
}
.cb-icon-btn:hover { background: rgba(255,255,255,0.12); color: var(--color-white); }

.cb-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: var(--color-bg-soft);
  display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain;
}
.cb-msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 0.92rem; line-height: 1.5; word-wrap: break-word; }
.cb-msg p { margin: 0 0 6px; color: inherit; }
.cb-msg p:last-child { margin: 0; }
.cb-msg ul { margin: 4px 0 6px; padding-left: 18px; list-style: disc; }
.cb-msg li { margin: 2px 0; }
.cb-msg a { color: var(--color-accent); text-decoration: underline; word-break: break-word; }
.cb-bot { align-self: flex-start; background: var(--color-white); color: var(--color-text); border: 1px solid var(--color-border); border-bottom-left-radius: 4px; }
.cb-user { align-self: flex-end; background: var(--color-primary); color: var(--color-white); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.cb-error { align-self: flex-start; background: #FFF7ED; color: #9A3412; border: 1px solid #FED7AA; }
.cb-error a { color: #9A3412; }

.cb-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.cb-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--color-text-soft); opacity: 0.4; animation: cbDot 1.2s infinite; }
.cb-typing span:nth-child(2) { animation-delay: 0.2s; }
.cb-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cbDot { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.cb-suggest[hidden] { display: none; }
.cb-suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.cb-suggest button {
  font-size: 0.82rem;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--color-accent-2);
  color: var(--color-accent);
  background: var(--color-white);
  transition: var(--transition);
}
.cb-suggest button:hover { background: var(--color-accent); color: var(--color-white); border-color: var(--color-accent); }

.cb-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--color-border); background: var(--color-white); }
.cb-form textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: 14px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--color-text);
  line-height: 1.4;
}
.cb-form textarea:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(0,102,255,0.1); }
.cb-send {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--color-primary); color: var(--color-white);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: var(--transition);
}
.cb-send:hover:not(:disabled) { background: var(--color-accent); }
.cb-send:disabled { opacity: 0.45; cursor: not-allowed; }

.cb-legal { font-size: 0.7rem; color: var(--color-text-soft); margin: 0; padding: 0 14px 10px; background: var(--color-white); line-height: 1.4; }
.cb-legal a { color: var(--color-accent); text-decoration: underline; }

@media (max-width: 720px) {
  .cb-launcher { right: 16px; bottom: 88px; width: 52px; height: 52px; }
  .cb-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    border: none;
    z-index: 200;
  }
  .cb.is-open .cb-launcher { display: none; }
  .cb-msg { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .cb-panel, .cb-typing span { animation: none; }
}
