/* Website AI chat widget — sample-style UI (blue + green) */
.mcw-ai-root {
  --mcw-ai-blue: #3b82f6;
  --mcw-ai-blue-soft: #60a5fa;
  --mcw-ai-green: #84cc16;
  --mcw-ai-green-bright: #a3e635;
  --mcw-ai-surface: #ffffff;
  --mcw-ai-ink: #0f172a;
  --mcw-ai-muted: #64748b;
  --mcw-ai-border: #e8edf5;
  --mcw-ai-bubble: #eef4ff;
  --mcw-ai-soft: #f8fafc;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: "Plus Jakarta Sans", "Manrope", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  max-height: calc(100vh - 24px);
}

/* ---- Teaser ---- */
.mcw-ai-teaser {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: min(300px, calc(100vw - 96px));
  pointer-events: none;
}

.mcw-ai-root.is-open .mcw-ai-teaser {
  display: none;
}

.mcw-ai-teaser-avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: 0 8px 20px rgba(48, 232, 122, 0.3);
  background: #22c55e;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: mcw-ai-avatar-bob 2.4s ease-in-out infinite;
}

.mcw-ai-teaser-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.mcw-ai-teaser-bubble {
  position: relative;
  background: #fff;
  color: var(--mcw-ai-ink);
  border: 1px solid var(--mcw-ai-border);
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  animation: mcw-ai-bubble-pop 2.8s ease-in-out infinite;
  pointer-events: auto;
  cursor: pointer;
  text-align: left;
}

.mcw-ai-teaser-bubble::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 14px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid var(--mcw-ai-border);
  border-bottom: 1px solid var(--mcw-ai-border);
  transform: rotate(-45deg);
}

.mcw-ai-teaser-bubble span {
  display: block;
  color: var(--mcw-ai-muted);
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
}

/* ---- Launcher ---- */
.mcw-ai-launcher-wrap {
  position: relative;
  display: inline-flex;
}

.mcw-ai-launcher {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 999px;
  background: #22c55e;
  color: #fff;
  box-shadow: 0 12px 28px rgba(34, 197, 94, 0.45);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  animation: mcw-ai-launcher-pulse 2.6s ease-in-out infinite;
}

.mcw-ai-root.is-open .mcw-ai-launcher {
  animation: none;
}

.mcw-ai-launcher svg {
  width: 36px;
  height: 36px;
  fill: #fff;
  color: #fff;
}

.mcw-ai-launcher-ring {
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  border: 2px solid rgba(48, 232, 122, 0.55);
  animation: mcw-ai-ring 2.6s ease-out infinite;
  pointer-events: none;
}

.mcw-ai-root.is-open .mcw-ai-launcher-ring {
  display: none;
}

.mcw-ai-launcher-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #3b82f6;
  border: 2px solid #fff;
  z-index: 3;
  box-shadow:
    0 0 0 0 rgba(59, 130, 246, 0.85),
    0 0 10px 2px rgba(59, 130, 246, 0.75);
  animation: mcw-ai-dot-blink 1s ease-in-out infinite;
}

.mcw-ai-root.is-open .mcw-ai-launcher-dot {
  animation: none;
  background: #22c55e;
  box-shadow: none;
}

.mcw-ai-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

/* ---- Panel ---- */
.mcw-ai-panel {
  display: none;
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 110px));
  max-height: calc(100vh - 110px);
  background: var(--mcw-ai-surface);
  border: 1px solid var(--mcw-ai-border);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
  overflow: hidden;
  flex-direction: column;
  min-height: 0;
}

.mcw-ai-root.is-open .mcw-ai-panel {
  display: flex;
}

.mcw-ai-header {
  padding: 14px 14px 12px;
  background: #fff;
  border-bottom: 1px solid var(--mcw-ai-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.mcw-ai-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mcw-ai-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  flex-shrink: 0;
  background: #22c55e;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(34, 197, 94, 0.3);
}

.mcw-ai-header-avatar svg {
  width: 24px;
  height: 24px;
  fill: #fff;
}

.mcw-ai-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--mcw-ai-ink);
  line-height: 1.2;
}

.mcw-ai-header p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--mcw-ai-muted);
}

.mcw-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.mcw-ai-header-btn {
  border: 0;
  background: transparent;
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.mcw-ai-header-btn:hover {
  background: var(--mcw-ai-soft);
  color: var(--mcw-ai-ink);
}

.mcw-ai-header-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ---- Body / views ---- */
.mcw-ai-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px;
  background: #fff;
}

.mcw-ai-chat-view,
.mcw-ai-gate-view {
  display: none;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.mcw-ai-root[data-view="gate"] .mcw-ai-gate-view,
.mcw-ai-root[data-view="chat"] .mcw-ai-chat-view {
  display: flex;
}

.mcw-ai-gate-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  height: 100%;
}

.mcw-ai-hint {
  font-size: 13px;
  color: var(--mcw-ai-muted);
  margin: 0 0 14px;
  line-height: 1.45;
}

.mcw-ai-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--mcw-ai-ink);
  margin-bottom: 4px;
}

.mcw-ai-form .mcw-ai-field {
  margin-bottom: 10px;
}

.mcw-ai-form input {
  width: 100%;
  border: 1px solid var(--mcw-ai-border);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  color: var(--mcw-ai-ink);
  background: #fff;
  box-sizing: border-box;
}

.mcw-ai-form input:focus {
  outline: 2px solid rgba(59, 130, 246, 0.25);
  border-color: var(--mcw-ai-blue);
}

.mcw-ai-error {
  display: none;
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 12px;
  flex-shrink: 0;
}

.mcw-ai-error.is-on {
  display: block;
}

.mcw-ai-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 0;
  border-radius: 10px;
  background: #22c55e;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 13px 16px;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 6px 14px rgba(34, 197, 94, 0.35);
  transition: transform .2s ease, background-color .2s ease, color .2s ease;
}

.mcw-ai-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 42%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.45) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateX(-120%) skewX(-18deg);
  animation: mcw-ai-btn-shimmer 3.6s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.mcw-ai-btn:hover {
  background: #16a34a;
  color: #fff;
  transform: translateY(-1px);
}

.mcw-ai-btn:hover::after {
  animation: none;
}

.mcw-ai-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.mcw-ai-btn-secondary {
  background: #f1f5f9;
  color: #334155;
}

.mcw-ai-footer-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px 14px;
  background: #fff;
  flex-shrink: 0;
  border-top: 1px solid var(--mcw-ai-border);
}

.mcw-ai-footer-actions .mcw-ai-btn {
  flex: 1;
}

/* ---- Messages ---- */
.mcw-ai-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mcw-ai-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}

.mcw-ai-row.is-user {
  flex-direction: row-reverse;
}

.mcw-ai-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  flex-shrink: 0;
  background: #22c55e;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mcw-ai-msg-avatar.is-user {
  background: #64748b;
}

.mcw-ai-msg-avatar svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

.mcw-ai-bubble {
  max-width: calc(100% - 40px);
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.mcw-ai-bubble.is-assistant {
  background: var(--mcw-ai-bubble);
  color: var(--mcw-ai-ink);
  border-bottom-left-radius: 5px;
}

.mcw-ai-bubble.is-user {
  background: #22c55e;
  color: #fff;
  border-bottom-right-radius: 5px;
}

.mcw-ai-time {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  padding-left: 38px;
}

.mcw-ai-quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
  padding-left: 38px;
}

.mcw-ai-quick button {
  border: 1px solid var(--mcw-ai-border);
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--mcw-ai-ink);
  cursor: pointer;
  text-align: left;
  line-height: 1.3;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color .15s, box-shadow .15s, background-color .15s, transform .15s;
}

.mcw-ai-quick button:hover {
  background: #fff;
  border-color: var(--mcw-ai-blue-soft);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.12);
  transform: translateY(-1px);
}

.mcw-ai-quick-icon {
  display: block;
  width: 18px;
  height: 18px;
  margin-bottom: 6px;
  color: var(--mcw-ai-blue);
}

.mcw-ai-quick-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ---- Composer (sample layout) ---- */
.mcw-ai-composer-wrap {
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid var(--mcw-ai-border);
  flex-shrink: 0;
}

.mcw-ai-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--mcw-ai-border);
  border-radius: 18px;
  background: #fff;
  padding: 8px 8px 8px 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.mcw-ai-composer textarea {
  flex: 1;
  width: auto;
  min-width: 0;
  border: 0;
  outline: none;
  resize: none;
  min-height: 24px;
  max-height: 96px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--mcw-ai-ink);
  background: transparent;
  font-family: inherit;
  line-height: 1.4;
}

.mcw-ai-composer textarea:focus {
  outline: none;
  border: 0;
}

.mcw-ai-send {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  flex-shrink: 0;
  background: #22c55e;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(34, 197, 94, 0.35);
}

.mcw-ai-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mcw-ai-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
  margin-left: 1px;
}

.mcw-ai-end-link {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--mcw-ai-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 4px 0;
  cursor: pointer;
  text-align: center;
}

.mcw-ai-end-link:hover {
  color: var(--mcw-ai-ink);
}

.mcw-ai-end-link:disabled {
  opacity: 0.7;
  cursor: default;
}

@keyframes mcw-ai-launcher-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 12px 28px rgba(34, 197, 94, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 16px 34px rgba(34, 197, 94, 0.55); }
}

@keyframes mcw-ai-ring {
  0% { transform: scale(0.92); opacity: 0.7; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

@keyframes mcw-ai-dot-blink {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    box-shadow:
      0 0 0 0 rgba(59, 130, 246, 0.9),
      0 0 10px 2px rgba(59, 130, 246, 0.7);
  }
  40% {
    opacity: 1;
    transform: scale(1.2);
    box-shadow:
      0 0 0 6px rgba(59, 130, 246, 0.25),
      0 0 14px 4px rgba(96, 165, 250, 0.85);
  }
  70% {
    opacity: 0.35;
    transform: scale(0.92);
    box-shadow:
      0 0 0 10px rgba(59, 130, 246, 0),
      0 0 4px 1px rgba(59, 130, 246, 0.4);
  }
}

@keyframes mcw-ai-btn-shimmer {
  0%, 20% { transform: translateX(-120%) skewX(-18deg); }
  45%, 100% { transform: translateX(220%) skewX(-18deg); }
}

@keyframes mcw-ai-bubble-pop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes mcw-ai-avatar-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .mcw-ai-launcher-dot,
  .mcw-ai-quick button::after,
  .mcw-ai-btn::after {
    animation: none;
  }
}

@media (max-width: 575.98px) {
  .mcw-ai-root {
    right: 12px;
    bottom: 12px;
  }

  .mcw-ai-panel {
    width: calc(100vw - 24px);
    height: min(72vh, 560px);
    max-height: calc(100vh - 96px);
  }

  .mcw-ai-teaser {
    max-width: calc(100vw - 88px);
  }
}
