/* Conseil produit (js/advisor.js). Uses the tokens from style.css; logical
   properties throughout so the Arabic page mirrors without overrides. */

.hagbot {
  position: fixed;
  inset-block-end: 24px;
  inset-inline-end: 24px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: var(--font-body);
}

.hagbot-launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 12px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font: 600 15px/1 var(--font-body);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(30, 27, 22, 0.18);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.hagbot-launcher:hover { background: var(--accent-light); transform: translateY(-1px); }
.hagbot-launcher:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.hagbot-launcher svg { width: 22px; height: 22px; flex: none; }
.hagbot.is-open .hagbot-launcher-label { display: none; }
.hagbot.is-open .hagbot-launcher { padding: 12px; }

.hagbot-panel {
  width: 380px;
  height: min(600px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(30, 27, 22, 0.22);
  overflow: hidden;
  animation: hagbot-in 0.25s ease both;
}

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

@keyframes hagbot-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.hagbot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #EAE0D2;
  border-block-end: 1px solid var(--border);
}

.hagbot-title {
  font: 600 19px/1.2 var(--font-display);
  color: var(--accent);
}

.hagbot-subtitle {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-block-start: 2px;
}

.hagbot-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
}

.hagbot-close:hover { background: rgba(123, 98, 70, 0.12); color: var(--ink); }
.hagbot-close svg { width: 20px; height: 20px; }

.hagbot-log {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.hagbot-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  animation: hagbot-msg 0.25s ease both;
}

@keyframes hagbot-msg {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.hagbot-msg--bot {
  align-self: flex-start;
  background: #EAE0D2;
  color: var(--ink);
  border-end-start-radius: 4px;
}

.hagbot-msg--user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--bg);
  border-end-end-radius: 4px;
}

.hagbot-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 14px 16px;
  background: #EAE0D2;
  border-radius: 14px;
  border-end-start-radius: 4px;
}

.hagbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-dim);
  animation: hagbot-dot 1s ease-in-out infinite;
}

.hagbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.hagbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes hagbot-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.hagbot-note {
  align-self: flex-start;
  max-width: 85%;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-dim);
  padding-inline-start: 12px;
  border-inline-start: 2px solid var(--border);
}

.hagbot-product {
  align-self: stretch;
  display: flex;
  gap: 14px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  animation: hagbot-msg 0.25s ease both;
  transition: border-color 0.2s ease;
}

.hagbot-product:hover { border-color: var(--accent); }
.hagbot-product:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hagbot-product-img {
  flex: none;
  width: 72px;
  aspect-ratio: 5 / 6;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
}

.hagbot-product-img img { width: 100%; height: 100%; object-fit: cover; }

.hagbot-product-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hagbot-product-name { font: 600 17px/1.2 var(--font-display); color: var(--accent); }
.hagbot-product-desc { font-size: 13px; line-height: 1.4; color: var(--ink-dim); }
.hagbot-product-link { margin-block-start: auto; font-size: 13px; font-weight: 700; color: var(--accent); }

.hagbot-actions {
  padding: 14px 20px 6px;
  border-block-start: 1px solid var(--border);
  max-height: 46%;
  overflow-y: auto;
}

.hagbot-actions:empty { display: none; }

.hagbot-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hagbot-choice {
  padding: 9px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: 500 14px/1.25 var(--font-body);
  text-align: start;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.hagbot-choice:hover { background: var(--accent); color: var(--bg); }
.hagbot-choice:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.hagbot-choice--call { background: var(--accent); color: var(--bg); }
.hagbot-choice--call:hover { background: var(--accent-light); }

.hagbot-search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: 400 15px/1.3 var(--font-body);
}

.hagbot-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.hagbot-picklist { list-style: none; margin-block-start: 8px; }

.hagbot-pick {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 4px;
  border-block-end: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}

.hagbot-pick:hover .hagbot-pick-name { text-decoration: underline; }
.hagbot-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hagbot-pick-name { font: 600 15px/1.3 var(--font-display); color: var(--accent); }
.hagbot-pick-desc {
  font-size: 12px;
  color: var(--ink-dim);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hagbot-actions > .hagbot-note { margin-block-start: 10px; }

.hagbot-foot {
  display: flex;
  justify-content: space-between;
  padding: 6px 20px 12px;
}

.hagbot-link {
  border: 0;
  background: none;
  padding: 6px 0;
  font: 500 13px/1 var(--font-body);
  color: var(--ink-dim);
  cursor: pointer;
}

.hagbot-link:last-child { margin-inline-start: auto; }
.hagbot-link:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 600px) {
  .hagbot { inset-block-end: 16px; inset-inline-end: 16px; }
  .hagbot-panel {
    position: fixed;
    inset-inline: 16px;
    inset-block-end: 84px;
    width: auto;
    height: min(560px, calc(100dvh - 110px));
  }
}

/* Reduce, never freeze: movement goes, the fades and the typing pulse stay. */
@media (prefers-reduced-motion: reduce) {
  .hagbot-panel, .hagbot-msg, .hagbot-product { animation-name: hagbot-fade; }
  .hagbot-typing span { animation-name: hagbot-pulse; }
  .hagbot-launcher:hover { transform: none; }
  .hagbot-log { scroll-behavior: auto; }
}

@keyframes hagbot-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes hagbot-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
