/* ============================================================
   Mobflix — Chat Widget (LP Curso de Revit)
   Namespace .mobflix-chat — isolado, consome tokens da LP
   ============================================================ */

.mobflix-chat,
.mobflix-chat *,
.mobflix-chat *::before,
.mobflix-chat *::after { box-sizing: border-box; }

.mobflix-chat {
  --mc-bg: var(--bg, #050508);
  --mc-surface: var(--surface, #16161D);
  --mc-surface-2: var(--surface-2, #1F1F28);
  --mc-line: var(--line, #25252F);
  --mc-text: var(--text, #FFFFFF);
  --mc-text-2: var(--text-2, #C9C9D1);
  --mc-mute: var(--text-mute, #8B8B96);
  --mc-green: var(--green, #22C55E);
  --mc-green-soft: var(--green-soft, #4ADE80);
  --mc-green-bg: var(--green-bg, rgba(34, 197, 94, 0.08));
  --mc-radius: var(--radius, 14px);
  --mc-radius-lg: var(--radius-lg, 20px);
  --mc-shadow-lg: 0 30px 80px -20px rgba(0,0,0,.55), 0 12px 32px -10px rgba(0,0,0,.35);
  --mc-shadow-green: 0 12px 40px -8px rgba(34,197,94,.45);
  --mc-transition: var(--transition, 200ms cubic-bezier(0.2, 0.8, 0.2, 1));
  --mc-font: 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-family: var(--mc-font);
  color: var(--mc-text);
}

/* ---------- FAB ---------- */
.mobflix-chat__fab {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--mc-green) 0%, var(--mc-green-soft) 100%);
  color: #042510;
  cursor: pointer;
  box-shadow: var(--mc-shadow-green);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--mc-transition), box-shadow var(--mc-transition), opacity var(--mc-transition);
  opacity: 0;
  transform: translateY(20px) scale(.85);
  pointer-events: none;
}
.mobflix-chat__fab.is-ready {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.mobflix-chat__fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 18px 50px -8px rgba(34,197,94,.6);
}
.mobflix-chat__fab:active { transform: translateY(0) scale(.98); }
.mobflix-chat__fab:focus-visible {
  outline: 3px solid rgba(34,197,94,.45);
  outline-offset: 3px;
}
.mobflix-chat__fab svg { width: 28px; height: 28px; }
.mobflix-chat__fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ff3b30;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 3px var(--mc-bg);
  animation: mc-pulse 2s infinite;
}
@keyframes mc-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .mobflix-chat__fab-badge { animation: none; }
}

/* Coordena com .sticky-bar mobile (esconde FAB quando sticky aparece) */
@media (max-width: 900px) {
  .mobflix-chat__fab {
    bottom: 18px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
  body:has(.sticky-bar.is-visible) .mobflix-chat__fab {
    bottom: 84px;
  }
}

/* ---------- Preview bubble (mensagem-isca proativa) ---------- */
.mobflix-chat__preview {
  position: fixed;
  bottom: 96px;
  right: 22px;
  z-index: 9997;
  max-width: 280px;
  background: var(--mc-surface);
  color: var(--mc-text);
  border: 1px solid var(--mc-line);
  border-radius: var(--mc-radius);
  padding: 14px 38px 14px 16px;
  box-shadow: var(--mc-shadow-lg);
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(.95);
  pointer-events: none;
  transition: opacity 320ms var(--mc-transition), transform 320ms var(--mc-transition);
}
.mobflix-chat__preview.is-shown {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.mobflix-chat__preview::before {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 24px;
  width: 12px;
  height: 12px;
  background: var(--mc-surface);
  border-right: 1px solid var(--mc-line);
  border-bottom: 1px solid var(--mc-line);
  transform: rotate(45deg);
}
.mobflix-chat__preview-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--mc-green);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.mobflix-chat__preview-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--mc-mute);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.mobflix-chat__preview-close:hover { background: var(--mc-surface-2); color: var(--mc-text); }
@media (max-width: 900px) {
  .mobflix-chat__preview { right: 16px; bottom: 86px; max-width: calc(100vw - 32px); }
  body:has(.sticky-bar.is-visible) .mobflix-chat__preview { bottom: 152px; }
}

/* ---------- Painel ---------- */
.mobflix-chat__panel {
  position: fixed;
  bottom: 96px;
  right: 22px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: min(620px, calc(100vh - 120px));
  background: var(--mc-bg);
  border: 1px solid var(--mc-line);
  border-radius: var(--mc-radius-lg);
  box-shadow: var(--mc-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(.96);
  pointer-events: none;
  transition: opacity 240ms var(--mc-transition), transform 240ms var(--mc-transition);
}
.mobflix-chat__panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (max-width: 640px) {
  .mobflix-chat__panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
}

/* ---------- Header ---------- */
.mobflix-chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(34,197,94,.10) 0%, transparent 100%);
  border-bottom: 1px solid var(--mc-line);
  flex-shrink: 0;
}
.mobflix-chat__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mc-green) 0%, var(--mc-green-soft) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #042510;
  font-size: 16px;
  flex-shrink: 0;
  position: relative;
}
.mobflix-chat__avatar::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--mc-green-soft);
  border: 2px solid var(--mc-bg);
}
.mobflix-chat__header-info { flex: 1; min-width: 0; }
.mobflix-chat__header-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--mc-text);
}
.mobflix-chat__header-status {
  font-size: 12px;
  color: var(--mc-mute);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.mobflix-chat__header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mc-green-soft);
  box-shadow: 0 0 8px var(--mc-green-soft);
}
.mobflix-chat__close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--mc-text-2);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--mc-transition);
}
.mobflix-chat__close:hover { background: var(--mc-surface-2); color: var(--mc-text); }

/* ---------- Body ---------- */
.mobflix-chat__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    radial-gradient(ellipse at top, rgba(34,197,94,.04) 0%, transparent 60%),
    var(--mc-bg);
  scroll-behavior: smooth;
}
.mobflix-chat__body::-webkit-scrollbar { width: 6px; }
.mobflix-chat__body::-webkit-scrollbar-track { background: transparent; }
.mobflix-chat__body::-webkit-scrollbar-thumb { background: var(--mc-line); border-radius: 3px; }

.mobflix-chat__msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: mc-msg-in 220ms var(--mc-transition);
}
@keyframes mc-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.mobflix-chat__msg--bot {
  align-self: flex-start;
  background: var(--mc-surface);
  border: 1px solid var(--mc-line);
  border-bottom-left-radius: 6px;
  color: var(--mc-text);
}
.mobflix-chat__msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--mc-green) 0%, var(--mc-green-soft) 100%);
  border-bottom-right-radius: 6px;
  color: #042510;
  font-weight: 500;
}
.mobflix-chat__msg--bot a {
  color: var(--mc-green-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Caret de streaming */
.mobflix-chat__msg.is-streaming::after {
  content: '▎';
  display: inline-block;
  margin-left: 2px;
  color: var(--mc-green);
  animation: mc-caret 800ms infinite;
}
@keyframes mc-caret {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Indicador "digitando" (antes do primeiro token) */
.mobflix-chat__typing {
  align-self: flex-start;
  background: var(--mc-surface);
  border: 1px solid var(--mc-line);
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  padding: 12px 16px;
  display: inline-flex;
  gap: 4px;
}
.mobflix-chat__typing span {
  width: 7px;
  height: 7px;
  background: var(--mc-mute);
  border-radius: 50%;
  animation: mc-dot 1.2s infinite;
}
.mobflix-chat__typing span:nth-child(2) { animation-delay: .15s; }
.mobflix-chat__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes mc-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- CTA inline (link Eduzz dentro da bolha) ---------- */
.mobflix-chat__cta-inline {
  align-self: flex-start;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  background: linear-gradient(135deg, var(--mc-green) 0%, var(--mc-green-soft) 100%);
  color: #042510;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  border-radius: 999px;
  box-shadow: var(--mc-shadow-green);
  transition: transform var(--mc-transition), box-shadow var(--mc-transition);
  animation: mc-msg-in 280ms var(--mc-transition);
}
.mobflix-chat__cta-inline:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 50px -8px rgba(34,197,94,.6);
}
.mobflix-chat__cta-inline svg { width: 14px; height: 14px; }

/* ---------- Quick replies ---------- */
.mobflix-chat__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  align-self: flex-start;
  max-width: 100%;
  animation: mc-msg-in 280ms var(--mc-transition);
}
.mobflix-chat__quick button {
  border: 1px solid var(--mc-green);
  background: var(--mc-green-bg);
  color: var(--mc-green-soft);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--mc-transition), transform var(--mc-transition);
  font-weight: 500;
}
.mobflix-chat__quick button:hover {
  background: rgba(34,197,94,.15);
  transform: translateY(-1px);
}

/* ---------- Footer / input ---------- */
.mobflix-chat__footer {
  flex-shrink: 0;
  padding: 12px 12px 14px;
  border-top: 1px solid var(--mc-line);
  background: var(--mc-bg);
}
.mobflix-chat__input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--mc-surface);
  border: 1px solid var(--mc-line);
  border-radius: 22px;
  padding: 6px 6px 6px 14px;
  transition: border-color var(--mc-transition);
}
.mobflix-chat__input-wrap:focus-within { border-color: var(--mc-green); }
.mobflix-chat__input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--mc-text);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  resize: none;
  max-height: 110px;
  padding: 8px 0;
}
.mobflix-chat__input::placeholder { color: var(--mc-mute); }
.mobflix-chat__send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--mc-green);
  color: #042510;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--mc-transition), opacity var(--mc-transition), background var(--mc-transition);
}
.mobflix-chat__send:hover:not(:disabled) {
  background: var(--mc-green-soft);
  transform: scale(1.05);
}
.mobflix-chat__send:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.mobflix-chat__send svg { width: 18px; height: 18px; }
.mobflix-chat__footer-hint {
  text-align: center;
  font-size: 11px;
  color: var(--mc-mute);
  margin-top: 8px;
}

/* Acessibilidade — esconde visualmente */
.mobflix-chat__sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
