/* ── Overlay ─────────────────────────────────── */
#chatbot-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

#chatbot-overlay.chatbot-open {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Chat window ─────────────────────────────── */
#chatbot-container {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  background: white;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

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

/* ── Header ──────────────────────────────────── */
#chatbot-header {
  background: #0057b8;
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

#chatbot-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

#chatbot-avatar {
  font-size: 28px;
  background: rgba(255,255,255,0.2);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chatbot-title {
  font-size: 18px;
  font-weight: bold;
}

#chatbot-subtitle {
  font-size: 13px;
  opacity: 0.8;
  margin-top: 2px;
}

#chatbot-toggle {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

#chatbot-toggle:hover {
  background: rgba(255,255,255,0.25);
}

/* ── Messages ────────────────────────────────── */
#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8f9fa;
}

#chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 3px;
}

.chatbot-message {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
}

.chatbot-user {
  background: #0057b8;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chatbot-assistant {
  background: white;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ── Timeout warning ─────────────────────────── */
#chatbot-timeout-warning {
  background: #fff3cd;
  color: #856404;
  padding: 12px 24px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border-top: 1px solid #ffeaa7;
}

#chatbot-keep-alive {
  background: #0057b8;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

/* ── Input area ──────────────────────────────── */
#chatbot-input-area {
  padding: 16px 24px;
  display: flex;
  gap: 10px;
  border-top: 1px solid #eee;
  background: white;
  flex-shrink: 0;
}

#chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  background: #f8f9fa;
}

#chatbot-input:focus {
  border-color: #0057b8;
  background: white;
}

#chatbot-send {
  background: #0057b8;
  color: white;
  border: none;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

#chatbot-send:hover {
  background: #0046a0;
}

#chatbot-send:active {
  transform: scale(0.95);
}

#chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Menu button ─────────────────────────────── */
.chat-menu-item a {
  display: flex !important;
  align-items: center;
  color: #0057b8 !important;
  font-weight: 600 !important;
}

.chat-menu-item a:hover {
  opacity: 0.8;
}

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 768px) {
  #chatbot-container {
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
  }

  #chatbot-overlay {
    align-items: flex-end;
  }

  .chatbot-message {
    max-width: 85%;
  }
}