/* ── Chat Widget ── */

.cc-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #d94d1a;
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(217, 77, 26, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  line-height: 1;
}

.cc-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(217, 77, 26, 0.5);
}

.cc-chat-toggle .cc-icon-close {
  display: none;
}

.cc-chat-toggle.cc-open .cc-icon-chat {
  display: none;
}

.cc-chat-toggle.cc-open .cc-icon-close {
  display: block;
}

/* ── Chat Panel ── */

.cc-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: rgba(250, 248, 245, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  border: 1px solid rgba(91, 59, 47, 0.1);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.cc-chat-panel.cc-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ── */

.cc-chat-header {
  padding: 1rem 1.25rem;
  background: #33261d;
  color: #faf5ef;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.cc-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #d94d1a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.cc-chat-header-text h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.cc-chat-header-text p {
  margin: 0;
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ── Messages ── */

.cc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cc-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.cc-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(91, 59, 47, 0.15);
  border-radius: 4px;
}

.cc-msg {
  max-width: 85%;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.cc-msg-assistant {
  align-self: flex-start;
  background: #fff;
  color: #33261d;
  border: 1px solid rgba(91, 59, 47, 0.08);
  border-bottom-left-radius: 4px;
}

.cc-msg-user {
  align-self: flex-end;
  background: #d94d1a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator ── */

.cc-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.65rem 0.9rem;
  background: #fff;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(91, 59, 47, 0.08);
}

.cc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8b6f47;
  animation: cc-bounce 1.4s infinite ease-in-out both;
}

.cc-typing span:nth-child(1) { animation-delay: 0s; }
.cc-typing span:nth-child(2) { animation-delay: 0.2s; }
.cc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cc-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Input ── */

.cc-chat-input {
  display: flex;
  padding: 0.75rem;
  border-top: 1px solid rgba(91, 59, 47, 0.08);
  gap: 0.5rem;
  flex-shrink: 0;
  background: rgba(250, 248, 245, 0.98);
}

.cc-chat-input input {
  flex: 1;
  border: 1px solid rgba(91, 59, 47, 0.15);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  color: #33261d;
  outline: none;
  transition: border-color 0.2s;
}

.cc-chat-input input:focus {
  border-color: #d94d1a;
}

.cc-chat-input input::placeholder {
  color: #8b6f47;
}

.cc-chat-input button {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: #d94d1a;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.2s;
  flex-shrink: 0;
}

.cc-chat-input button:hover {
  background: #c04215;
}

.cc-chat-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cc-char-count {
  font-size: 0.7rem;
  color: #8b6f47;
  text-align: right;
  padding: 0 0.75rem 0.25rem;
  flex-shrink: 0;
}

.cc-char-count.cc-near-limit {
  color: #d94d1a;
}

/* ── Mobile ── */

@media (max-width: 640px) {
  .cc-chat-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .cc-chat-toggle.cc-open {
    display: none;
  }

  .cc-chat-header {
    padding: 1rem 1.25rem;
  }

  .cc-chat-close-mobile {
    display: block;
    margin-left: auto;
    background: none;
    border: none;
    color: #faf5ef;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
  }
}

@media (min-width: 641px) {
  .cc-chat-close-mobile {
    display: none;
  }
}
