/* =========================================================================
   SOMBRAS OSIRIS · Widget de chat "Laura"
   Depende de osiris-home.css
   ========================================================================= */

/* ---- Burbuja flotante ---- */
#chatBubble {
  position: fixed; bottom: 24px; right: 24px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); border: none; cursor: pointer;
  box-shadow: 0 10px 32px var(--accent-glow);
  display: flex; align-items: center; justify-content: center; z-index: 998;
  transition: transform .2s; animation: chatpulse 2.4s ease-in-out infinite;
}
#chatBubble:hover { transform: scale(1.08); }
#chatBubble svg { width: 28px; height: 28px; }
#chatBubble .chat-bubble-photo {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
}
#chatBubble .chat-bubble-dot {
  position: absolute; top: 2px; right: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--green); border: 2px solid var(--surface); box-shadow: 0 0 8px var(--green);
}
#chatBubble.hidden { display: none; }

/* ---- Teaser (mini-chat que se abre al entrar) ---- */
#chatTeaser {
  position: fixed; right: 24px; bottom: 24px; z-index: 997;
  width: 290px; max-width: calc(100vw - 36px);
  background: var(--surface); border: 1px solid var(--line2); border-radius: 16px;
  box-shadow: 0 22px 60px rgba(0,0,0,.5);
  padding: 14px 32px 14px 14px; cursor: pointer;
  display: none; align-items: flex-start; gap: 12px;
  transform-origin: bottom right;
}
#chatTeaser.show { display: flex; animation: teaserIn .32s cubic-bezier(.16,1,.3,1); }
#chatTeaser:hover { border-color: var(--accent-line); }
@keyframes teaserIn { from { opacity: 0; transform: translateY(14px) scale(.92); } to { opacity: 1; transform: translateY(0) scale(1); } }
#chatTeaser .teaser-avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 2px solid var(--accent-line);
}
#chatTeaser .teaser-body { flex: 1; min-width: 0; }
#chatTeaser .teaser-name {
  font-weight: 600; font-size: 13.5px; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
#chatTeaser .teaser-name::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px var(--green); flex-shrink: 0;
}
#chatTeaser .teaser-text { font-size: 13.5px; line-height: 1.4; color: var(--text-dim); margin-top: 4px; }
#chatTeaser .teaser-close {
  position: absolute; top: 8px; right: 8px; background: none; border: none;
  color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; display: flex;
  transition: background var(--t-fast), color var(--t-fast);
}
#chatTeaser .teaser-close:hover { background: var(--surface3); color: var(--text); }
#chatTeaser .teaser-close svg { width: 15px; height: 15px; }
@media (prefers-reduced-motion: reduce) { #chatTeaser.show { animation: none; } }
@keyframes chatpulse {
  0%   { box-shadow: 0 10px 32px var(--accent-glow), 0 0 0 0 rgba(212,160,23,.5); }
  70%  { box-shadow: 0 10px 32px var(--accent-glow), 0 0 0 18px rgba(212,160,23,0); }
  100% { box-shadow: 0 10px 32px var(--accent-glow), 0 0 0 0 rgba(212,160,23,0); }
}
@media (prefers-reduced-motion: reduce) { #chatBubble { animation: none; } }

/* ---- Ventana ---- */
#chatWindow {
  position: fixed; bottom: 24px; right: 24px;
  width: 392px; height: 600px; max-height: calc(100vh - 48px);
  background: var(--surface); border: 1px solid var(--line2); border-radius: var(--radius-xl);
  box-shadow: 0 28px 80px rgba(0,0,0,.55);
  display: none; flex-direction: column; overflow: hidden; z-index: 999;
  animation: chatSlideUp .26s cubic-bezier(.16,1,.3,1);
}
#chatWindow.open { display: flex; }
@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-header {
  background: linear-gradient(135deg, var(--surface2), var(--surface3));
  padding: 16px 18px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line);
}
.chat-avatar {
  width: 42px; height: 42px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 19px; flex-shrink: 0;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-title-block { flex: 1; }
.chat-title { font-weight: 600; font-size: 15px; color: var(--text); }
.chat-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.chat-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.chat-close { background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: flex; transition: background var(--t-fast), color var(--t-fast); }
.chat-close:hover { background: var(--surface3); color: var(--text); }
.chat-close svg { width: 18px; height: 18px; }

.chat-body { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }

.msg {
  max-width: 80%; padding: 10px 14px; border-radius: 14px;
  font-size: 14.5px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; animation: msgIn .2s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg.bot { background: var(--surface2); color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.user { background: var(--accent); color: var(--on-accent); font-weight: 500; border-bottom-right-radius: 4px; align-self: flex-end; }

.typing { align-self: flex-start; background: var(--surface2); border: 1px solid var(--line); padding: 12px 14px; border-radius: 14px; border-bottom-left-radius: 4px; display: flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: typingDot 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typingDot { 0%,60%,100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.quick-actions { padding: 4px 16px 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.quick-actions button {
  background: var(--surface2); border: 1px solid var(--line); color: var(--text-dim);
  padding: 8px 12px; border-radius: 18px; font-family: var(--font-body); font-size: 13px; cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.quick-actions button:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.quick-actions.hidden { display: none; }

.chat-input-area { border-top: 1px solid var(--line); padding: 12px 12px 14px; display: flex; gap: 8px; align-items: flex-end; background: var(--surface); }
.chat-input {
  flex: 1; background: var(--surface2); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px; color: var(--text); font-family: var(--font-body); font-size: 14.5px;
  resize: none; min-height: 42px; max-height: 100px; outline: none; transition: border-color var(--t-fast);
}
.chat-input:focus { border-color: var(--accent-line); }
.chat-input::placeholder { color: var(--hint); }
.chat-send {
  width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: transform var(--t-fast), background var(--t-fast);
}
.chat-send:hover { transform: scale(1.06); background: var(--accent-2); }
.chat-send svg { width: 20px; height: 20px; }

@media (max-width: 600px) {
  body:has(#chatWindow.open) { overflow: hidden; position: fixed; width: 100%; }
  #chatWindow {
    top: 0; left: 0; right: 0; bottom: 0; width: 100%;
    height: var(--vvh, 100vh); max-height: var(--vvh, 100vh);
    border-radius: 0; border: none;
  }
  #chatBubble { bottom: 16px; right: 16px; width: 48px; height: 48px; }
}
