/* ===== Chat Widget ===== */
.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-gold);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(184, 120, 42, 0.4);
  z-index: 9998;
  transition: transform 0.2s, box-shadow 0.2s;
}

.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(184, 120, 42, 0.5);
}

.chat-nudge {
  position: fixed;
  bottom: 88px;
  right: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 9998;
  opacity: 0;
  transform: translateY(8px);
  animation: chatNudgeIn 0.4s 2s forwards;
  pointer-events: none;
  white-space: nowrap;
}

.chat-nudge::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--accent-gold);
  border-bottom: 1px solid var(--accent-gold);
  transform: rotate(45deg);
}

.chat-nudge.hidden {
  opacity: 0 !important;
  pointer-events: none;
  transition: opacity 0.3s;
}

@keyframes chatNudgeIn {
  to { opacity: 1; transform: translateY(0); }
}

.chat-toggle svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: opacity 0.15s;
}

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

.chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 120px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

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

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chat-header-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.chat-header-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-header-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-msg-bot {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.chat-msg-user {
  align-self: flex-end;
  background: var(--accent-gold);
  color: #fff;
}

.chat-msg-bot p { margin: 0 0 8px; }
.chat-msg-bot p:last-child { margin-bottom: 0; }
.chat-msg-bot strong { color: var(--accent-gold); }
.chat-msg-bot code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.82rem;
}
.chat-msg-bot ul, .chat-msg-bot ol {
  margin: 4px 0;
  padding-left: 18px;
}
.chat-msg-bot li { margin-bottom: 2px; }

.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: chatBounce 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

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

.chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

.chat-input::placeholder { color: var(--text-secondary); }
.chat-input:focus { border-color: var(--accent-gold); }

.chat-send {
  background: var(--accent-gold);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

.chat-send:hover { opacity: 0.85; }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.chat-msg-fade {
  animation: chatFadeIn 0.3s ease;
}

@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .chat-toggle { bottom: 16px; right: 16px; }
}
