/* ================================================================
   Monabot — WhatsApp Multi-Departamento
   Frontend styles with organic pulse effect
   ================================================================ */

:root {
  --mbt-theme:   #1a1a2e;
  --mbt-accent:  #e94560;
  --mbt-size:    64px;
  --mbt-z:       99999;
  --mbt-ease:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --mbt-shadow:  0 16px 48px rgba(0,0,0,0.25);
  --mbt-radius:  20px;
}

/* ── Root ────────────────────────────────────────────────────── */
/*
  IMPORTANT: padding + negative margin creates space so
  rings don't get clipped by the viewport edge.
  overflow must NEVER be hidden here.
*/
#mbt-root {
  position: fixed;
  z-index: var(--mbt-z);
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  padding: 70px;
  margin: -70px;
}
#mbt-root[data-position="bottom-right"] { bottom: 28px; right: 28px; align-items: flex-end; }
#mbt-root[data-position="bottom-left"]  { bottom: 28px; left:  28px; align-items: flex-start; }

/*
  ── Ring Wrapper ─────────────────────────────────────────────
  KEY FIX: rings live in a 200×200 wrapper, NOT inside the button.
  The button (64×64) is centered inside this wrapper via flex.
  This means rings can grow to ~150px without ever being clipped.
*/
.mbt-btn-wrap {
  position: relative;
  width:  200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;   /* ← CRITICAL: never clip the rings */
  pointer-events: none;
}

/* ── Pulse Rings ─────────────────────────────────────────────── */
.mbt-ring {
  position: absolute;
  top:  50%;
  left: 50%;
  border-radius: 50%;
  border: 2px solid var(--mbt-theme);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

/* Organic (3 waves, staggered) */
.mbt-wrap--pulse-organic .mbt-ring-1 {
  width:  calc(var(--mbt-size) + 24px);
  height: calc(var(--mbt-size) + 24px);
  animation: mbt-organic 2.8s ease-out infinite 0s;
}
.mbt-wrap--pulse-organic .mbt-ring-2 {
  width:  calc(var(--mbt-size) + 54px);
  height: calc(var(--mbt-size) + 54px);
  animation: mbt-organic 2.8s ease-out infinite 0.75s;
}
.mbt-wrap--pulse-organic .mbt-ring-3 {
  width:  calc(var(--mbt-size) + 86px);
  height: calc(var(--mbt-size) + 86px);
  animation: mbt-organic 2.8s ease-out infinite 1.5s;
}
@keyframes mbt-organic {
  0%   { transform: translate(-50%,-50%) scale(0.82); opacity: 0.9;  }
  60%  { transform: translate(-50%,-50%) scale(1.22); opacity: 0.25; }
  100% { transform: translate(-50%,-50%) scale(1.45); opacity: 0;    }
}

/* Pulse Ring */
.mbt-wrap--pulse-ring .mbt-ring-1 {
  width:  calc(var(--mbt-size) + 28px);
  height: calc(var(--mbt-size) + 28px);
  border-width: 3px;
  animation: mbt-ring 1.9s ease-out infinite 0s;
}
.mbt-wrap--pulse-ring .mbt-ring-2 {
  width:  calc(var(--mbt-size) + 58px);
  height: calc(var(--mbt-size) + 58px);
  animation: mbt-ring 1.9s ease-out infinite 0.45s;
}
.mbt-wrap--pulse-ring .mbt-ring-3 { display: none; }
@keyframes mbt-ring {
  0%   { transform: translate(-50%,-50%) scale(1);    opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1.45); opacity: 0; }
}

/* Minimal */
.mbt-wrap--minimal .mbt-ring { display: none; }

/* Pause rings when widget open */
.mbt-btn-wrap.is-open .mbt-ring { animation-play-state: paused; opacity: 0 !important; }

/* ── Floating Button ─────────────────────────────────────────── */
.mbt-btn {
  position: relative;
  z-index: 2;
  width:  var(--mbt-size);
  height: var(--mbt-size);
  border-radius: 50%; border: none; cursor: pointer;
  pointer-events: all; background: transparent; padding: 0;
  outline: none; -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  animation: mbt-entrance 0.65s var(--mbt-ease) both;
}
@keyframes mbt-entrance {
  from { transform: scale(0) rotate(-180deg); opacity: 0; }
  to   { transform: scale(1) rotate(0);       opacity: 1; }
}

.mbt-inner {
  width:  var(--mbt-size);
  height: var(--mbt-size);
  border-radius: 50%;
  background: var(--mbt-theme);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--mbt-shadow);
  transition: transform 0.35s var(--mbt-ease), background 0.3s;
  position: relative;
}
.mbt-btn:hover .mbt-inner { transform: scale(1.1); }

/* Icons */
.mbt-icon-wa, .mbt-icon-close {
  width: 30px; height: 30px; position: absolute;
  transition: opacity 0.3s, transform 0.4s var(--mbt-ease);
}
.mbt-icon-close { opacity: 0; transform: rotate(-90deg) scale(0.5); }
.mbt-icon-wa    { opacity: 1; transform: rotate(0) scale(1); }
.mbt-btn-wrap.is-open .mbt-icon-wa    { opacity: 0; transform: rotate(90deg) scale(0.5); }
.mbt-btn-wrap.is-open .mbt-icon-close { opacity: 1; transform: rotate(0) scale(1); }
.mbt-btn-wrap.is-open .mbt-inner      { background: var(--mbt-accent); }

/* Notification dot */
.mbt-notif-dot {
  position: absolute; top: -2px; right: -2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--mbt-accent); border: 2.5px solid white;
  z-index: 3; transition: opacity 0.3s, transform 0.35s var(--mbt-ease);
}
.mbt-btn-wrap.is-open .mbt-notif-dot { opacity: 0; transform: scale(0); }

/* ── Widget ──────────────────────────────────────────────────── */
.mbt-widget {
  pointer-events: all;
  width: 360px;
  border-radius: var(--mbt-radius);
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.1);
  transform-origin: bottom right;
  transition: opacity 0.4s ease, transform 0.5s var(--mbt-ease);
  background: white;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#mbt-root[data-position="bottom-left"] .mbt-widget { transform-origin: bottom left; }

.mbt-widget[aria-hidden="true"]  { opacity: 0; transform: scale(0.72) translateY(24px); pointer-events: none; }
.mbt-widget[aria-hidden="false"] { opacity: 1; transform: scale(1) translateY(0); }

/* Header */
.mbt-header {
  background: var(--mbt-theme);
  padding: 20px 20px;
  display: flex; align-items: center; gap: 14px;
  position: relative;
}
.mbt-header::after {
  content: ''; position: absolute;
  bottom: -1px; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}
.mbt-header-logo {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,0.15); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  position: relative; border: 2px solid rgba(255,255,255,0.2);
}
.mbt-logo-ring {
  position: absolute; inset: -5px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.2);
  animation: mbt-logo-ring 3s ease-in-out infinite;
}
@keyframes mbt-logo-ring {
  0%,100% { opacity: 0.3; transform: scale(1); }
  50%     { opacity: 0.7; transform: scale(1.05); }
}
.mbt-logo-icon { display: flex; align-items: center; justify-content: center; }
.mbt-header-info { flex: 1; }
.mbt-brand-name { font-size: 16px; font-weight: 700; color: white; letter-spacing: 0.02em; }
.mbt-online-status {
  font-size: 12px; color: rgba(255,255,255,0.75);
  display: flex; align-items: center; gap: 6px; margin-top: 3px;
}
.mbt-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; flex-shrink: 0;
  animation: mbt-blink 2s ease-in-out infinite;
}
@keyframes mbt-blink { 0%,100%{opacity:1} 50%{opacity:0.4} }
.mbt-close-btn {
  background: rgba(255,255,255,0.12); border: none; border-radius: 50%;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: white; transition: background 0.2s; flex-shrink: 0;
}
.mbt-close-btn svg { width: 14px; height: 14px; }
.mbt-close-btn:hover { background: rgba(255,255,255,0.22); }

/* Body */
.mbt-body { background: #f0f2f5; padding: 20px 16px 16px; }

/* Greeting bubble */
.mbt-greeting-wrap { margin-bottom: 16px; }
.mbt-chat-bubble {
  background: white; border-radius: 4px 18px 18px 18px;
  padding: 14px 18px; display: inline-block; max-width: 88%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07); border: 1px solid #eee;
  position: relative;
}
.mbt-chat-bubble::before {
  content: ''; position: absolute; top: 0; left: -8px;
  border: 8px solid transparent; border-right-color: white; border-top-color: white;
}
.mbt-greeting-text { font-size: 14px; line-height: 1.6; color: #1a1a1a; }

/* Typing dots */
.mbt-typing-wrap {
  display: flex; gap: 5px; align-items: center; padding: 2px 4px;
}
.mbt-typing-wrap span {
  width: 8px; height: 8px; border-radius: 50%; background: #c0c0c0;
  animation: mbt-dot 1.4s ease-in-out infinite;
}
.mbt-typing-wrap span:nth-child(2) { animation-delay: 0.2s; }
.mbt-typing-wrap span:nth-child(3) { animation-delay: 0.4s; }
@keyframes mbt-dot { 0%,80%,100%{transform:scale(0.6);opacity:0.4} 40%{transform:scale(1);opacity:1} }

/* Departments */
.mbt-departments { display: flex; flex-direction: column; gap: 8px; }

.mbt-dept-btn {
  width: 100%;
  background: white; border: 1.5px solid #e8e8e8;
  border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; text-align: left;
  transition: all 0.25s ease;
  font-family: inherit;
  animation: mbt-dept-in 0.5s var(--mbt-ease) both;
}
.mbt-dept-btn:nth-child(1) { animation-delay: 0.05s; }
.mbt-dept-btn:nth-child(2) { animation-delay: 0.12s; }
.mbt-dept-btn:nth-child(3) { animation-delay: 0.19s; }
.mbt-dept-btn:nth-child(4) { animation-delay: 0.26s; }
.mbt-dept-btn:nth-child(5) { animation-delay: 0.33s; }

@keyframes mbt-dept-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mbt-dept-btn:hover {
  border-color: var(--mbt-theme);
  background: #f8f9ff;
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.mbt-dept-btn:active { transform: scale(0.98) translateX(0); }

.mbt-dept-icon {
  font-size: 24px; flex-shrink: 0; line-height: 1;
  width: 44px; height: 44px; border-radius: 12px;
  background: #f5f5f5; display: flex; align-items: center; justify-content: center;
  transition: background 0.25s;
}
.mbt-dept-btn:hover .mbt-dept-icon { background: rgba(26,26,46,0.08); }

.mbt-dept-info { flex: 1; min-width: 0; }
.mbt-dept-name { display: block; font-size: 14px; font-weight: 600; color: #1a1a1a; margin-bottom: 2px; }
.mbt-dept-desc { display: block; font-size: 12px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mbt-dept-arrow { width: 16px; height: 16px; color: #ccc; flex-shrink: 0; transition: color 0.25s, transform 0.25s; }
.mbt-dept-btn:hover .mbt-dept-arrow { color: var(--mbt-theme); transform: translateX(2px); }

/* Footer */
.mbt-footer {
  background: white; padding: 10px 16px;
  text-align: center; font-size: 11px; color: #bbb;
  border-top: 1px solid #f0f0f0; letter-spacing: 0.05em;
}
.mbt-footer strong { color: #999; }

/* ── Accessibility ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .mbt-ring, .mbt-logo-ring, .mbt-dot, .mbt-typing-wrap span { animation: none !important; }
  .mbt-widget { transition: opacity 0.15s ease !important; }
  .mbt-btn { animation: none !important; }
  .mbt-dept-btn { animation: none !important; }
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .mbt-widget { width: calc(100vw - 32px); }
  #mbt-root[data-position="bottom-right"] { right: 16px; bottom: 16px; }
  #mbt-root[data-position="bottom-left"]  { left:  16px; bottom: 16px; }
}

.mbt-btn{border-radius:50%!important;overflow:hidden!important;background:var(--mbt-theme)!important;display:flex!important;align-items:center!important;justify-content:center!important;}
.mbt-inner{position:absolute!important;inset:0!important;background:transparent!important;border-radius:0!important;box-shadow:none!important;}
.mbt-btn-wrap.is-open .mbt-btn{background:var(--mbt-accent)!important;}
