/* ═══════════════════════════════════════════════════════════════
   RBQ ESTUDIO JURÍDICO — Chatbot Widget
   OS Quiet Luxury · Famara Web Studio
═══════════════════════════════════════════════════════════════ */

/* ── Trigger button ─────────────────────────────────────────── */
.rbq-chat-trigger {
  position: fixed;
  bottom: 6.5rem;
  right: 2rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  cursor: pointer;
  z-index: 9100;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(26,25,22,0.22), 0 1px 4px rgba(26,25,22,0.12);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  opacity: 0;
  animation: chatTriggerIn 0.6s 1.2s var(--ease) forwards;
  flex-shrink: 0;
}

@keyframes chatTriggerIn {
  from { opacity: 0; transform: scale(0.7) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.rbq-chat-trigger:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(26,25,22,0.3);
}

.rbq-chat-trigger svg {
  width: 20px;
  height: 20px;
  color: var(--bg);
  transition: transform 0.3s var(--ease), opacity 0.2s;
  flex-shrink: 0;
}

.rbq-chat-trigger .icon-close { display: none; }
.rbq-chat-trigger.open .icon-chat { display: none; }
.rbq-chat-trigger.open .icon-close { display: block; }

/* Notification dot */
.rbq-chat-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent-light);
  border: 2px solid var(--text);
  display: none;
  animation: dotPulse 2s ease-in-out infinite;
}
.rbq-chat-dot.show { display: block; }

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.25); opacity: 0.7; }
}

/* ── Welcome toast ──────────────────────────────────────────── */
.rbq-chat-toast {
  position: fixed;
  bottom: 10.5rem;
  right: 2rem;
  width: 230px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(26,25,22,0.1), 0 2px 8px rgba(26,25,22,0.06);
  padding: 1rem 1.2rem 1.1rem;
  cursor: pointer;
  z-index: 9099;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
  pointer-events: none;
}
.rbq-chat-toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.rbq-chat-toast:hover { box-shadow: 0 12px 40px rgba(26,25,22,0.14); }

.rbq-chat-toast-label {
  font-size: 0.54rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--font-body);
  font-weight: 500;
  display: block;
  margin-bottom: 0.45rem;
}
.rbq-chat-toast p {
  font-size: 0.82rem;
  color: var(--text-2);
  line-height: 1.5;
  font-family: var(--font-body);
  font-weight: 300;
}

/* Dismiss X on toast */
.rbq-chat-toast-close {
  position: absolute;
  top: 0.5rem; right: 0.6rem;
  background: none;
  border: none;
  font-size: 0.9rem;
  color: var(--text-3);
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  transition: color 0.2s;
}
.rbq-chat-toast-close:hover { color: var(--text); }

/* ── Chat panel ─────────────────────────────────────────────── */
.rbq-chat-panel {
  position: fixed;
  bottom: 10.5rem;
  right: 2rem;
  width: 348px;
  height: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(26,25,22,0.16), 0 4px 16px rgba(26,25,22,0.08);
  display: flex;
  flex-direction: column;
  z-index: 9100;
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.38s var(--ease), transform 0.38s var(--ease);
  overflow: hidden;
}
.rbq-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Panel header */
.rbq-chat-header {
  background: var(--text);
  padding: 1rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}
.rbq-chat-header-info { flex: 1; min-width: 0; }
.rbq-chat-header-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 300;
  color: var(--bg);
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rbq-chat-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.18rem;
}
.rbq-chat-status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-light);
  animation: statusPulse 2.8s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}
.rbq-chat-online-label {
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  color: rgba(247,245,241,0.42);
  font-family: var(--font-body);
  text-transform: uppercase;
}
.rbq-chat-close {
  background: none;
  border: none;
  color: rgba(247,245,241,0.45);
  cursor: pointer;
  padding: 0.3rem;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rbq-chat-close:hover { color: var(--bg); }
.rbq-chat-close svg { width: 15px; height: 15px; }

/* Messages */
.rbq-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}
.rbq-chat-messages::-webkit-scrollbar { width: 2px; }
.rbq-chat-messages::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: 2px; }
.rbq-chat-messages::-webkit-scrollbar-track { background: transparent; }

.rbq-chat-msg {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: msgIn 0.32s var(--ease) both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.rbq-chat-bubble {
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 0.8rem 0.95rem;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.65;
  font-family: var(--font-body);
  font-weight: 300;
  max-width: 100%;
}
.rbq-chat-bubble strong {
  color: var(--accent);
  font-weight: 500;
}
.rbq-chat-bubble em {
  font-style: italic;
  color: var(--text-2);
}

/* Action button (WhatsApp, form link) */
.rbq-chat-action-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--font-body);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.28s var(--ease);
  align-self: flex-start;
  animation: msgIn 0.32s 0.12s var(--ease) both;
}
.rbq-chat-action-btn:hover { background: var(--text); }

/* Typing indicator */
.rbq-chat-typing {
  display: flex;
  gap: 5px;
  padding: 0.75rem 0.95rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  width: fit-content;
  animation: msgIn 0.28s var(--ease) both;
}
.rbq-chat-typing span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typingDot 1.1s ease-in-out infinite;
}
.rbq-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.rbq-chat-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typingDot {
  0%, 55%, 100% { transform: translateY(0); opacity: 0.4; }
  28%            { transform: translateY(-5px); opacity: 1; }
}

/* Chips */
.rbq-chat-chips {
  padding: 0.7rem 0.9rem 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.rbq-chip {
  background: transparent;
  border: 1px solid var(--border-accent);
  color: var(--accent);
  font-size: 0.63rem;
  letter-spacing: 0.05em;
  font-family: var(--font-body);
  font-weight: 400;
  padding: 0.32rem 0.72rem;
  cursor: pointer;
  transition: background 0.22s var(--ease), color 0.22s, border-color 0.22s;
  white-space: nowrap;
  line-height: 1.4;
}
.rbq-chip:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.rbq-chip-home {
  border-color: var(--border);
  color: var(--text-3);
  margin-left: auto;
}
.rbq-chip-home:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .rbq-chat-trigger { bottom: 10.5rem; right: 1.2rem; left: auto; width: 48px; height: 48px; }
  .rbq-chat-trigger svg { width: 18px; height: 18px; }
  .rbq-chat-toast  { bottom: 15rem; right: 1.2rem; left: auto; width: 210px; }
  .rbq-chat-panel  {
    bottom: 0; left: 0; right: 0;
    width: 100%;
    height: 72vh;
    border-left: none; border-right: none; border-bottom: none;
    border-radius: 0;
  }
}
@media (max-width: 480px) {
  .rbq-chat-trigger { bottom: 10rem; right: 1rem; left: auto; }
  .rbq-chat-toast   { bottom: 14.5rem; right: 1rem; left: auto; }
  .rbq-chat-panel   { height: 76vh; }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .rbq-chat-trigger,
  .rbq-chat-msg,
  .rbq-chat-typing span { animation: none; }
  .rbq-chat-trigger { opacity: 1; }
}
