/* Serenity AI chat — design clair, icône seule par défaut */

.ai-chat-toggle-icon {
  display: block;
}

.ai-chat-icon-close {
  display: none;
}

.ai-chat-root.ai-chat-open .ai-chat-icon-open {
  display: none;
}

.ai-chat-root.ai-chat-open .ai-chat-icon-close {
  display: block;
}

.ai-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(61, 58, 53, 0.14);
  border-color: var(--gold);
  color: var(--ocean);
}

.ai-chat-root.ai-chat-open .ai-chat-toggle {
  background: var(--sage-dark);
  color: #fff;
  border-color: var(--sage-dark);
}

.ai-chat-root:not(.ai-chat-open) .ai-chat-hint {
  cursor: pointer;
}

.ai-chat-hint[hidden] {
  display: none !important;
}

.ai-chat-hint {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 240px;
  padding: 0.55rem 0.65rem 0.55rem 0.85rem;
  background: #fff;
  border: 1px solid rgba(196, 165, 116, 0.3);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(61, 58, 53, 0.1);
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--earth);
  animation: aiHintIn 0.3s ease;
  white-space: nowrap;
}

.ai-chat-hint::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-right: 1px solid rgba(196, 165, 116, 0.3);
  border-bottom: 1px solid rgba(196, 165, 116, 0.3);
  transform: rotate(45deg);
}

.ai-chat-hint-close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--sand);
  color: var(--sage-dark);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes aiHintIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chat-root.ai-chat-open .ai-chat-hint {
  display: none !important;
}

/* Fenêtre — visible uniquement à l'ouverture */
.ai-chat-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: min(400px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 7rem));
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 12px 40px rgba(61, 58, 53, 0.14);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-chat-panel[hidden] {
  display: none !important;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.ai-chat-header-info {
  min-width: 0;
}

.ai-chat-header-info strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--earth);
}

.ai-chat-header-info span {
  display: block;
  font-size: 0.75rem;
  color: var(--sage-dark);
  margin-top: 0.15rem;
}

.ai-chat-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--sand);
  color: var(--sage-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.ai-chat-close:hover {
  background: #ebe4d8;
}

.ai-chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fafafa;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

.ai-chat-row {
  display: flex;
  animation: aiMsgIn 0.25s ease;
}

.ai-chat-row-user {
  justify-content: flex-end;
}

.ai-chat-row-bot {
  justify-content: flex-start;
}

.ai-chat-msg {
  max-width: 88%;
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-chat-msg-bot {
  background: #fff;
  color: var(--earth);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 4px;
}

.ai-chat-msg-offer {
  background: #f0f7f4;
  border-color: rgba(92, 107, 82, 0.2);
}

.ai-chat-root.ai-chat-proactive .ai-chat-panel {
  animation: aiPanelOffer 0.4s ease;
}

@keyframes aiPanelOffer {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-chat-msg-user {
  background: var(--sage-dark);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 0.9rem;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sage);
  animation: aiTypingBounce 1.2s ease infinite;
}

.ai-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@keyframes aiMsgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chat-suggestions-wrap {
  flex-shrink: 0;
  padding: 0.65rem 1rem 0.75rem;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-chat-suggestions-wrap[hidden] {
  display: none !important;
}

.ai-chat-suggestions-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--sage-dark);
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ai-chat-suggestions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.ai-chat-suggestion {
  border: 1px solid rgba(196, 165, 116, 0.35);
  border-radius: 10px;
  padding: 0.45rem 0.35rem;
  font-size: 0.72rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  background: var(--cream);
  color: var(--earth);
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}

.ai-chat-suggestion:hover {
  background: #fff;
  border-color: var(--gold);
}

.ai-chat-footer {
  flex-shrink: 0;
  padding: 0.75rem 1rem 0.65rem;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.ai-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin: 0;
}

.ai-chat-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--earth);
  background: #fafafa;
  min-height: 42px;
  max-height: 96px;
  line-height: 1.4;
}

.ai-chat-form textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: #fff;
}

.ai-chat-send {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  border: none;
  border-radius: 12px;
  background: var(--sage-dark);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.ai-chat-send:hover:not(:disabled) {
  background: var(--earth);
}

.ai-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ai-chat-disclaimer {
  margin: 0.45rem 0 0;
  font-size: 0.65rem;
  color: var(--sage-dark);
  text-align: center;
  opacity: 0.8;
}

@media (max-width: 480px) {
  .ai-chat-hint {
    max-width: 200px;
    font-size: 0.75rem;
    white-space: normal;
  }

  .ai-chat-panel {
    position: fixed;
    inset: calc(var(--safe-top) + 0.75rem) calc(0.75rem + var(--safe-right)) calc(0.75rem + var(--safe-bottom)) calc(0.75rem + var(--safe-left));
    width: auto;
    height: auto;
    bottom: auto;
    border-radius: 16px;
  }

  .ai-chat-suggestions {
    grid-template-columns: repeat(2, 1fr);
  }

  .ai-chat-form textarea {
    font-size: 16px;
  }

  .ai-chat-send {
    width: var(--touch-min);
    height: var(--touch-min);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
  }
}
