/* ═══════════════════════════════════════════════
   PanOncology AI ChatBot — Widget CSS
   ═══════════════════════════════════════════════ */

:root {
  --panochat-primary: #0d9488;
  --panochat-primary-dark: #0a7a70;
  --panochat-bg: #ffffff;
  --panochat-surface: #f8fafc;
  --panochat-border: #e2e8f0;
  --panochat-text: #1e293b;
  --panochat-text-muted: #64748b;
  --panochat-bot-bubble: #f0fdf9;
  --panochat-user-bubble: #eff6ff;
  --panochat-radius: 18px;
  --panochat-shadow: 0 20px 60px rgba(0,0,0,.18);
  --panochat-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --panochat-z: 99999;
}

/* ── CONTENEDOR RAÍZ ── */
#panochat-root {
  position: fixed;
  z-index: var(--panochat-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

#panochat-root.panochat-bottom-right { bottom: 24px; right: 24px; }
#panochat-root.panochat-bottom-left  { bottom: 24px; left:  24px; align-items: flex-start; }

/* ── BOTÓN FLOTANTE ── */
#panochat-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--panochat-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(13,148,136,.45);
  transition: transform .2s, box-shadow .2s;
  position: relative;
  flex-shrink: 0;
}
#panochat-fab svg { width: 28px; height: 28px; }
#panochat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 32px rgba(13,148,136,.55);
}
#panochat-fab:active { transform: scale(.96); }

.panochat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ── VENTANA ── */
#panochat-window {
  width: 380px;
  max-height: 580px;
  background: var(--panochat-bg);
  border-radius: var(--panochat-radius);
  box-shadow: var(--panochat-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--panochat-border);
  font-family: var(--panochat-font);
  animation: panochat-slide-up .25s ease;
}
#panochat-window.panochat-open {
  display: flex;
}
@keyframes panochat-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── HEADER ── */
.panochat-header {
  background: linear-gradient(90deg, var(--panochat-primary), var(--panochat-primary-dark));
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.panochat-header-info { display: flex; align-items: center; gap: 10px; }
.panochat-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.panochat-header-title { font-weight: 700; font-size: 15px; }
.panochat-header-status { font-size: 11px; opacity: .8; margin-top: 2px; }
.panochat-header-actions { display: flex; gap: 8px; }
.panochat-btn-icon {
  background: rgba(255,255,255,.15);
  border: none;
  color: white;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.panochat-btn-icon:hover { background: rgba(255,255,255,.28); }

/* ── SELECTOR DE PERFIL ── */
.panochat-profile-selector {
  padding: 20px 16px;
  border-bottom: 1px solid var(--panochat-border);
  background: var(--panochat-surface);
  flex-shrink: 0;
}
.panochat-profile-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--panochat-text-muted);
  margin: 0 0 12px;
  text-align: center;
}
.panochat-profile-options {
  display: flex;
  gap: 10px;
}
.panochat-profile-btn {
  flex: 1;
  padding: 12px 10px;
  border: 2px solid var(--panochat-border);
  border-radius: 12px;
  background: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--panochat-text);
  transition: border-color .15s, background .15s;
  font-family: var(--panochat-font);
}
.panochat-profile-btn:hover {
  border-color: var(--panochat-primary);
  background: var(--panochat-bot-bubble);
}
.panochat-profile-btn.panochat-active {
  border-color: var(--panochat-primary);
  background: var(--panochat-bot-bubble);
  color: var(--panochat-primary);
}
.panochat-profile-icon { font-size: 24px; }

/* ── MENSAJES ── */
.panochat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.panochat-messages::-webkit-scrollbar { width: 4px; }
.panochat-messages::-webkit-scrollbar-track { background: transparent; }
.panochat-messages::-webkit-scrollbar-thumb { background: var(--panochat-border); border-radius: 2px; }

/* Burbuja genérica */
.panochat-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: panochat-msg-in .2s ease;
}
@keyframes panochat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bot */
.panochat-msg.panochat-msg-bot {
  align-self: flex-start;
}
.panochat-msg.panochat-msg-bot .panochat-bubble {
  background: var(--panochat-bot-bubble);
  border: 1px solid #ccfbf1;
  border-bottom-left-radius: 4px;
  color: var(--panochat-text);
}

/* Usuario */
.panochat-msg.panochat-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.panochat-msg.panochat-msg-user .panochat-bubble {
  background: var(--panochat-user-bubble);
  border: 1px solid #bfdbfe;
  border-bottom-right-radius: 4px;
  color: var(--panochat-text);
}

.panochat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panochat-surface);
  border: 1px solid var(--panochat-border);
  flex-shrink: 0;
  margin-top: 2px;
}

.panochat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Typing indicator */
.panochat-typing .panochat-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}
.panochat-dot {
  width: 7px; height: 7px;
  background: var(--panochat-primary);
  border-radius: 50%;
  animation: panochat-bounce .8s ease infinite;
}
.panochat-dot:nth-child(2) { animation-delay: .15s; }
.panochat-dot:nth-child(3) { animation-delay: .30s; }
@keyframes panochat-bounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%            { transform: scale(1);  opacity: 1; }
}

/* ── DISCLAIMER ── */
.panochat-disclaimer {
  font-size: 11px;
  color: var(--panochat-text-muted);
  text-align: center;
  padding: 6px 12px;
  background: #fefce8;
  border-top: 1px solid #fef08a;
  flex-shrink: 0;
}

/* ── INPUT ── */
.panochat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--panochat-border);
  background: white;
  flex-shrink: 0;
  align-items: flex-end;
}
#panochat-input {
  flex: 1;
  border: 1px solid var(--panochat-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: var(--panochat-font);
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
  color: var(--panochat-text);
  background: var(--panochat-surface);
  transition: border-color .15s;
}
#panochat-input:focus { border-color: var(--panochat-primary); }
#panochat-input::placeholder { color: var(--panochat-text-muted); }

#panochat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--panochat-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
}
#panochat-send:hover   { background: var(--panochat-primary-dark); }
#panochat-send:active  { transform: scale(.93); }
#panochat-send:disabled { opacity: .45; cursor: not-allowed; }

/* ── RESPONSIVE ── */
@media (max-width: 440px) {
  #panochat-window {
    width: calc(100vw - 32px);
    max-height: 70vh;
  }
  #panochat-root.panochat-bottom-right,
  #panochat-root.panochat-bottom-left {
    bottom: 16px;
    right: 16px;
    left: auto;
  }
}
