/* =============================================================
   Cleaning City 616 — Chat widget
   Loaded only from index.html. Uses CSS vars from site.css.
   ============================================================= */

/* ---- Floating bubble ---- */
#cc-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9100;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--forest);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(48,91,46,.38), 0 1px 4px rgba(48,91,46,.22);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, opacity .28s ease;
}
#cc-chat-bubble:hover {
  background: var(--pine);
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(48,91,46,.46);
}
#cc-chat-bubble:active { transform: translateY(0); }
#cc-chat-bubble:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}
.cc-bubble-icon { display: block; }
.cc-bubble-icon--close { display: none; }

/* ---- Panel ---- */
#cc-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9100;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 112px);
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(48,91,46,.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* enter animation */
  transform-origin: bottom right;
  transform: scale(.88) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform .24s cubic-bezier(.34,1.46,.64,1), opacity .18s ease;
}
#cc-chat-panel.cc-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ---- Panel header ---- */
.cc-header {
  background: var(--forest);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}
.cc-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  border: 1.5px solid rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--sage-l);
}
.cc-header-text { flex: 1; min-width: 0; }
.cc-header-name {
  font-family: var(--sans);
  font-size: .93rem;
  font-weight: 700;
  color: var(--cream);
  margin: 0;
  line-height: 1.2;
}
.cc-header-status {
  font-family: var(--sans);
  font-size: .76rem;
  color: var(--sage-l);
  margin: 2px 0 0;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 5px;
}
.cc-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sage-l);
  flex-shrink: 0;
}
.cc-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sage-l);
  padding: 5px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .15s ease, background .15s ease;
}
.cc-close:hover {
  color: var(--cream);
  background: rgba(255,255,255,.12);
}
.cc-close:focus-visible {
  outline: 2px solid var(--sage-l);
  outline-offset: 2px;
}

/* ---- Messages area ---- */
.cc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--cream);
  min-height: 180px;
}
/* Custom scrollbar (Webkit) */
.cc-messages::-webkit-scrollbar { width: 4px; }
.cc-messages::-webkit-scrollbar-track { background: transparent; }
.cc-messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* Welcome bubble — agent side (left) */
.cc-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.cc-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--forest);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.cc-bubble {
  background: var(--white);
  border-radius: 14px 14px 14px 4px;
  padding: 11px 14px;
  box-shadow: var(--shadow-sm);
  max-width: 82%;
}
.cc-bubble p {
  font-family: var(--sans);
  font-size: .88rem;
  color: var(--charcoal);
  margin: 0;
  line-height: 1.55;
}
.cc-bubble p + p { margin-top: 6px; }

/* Quick-action chips */
.cc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
}
.cc-chip {
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  color: var(--forest);
  background: var(--sage-wash);
  border: 1.5px solid var(--sage-l);
  border-radius: 20px;
  padding: 5px 12px;
  cursor: default;
  line-height: 1.2;
  white-space: nowrap;
  user-select: none;
}
.cc-chip--link {
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.cc-chip--link:hover {
  background: var(--sage-l);
  border-color: var(--sage);
  color: var(--forest-d);
}
.cc-chip--link:active {
  transform: translateY(1px);
}

/* ---- Input row ---- */
.cc-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--white);
  flex-shrink: 0;
}
.cc-input {
  flex: 1;
  font-family: var(--sans);
  font-size: .88rem;
  color: var(--charcoal);
  background: var(--cream);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  min-width: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.cc-input::placeholder { color: var(--charcoal-soft); opacity: .55; }
.cc-input:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(127,168,106,.14);
}
.cc-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--lime);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pine);
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.cc-send:hover {
  background: var(--lime-d);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(111,175,62,.32);
}
.cc-send:active { transform: translateY(0); box-shadow: none; }
.cc-send:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 2px;
}

/* ---- Footer-hide state ---- */
/*
 * Applied via JS (IntersectionObserver) when the footer enters the viewport.
 * Uses opacity so the layout never shifts and no position math is needed.
 * The bubble and panel each already have opacity in their transition lists,
 * so the fade is handled automatically.
 */
#cc-chat-bubble.cc-hidden,
#cc-chat-panel.cc-hidden {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  #cc-chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }
  #cc-chat-panel {
    bottom: 82px;
    right: 16px;
    width: calc(100vw - 32px);
    max-height: calc(100dvh - 106px);
  }
}
