:root {
  --ai-bg: rgba(13, 17, 23, 0.96);
  --ai-surface: rgba(22, 27, 34, 0.98);
  --ai-border: rgba(255, 255, 255, 0.08);
  --ai-text: #e6edf3;
  --ai-muted: #a9b4c0;
  --ai-primary: #0dcaf0;      /* Bootstrap info */
  --ai-primary-soft: rgba(13, 202, 240, 0.12);
  --ai-user-bg: rgba(13, 202, 240, 0.16);
  --ai-bot-bg: rgba(255, 255, 255, 0.04);
  --ai-shadow: 0 20px 60px rgba(0, 0, 0, 0.40);
  --ai-radius: 22px;
}

/* Bouton navbar */
.ai-chat-nav-btn {
  box-shadow: 0 8px 24px rgba(13, 202, 240, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.ai-chat-nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(13, 202, 240, 0.14);
}

.ai-chat-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ai-primary);
  box-shadow: 0 0 0 6px rgba(13, 202, 240, 0.12);
  display: inline-block;
}

/* Overlay */
.ai-chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 1050;
}

/* Panel chat */
.ai-chat-panel {
  position: fixed;
  top: 74px;
  right: 16px;
  z-index: 1055;
  width: 390px;
  max-width: calc(100vw - 24px);
  height: min(680px, calc(100vh - 92px));
  max-height: calc(100vh - 92px);
}

.ai-chat-card {
  height: 100%;
  border-radius: var(--ai-radius);
  overflow: hidden;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border) !important;
  backdrop-filter: blur(16px);
  color: var(--ai-text);
}

.ai-chat-header {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0));
  border-bottom: 1px solid var(--ai-border);
  color: var(--ai-text);
  padding: 1rem 1rem 0.9rem;
}

.ai-chat-body {
  background: transparent;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-chat-footer {
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--ai-border);
  padding: 0.85rem 1rem 1rem;
}

.ai-chat-input {
  resize: none;
  max-height: 140px;
  min-height: 46px;
  border-radius: 14px 0 0 14px !important;
  background: var(--ai-surface);
  color: var(--ai-text);
  border: 1px solid var(--ai-border);
}

.ai-chat-input:focus {
  background: var(--ai-surface);
  color: var(--ai-text);
  border-color: rgba(13, 202, 240, 0.45);
  box-shadow: 0 0 0 0.2rem rgba(13, 202, 240, 0.15);
}

.ai-chat-input::placeholder {
  color: #8b98a8;
}

#aiChatSend {
  border-radius: 0 14px 14px 0 !important;
  min-width: 95px;
}

/* Messages */
.ai-msg {
  padding: 0.9rem 1rem;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg p:last-child {
  margin-bottom: 0;
}

.ai-msg-bot {
  align-self: flex-start;
  background: var(--ai-bot-bg);
  border: 1px solid var(--ai-border);
  color: var(--ai-text);
}

.ai-msg-user {
  align-self: flex-end;
  background: var(--ai-user-bg);
  border: 1px solid rgba(13, 202, 240, 0.22);
  color: #dff8ff;
}

.ai-msg-error {
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.25);
  color: #ffd5da;
}

/* Suggestions */
.ai-suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ai-chip {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ai-text);
  border: 1px solid var(--ai-border);
  border-radius: 999px;
  padding: 0.52rem 0.85rem;
  font-size: 0.83rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.ai-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(13, 202, 240, 0.25);
  background: rgba(13, 202, 240, 0.08);
}

/* Sources */
.ai-sources {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.10);
  font-size: 0.8rem;
  color: var(--ai-muted);
}

.ai-sources a {
  color: #7ddfff;
  text-decoration: none;
}

.ai-sources a:hover {
  text-decoration: underline;
}

/* Loader typing */
.ai-typing {
  opacity: 0.85;
  font-style: italic;
}

/* Scrollbar */
.ai-chat-body::-webkit-scrollbar {
  width: 10px;
}

.ai-chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 12px;
}

.ai-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

/* Mobile */
@media (max-width: 768px) {
  .ai-chat-panel {
    top: 66px;
    right: 8px;
    left: 8px;
    width: auto;
    max-width: none;
    height: calc(100vh - 78px);
    max-height: calc(100vh - 78px);
  }

  .ai-chat-card {
    border-radius: 18px;
  }

  .ai-chat-nav-btn span:last-child {
    display: none;
  }
}