/* ════════════════════════════════════════════════════════════════════
   Straven Partners — AI Chat Widget
   Floating button + side panel with three modes:
   Qwen · YandexGPT · Telegram
   ════════════════════════════════════════════════════════════════════ */

/* Floating launcher button */
.chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bronze);
  color: var(--midnight);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(13, 18, 32, 0.4);
  transition: transform .25s, box-shadow .25s, background .25s;
  font-family: var(--sans);
}
.chat-launcher:hover {
  background: var(--bronze2);
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(196, 150, 90, 0.45);
}
.chat-launcher.open {
  background: var(--midnight2);
  color: var(--paper);
  border: 1px solid rgba(196, 150, 90, 0.35);
}
.chat-launcher svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
}
.chat-launcher-label {
  position: absolute;
  right: 68px;
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  background: var(--midnight2);
  border: 1px solid rgba(196, 150, 90, 0.25);
  padding: 8px 14px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.chat-launcher:hover .chat-launcher-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* Chat pulse ring (subtle attention indicator) */
.chat-launcher::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--bronze);
  opacity: 0;
  animation: chat-pulse 2.4s ease-out infinite;
}
.chat-launcher.open::before { animation: none; opacity: 0; }
@keyframes chat-pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Chat panel */
.chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 160;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 48px);
  background: var(--midnight2);
  border: 1px solid rgba(196, 150, 90, 0.22);
  box-shadow: 0 24px 60px rgba(13, 18, 32, 0.55);
  display: flex;
  flex-direction: column;
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s cubic-bezier(.22,.68,0,1), opacity .2s;
}
.chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Chat header */
.chat-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(196, 150, 90, 0.15);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.chat-header-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  color: var(--paper);
  line-height: 1.2;
}
.chat-header-title em {
  font-style: italic;
  color: var(--bronze);
}
.chat-header-sub {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mist);
  margin-top: 4px;
}
.chat-close {
  background: none;
  border: none;
  color: var(--mist);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color .2s;
}
.chat-close:hover { color: var(--paper); }

/* Mode tabs (Qwen / Yandex / Telegram) */
.chat-modes {
  display: flex;
  gap: 1px;
  background: rgba(196, 150, 90, 0.12);
  border-bottom: 1px solid rgba(196, 150, 90, 0.15);
  flex-shrink: 0;
}
.chat-mode {
  flex: 1;
  padding: 11px 8px;
  background: var(--midnight2);
  border: none;
  color: var(--mist);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, color .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.chat-mode:hover { background: var(--slate); color: var(--paper); }
.chat-mode.active {
  background: var(--midnight);
  color: var(--bronze);
  position: relative;
}
.chat-mode.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--bronze);
}
.chat-mode-icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 150, 90, 0.3) transparent;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(196, 150, 90, 0.3); }

.chat-msg {
  max-width: 82%;
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 300;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--bronze);
  color: var(--midnight);
  border-radius: 14px 14px 4px 14px;
}
.chat-msg.bot {
  align-self: flex-start;
  background: var(--midnight);
  color: var(--paper);
  border: 1px solid rgba(196, 150, 90, 0.15);
  border-radius: 14px 14px 14px 4px;
}
.chat-msg.system {
  align-self: center;
  background: rgba(12, 104, 112, 0.12);
  color: var(--mist);
  font-size: 11px;
  border: 1px solid rgba(12, 104, 112, 0.3);
  border-radius: 4px;
  padding: 8px 14px;
  max-width: 90%;
  text-align: center;
}
.chat-msg.error {
  background: rgba(220, 80, 80, 0.08);
  color: var(--danger-soft);
  border: 1px solid rgba(220, 80, 80, 0.3);
  align-self: center;
  border-radius: 4px;
  font-size: 11px;
}

.chat-msg-meta {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mist);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-msg-meta::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--bronze);
}

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  padding: 14px 18px;
  background: var(--midnight);
  border: 1px solid rgba(196, 150, 90, 0.15);
  border-radius: 14px 14px 14px 4px;
  display: flex;
  gap: 4px;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mist);
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Telegram CTA block (when Telegram mode is selected) */
.chat-cta {
  margin: 12px 18px;
  padding: 16px;
  background: var(--midnight);
  border: 1px solid rgba(196, 150, 90, 0.18);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
}
.chat-cta-icon {
  width: 44px;
  height: 44px;
  border: 1px solid var(--bronze);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bronze);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
}
.chat-cta-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  color: var(--paper);
  line-height: 1.3;
}
.chat-cta-text {
  font-size: 12px;
  color: var(--mist);
  line-height: 1.6;
  font-weight: 300;
}
.chat-cta-btn {
  display: inline-block;
  padding: 11px 22px;
  background: var(--bronze);
  color: var(--midnight);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background .2s;
  width: 100%;
  text-align: center;
}
.chat-cta-btn:hover { background: var(--bronze2); }

/* Input area */
.chat-input-area {
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(196, 150, 90, 0.15);
  flex-shrink: 0;
  background: var(--midnight2);
}
.chat-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--midnight);
  border: 1px solid rgba(196, 150, 90, 0.18);
  color: var(--paper);
  padding: 11px 14px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 300;
  resize: none;
  outline: none;
  border-radius: 0;
  min-height: 42px;
  max-height: 100px;
  line-height: 1.5;
  transition: border-color .2s;
}
.chat-input::placeholder { color: rgba(154, 168, 186, 0.6); }
.chat-input:focus { border-color: rgba(196, 150, 90, 0.5); }
.chat-send {
  background: var(--bronze);
  color: var(--midnight);
  border: none;
  padding: 0 14px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}
.chat-send:hover { background: var(--bronze2); }
.chat-send:disabled { background: var(--slate); cursor: not-allowed; opacity: 0.5; }
.chat-send svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.chat-disclaimer {
  font-size: 10px;
  color: rgba(154, 168, 186, 0.55);
  margin-top: 8px;
  text-align: center;
  line-height: 1.4;
}
.chat-disclaimer a {
  color: var(--bronze);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(196, 150, 90, 0.4);
}

/* Suggestions row */
.chat-suggestions {
  display: flex;
  gap: 6px;
  padding: 8px 14px 0;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.chat-suggestion {
  font-size: 11px;
  color: var(--mist);
  background: var(--midnight);
  border: 1px solid rgba(196, 150, 90, 0.18);
  padding: 6px 10px;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
  font-weight: 300;
  font-family: var(--sans);
}
.chat-suggestion:hover {
  background: var(--slate);
  color: var(--paper);
  border-color: rgba(196, 150, 90, 0.4);
}

/* Mobile */
@media (max-width: 600px) {
  .chat-launcher { bottom: 16px; right: 16px; width: 52px; height: 52px; }
  .chat-launcher-label { display: none; }
  .chat-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .chat-launcher::before { animation: none; }
  .chat-panel { transition: opacity .15s; }
}
