/* ============================================
   Clanky — Chat Widget
   ============================================ */

.ckc {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 99999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Floating Action Button */
.ckc-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #f1a2aa, #c97882);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(241,162,170,0.45), 0 0 0 0 rgba(241,162,170,0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: ckc-pulse 3s ease-in-out infinite;
}

.ckc-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(201,120,130,0.55);
}

.ckc--open .ckc-fab {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

@keyframes ckc-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(241,162,170,0.45), 0 0 0 0 rgba(241,162,170,0.3); }
  50% { box-shadow: 0 4px 20px rgba(241,162,170,0.45), 0 0 0 12px rgba(241,162,170,0); }
}

/* Chat Panel */
.ckc-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 370px;
  max-height: 540px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #eaeaea;
  border-radius: 16px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.12), 0 4px 24px rgba(0,0,0,0.06);
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}

.ckc--open .ckc-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Header */
.ckc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fdf0f2, #fce4e8);
  border-bottom: 1px solid #eaeaea;
}

.ckc-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ckc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f1a2aa, #c97882);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.ckc-header-name {
  font-weight: 700;
  font-size: 0.9375rem;
  color: #1a1a2e;
}

.ckc-header-status {
  font-size: 0.75rem;
  color: #27ae60;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ckc-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #27ae60;
  display: inline-block;
}

.ckc-close {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
}

.ckc-close:hover {
  color: #1a1a2e;
  background: rgba(0,0,0,0.05);
}

/* Messages Area */
.ckc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 280px;
  max-height: 360px;
  scrollbar-width: thin;
  scrollbar-color: #eaeaea transparent;
}

.ckc-messages::-webkit-scrollbar { width: 4px; }
.ckc-messages::-webkit-scrollbar-thumb { background: #eaeaea; border-radius: 2px; }

/* Message Bubbles */
.ckc-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: ckc-msg-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ckc-msg--bot { align-self: flex-start; }
.ckc-msg--user { align-self: flex-end; }

.ckc-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.ckc-msg--bot .ckc-bubble {
  background: #f8f6f5;
  border: 1px solid #eaeaea;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
}

.ckc-msg--user .ckc-bubble {
  background: linear-gradient(135deg, #f1a2aa, #c97882);
  color: white;
  border-bottom-right-radius: 4px;
}

.ckc-time {
  font-size: 0.6875rem;
  color: #999;
  margin-top: 2px;
  padding: 0 4px;
}

.ckc-msg--user .ckc-time { align-self: flex-end; }

@keyframes ckc-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typing Indicator */
.ckc-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 2px;
}

.ckc-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #999;
  animation: ckc-dot-bounce 1.4s ease-in-out infinite;
}

.ckc-dots span:nth-child(2) { animation-delay: 0.2s; }
.ckc-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ckc-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input Area */
.ckc-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eaeaea;
  background: #fafafa;
}

.ckc-input {
  flex: 1;
  background: #ffffff;
  border: 1px solid #eaeaea;
  border-radius: 12px;
  padding: 10px 14px;
  color: #1a1a2e;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  max-height: 120px;
}

.ckc-input::placeholder { color: #bbb; }
.ckc-input:focus { border-color: #f1a2aa; }

.ckc-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #f1a2aa, #c97882);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.ckc-send:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 2px 12px rgba(201,120,130,0.4);
}

.ckc-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Product Cards in chat */
.ckc-products {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.ckc-product-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #eaeaea;
  border-radius: 10px;
  padding: 8px;
}

.ckc-product-img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.ckc-product-info {
  flex: 1;
  min-width: 0;
}

.ckc-product-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1a1a2e;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ckc-product-price {
  font-size: 0.75rem;
  font-weight: 700;
  color: #c97882;
}

.ckc-product-add {
  padding: 6px 14px;
  background: linear-gradient(135deg, #f1a2aa, #c97882);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
}

.ckc-product-add:hover { opacity: 0.9; }
.ckc-product-add--done { background: #27ae60; pointer-events: none; }
.ckc-product-link { text-decoration: none; display: inline-flex; align-items: center; background: #555; }
.ckc-product-link:hover { background: #333; }

/* Markdown in bubbles */
.ckc-msg--bot .ckc-bubble strong { font-weight: 700; color: #c97882; }
.ckc-msg--bot .ckc-bubble a { color: #c97882; text-decoration: underline; }
.ckc-msg--bot .ckc-bubble ul { margin: 6px 0; padding-left: 16px; }
.ckc-msg--bot .ckc-bubble li { margin: 2px 0; }

/* Mobile */
@media (max-width: 480px) {
  .ckc { bottom: 1rem; right: 1rem; }
  .ckc-panel {
    width: calc(100vw - 2rem);
    max-height: calc(100dvh - 6rem);
  }
  .ckc-messages { max-height: calc(100dvh - 14rem); }
}
