/* ===== BIS Chatbot Widget ===== */
#bis-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #D4915C, #E8A063);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(212, 145, 92, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: bis-pulse 2.8s ease-in-out infinite;
}

#bis-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(212, 145, 92, 0.6);
  animation: none;
}

#bis-chat-btn svg {
  position: absolute;
  width: 26px;
  height: 26px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#bis-chat-btn .bot-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

#bis-chat-btn .close-icon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

#bis-chat-btn.active .bot-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

#bis-chat-btn.active .close-icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

#bis-chat-btn.active {
  animation: none;
}

@keyframes bis-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(212, 145, 92, 0.45); }
  50%       { box-shadow: 0 4px 28px rgba(212, 145, 92, 0.75), 0 0 0 8px rgba(212, 145, 92, 0.12); }
}

/* ===== Chat Panel ===== */
#bis-chat-panel {
  position: fixed;
  bottom: 98px;
  right: 28px;
  z-index: 9000;
  width: 360px;
  max-height: 540px;
  background: #16191e;
  border: 1px solid rgba(212, 145, 92, 0.25);
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#bis-chat-panel.bis-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.bis-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(212,145,92,0.12), rgba(232,160,99,0.06));
  border-bottom: 1px solid rgba(212, 145, 92, 0.18);
  flex-shrink: 0;
}

.bis-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #D4915C, #E8A063);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.bis-chat-title {
  flex: 1;
}

.bis-chat-title strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #e2c9b0;
  letter-spacing: 0.01em;
}

.bis-chat-title span {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: #8a9ab0;
  margin-top: 2px;
}

.bis-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
  animation: bis-blink 2s ease-in-out infinite;
}

@keyframes bis-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.bis-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #64748b;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.bis-chat-close:hover {
  color: #94a3b8;
  background: rgba(255,255,255,0.06);
}

/* Messages area */
.bis-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.bis-chat-msgs::-webkit-scrollbar { width: 4px; }
.bis-chat-msgs::-webkit-scrollbar-track { background: transparent; }
.bis-chat-msgs::-webkit-scrollbar-thumb { background: rgba(212,145,92,0.3); border-radius: 2px; }

/* Suggested questions */
.bis-suggestions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 4px 0 4px;
}

.bis-suggestion-intro {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 2px;
}

.bis-suggestion-btn {
  background: rgba(212, 145, 92, 0.08);
  border: 1px solid rgba(212, 145, 92, 0.22);
  border-radius: 10px;
  color: #d4a574;
  font-size: 12.5px;
  padding: 8px 11px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
  line-height: 1.4;
}

.bis-suggestion-btn:hover {
  background: rgba(212, 145, 92, 0.16);
  border-color: rgba(212, 145, 92, 0.4);
}

/* Message bubbles */
.bis-msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
}

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

.bis-msg.bis-bot {
  align-self: flex-start;
}

.bis-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #D4915C, #E8A063);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}

.bis-msg-bubble {
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 100%;
  word-wrap: break-word;
}

.bis-msg.bis-user .bis-msg-bubble {
  background: linear-gradient(135deg, rgba(212,145,92,0.22), rgba(232,160,99,0.16));
  border: 1px solid rgba(212,145,92,0.3);
  color: #e2c9b0;
  border-radius: 14px 14px 4px 14px;
}

.bis-msg.bis-bot .bis-msg-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: #cbd5e1;
  border-radius: 14px 14px 14px 4px;
}

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

.bis-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(212,145,92,0.6);
  animation: bis-typing-bounce 1.2s ease-in-out infinite;
}

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

@keyframes bis-typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.bis-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.bis-chat-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: #e2e8f0;
  font-size: 13.5px;
  padding: 9px 12px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  min-height: 40px;
  max-height: 100px;
  transition: border-color 0.15s ease;
}

.bis-chat-input::placeholder { color: #475569; }

.bis-chat-input:focus {
  border-color: rgba(212,145,92,0.45);
}

.bis-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #D4915C, #E8A063);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.bis-chat-send:hover:not(:disabled) {
  opacity: 0.88;
  transform: scale(1.06);
}

.bis-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bis-chat-send svg {
  width: 17px;
  height: 17px;
  color: white;
}

/* Error message */
.bis-error-bubble {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  align-self: center;
  text-align: center;
}

/* ===== Light mode overrides ===== */
[data-theme="light"] #bis-chat-panel {
  background: #ffffff;
  border-color: rgba(212, 145, 92, 0.3);
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
}

[data-theme="light"] .bis-chat-header {
  background: linear-gradient(135deg, rgba(212,145,92,0.09), rgba(232,160,99,0.04));
  border-bottom-color: rgba(212,145,92,0.2);
}

[data-theme="light"] .bis-chat-title strong { color: #92400e; }
[data-theme="light"] .bis-chat-title span   { color: #78716c; }
[data-theme="light"] .bis-chat-close        { color: #a8a29e; }
[data-theme="light"] .bis-chat-close:hover  { color: #57534e; background: rgba(0,0,0,0.05); }

[data-theme="light"] .bis-msg.bis-user .bis-msg-bubble {
  background: linear-gradient(135deg, rgba(212,145,92,0.18), rgba(232,160,99,0.1));
  border-color: rgba(212,145,92,0.35);
  color: #92400e;
}

[data-theme="light"] .bis-msg.bis-bot .bis-msg-bubble {
  background: #f8f7f5;
  border-color: rgba(0,0,0,0.08);
  color: #374151;
}

[data-theme="light"] .bis-suggestion-btn {
  color: #b45309;
}

[data-theme="light"] .bis-suggestion-intro { color: #9ca3af; }

[data-theme="light"] .bis-chat-input {
  background: #f8f7f5;
  border-color: rgba(0,0,0,0.1);
  color: #1c1917;
}

[data-theme="light"] .bis-chat-input::placeholder { color: #a8a29e; }
[data-theme="light"] .bis-chat-input:focus { border-color: rgba(212,145,92,0.5); }

[data-theme="light"] .bis-chat-input-row { border-top-color: rgba(0,0,0,0.07); }

[data-theme="light"] .bis-error-bubble {
  background: rgba(239,68,68,0.07);
  color: #b91c1c;
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  #bis-chat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 88px;
    max-height: 72vh;
  }

  #bis-chat-btn {
    right: 18px;
    bottom: 18px;
  }
}
