/* ═══════════════════════════════════════════════════════════════
   BECCA Assistant
   ═══════════════════════════════════════════════════════════════ */

:root {
  --becca-orange: #ff7c00;
  --becca-orange-hover: #e56f00;
  --becca-orange-soft: #fff4eb;
  --becca-green-border: #b8d4be;
  --becca-green-text: #2d6a3e;
  --becca-ink: #1a1a1a;
  --becca-muted: #6b7280;
  --becca-surface: #ffffff;
  --becca-bg: #f6f7f8;
  --becca-radius: 18px;
  --becca-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
}

html[data-theme="dark"] {
  --becca-orange: #f88424;
  --becca-orange-hover: #e16601;
  --becca-orange-soft: #522500;
  --becca-green-border: #2a7337;
  --becca-green-text: #9dcb9a;
  --becca-ink: #f2f4f4;
  --becca-muted: #b6bdc0;
  --becca-surface: #252525;
  --becca-bg: #1c2529;
  --becca-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

/* Esconder FAB duplicado nas páginas de conta com botão BECCA próprio */
.sl-page--maia-chat .chat-fab {
  display: none !important;
}

/* Não sobrepor o drawer do carrinho */
body.cart-drawer-open .chat-fab,
body.cart-drawer-open .chat-shopping-backdrop,
body.cart-drawer-open .chat-popup {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ── Backdrop ── */
.chat-shopping-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8998;
  background: rgba(38, 42, 46, 0.42);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}
.chat-shopping-backdrop--visible {
  opacity: 1;
  visibility: visible;
}

/* ── FAB ── */
.chat-fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  left: auto;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.chat-fab__btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--becca-orange);
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 24px rgba(255, 124, 0, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}
.chat-fab__btn:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 28px rgba(255, 124, 0, 0.42);
}
.chat-fab__btn svg { color: #fff; }

.chat-fab__pulse { display: none; }

.chat-fab__label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  background: var(--becca-surface);
  color: var(--becca-ink);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  border: 1px solid #ececec;
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}
.chat-fab__label:hover {
  background: #fafafa;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
}
.chat-fab__label .dot {
  width: 8px;
  height: 8px;
  background: var(--becca-orange);
  border-radius: 50%;
  animation: chat-pulse 2s ease-in-out infinite;
}

@keyframes chat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ── Popup (painel centrado) ── */
.chat-popup {
  position: fixed;
  left: 50%;
  top: 50%;
  bottom: auto;
  right: auto;
  transform: translate(-50%, -50%);
  z-index: 9001;
  width: min(440px, calc(100vw - 1.25rem));
  max-height: min(680px, calc(100vh - 1.5rem));
  background: var(--becca-surface);
  border-radius: var(--becca-radius);
  box-shadow: var(--becca-shadow);
  overflow: hidden;
  display: none;
  flex-direction: column;
  animation: chat-spotlight-in 0.28s ease;
}
.chat-popup.open { display: flex; }

@keyframes chat-spotlight-in {
  from { opacity: 0; transform: translate(-50%, -46%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ── Header ── */
.chat-popup__header {
  background: var(--becca-surface);
  color: var(--becca-ink);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid #ececec;
}

.chat-popup__header-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.chat-popup__header-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--becca-orange-soft);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--becca-orange);
}

.chat-popup__header-dot { display: none; }

.chat-popup__header-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.chat-popup__header-sub { display: none; }

.chat-popup__header-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.chat-popup__header-btn {
  background: none;
  border: none;
  color: #5c6360;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}
.chat-popup__header-btn:hover {
  background: #f3f4f6;
  color: var(--becca-ink);
}

.chat-popup__header-btn--menu { display: grid; }

/* ── Messages / welcome ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 280px;
  max-height: min(460px, calc(100vh - 220px));
  background: linear-gradient(165deg, #fff5eb 0%, #fafbfc 38%, #ffffff 100%);
}

.chat-popup--conversation .chat-messages {
  padding-top: 0.85rem;
}

/* Welcome screen */
.becca-welcome {
  flex-shrink: 0;
  padding-bottom: 0.5rem;
}

.becca-welcome__hello {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--becca-ink);
  line-height: 1.15;
}

.becca-welcome__sub {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--becca-ink);
  line-height: 1.35;
}

.becca-welcome__desc {
  margin: 0 0 1.15rem;
  font-size: 0.82rem;
  color: var(--becca-muted);
  line-height: 1.5;
}

.becca-suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}

.becca-suggestion {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  max-width: 100%;
  padding: 0.72rem 0.85rem;
  background: var(--becca-surface);
  border: 1.5px solid var(--becca-green-border);
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--becca-ink);
  text-align: left;
  line-height: 1.35;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.becca-suggestion:hover {
  border-color: #9fc4a8;
  box-shadow: 0 4px 14px rgba(45, 106, 62, 0.1);
  transform: translateY(-1px);
}

.becca-suggestion__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--becca-orange-soft);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--becca-orange);
}

.becca-suggestion__text { flex: 1; min-width: 0; }

.becca-suggestion__chev {
  flex-shrink: 0;
  color: var(--becca-orange);
  opacity: 0.85;
}

.becca-suggestion--hidden { display: none; }

.becca-show-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.25rem auto 0;
  padding: 0.45rem 0.85rem;
  background: #fff0e6;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--becca-green-text);
  cursor: pointer;
  transition: background 0.15s;
}
.becca-show-more:hover { background: #ffe4d4; }
.becca-show-more svg { color: var(--becca-green-text); }

/* Chat bubbles */
.chat-msg {
  max-width: 88%;
  padding: 0.6rem 0.9rem;
  border-radius: 14px;
  font-size: 0.82rem;
  line-height: 1.45;
  word-break: break-word;
}

.chat-msg--system {
  align-self: center;
  background: none;
  color: #999;
  font-size: 0.72rem;
  text-align: center;
  padding: 0.25rem;
}

.chat-msg--bot {
  align-self: flex-start;
  background: var(--becca-surface);
  color: #333;
  border: 1px solid #e8ece8;
  border-bottom-left-radius: 4px;
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--becca-orange);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg__time {
  display: block;
  font-size: 0.6rem;
  opacity: 0.6;
  margin-top: 0.2rem;
}

.chat-msg--attach {
  padding: 0.45rem 0.5rem 0.4rem;
  max-width: min(88%, 240px);
  overflow: hidden;
}

.chat-msg__attach {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.chat-msg__attach-img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}

.chat-msg__attach-name {
  font-size: 0.68rem;
  opacity: 0.85;
  line-height: 1.2;
  word-break: break-all;
}

.chat-msg__attach--file {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.15rem;
}

.chat-msg__attach-icon {
  display: inline-flex;
  flex-shrink: 0;
  opacity: 0.9;
}

.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 0.2rem;
  padding: 0.5rem 0.7rem;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  background: #bbb;
  border-radius: 50%;
  animation: typing-bounce 0.6s infinite alternate;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  from { opacity: 0.3; transform: translateY(0); }
  to { opacity: 1; transform: translateY(-4px); }
}

/* ── Composer (footer) ── */
.chat-footer {
  flex-shrink: 0;
  padding: 0.65rem 1rem 0.75rem;
  background: var(--becca-surface);
  border-top: 1px solid #ececec;
}

.chat-composer {
  position: relative;
  background: var(--becca-surface);
  border: 1px solid #e4e4e4;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  padding: 0.65rem 0.75rem 0.55rem;
}

.chat-composer__input {
  width: 100%;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.84rem;
  color: var(--becca-ink);
  resize: none;
  min-height: 44px;
  max-height: 100px;
  background: transparent;
  outline: none;
  line-height: 1.45;
}
.chat-composer__input::placeholder { color: #aaa; }

.chat-composer__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.35rem;
}

.chat-composer__left,
.chat-composer__right {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.chat-composer__btn {
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--becca-orange);
  transition: background 0.15s, opacity 0.15s;
}
.chat-composer__btn:hover { background: var(--becca-orange-soft); }
.chat-composer__btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.chat-composer__btn:disabled:hover { background: none; }

.chat-composer__btn--send {
  color: #bbb;
}
.chat-composer__btn--send:not(:disabled) {
  color: var(--becca-orange);
}

.chat-popup__legal {
  font-size: 0.62rem;
  color: #8a9099;
  line-height: 1.45;
  margin: 0.55rem 0 0;
  text-align: center;
}
.chat-popup__legal a {
  color: var(--becca-orange);
  text-decoration: underline;
}
.chat-popup__legal a:hover { color: var(--becca-orange-hover); }

.chat-popup__powered-line { display: none; }

/* Emoji picker (escondido por defeito, abre via +) */
.chat-emoji-picker {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--becca-surface);
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
  z-index: 10;
}
.chat-emoji-picker.open { display: block; }

.chat-emoji-picker__search {
  width: 100%;
  padding: 0.35rem 0.6rem;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
  outline: none;
}
.chat-emoji-picker__search:focus { border-color: var(--becca-orange); }

.chat-emoji-picker__label {
  font-size: 0.65rem;
  font-weight: 600;
  color: #999;
  padding: 0.2rem 0.1rem;
}

.chat-emoji-picker__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.chat-emoji-picker__grid button {
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.15rem;
  border-radius: 4px;
  transition: background 0.1s;
}
.chat-emoji-picker__grid button:hover { background: #f0f0f0; }

/* Close confirm */
.chat-confirm {
  display: none;
  padding: 1.5rem 1.25rem;
  text-align: center;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--becca-surface);
}
.chat-confirm.visible { display: flex; }
.chat-confirm__title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #333;
}
.chat-confirm__btn {
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.chat-confirm__btn--yes { background: var(--becca-orange); color: #fff; }
.chat-confirm__btn--yes:hover { background: var(--becca-orange-hover); }
.chat-confirm__btn--no {
  background: #f3f4f6;
  color: var(--becca-ink);
}
.chat-confirm__btn--no:hover { background: #e8eaed; }

/* Legacy aliases - shopping-list mode unificado */
.chat-popup.chat-popup--shopping-list {
  /* herda estilos base */
}

.chat-popup--shopping-list .chat-messages {
  min-height: 280px;
}

.chat-input-area { display: none; }

.chat-send-text,
.chat-send-ico { display: none; }

.chat-msg--maia-cta {
  background: var(--becca-orange-soft) !important;
  border: 1px solid #ffd9bf !important;
  max-width: 92% !important;
}
.chat-msg--maia-cta strong { color: #c2410c; }

/* Legacy maia-sl (mantido para compatibilidade) */
.maia-sl-onboard { display: none; }

@media (max-width: 480px) {
  .chat-popup {
    width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
  }
  .chat-messages {
    max-height: min(400px, calc(100vh - 200px));
  }
  .becca-welcome__hello { font-size: 1.45rem; }
}

/* ── Dark · Knuspr tangerine-dark ── */
html[data-theme="dark"] .chat-fab__label {
  border-color: #374045;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .4);
}
html[data-theme="dark"] .chat-fab__label:hover {
  background: #1c2529;
}
html[data-theme="dark"] .chat-popup__header,
html[data-theme="dark"] .chat-popup__footer {
  border-color: #374045;
}
html[data-theme="dark"] .chat-msg--maia-cta {
  background: #522500 !important;
  border-color: #b85300 !important;
}
html[data-theme="dark"] .chat-msg--maia-cta strong { color: #ffbc85; }
