/* Assistant IA — widget flottant Yombal Marché */

.assistant-fab {
  position: fixed;
  right: clamp(16px, 3vw, 24px);
  bottom: clamp(16px, 3vw, 24px);
  z-index: 10000;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: linear-gradient(145deg, var(--green2), var(--green));
  color: #fff;
  box-shadow: 0 12px 36px rgba(26, 61, 43, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s ease;
}
.assistant-fab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 16px 44px rgba(26, 61, 43, 0.34);
}
.assistant-fab:focus-visible {
  outline: 3px solid var(--gold2);
  outline-offset: 3px;
}
.assistant-fab[aria-expanded="true"] {
  background: var(--terra);
}
.assistant-fab-icon {
  font-size: 26px;
  line-height: 1;
}

.assistant-panel {
  position: fixed;
  right: clamp(12px, 3vw, 24px);
  bottom: calc(clamp(16px, 3vw, 24px) + 68px);
  z-index: 10000;
  width: min(400px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.28s var(--ease-out), transform 0.28s var(--ease-out), visibility 0.28s;
}
.assistant-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--green), var(--green2));
  color: #fff;
}
.assistant-header-text h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}
.assistant-header-text p {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.88;
}
.assistant-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.assistant-close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.assistant-messages {
  flex: 1 1 auto;
  min-height: 200px;
  max-height: 360px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(180deg, #fffdfa 0%, var(--surface-muted) 100%);
}
.assistant-msg {
  max-width: 92%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.assistant-msg--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.assistant-msg--user {
  align-self: flex-end;
  background: var(--green);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.assistant-msg--loading {
  opacity: 0.7;
  font-style: italic;
}
.assistant-sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
  font-size: 12px;
}
.assistant-sources strong {
  display: block;
  margin-bottom: 6px;
  color: var(--green);
}
.assistant-sources a {
  display: inline-block;
  margin: 0 8px 6px 0;
  color: var(--terra);
  text-decoration: none;
  font-weight: 600;
}
.assistant-sources a:hover {
  text-decoration: underline;
}

.assistant-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-soft);
  background: #fff;
}
.assistant-input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: 14px;
  background: var(--surface);
}
.assistant-input:focus {
  outline: none;
  border-color: var(--green3);
  box-shadow: 0 0 0 3px rgba(61, 122, 85, 0.15);
}
.assistant-send {
  flex-shrink: 0;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--terra);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.assistant-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.assistant-send:not(:disabled):hover {
  background: var(--terra2);
}

body.cookie-banner-visible .assistant-fab,
body.cookie-banner-visible .assistant-panel {
  bottom: calc(clamp(16px, 3vw, 24px) + 88px);
}
body.cookie-banner-visible .assistant-panel {
  bottom: calc(clamp(16px, 3vw, 24px) + 156px);
}

@media (max-width: 520px) {
  .assistant-panel {
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100vh - 100px);
  }
  .assistant-messages {
    max-height: calc(100vh - 260px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-fab,
  .assistant-panel {
    transition: none;
  }
}
