/*--------------------------------------------------------------
  Chat Widget - preset-aware (var(--cp-*)) floating chat
--------------------------------------------------------------*/

/* floating action button (bottom-left, always visible) */
.cp-chat-fab {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--cp-aqua);
  color: var(--cp-navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 10001;
  transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}
.cp-chat-fab:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
}
.cp-chat-fab svg {
  width: 26px;
  height: 26px;
  display: block;
}
.cp-chat-fab .cp-chat-fab-close {
  display: none;
}
.cp-chat-fab.is-open .cp-chat-fab-open {
  display: none;
}
.cp-chat-fab.is-open .cp-chat-fab-close {
  display: block;
}

/* slide-out panel (from the left) */
.cp-chat-panel {
  position: fixed;
  left: 24px;
  bottom: 96px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: min(580px, calc(100vh - 140px));
  display: flex;
  flex-direction: column;
  background: var(--cp-navy);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.50);
  overflow: hidden;
  z-index: 10002;
  transform: translateX(calc(-100% - 40px));
  opacity: 0;
  visibility: hidden;
  transition: transform 0.38s cubic-bezier(0.22, 0.9, 0.32, 1),
    opacity 0.3s ease,
    visibility 0s linear 0.38s;
}
.cp-chat-panel.is-open {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  transition: transform 0.38s cubic-bezier(0.22, 0.9, 0.32, 1),
    opacity 0.3s ease,
    visibility 0s;
}

/* header */
.cp-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--cp-card);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.cp-chat-avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--cp-aqua);
  color: var(--cp-navy);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cp-chat-avatar svg {
  width: 20px;
  height: 20px;
}
.cp-chat-headtext {
  flex: 1 1 auto;
  min-width: 0;
}
.cp-chat-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--cp-aqua);
  line-height: 1.25;
}
.cp-chat-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: color-mix(in srgb, var(--cp-aqua) 65%, var(--cp-ice));
  display: flex;
  align-items: center;
  gap: 6px;
}
.cp-chat-subtitle::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38c172;
}
.cp-chat-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: var(--cp-ice);
  color: #000;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}
.cp-chat-close:hover {
  background: var(--cp-aqua);
  color: #000;
}

/* messages area */
.cp-chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--cp-ice) 25%, transparent) transparent;
}
.cp-chat-body::-webkit-scrollbar {
  width: 5px;
}
.cp-chat-body::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--cp-ice) 25%, transparent);
  border-radius: 99px;
}

/* message rows + bubbles */
.cp-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: cp-chat-msg-in 0.25s ease both;
}
@keyframes cp-chat-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.cp-chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 16px;
  word-wrap: break-word;
}
.cp-chat-time {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.4px;
  color: color-mix(in srgb, var(--cp-ice) 45%, transparent);
}
/* system / AI messages: left-aligned */
.cp-chat-msg.is-system {
  align-items: flex-start;
}
.cp-chat-msg.is-system .cp-chat-bubble {
  background: color-mix(in srgb, var(--cp-ice) 12%, transparent);
  color: color-mix(in srgb, var(--cp-ice) 92%, transparent);
  border-bottom-left-radius: 4px;
}
.cp-chat-msg.is-system .cp-chat-time {
  margin-left: 4px;
}
/* user messages: right-aligned, distinct color */
.cp-chat-msg.is-user {
  align-items: flex-end;
}
.cp-chat-msg.is-user .cp-chat-bubble {
  background: var(--cp-aqua);
  color: var(--cp-navy);
  border-bottom-right-radius: 4px;
}
.cp-chat-msg.is-user .cp-chat-time {
  margin-right: 4px;
}

/* typing indicator */
.cp-chat-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
}
.cp-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--cp-ice) 60%, transparent);
  animation: cp-chat-typing-blink 1.2s infinite;
}
.cp-chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.cp-chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes cp-chat-typing-blink {
  0%, 60%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* quick questions */
.cp-chat-quick {
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.cp-chat-quick-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--cp-ice) 25%, transparent);
  border-radius: 999px;
  background: transparent;
  color: color-mix(in srgb, var(--cp-ice) 85%, transparent);
  font-size: 12px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.cp-chat-quick-btn i {
  color: var(--cp-aqua);
  font-size: 11px;
  transition: color 0.2s ease;
}
.cp-chat-quick-btn:hover {
  background: var(--cp-aqua);
  border-color: var(--cp-aqua);
  color: var(--cp-navy);
}
.cp-chat-quick-btn:hover i {
  color: var(--cp-navy);
}

/* input area */
.cp-chat-inputbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--cp-card);
}
.cp-chat-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--cp-ice) 18%, transparent);
  border-radius: 999px;
  background: var(--cp-ice);
  color: #000;
  font-size: 14px;
  padding: 10px 16px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.cp-chat-input::placeholder {
  color: #5b6b72;
}
.cp-chat-input:focus {
  border-color: var(--cp-aqua);
  background: color-mix(in srgb, var(--cp-ice) 80%, #ffffff);
}
.cp-chat-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--cp-aqua);
  color: var(--cp-navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.cp-chat-send:hover {
  transform: scale(1.08);
}
.cp-chat-send svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* responsive: full-width sheet on small screens */
@media (max-width: 575px) {
  .cp-chat-panel {
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 75vh;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .cp-chat-fab {
    left: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
  }
}
