/*
 * Maximus Bone Expander IA — chat público
 * Sistema visual: Consultor Maximus Design System v1.0 (handoff).
 * Todas as regras são prefixadas com .mbeai- para não vazar para o tema.
 * Exceção controlada: .mbeai-scroll-lock / .mbeai-body-lock, aplicadas via JS
 * apenas enquanto o chat fullscreen mobile está ativo.
 */

/* ===== Lock global (somente com o app mobile aberto) ===== */
html.mbeai-scroll-lock {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

body.mbeai-body-lock {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

/* ===== Shell ===== */
.mbeai-chat-shell,
.mbeai-chat-shell *,
.mbeai-chat-shell *::before,
.mbeai-chat-shell *::after {
  box-sizing: border-box;
}

.mbeai-chat-shell {
  /* Tokens — Consultor Maximus DS v1.0 */
  --mbeai-bg-base: #07070b;
  --mbeai-bg-secondary: #101119;
  --mbeai-bg-chat: #0c0c12;
  --mbeai-glass: rgba(255, 255, 255, 0.05);
  --mbeai-glass-soft: rgba(255, 255, 255, 0.04);
  --mbeai-glass-medium: rgba(255, 255, 255, 0.06);
  --mbeai-glass-strong: rgba(255, 255, 255, 0.08);
  --mbeai-border: rgba(255, 255, 255, 0.08);
  --mbeai-border-soft: rgba(255, 255, 255, 0.07);
  --mbeai-border-strong: rgba(255, 255, 255, 0.12);
  --mbeai-text: #f5f5f7;
  --mbeai-text-secondary: rgba(245, 245, 247, 0.6);
  --mbeai-text-tertiary: rgba(245, 245, 247, 0.38);
  --mbeai-placeholder: rgba(245, 245, 247, 0.4);
  --mbeai-gold-light: #ead199;
  --mbeai-gold: #d8b26a;
  --mbeai-gold-mid: #c79a48;
  --mbeai-gold-deep: #b98b3e;
  --mbeai-gold-gradient: linear-gradient(150deg, #ead199, #c79a48);
  --mbeai-gold-ink: #1c1608;
  --mbeai-success: #5fd08a;
  --mbeai-warning: #f0b24a;
  --mbeai-error: #f0685e;
  --mbeai-info: #6fa8ff;
  --mbeai-radius-sm: 8px;
  --mbeai-radius-md: 14px;
  --mbeai-radius-lg: 20px;
  --mbeai-radius-xl: 28px;
  --mbeai-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.9);
  --mbeai-blur: blur(24px) saturate(150%);

  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--mbeai-text);
  background:
    radial-gradient(1100px 700px at 82% -8%, rgba(216, 178, 106, 0.16), transparent 60%),
    radial-gradient(900px 620px at 8% 108%, rgba(120, 108, 200, 0.13), transparent 60%),
    linear-gradient(180deg, #09090e 0%, #07070b 100%);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  isolation: isolate;
}

.mbeai-chat-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 0%, transparent 55%, rgba(0, 0, 0, 0.5) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 36%);
}

/* Fullscreen real no mobile (classe aplicada via JS) */
.mbeai-chat-shell.mbeai-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 999999;
  width: 100vw;
  height: var(--mbeai-app-height, 100dvh);
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.mbeai-chat-shell.mbeai-fullscreen .mbeai-chat-app {
  height: 100%;
  min-height: 0;
  max-width: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* ===== Reset interno (escopado) ===== */
.mbeai-chat-shell :where(button, textarea, img, p, ul, ol, a, svg, strong, span) {
  font: inherit;
}

.mbeai-chat-shell :where(button, textarea) {
  margin: 0;
}

.mbeai-chat-shell button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
  color: inherit;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mbeai-chat-shell textarea {
  appearance: none;
  -webkit-appearance: none;
}

.mbeai-chat-shell img,
.mbeai-chat-shell svg {
  display: block;
  max-width: 100%;
}

.mbeai-chat-shell p {
  margin: 0;
  padding: 0;
}

.mbeai-chat-shell a {
  color: var(--mbeai-gold);
  text-decoration: none;
}

.mbeai-chat-shell a:hover {
  color: var(--mbeai-gold-light);
}

/* ===== App ===== */
.mbeai-chat-shell .mbeai-chat-app {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  max-width: 760px;
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(600px 400px at 85% 0%, rgba(216, 178, 106, 0.13), transparent 55%),
    radial-gradient(500px 420px at 0% 100%, rgba(120, 108, 200, 0.12), transparent 55%),
    linear-gradient(180deg, #0c0c12, #08080d);
}

/* ===== Header ===== */
.mbeai-chat-shell .mbeai-chat-header {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: max(10px, env(safe-area-inset-top, 0px)) 12px 12px 8px;
  background: rgba(12, 12, 18, 0.55);
  border-bottom: 1px solid var(--mbeai-border-soft);
  backdrop-filter: var(--mbeai-blur);
  -webkit-backdrop-filter: var(--mbeai-blur);
}

.mbeai-chat-shell .mbeai-header-btn {
  display: grid;
  width: 38px;
  height: 38px;
  min-width: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: var(--mbeai-text);
  transition: background 0.16s ease, transform 0.16s ease;
}

.mbeai-chat-shell .mbeai-back {
  background: transparent;
}

.mbeai-chat-shell .mbeai-menu-toggle {
  background: var(--mbeai-glass-medium);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mbeai-chat-shell .mbeai-header-btn:hover {
  background: var(--mbeai-glass-strong);
}

.mbeai-chat-shell .mbeai-header-btn:active {
  transform: scale(0.94);
}

.mbeai-chat-shell .mbeai-avatar {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  overflow: visible;
  border-radius: 13px;
  color: var(--mbeai-gold-ink);
  background: var(--mbeai-gold-gradient);
  box-shadow: 0 8px 20px -10px rgba(216, 178, 106, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.mbeai-chat-shell .mbeai-avatar img {
  width: 100%;
  height: 100%;
  padding: 5px;
  border-radius: inherit;
  object-fit: contain;
}

.mbeai-chat-shell .mbeai-avatar-status {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  border: 2.5px solid #0c0c12;
  border-radius: 999px;
  background: var(--mbeai-success);
}

.mbeai-chat-shell .mbeai-header-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.mbeai-chat-shell .mbeai-header-copy h2 {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: var(--mbeai-text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-transform: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mbeai-chat-shell .mbeai-header-copy p {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  overflow: hidden;
  color: rgba(245, 245, 247, 0.5);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mbeai-chat-shell .mbeai-status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--mbeai-success);
  box-shadow: 0 0 10px rgba(95, 208, 138, 0.8);
}

/* Menu do header */
.mbeai-chat-shell .mbeai-menu-wrap {
  position: relative;
  flex: 0 0 auto;
}

.mbeai-chat-shell .mbeai-menu,
.mbeai-chat-shell .mbeai-attach-menu {
  position: absolute;
  z-index: 60;
  display: flex;
  min-width: 224px;
  flex-direction: column;
  padding: 6px;
  border: 1px solid var(--mbeai-border-strong);
  border-radius: 16px;
  background: rgba(18, 18, 26, 0.92);
  box-shadow: 0 24px 50px -22px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: var(--mbeai-blur);
  -webkit-backdrop-filter: var(--mbeai-blur);
  animation: mbeai-pop 0.18s ease both;
}

.mbeai-chat-shell .mbeai-menu {
  top: calc(100% + 8px);
  right: 0;
}

.mbeai-chat-shell .mbeai-menu[hidden],
.mbeai-chat-shell .mbeai-attach-menu[hidden] {
  display: none;
}

.mbeai-chat-shell .mbeai-menu > *,
.mbeai-chat-shell .mbeai-attach-menu > * {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 11px;
  color: rgba(245, 245, 247, 0.88);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.mbeai-chat-shell .mbeai-menu > *:hover,
.mbeai-chat-shell .mbeai-attach-menu > *:hover {
  color: var(--mbeai-text);
  background: rgba(255, 255, 255, 0.08);
}

.mbeai-chat-shell .mbeai-menu svg,
.mbeai-chat-shell .mbeai-attach-menu svg {
  flex: 0 0 auto;
  color: var(--mbeai-gold);
}

/* ===== Mensagens ===== */
.mbeai-chat-shell .mbeai-messages-panel {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.mbeai-chat-shell .mbeai-messages {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px 12px;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.mbeai-chat-shell .mbeai-messages::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.mbeai-chat-shell .mbeai-date-divider {
  align-self: center;
  flex: 0 0 auto;
  padding: 5px 12px;
  border: 1px solid var(--mbeai-border-soft);
  border-radius: 999px;
  color: rgba(245, 245, 247, 0.45);
  background: var(--mbeai-glass);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
}

.mbeai-chat-shell .mbeai-message {
  display: flex;
  width: 100%;
  flex: 0 0 auto;
  animation: mbeai-in 0.32s ease both;
}

.mbeai-chat-shell .mbeai-message-user {
  align-self: flex-end;
  max-width: 82%;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.mbeai-chat-shell .mbeai-message-ai {
  align-self: flex-start;
  max-width: 90%;
  flex-direction: column;
  align-items: flex-start;
}

.mbeai-chat-shell .mbeai-ai-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-left: 2px;
  color: rgba(245, 245, 247, 0.85);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.1;
}

.mbeai-chat-shell .mbeai-ai-mark {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: var(--mbeai-gold-ink);
  background: var(--mbeai-gold-gradient);
}

.mbeai-chat-shell .mbeai-bubble {
  width: fit-content;
  max-width: 100%;
  padding: 15px 17px;
  overflow-wrap: anywhere;
  word-break: break-word;
  border: 1px solid var(--mbeai-border);
  border-radius: 6px 20px 20px 20px;
  color: rgba(245, 245, 247, 0.9);
  background: rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 15px;
  line-height: 1.55;
  white-space: normal;
}

.mbeai-chat-shell .mbeai-message-user .mbeai-bubble {
  padding: 12px 16px;
  border-color: var(--mbeai-border-strong);
  border-radius: 20px 20px 6px 20px;
  color: var(--mbeai-text);
  background: rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  line-height: 1.45;
}

/* Miniaturas de anexos dentro da mensagem do usuário */
.mbeai-chat-shell .mbeai-user-attachments {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.mbeai-chat-shell .mbeai-user-attachments img {
  width: 150px;
  height: 104px;
  border: 1px solid var(--mbeai-border-strong);
  border-radius: 20px 20px 6px 20px;
  object-fit: cover;
}

.mbeai-chat-shell .mbeai-user-video-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--mbeai-border-strong);
  border-radius: 20px 20px 6px 20px;
  color: rgba(245, 245, 247, 0.85);
  background: rgba(255, 255, 255, 0.07);
  font-size: 13px;
  font-weight: 600;
}

.mbeai-chat-shell .mbeai-user-video-chip svg {
  color: var(--mbeai-gold);
}

/* Conteúdo formatado das respostas */
.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble p + p,
.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble p + ul,
.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble p + ol,
.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble ul + p,
.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble ol + p {
  margin-top: 10px;
}

.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble ul,
.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble ol {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 0;
  padding-left: 20px;
  list-style-position: outside;
}

.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble ul {
  list-style-type: disc;
}

.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble ol {
  list-style-type: decimal;
}

.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble li {
  margin: 0;
  padding-left: 2px;
}

.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble strong {
  color: var(--mbeai-text);
  font-weight: 700;
}

.mbeai-chat-shell .mbeai-message-ai .mbeai-bubble a {
  word-break: break-word;
  text-decoration: underline;
  text-decoration-color: rgba(216, 178, 106, 0.4);
  text-underline-offset: 2px;
}

/* Aviso de processamento (ex.: vídeo por áudio) */
.mbeai-chat-shell .mbeai-bubble-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 13px;
  border: 1px solid rgba(111, 168, 255, 0.28);
  border-radius: 12px;
  color: rgba(245, 245, 247, 0.85);
  background: rgba(111, 168, 255, 0.08);
  font-size: 13px;
  line-height: 1.4;
}

.mbeai-chat-shell .mbeai-bubble-notice svg {
  flex: 0 0 auto;
  color: var(--mbeai-info);
}

.mbeai-chat-shell .mbeai-user-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(245, 245, 247, 0.4);
  font-size: 11px;
  line-height: 1;
}

.mbeai-chat-shell .mbeai-user-meta svg {
  color: var(--mbeai-success);
}

/* Ações da resposta */
.mbeai-chat-shell .mbeai-response-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
  padding-left: 2px;
  color: rgba(245, 245, 247, 0.5);
}

.mbeai-chat-shell .mbeai-action {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: inherit;
  background: transparent;
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.mbeai-chat-shell .mbeai-action:hover {
  color: var(--mbeai-text);
  background: rgba(255, 255, 255, 0.08);
}

.mbeai-chat-shell .mbeai-action:active {
  transform: scale(0.94);
}

.mbeai-chat-shell .mbeai-action.is-done,
.mbeai-chat-shell .mbeai-action.is-liked {
  color: var(--mbeai-success);
}

.mbeai-chat-shell .mbeai-action.is-speaking {
  color: var(--mbeai-gold);
  background: rgba(216, 178, 106, 0.12);
}

.mbeai-chat-shell .mbeai-action:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

/* Indicador de digitação */
.mbeai-chat-shell .mbeai-typing-bubble {
  display: flex;
  gap: 5px;
  padding: 13px 16px;
  border-radius: 6px 18px 18px 18px;
}

.mbeai-chat-shell .mbeai-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--mbeai-gold);
  animation: mbeai-type 1.2s infinite;
}

.mbeai-chat-shell .mbeai-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.mbeai-chat-shell .mbeai-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* Card de encaminhamento (handoff) */
.mbeai-chat-shell .mbeai-handoff {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid rgba(216, 178, 106, 0.22);
  border-left: 3px solid var(--mbeai-gold);
  border-radius: 12px;
  background: rgba(216, 178, 106, 0.1);
}

.mbeai-chat-shell .mbeai-handoff strong {
  color: var(--mbeai-text);
  font-size: 14px;
  font-weight: 700;
}

.mbeai-chat-shell .mbeai-handoff span {
  color: rgba(245, 245, 247, 0.85);
  font-size: 13.5px;
  line-height: 1.45;
}

.mbeai-chat-shell .mbeai-whatsapp {
  display: inline-flex;
  width: fit-content;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 999px;
  color: #04110d;
  background: linear-gradient(135deg, #75efa5, #25d366);
  box-shadow: 0 12px 26px rgba(37, 211, 102, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.mbeai-chat-shell .mbeai-whatsapp:hover {
  color: #04110d;
  box-shadow: 0 15px 30px rgba(37, 211, 102, 0.28);
  transform: translateY(-1px);
}

/* ===== Dock inferior ===== */
.mbeai-chat-shell .mbeai-bottom-dock {
  position: relative;
  z-index: 30;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--mbeai-border-soft);
  background: rgba(12, 12, 18, 0.6);
  backdrop-filter: var(--mbeai-blur);
  -webkit-backdrop-filter: var(--mbeai-blur);
}

/* Sugestões */
.mbeai-chat-shell .mbeai-suggestions {
  display: flex;
  gap: 8px;
  margin: 0 -14px;
  padding: 0 14px 1px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.mbeai-chat-shell .mbeai-suggestions::-webkit-scrollbar {
  display: none;
}

.mbeai-chat-shell .mbeai-suggestions[hidden] {
  display: none;
}

.mbeai-chat-shell .mbeai-suggestion {
  min-height: 36px;
  flex: 0 0 auto;
  max-width: 82vw;
  padding: 8px 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: rgba(245, 245, 247, 0.85);
  background: var(--mbeai-glass);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.mbeai-chat-shell .mbeai-suggestion:hover {
  border-color: rgba(216, 178, 106, 0.32);
  color: var(--mbeai-text);
  background: rgba(216, 178, 106, 0.1);
}

.mbeai-chat-shell .mbeai-suggestion:active {
  transform: scale(0.98);
}

.mbeai-chat-shell .mbeai-suggestion:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

/* Painel de gravação */
.mbeai-chat-shell .mbeai-recording-panel {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(240, 104, 94, 0.3);
  border-radius: 16px;
  color: var(--mbeai-error);
  background: rgba(240, 104, 94, 0.08);
}

.mbeai-chat-shell .mbeai-recording-panel[hidden] {
  display: none;
}

.mbeai-chat-shell .mbeai-recording-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--mbeai-error);
  box-shadow: 0 0 12px var(--mbeai-error);
  animation: mbeai-pulse 1.4s ease-in-out infinite;
}

.mbeai-chat-shell .mbeai-recording-label {
  min-width: 0;
  color: rgba(245, 245, 247, 0.82);
  font-size: 13px;
  font-weight: 600;
}

.mbeai-chat-shell .mbeai-waveform {
  display: flex;
  height: 26px;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 2.5px;
}

.mbeai-chat-shell .mbeai-waveform span {
  width: 3px;
  height: 50%;
  border-radius: 2px;
  background: currentColor;
  animation: mbeai-wave 1s ease-in-out infinite;
}

.mbeai-chat-shell .mbeai-waveform span:nth-child(2) { height: 80%; animation-delay: 0.1s; }
.mbeai-chat-shell .mbeai-waveform span:nth-child(3) { height: 100%; animation-delay: 0.2s; }
.mbeai-chat-shell .mbeai-waveform span:nth-child(4) { height: 65%; animation-delay: 0.3s; }
.mbeai-chat-shell .mbeai-waveform span:nth-child(5) { height: 90%; animation-delay: 0.4s; }
.mbeai-chat-shell .mbeai-waveform span:nth-child(6) { height: 45%; animation-delay: 0.5s; }
.mbeai-chat-shell .mbeai-waveform span:nth-child(7) { height: 75%; animation-delay: 0.6s; }

.mbeai-chat-shell .mbeai-recording-time {
  flex: 0 0 auto;
  color: var(--mbeai-error);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  font-weight: 500;
}

/* Prévia de anexos */
.mbeai-chat-shell .mbeai-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mbeai-chat-shell .mbeai-attachments[hidden] {
  display: none;
}

.mbeai-chat-shell .mbeai-attachment {
  position: relative;
  flex: 0 0 auto;
  animation: mbeai-pop 0.2s ease both;
}

.mbeai-chat-shell .mbeai-attachment-thumb {
  width: 72px;
  height: 72px;
  overflow: hidden;
  border: 1px solid var(--mbeai-border-strong);
  border-radius: 14px;
}

.mbeai-chat-shell .mbeai-attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mbeai-chat-shell .mbeai-attachment-file {
  display: flex;
  height: 72px;
  align-items: center;
  gap: 10px;
  max-width: 230px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--mbeai-border-strong);
  border-radius: 14px;
  background: var(--mbeai-glass-soft);
}

.mbeai-chat-shell .mbeai-attachment-file-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--mbeai-info);
  background: rgba(111, 168, 255, 0.15);
}

.mbeai-chat-shell .mbeai-attachment-name {
  overflow: hidden;
  color: var(--mbeai-text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mbeai-chat-shell .mbeai-attachment-size {
  margin-top: 2px;
  color: var(--mbeai-text-tertiary);
  font-size: 11px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

.mbeai-chat-shell .mbeai-attachment-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--mbeai-border-strong);
  border-radius: 999px;
  color: #ffffff;
  background: #1c1c22;
  transition: transform 0.15s ease, background 0.15s ease;
}

.mbeai-chat-shell .mbeai-attachment-remove:hover {
  background: var(--mbeai-error);
}

.mbeai-chat-shell .mbeai-attachment-remove:active {
  transform: scale(0.9);
}

/* ===== Composer ===== */
.mbeai-chat-shell .mbeai-composer {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.mbeai-chat-shell .mbeai-attach-wrap {
  position: relative;
  flex: 0 0 auto;
}

.mbeai-chat-shell .mbeai-plus {
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: rgba(245, 245, 247, 0.8);
  background: var(--mbeai-glass-medium);
  transition: background 0.16s ease, transform 0.2s ease, border-color 0.16s ease;
}

.mbeai-chat-shell .mbeai-plus:hover {
  background: var(--mbeai-glass-strong);
}

.mbeai-chat-shell .mbeai-plus:active {
  transform: scale(0.94);
}

.mbeai-chat-shell .mbeai-plus[aria-expanded="true"] {
  border-color: rgba(216, 178, 106, 0.4);
  color: var(--mbeai-gold);
  transform: rotate(45deg);
}

.mbeai-chat-shell .mbeai-attach-menu {
  bottom: calc(100% + 10px);
  left: 0;
}

.mbeai-chat-shell .mbeai-input-shell {
  display: flex;
  min-height: 44px;
  min-width: 0;
  flex: 1 1 auto;
  align-items: flex-end;
  gap: 4px;
  padding: 0 5px 0 0;
  border: 1px solid var(--mbeai-border-strong);
  border-radius: 22px;
  background: var(--mbeai-glass-medium);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.mbeai-chat-shell .mbeai-input-shell:focus-within {
  border-color: rgba(216, 178, 106, 0.46);
  background: rgba(255, 255, 255, 0.075);
  box-shadow: 0 0 0 3px rgba(216, 178, 106, 0.14);
}

.mbeai-chat-shell .mbeai-composer textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  max-height: 120px;
  flex: 1 1 auto;
  resize: none;
  border: 0;
  border-radius: 22px;
  padding: 11px 4px 10px 16px;
  color: var(--mbeai-text);
  background: transparent;
  box-shadow: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.35;
}

.mbeai-chat-shell .mbeai-composer textarea::placeholder {
  color: var(--mbeai-placeholder);
  opacity: 1;
}

.mbeai-chat-shell .mbeai-composer textarea:focus {
  outline: none;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.mbeai-chat-shell .mbeai-inline-camera {
  display: grid;
  width: 34px;
  height: 34px;
  min-width: 34px;
  flex: 0 0 auto;
  place-items: center;
  margin-bottom: 5px;
  border-radius: 999px;
  color: rgba(245, 245, 247, 0.7);
  background: transparent;
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.mbeai-chat-shell .mbeai-inline-camera:hover {
  color: var(--mbeai-text);
  background: rgba(255, 255, 255, 0.08);
}

.mbeai-chat-shell .mbeai-inline-camera:active {
  transform: scale(0.92);
}

/* Botão principal contextual */
.mbeai-chat-shell .mbeai-main-btn {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  color: var(--mbeai-gold-ink);
  background: var(--mbeai-gold-gradient);
  box-shadow: 0 6px 18px -6px rgba(216, 178, 106, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: opacity 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.mbeai-chat-shell .mbeai-main-btn:hover {
  transform: translateY(-1px);
}

.mbeai-chat-shell .mbeai-main-btn:active {
  transform: scale(0.92);
}

.mbeai-chat-shell .mbeai-main-btn > * {
  grid-area: 1 / 1;
}

.mbeai-chat-shell .mbeai-icon-send,
.mbeai-chat-shell .mbeai-icon-stop,
.mbeai-chat-shell .mbeai-icon-spinner {
  display: none;
}

.mbeai-chat-shell .mbeai-main-btn.is-send .mbeai-icon-send {
  display: block;
}

.mbeai-chat-shell .mbeai-main-btn.is-send .mbeai-icon-mic,
.mbeai-chat-shell .mbeai-main-btn.is-recording .mbeai-icon-mic,
.mbeai-chat-shell .mbeai-main-btn.is-busy .mbeai-icon-mic {
  display: none;
}

.mbeai-chat-shell .mbeai-main-btn.is-recording {
  color: #ffffff;
  background: var(--mbeai-error);
  box-shadow: 0 0 0 0 rgba(240, 104, 94, 0.34);
  animation: mbeai-record 1.1s ease-in-out infinite;
}

.mbeai-chat-shell .mbeai-main-btn.is-recording .mbeai-icon-stop {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: currentColor;
}

.mbeai-chat-shell .mbeai-main-btn.is-busy .mbeai-icon-send,
.mbeai-chat-shell .mbeai-main-btn.is-busy .mbeai-icon-stop {
  display: none;
}

.mbeai-chat-shell .mbeai-main-btn.is-busy .mbeai-icon-spinner {
  display: block;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(28, 22, 8, 0.35);
  border-top-color: var(--mbeai-gold-ink);
  border-radius: 999px;
  animation: mbeai-spin 0.7s linear infinite;
}

.mbeai-chat-shell .mbeai-main-btn:disabled,
.mbeai-chat-shell .mbeai-plus:disabled,
.mbeai-chat-shell .mbeai-inline-camera:disabled,
.mbeai-chat-shell .mbeai-composer textarea:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

/* Rodapé do dock */
.mbeai-chat-shell .mbeai-footer-row {
  display: flex;
  min-height: 18px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}

.mbeai-chat-shell .mbeai-audio-note,
.mbeai-chat-shell .mbeai-live-status {
  margin: 0;
  color: var(--mbeai-text-tertiary);
  font-size: 11.5px;
  line-height: 1.35;
}

.mbeai-chat-shell .mbeai-live-status {
  flex: 0 0 auto;
  color: rgba(234, 209, 153, 0.78);
  font-weight: 700;
  text-align: right;
}

/* ===== Toast ===== */
.mbeai-chat-shell .mbeai-toast {
  position: absolute;
  right: 14px;
  bottom: calc(118px + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  display: flex;
  max-width: min(360px, calc(100% - 28px));
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--mbeai-border-strong);
  border-radius: 16px;
  color: var(--mbeai-text);
  background: rgba(12, 12, 18, 0.82);
  box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  font-size: 14px;
  font-weight: 500;
  animation: mbeai-toast 0.28s ease both;
}

.mbeai-chat-shell .mbeai-toast[hidden] {
  display: none;
}

.mbeai-chat-shell .mbeai-toast-icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: rgba(95, 208, 138, 0.16);
  color: var(--mbeai-success);
  font-size: 14px;
  font-weight: 800;
}

.mbeai-chat-shell .mbeai-toast-icon::before {
  content: "✓";
}

.mbeai-chat-shell .mbeai-toast.is-error .mbeai-toast-icon {
  background: rgba(240, 104, 94, 0.16);
  color: var(--mbeai-error);
}

.mbeai-chat-shell .mbeai-toast.is-error .mbeai-toast-icon::before {
  content: "!";
}

.mbeai-chat-shell .mbeai-toast.is-info .mbeai-toast-icon {
  background: rgba(111, 168, 255, 0.16);
  color: var(--mbeai-info);
}

.mbeai-chat-shell .mbeai-toast.is-info .mbeai-toast-icon::before {
  content: "i";
}

/* ===== Acessibilidade ===== */
.mbeai-chat-shell .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  white-space: nowrap;
}

.mbeai-chat-shell :where(button, textarea, a):focus-visible {
  outline: 2px solid rgba(234, 209, 153, 0.9);
  outline-offset: 3px;
}

/* ===== Animações ===== */
@keyframes mbeai-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes mbeai-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes mbeai-type {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

@keyframes mbeai-wave {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

@keyframes mbeai-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes mbeai-spin {
  to { transform: rotate(360deg); }
}

@keyframes mbeai-record {
  0% { box-shadow: 0 0 0 0 rgba(240, 104, 94, 0.34); }
  70% { box-shadow: 0 0 0 12px rgba(240, 104, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(240, 104, 94, 0); }
}

@keyframes mbeai-toast {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Desktop (aplicação centralizada) ===== */
@media (min-width: 900px) {
  .mbeai-chat-shell {
    padding: 24px;
  }

  .mbeai-chat-shell .mbeai-chat-app {
    min-height: 0;
    height: min(920px, calc(100vh - 48px));
    height: min(920px, calc(100dvh - 48px));
    border: 1px solid var(--mbeai-border);
    border-radius: var(--mbeai-radius-xl);
    box-shadow: var(--mbeai-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  .mbeai-chat-shell .mbeai-chat-header {
    padding: 14px 16px 14px 10px;
  }

  .mbeai-chat-shell .mbeai-messages {
    padding: 20px 22px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(150, 150, 160, 0.3) transparent;
  }

  .mbeai-chat-shell .mbeai-messages::-webkit-scrollbar {
    width: 8px;
  }

  .mbeai-chat-shell .mbeai-messages::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 99px;
    background: rgba(150, 150, 160, 0.3);
    background-clip: content-box;
  }

  .mbeai-chat-shell .mbeai-bottom-dock {
    padding-right: 18px;
    padding-left: 18px;
    padding-bottom: 14px;
  }

  .mbeai-chat-shell .mbeai-suggestions {
    margin-right: -18px;
    margin-left: -18px;
    padding-right: 18px;
    padding-left: 18px;
  }

  .mbeai-chat-shell .mbeai-toast {
    right: 22px;
    bottom: 130px;
  }
}

/* ===== Ajustes mobile estreito ===== */
@media (max-width: 430px) {
  .mbeai-chat-shell .mbeai-chat-header {
    padding-right: 10px;
  }

  .mbeai-chat-shell .mbeai-messages {
    padding-right: 14px;
    padding-left: 14px;
  }

  .mbeai-chat-shell .mbeai-bottom-dock {
    padding-right: 12px;
    padding-left: 12px;
  }

  .mbeai-chat-shell .mbeai-suggestions {
    margin-right: -12px;
    margin-left: -12px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .mbeai-chat-shell .mbeai-message-user {
    max-width: 84%;
  }

  .mbeai-chat-shell .mbeai-message-ai {
    max-width: 91%;
  }

  .mbeai-chat-shell .mbeai-bubble {
    padding: 13px 15px;
  }

  .mbeai-chat-shell .mbeai-footer-row {
    flex-direction: column;
    gap: 3px;
  }

  .mbeai-chat-shell .mbeai-live-status {
    text-align: left;
  }
}

@media (max-width: 340px) {
  .mbeai-chat-shell .mbeai-header-copy h2 {
    font-size: 15px;
  }

  .mbeai-chat-shell .mbeai-composer {
    gap: 6px;
  }

  .mbeai-chat-shell .mbeai-plus,
  .mbeai-chat-shell .mbeai-main-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
  }

  .mbeai-chat-shell .mbeai-recording-label {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ===== Movimento reduzido ===== */
@media (prefers-reduced-motion: reduce) {
  .mbeai-chat-shell,
  .mbeai-chat-shell *,
  .mbeai-chat-shell *::before,
  .mbeai-chat-shell *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .mbeai-chat-shell .mbeai-main-btn.is-busy .mbeai-icon-spinner {
    animation-iteration-count: infinite !important;
    animation-duration: 0.7s !important;
  }
}
