/* CrownOS Chat Widget — Floating sales assistant */

#cr-chat-launch {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  background: #1a1a2e;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

#cr-chat-launch:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4);
}

#cr-chat-launch svg {
  width: 26px;
  height: 26px;
  fill: #e8c97a;
}

#cr-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-height: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
}

#cr-chat-window.open {
  display: flex;
  animation: cr-slide-in 0.25s ease-out;
}

@keyframes cr-slide-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

#cr-chat-header {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d1f4e 100%);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#cr-chat-header-avatar {
  width: 38px;
  height: 38px;
  background: #e8c97a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#cr-chat-header-avatar svg {
  width: 20px;
  height: 20px;
  fill: #1a1a2e;
}

#cr-chat-header-info { flex: 1; }

#cr-chat-header-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

#cr-chat-header-status {
  font-size: 11px;
  color: #e8c97a;
  margin-top: 1px;
}

#cr-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

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

#cr-chat-close svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

#cr-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.cr-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
}

.cr-msg.from-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cr-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cr-msg.from-bot .cr-msg-avatar {
  background: #1a1a2e;
}

.cr-msg.from-user .cr-msg-avatar {
  background: #e8c97a;
}

.cr-msg-avatar svg {
  width: 14px;
  height: 14px;
  fill: #fff;
}

.cr-msg.from-user .cr-msg-avatar svg {
  fill: #1a1a2e;
}

.cr-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: #2a2a2a;
  word-break: break-word;
}

.cr-msg.from-bot .cr-msg-bubble {
  background: #fff;
  border: 1px solid #eee;
  border-top-left-radius: 4px;
}

.cr-msg.from-user .cr-msg-bubble {
  background: #1a1a2e;
  color: #fff;
  border-top-right-radius: 4px;
}

.cr-typing {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 4px;
}

.cr-typing-dot {
  width: 7px;
  height: 7px;
  background: #c0c0c0;
  border-radius: 50%;
  animation: cr-bounce 1.2s infinite;
}

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

@keyframes cr-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

#cr-chat-input-area {
  padding: 14px 16px;
  border-top: 1px solid #eee;
  background: #fff;
}

#cr-lead-form {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  background: #f5f0e8;
  border-radius: 10px;
}

#cr-lead-form.visible { display: flex; }

#cr-lead-form h4 {
  font-size: 12px;
  color: #1a1a2e;
  font-weight: 600;
  margin: 0 0 4px;
}

#cr-lead-form input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}

#cr-lead-form button {
  padding: 8px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
}

#cr-chat-input-row {
  display: flex;
  gap: 8px;
}

#cr-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #ddd;
  border-radius: 24px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  resize: none;
  line-height: 1.4;
  max-height: 80px;
  transition: border-color 0.2s;
}

#cr-chat-input:focus {
  border-color: #1a1a2e;
}

#cr-chat-send {
  width: 38px;
  height: 38px;
  background: #1a1a2e;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background 0.2s;
}

#cr-chat-send:hover { background: #2d1f4e; }

#cr-chat-send svg {
  width: 16px;
  height: 16px;
  fill: #e8c97a;
}

#cr-chat-window.open #cr-chat-launch { display: none; }