/**
 * AI Luce — floating chatbot (stacked above WhatsApp floater).
 */

.moxie-luce {
  --luce-orange: var(--cn-orange, #f4510b);
  --luce-orange-deep: var(--cn-orange-deep, #bb3505);
  --luce-cream: #fff8f3;
  --luce-ink: #2a1f1a;
  --luce-muted: #725e52;
  --luce-wa-size: 56px;
  --luce-gap: 12px;
  --luce-edge: max(16px, env(safe-area-inset-right, 0px));
  --luce-bottom-edge: max(16px, env(safe-area-inset-bottom, 0px));

  position: fixed;
  z-index: 9990;
  right: var(--luce-edge);
  /* Sit above .moxie-cn-wa-floater (bottom-right orange WA). */
  bottom: calc(var(--luce-bottom-edge) + var(--luce-wa-size) + var(--luce-gap));
  font-family: inherit;
  color: var(--luce-ink);
}

@media (max-width: 640px) {
  .moxie-luce {
    --luce-wa-size: 52px;
    --luce-edge: max(12px, env(safe-area-inset-right, 0px));
    --luce-bottom-edge: max(12px, env(safe-area-inset-bottom, 0px));
  }
}

.moxie-luce__launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--luce-cream);
  box-shadow: 0 10px 28px rgba(244, 81, 11, 0.28);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.moxie-luce__launcher:hover,
.moxie-luce__launcher:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(187, 53, 5, 0.36);
  outline: none;
}

.moxie-luce__launcher:focus-visible {
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 5px var(--luce-orange),
    0 14px 32px rgba(187, 53, 5, 0.36);
}

.moxie-luce__launcher-img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
}

.moxie-luce__launcher-video {
  pointer-events: none;
  background: var(--luce-cream);
}

.moxie-luce__launcher-fallback[hidden] {
  display: none !important;
}

.moxie-luce__launcher-dot {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
}

.moxie-luce__panel {
  position: absolute;
  right: 0;
  bottom: calc(56px + 10px);
  width: min(380px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 140px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(244, 81, 11, 0.14);
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(42, 31, 26, 0.18);
}

.moxie-luce__panel[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  /* After base rules so diameter matches .moxie-cn-wa-floater (52px). */
  .moxie-luce__launcher {
    width: 52px;
    height: 52px;
  }

  .moxie-luce__panel {
    bottom: calc(52px + 10px);
    height: min(480px, calc(100vh - 160px));
  }
}

.moxie-luce__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, var(--luce-orange) 0%, var(--luce-orange-deep) 100%);
  color: #fff;
}

.moxie-luce__header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.moxie-luce__header-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  border: 2px solid rgba(255, 255, 255, 0.92);
  background: var(--luce-cream);
  flex-shrink: 0;
}

.moxie-luce__title {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.moxie-luce__subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  opacity: 0.92;
  line-height: 1.3;
}

.moxie-luce__close {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.moxie-luce__close:hover,
.moxie-luce__close:focus-visible {
  background: rgba(255, 255, 255, 0.28);
  outline: none;
}

.moxie-luce__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  background: var(--luce-cream);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.moxie-luce__bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.moxie-luce__bubble--assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--luce-ink);
  border: 1px solid rgba(244, 81, 11, 0.12);
  border-bottom-left-radius: 4px;
}

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

.moxie-luce__bubble--error {
  align-self: stretch;
  background: #fff1f0;
  color: #9b1c1c;
  border: 1px solid #fecaca;
}

.moxie-luce__bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.moxie-luce__bubble--assistant a {
  color: var(--luce-orange-deep);
}

.moxie-luce__typing {
  align-self: flex-start;
  font-size: 0.82rem;
  color: var(--luce-muted);
  padding: 0 4px;
}

.moxie-luce__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 8px;
  background: var(--luce-cream);
}

.moxie-luce__chip {
  border: 1px solid rgba(244, 81, 11, 0.28);
  background: #fff;
  color: var(--luce-orange-deep);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  line-height: 1.3;
  cursor: pointer;
}

.moxie-luce__chip:hover,
.moxie-luce__chip:focus-visible {
  background: rgba(244, 81, 11, 0.08);
  outline: none;
}

.moxie-luce__composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(244, 81, 11, 0.12);
  background: #fff;
  position: relative;
}

.moxie-luce__composer input[type="text"]:not(.moxie-luce__hp) {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid rgba(42, 31, 26, 0.14);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--luce-ink);
  background: #fff;
}

.moxie-luce__composer input[type="text"]:focus {
  outline: none;
  border-color: var(--luce-orange);
  box-shadow: 0 0 0 3px rgba(244, 81, 11, 0.16);
}

.moxie-luce__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.moxie-luce__send {
  flex: 0 0 auto;
  border: none;
  border-radius: 999px;
  padding: 0 16px;
  background: var(--luce-orange);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}

.moxie-luce__send:hover,
.moxie-luce__send:focus-visible {
  background: var(--luce-orange-deep);
  outline: none;
}

.moxie-luce__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.moxie-luce__footer {
  margin: 0;
  padding: 0 12px 10px;
  text-align: center;
  font-size: 0.75rem;
  background: #fff;
}

.moxie-luce__footer a {
  color: var(--luce-orange-deep);
  text-decoration: none;
  font-weight: 600;
}

.moxie-luce__footer a:hover,
.moxie-luce__footer a:focus-visible {
  text-decoration: underline;
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .moxie-luce__launcher,
  .moxie-luce__launcher:hover,
  .moxie-luce__launcher:focus-visible {
    transition: none;
    transform: none;
  }
}
