/* CCI Chat Widget v2.0 */

#cci-chat-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #1B6B4A;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999998;
  transition: background 0.2s;
  padding: 0;
}

#cci-chat-button:hover {
  background: #145A3E;
}

#cci-chat-button svg {
  display: block;
}

#cci-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 360px;
  height: 480px;
  background: #F8FAFB;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 999997;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1F2937;
  font-size: 14px;
  overflow: hidden;
}

#cci-chat-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Header */
#cci-chat-header {
  background: #1B6B4A;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

#cci-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.85;
  display: flex;
  align-items: center;
}

#cci-chat-close:hover {
  opacity: 1;
}

/* Messages area */
#cci-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.cci-message {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 10px;
  line-height: 1.5;
  word-break: break-word;
  font-size: 14px;
}

.cci-message-user {
  background: #1B6B4A;
  color: #fff;
  align-self: flex-end;
  border-radius: 10px 10px 2px 10px;
}

.cci-message-bot {
  background: #fff;
  border: 1px solid #E5E7EB;
  color: #1F2937;
  align-self: flex-start;
  border-radius: 10px 10px 10px 2px;
}

/* Typing indicator */
.cci-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 11px 14px;
}

.cci-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9CA3AF;
  animation: cci-bounce 1.2s infinite ease-in-out;
}

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

@keyframes cci-bounce {
  0%, 80%, 100% { transform: scale(0.75); opacity: 0.5; }
  40%            { transform: scale(1.1);  opacity: 1; }
}

/* Input area */
#cci-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #E5E7EB;
  background: #fff;
  flex-shrink: 0;
}

#cci-chat-input {
  flex: 1;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 14px;
  font-family: inherit;
  color: #1F2937;
  background: #fff;
  outline: none;
  min-width: 0;
}

#cci-chat-input:focus {
  border-color: #1B6B4A;
  box-shadow: 0 0 0 2px rgba(27, 107, 74, 0.12);
}

#cci-chat-send {
  background: #1B6B4A;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 15px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

#cci-chat-send:hover:not(:disabled) {
  background: #145A3E;
}

#cci-chat-send:disabled,
#cci-chat-input:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Footer */
#cci-chat-footer {
  text-align: center;
  font-size: 11px;
  color: #6B7280;
  padding: 6px 8px;
  background: #fff;
  border-top: 1px solid #E5E7EB;
  flex-shrink: 0;
}

/* ToU prompt */
.cci-tou-prompt {
  padding: 28px 20px;
  text-align: center;
}

.cci-tou-prompt h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
  color: #1F2937;
}

.cci-tou-prompt p {
  font-size: 14px;
  color: #4B5563;
  margin: 0 0 22px;
  line-height: 1.55;
}

.cci-tou-prompt a {
  color: #1B6B4A;
  text-decoration: underline;
}

.cci-tou-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.cci-tou-agree {
  background: #1B6B4A;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 22px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}

.cci-tou-agree:hover {
  background: #145A3E;
}

.cci-tou-decline {
  background: none;
  color: #6B7280;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 9px 22px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.cci-tou-decline:hover {
  background: #F3F4F6;
}

/* Attention nudge — pulse ring + proactive tooltip */
@keyframes cci-pulse {
  0%   { box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 0 0 0    rgba(27,107,74,0.45); }
  70%  { box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 0 0 14px rgba(27,107,74,0);    }
  100% { box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 0 0 0    rgba(27,107,74,0);    }
}

@keyframes cci-tooltip-appear {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

#cci-chat-button {
  animation: cci-pulse 2s ease-out 2.5s 3; /* 3 pulses starting 2.5s after load */
}

#cci-chat-button::after {
  content: 'Questions? Ask our AI \2192';
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: #1B6B4A;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  pointer-events: none;
  opacity: 0;
  animation: cci-tooltip-appear 5s ease 5s 1; /* starts at 5s: fade in, hold, fade out */
}

/* Mobile */
@media (max-width: 480px) {
  #cci-chat-button {
    right: 16px;
    bottom: 16px;
  }

  #cci-chat-panel {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 88px;
    height: 70vh;
    max-height: 520px;
  }
}
