/* ==========================================================================
   B'DESK — WIDGET ASSISTANT IA (DESIGN BOULANGER MODERNE)
   ========================================================================== */

.ai-assistant {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1100;
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Bouton Déclencheur Flottant (Orb) */
.ai-assistant-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 60px;
  height: 60px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #0c2340 0%, #16365c 100%);
  color: #ffffff;
  box-shadow: 0 10px 30px rgba(12, 35, 64, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.ai-assistant-toggle img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
  transform: none;
}

.ai-assistant-toggle:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 14px 36px rgba(12, 35, 64, 0.45), 0 0 20px rgba(243, 112, 33, 0.4);
}

.ai-assistant-toggle:focus-visible {
  outline: 3px solid rgba(243, 112, 33, 0.5);
  outline-offset: 3px;
}

.ai-assistant-brand {
  color: #f37021;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1;
}

.ai-assistant-ai {
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1;
  background: #f37021;
  padding: 2px 5px;
  border-radius: 6px;
  margin-left: -1px;
}

/* Panneau de Conversation */
.ai-assistant-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 32px));
  height: 520px;
  overflow: hidden;
  border: 1px solid rgba(219, 228, 238, 0.9);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(12, 35, 64, 0.22), 0 4px 16px rgba(12, 35, 64, 0.08);
  animation: assistant-slide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-assistant-panel[hidden] {
  display: none;
}

@keyframes assistant-slide {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* En-tête du Chat */
.ai-assistant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #0c2340 0%, #16365c 100%);
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-assistant-head strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.ai-assistant-head strong::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.ai-assistant-close {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-assistant-close:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.05);
}

/* Zone des Messages */
.ai-assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f5f8fb;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-assistant-messages::-webkit-scrollbar {
  width: 6px;
}
.ai-assistant-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.ai-message {
  max-width: 86%;
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-message.bot {
  align-self: flex-start;
  border: 1px solid #dbe4ee;
  background: #ffffff;
  color: #0d1e32;
  box-shadow: 0 2px 8px rgba(12, 35, 64, 0.04);
  border-bottom-left-radius: 4px;
}

.ai-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #f37021 0%, #ff833e 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(243, 112, 33, 0.28);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

/* Formulaire de Saisie */
.ai-assistant-form {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid #dbe4ee;
  background: #ffffff;
}

.ai-assistant-input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  color: #0d1e32;
  background: #fbfcfd;
  font: inherit;
  font-size: 13px;
  transition: all 0.2s ease;
}

.ai-assistant-input:focus {
  border-color: #f37021;
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(243, 112, 33, 0.15);
}

.ai-assistant-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #f37021 0%, #ff833e 100%);
  color: #ffffff;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.2px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(243, 112, 33, 0.25);
  transition: all 0.2s ease;
}

.ai-assistant-send:hover:not(:disabled) {
  background: linear-gradient(135deg, #ff7e33 0%, #f37021 100%);
  box-shadow: 0 6px 16px rgba(243, 112, 33, 0.35);
  transform: translateY(-1px);
}

.ai-assistant-send:disabled,
.ai-assistant-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .ai-assistant {
    right: 16px;
    bottom: 16px;
  }

  .ai-assistant-panel {
    bottom: 72px;
    height: min(480px, calc(100vh - 110px));
  }
}

body.dark-mode .ai-assistant-panel,
body.dark-mode .ai-assistant-input {
  background: var(--surface) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

body.dark-mode .ai-assistant-messages {
  background: var(--surface-alt);
}

body.dark-mode .ai-message.bot {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
  box-shadow: none;
}

body.dark-mode .ai-assistant-form {
  background: var(--surface);
  border-color: var(--line);
}

body.dark-mode .ai-message {
  color: var(--text);
}
