/* =================================================
   CHROMA AI — Floating Chat Widget
   v1.0.0
================================================= */

:root {
  --chroma-accent:    #B85C8A;
  --chroma-accent-d:  #9A4A72;
  --chroma-bg:        #FFFFFF;
  --chroma-surface:   #F8F5F3;
  --chroma-border:    #EDE8E3;
  --chroma-text:      #2C2420;
  --chroma-muted:     #8A7F79;
  --chroma-radius:    16px;
  --chroma-shadow:    0 12px 48px rgba(44,36,32,.18), 0 2px 8px rgba(44,36,32,.08);
  --chroma-z:         999999;
  --chroma-w:         360px;
  --chroma-h:         520px;
}

/* ---- Widget container ---- */
.chroma-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--chroma-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--chroma-text);
}

/* ---- Trigger button ---- */
.chroma-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 0 0;
  height: 52px;
  background: var(--chroma-accent);
  color: #fff;
  border: none;
  border-radius: 52px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(184,92,138,.35);
  transition: transform .2s, box-shadow .2s, background .2s;
  position: relative;
  overflow: hidden;
}
.chroma-trigger:hover {
  background: var(--chroma-accent-d);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(184,92,138,.4);
}
.chroma-trigger:active { transform: translateY(0); }

.chroma-trigger__icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .2s, transform .2s;
}
.chroma-trigger__icon--close {
  position: absolute;
  left: 0;
  opacity: 0;
  transform: rotate(-90deg);
}
.chroma-widget.is-open .chroma-trigger__icon--open  { opacity: 0; transform: rotate(90deg); }
.chroma-widget.is-open .chroma-trigger__icon--close { opacity: 1; transform: rotate(0); }

.chroma-trigger__label {
  font-weight: 600;
  font-size: .88rem;
  letter-spacing: .01em;
  white-space: nowrap;
}

/* Online pulse dot on button */
.chroma-trigger__dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 9px;
  height: 9px;
  background: #4CAF50;
  border: 2px solid var(--chroma-accent);
  border-radius: 50%;
  animation: chroma-pulse 2s ease-in-out infinite;
}
.chroma-widget.is-open .chroma-trigger__dot { display: none; }

@keyframes chroma-pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: .6; }
}

/* ---- Chat panel ---- */
.chroma-panel {
  width: var(--chroma-w);
  background: var(--chroma-bg);
  border-radius: var(--chroma-radius);
  box-shadow: var(--chroma-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-origin: bottom right;

  /* Hidden state */
  opacity: 0;
  transform: scale(.92) translateY(12px);
  pointer-events: none;
  transition: opacity .25s cubic-bezier(.4,0,.2,1),
              transform .25s cubic-bezier(.4,0,.2,1);
}
.chroma-panel[hidden] { display: flex !important; } /* override hidden for animation */
.chroma-widget.is-open .chroma-panel {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* ---- Panel header ---- */
.chroma-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 14px 16px;
  background: var(--chroma-accent);
  color: #fff;
  flex-shrink: 0;
}
.chroma-header-info { display: flex; align-items: center; gap: 10px; }

.chroma-header-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chroma-header-name  { font-weight: 700; font-size: .9rem; line-height: 1.2; }
.chroma-header-status {
  font-size: .72rem;
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.chroma-online-dot {
  width: 6px; height: 6px;
  background: #69F0AE;
  border-radius: 50%;
  display: inline-block;
  animation: chroma-pulse 2s ease-in-out infinite;
}

.chroma-header-actions { display: flex; align-items: center; gap: 2px; }

.chroma-icon-btn {
  width: 30px; height: 30px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.chroma-icon-btn:hover {
  background: rgba(255,255,255,.18);
  color: #fff;
}

/* ---- Messages ---- */
.chroma-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: var(--chroma-h);
  min-height: 280px;
  scroll-behavior: smooth;
  background: var(--chroma-surface);
}

.chroma-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 88%;
  animation: chroma-msgIn .2s ease-out;
}
@keyframes chroma-msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chroma-msg--bot  { align-self: flex-start; }
.chroma-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.chroma-msg-avatar {
  width: 26px; height: 26px;
  background: var(--chroma-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  font-size: 11px;
}

.chroma-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .84rem;
  line-height: 1.6;
  word-break: break-word;
}
.chroma-msg--bot .chroma-bubble {
  background: var(--chroma-bg);
  border: 1px solid var(--chroma-border);
  border-bottom-left-radius: 4px;
  color: var(--chroma-text);
}
.chroma-msg--user .chroma-bubble {
  background: var(--chroma-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ---- Typing ---- */
.chroma-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 10px;
  background: var(--chroma-surface);
}
.chroma-typing-avatar {
  width: 26px; height: 26px;
  background: var(--chroma-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.chroma-dots {
  background: var(--chroma-bg);
  border: 1px solid var(--chroma-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 9px 14px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.chroma-dots span {
  width: 6px; height: 6px;
  background: var(--chroma-muted);
  border-radius: 50%;
  animation: chroma-bounce 1.2s ease-in-out infinite;
}
.chroma-dots span:nth-child(2) { animation-delay: .18s; }
.chroma-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes chroma-bounce {
  0%,60%,100% { transform: translateY(0); opacity:.4; }
  30%          { transform: translateY(-5px); opacity:1; }
}

/* ---- Input ---- */
.chroma-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--chroma-border);
  background: var(--chroma-bg);
  flex-shrink: 0;
}
.chroma-input {
  flex: 1;
  border: 1.5px solid var(--chroma-border);
  border-radius: 12px;
  padding: 9px 13px;
  font-family: inherit;
  font-size: .84rem;
  color: var(--chroma-text);
  background: var(--chroma-surface);
  resize: none;
  outline: none;
  transition: border-color .15s;
  min-height: 38px;
  max-height: 100px;
  line-height: 1.5;
}
.chroma-input:focus { border-color: var(--chroma-accent); }
.chroma-input:disabled { opacity: .5; cursor: not-allowed; }
.chroma-input::placeholder { color: var(--chroma-muted); }

.chroma-send-btn {
  width: 38px; height: 38px;
  background: var(--chroma-accent);
  border: none;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, transform .15s;
}
.chroma-send-btn:hover   { background: var(--chroma-accent-d); transform: scale(1.08); }
.chroma-send-btn:active  { transform: scale(.94); }
.chroma-send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ---- Footer ---- */
.chroma-footer {
  padding: 6px 16px 8px;
  text-align: center;
  font-size: .68rem;
  color: var(--chroma-muted);
  border-top: 1px solid var(--chroma-border);
  background: var(--chroma-bg);
}
.chroma-footer a { color: var(--chroma-accent); text-decoration: none; }

/* ---- Mobile ---- */
@media (max-width: 480px) {
  .chroma-widget { bottom: 16px; right: 16px; }
  .chroma-panel  { width: calc(100vw - 32px); }
  .chroma-trigger__label { display: none; }
  .chroma-trigger { padding: 0; width: 52px; border-radius: 50%; justify-content: center; }
  .chroma-trigger__dot { top: 6px; right: 6px; }
}
