/* ============================================================================
   CAKE MAMA — CHAT ASSISTANT STYLES  (Phase 2, stage 1 of 3)
   ----------------------------------------------------------------------------
   Bubble + floating chat window. Relies on the palette variables defined in
   ../styles.css (--cream, --coral-deep, --rule, etc.) — load styles.css
   before this file.
   ============================================================================ */

/* ----- bubble ------------------------------------------------------------ */

.cm-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--cream-2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  z-index: 9998;
  overflow: hidden;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.cm-bubble:hover,
.cm-bubble:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  outline: none;
}
.cm-bubble img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* ----- window ------------------------------------------------------------ */

.cm-window {
  position: fixed;
  bottom: 110px;
  right: 24px;
  width: 360px;
  max-height: 520px;
  background: var(--cream);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: "Outfit", system-ui, sans-serif;
  color: var(--ink);
}
.cm-window[hidden] { display: none; }

.cm-window-header {
  background: var(--coral-deep);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}
.cm-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 48px;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.3);
}
.cm-header-text {
  flex: 1;
  min-width: 0;
}
.cm-header-name {
  display: block;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  color: #fff;
}
.cm-header-role {
  display: block;
  font-weight: 400;
  font-size: 12px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.02em;
}
/* Graceful truncation at any width — works at desktop too, not just mobile. */
.cm-header-name,
.cm-header-role {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cm-close {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  margin: 0;
  border-radius: 4px;
}
.cm-close:hover,
.cm-close:focus-visible {
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}

/* ----- messages + input -------------------------------------------------- */

.cm-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  min-height: 160px;
  background: var(--cream);
}

.cm-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--rule);
  background: var(--cream-2);
}
.cm-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  outline: none;
}
.cm-input:focus {
  border-color: var(--coral);
}
.cm-input:disabled {
  background: #f3ede4;
  color: var(--ink-soft);
}
.cm-send {
  padding: 10px 16px;
  background: var(--coral-deep);
  color: #fff;
  border: 0;
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
}
.cm-send:disabled {
  background: #d9d2c7;
  color: #8c857e;
  cursor: not-allowed;
}

/* ----- message bubbles --------------------------------------------------- */

.cm-msg {
  display: flex;
  margin-bottom: 10px;
}
.cm-msg-user {
  justify-content: flex-end;
}
.cm-msg-assistant {
  justify-content: flex-start;
}
.cm-msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.cm-msg-user .cm-msg-bubble {
  background: var(--coral-deep);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cm-msg-assistant .cm-msg-bubble {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-bottom-left-radius: 4px;
}

/* ----- typing indicator -------------------------------------------------- */

.cm-typing .cm-msg-bubble {
  padding: 12px 14px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.cm-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: 0.4;
  animation: cm-dot-pulse 1.2s infinite ease-in-out;
}
.cm-dot:nth-child(2) { animation-delay: 0.2s; }
.cm-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes cm-dot-pulse {
  0%, 60%, 100% { opacity: 0.4; transform: scale(1); }
  30%           { opacity: 1;   transform: scale(1.2); }
}

/* ----- mobile ------------------------------------------------------------ */

@media (max-width: 480px) {
  .cm-bubble {
    bottom: 16px;
    right: 16px;
  }
  .cm-window {
    width: calc(100vw - 32px);
    bottom: 96px;
    right: 16px;
    left: 16px;
    max-height: calc(100vh - 160px);
  }
}
