/* AI chat widget (inc/ai-chat). Self-contained: no dependency on the theme bundle. */
.maneks-ai-chat {
  /* Brand colour: every brand stylesheet (assets/inc/css/brands/<SITE_PREFIX>.css)
     sets --primary-color on :root (PP blue, NS/SS navy, NP purple, BB dark). The
     bubble, header and buttons follow it; the fallback only shows on a shop
     without a brand file. */
  --mac-accent: var(--primary-color, #1878f6);
  --mac-accent-dark: color-mix(in srgb, var(--mac-accent), #000 18%);
  --mac-bg: #ffffff;
  --mac-surface: #f4f5f7;
  --mac-text: #1e2124;
  --mac-muted: #6b7280;
  --mac-user: color-mix(in srgb, var(--mac-accent) 12%, #ffffff);
  --mac-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  --mac-bottom: 20px;
  --mac-right: 20px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  color: var(--mac-text);
}

/* --mac-bottom is raised by js/ai-chat.js only while something else sits at the
   bottom of the screen (the sticky add-to-cart bar after scrolling on product
   pages, the floating cart button when the shop enables it). Otherwise the
   bubble stays in the corner, 20px from the bottom, on every page. */

.mac-bubble {
  position: fixed;
  right: var(--mac-right);
  bottom: var(--mac-bottom);
  z-index: 99990;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--mac-accent);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.mac-bubble:hover { background: var(--mac-accent-dark); transform: translateY(-1px); }
.mac-bubble:focus-visible { outline: 3px solid #1e2124; outline-offset: 3px; }
.maneks-ai-chat.is-open .mac-bubble { background: #d9dbe0; color: var(--mac-text); }

.mac-teaser {
  position: fixed;
  right: var(--mac-right);
  bottom: calc(var(--mac-bottom) + 72px);
  z-index: 99989;
  max-width: 260px;
  padding: 12px 14px;
  background: var(--mac-bg);
  border-radius: 14px;
  box-shadow: var(--mac-shadow);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.mac-teaser.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.mac-teaser.is-hidden { display: none; }
.mac-teaser__name { font-size: 12px; color: var(--mac-muted); display: flex; align-items: center; gap: 6px; }
.mac-teaser__text { font-weight: 600; margin-top: 2px; }

.mac-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  flex: 0 0 auto;
}
.mac-dot--light { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }

.mac-panel {
  position: fixed;
  right: var(--mac-right);
  bottom: calc(var(--mac-bottom) + 72px);
  z-index: 99991;
  width: 380px;
  max-width: calc(100vw - 2 * var(--mac-right));
  height: 560px;
  max-height: calc(100vh - var(--mac-bottom) - 90px);
  display: flex;
  flex-direction: column;
  background: var(--mac-bg);
  border-radius: 16px;
  box-shadow: var(--mac-shadow);
  overflow: hidden;
}
.mac-panel[hidden] { display: none; }

.mac-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: var(--mac-accent);
  color: #fff;
}
.mac-header__title { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.mac-close {
  border: 0;
  background: transparent;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mac-close:hover { background: rgba(255, 255, 255, 0.18); }
.mac-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.mac-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: var(--mac-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.mac-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.mac-msg a { color: var(--mac-accent-dark); text-decoration: underline; }
.mac-msg--assistant {
  align-self: flex-start;
  background: var(--mac-bg);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.mac-msg--user {
  align-self: flex-end;
  background: var(--mac-user);
  border-bottom-right-radius: 4px;
}
.mac-msg--system {
  align-self: center;
  max-width: 100%;
  font-size: 13px;
  text-align: center;
  background: transparent;
  color: var(--mac-muted);
  padding: 4px 8px;
}
.mac-msg--error { color: #b42318; background: #fee4e2; border-radius: 10px; }
.mac-msg--success { color: #067647; background: #dcfae6; border-radius: 10px; font-weight: 600; }
.mac-msg--typing { color: var(--mac-muted); font-style: italic; }

.mac-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  background: var(--mac-bg);
}
.mac-input {
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font: inherit;
  line-height: 1.4;
  color: var(--mac-text);
  background: var(--mac-bg);
}
.mac-input:focus { outline: 2px solid var(--mac-accent); outline-offset: 0; border-color: var(--mac-accent); }
.mac-input:disabled { background: var(--mac-surface); color: var(--mac-muted); }
.mac-send {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--mac-accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.mac-send:hover { background: var(--mac-accent-dark); }
.mac-send:disabled { background: #d1d5db; cursor: not-allowed; }
.mac-send:focus-visible { outline: 2px solid var(--mac-text); outline-offset: 2px; }

.mac-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px 8px;
  background: var(--mac-bg);
  font-size: 11px;
  color: var(--mac-muted);
}
.mac-newchat {
  display: none;
  border: 0;
  background: transparent;
  color: var(--mac-accent-dark);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.mac-newchat.is-visible { display: inline; }

@media (max-width: 480px) {
  .mac-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .maneks-ai-chat.is-open .mac-bubble,
  .maneks-ai-chat.is-open .mac-teaser { display: none; }
  .mac-input { font-size: 16px; } /* prevents iOS zoom */
}

@media (prefers-reduced-motion: reduce) {
  .mac-bubble, .mac-teaser { transition: none; }
}
