/* "Ask AI" buyer assistant panel (marketplace/agent.js, public/js/agent.js).
   Colours come from the site tokens in shadcn-common.css, so .dark works. */

/* Header button: same metrics as .nav-link (font-size/weight/colour come
   from the header rules); only the button chrome is reset here. */
/* Quiet on purpose (2026-11-11): a plain nav link like Services/Purchases.
   Only the small icon carries the accent; the header's loudest item must
   stay the shop's own main action, not the assistant. */
.agent-open-btn {
  position: relative;
  background: transparent;
  border: 0;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
  gap: 6px;
}
.agent-open-btn .agent-mark {
  width: auto;
  height: auto;
  flex: 0 0 auto;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: hsl(255, 70%, 60%);
}
.dark .agent-open-btn .agent-mark { color: hsl(255, 85%, 76%); }
.agent-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 7px;
  color: #fff;
  background: linear-gradient(135deg, hsl(258, 85%, 66%), hsl(222, 90%, 60%));
  box-shadow: 0 1px 2px rgba(80, 60, 200, 0.35);
}
/* Tooltip "Nezhna Assistant  Ctrl + I" (desktop only). */
@media (hover: hover) and (min-width: 992px) {
  .agent-open-btn[data-tip]:hover::before {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    white-space: pre;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 9px;
    border-radius: 6px;
    background: var(--foreground, #111);
    color: var(--background, #fff);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    pointer-events: none;
    z-index: 1200;
  }
}

.agent-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  height: 100vh;
  height: 100dvh; /* mobile: the composer stays above the browser bar */
  width: min(440px, 100vw);
  z-index: 1110; /* above the service-page chat FAB (1098) and drawer (1100) */
  display: flex;
  flex-direction: column;
  background: var(--card, #fff);
  color: var(--card-foreground, #111);
  border-left: 1px solid var(--border, #e5e7eb);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  visibility: hidden;
}
.agent-panel.is-open { transform: none; visibility: visible; }
.agent-panel.is-wide { width: min(760px, 100vw); }
@media (max-width: 575px) {
  .agent-panel, .agent-panel.is-wide { width: 100vw; border-left: 0; }
}

.agent-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--muted, #f4f4f5);
}
.agent-title { font-weight: 600; flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.agent-beta {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  background: hsla(255, 70%, 60%, 0.15);
  color: hsl(255, 60%, 55%);
}
.agent-icon-btn {
  background: none;
  border: 0;
  color: var(--muted-foreground, #666);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
}
.agent-icon-btn:hover { background: var(--accent, #eee); color: var(--foreground, #111); }

.agent-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agent-msg { max-width: 92%; line-height: 1.5; font-size: 14.5px; overflow-wrap: anywhere; }
.agent-turn--user { align-self: flex-end; max-width: 88%; display: flex; flex-direction: column; align-items: flex-end; }
.agent-msg--user {
  max-width: 100%;
  background: hsla(255, 75%, 62%, 0.1);
  color: var(--foreground, #111);
  padding: 9px 13px;
  border-radius: 12px;
  white-space: pre-wrap;
}
.agent-time { font-size: 11px; color: var(--muted-foreground, #888); margin-top: 4px; }
.agent-p { margin: 0 0 8px; }
.agent-p:last-child { margin-bottom: 0; }
.agent-list { margin: 0 0 8px; padding-left: 20px; }
.agent-list li { margin: 2px 0; }
.agent-code { font-size: 12.5px; padding: 1px 5px; border-radius: 4px; background: var(--muted, #f1f1f1); }
.agent-msg--assistant { align-self: stretch; max-width: 100%; }
.agent-msg--assistant a:not(.agent-btn) { color: hsl(255, 60%, 55%); }
.dark .agent-msg--assistant a:not(.agent-btn) { color: hsl(255, 85%, 78%); }
.agent-msg--error { color: var(--destructive, #d33); font-size: 13px; }
.agent-typing { display: flex; gap: 4px; padding: 6px 2px; }
.agent-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: hsl(255, 60%, 65%);
  animation: agent-dot 1.2s infinite ease-in-out;
}
.agent-typing span:nth-child(2) { animation-delay: 0.15s; }
.agent-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes agent-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .agent-typing span { animation: none; opacity: 0.6; } }

.agent-card {
  margin-top: 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--background, #fafafa);
  overflow: hidden;
}
.agent-card-title { font-weight: 600; font-size: 13px; padding: 10px 12px 0; }
.agent-row {
  padding: 10px 12px;
  border-top: 1px solid var(--border, #e5e7eb);
  font-size: 13px;
}
.agent-row:first-child, .agent-card-title + .agent-row { border-top: 0; }
.agent-row-top { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; }
.agent-row-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.agent-row-price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.agent-meta { color: var(--muted-foreground, #666); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.agent-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.agent-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #ddd);
  background: var(--card, #fff);
  color: var(--foreground, #111);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
/* Links styled as buttons: the panel lives inside pages whose own "a",
   "a:visited" and ".agent-msg--assistant a" rules would otherwise win and
   paint purple text on the black primary button. */
.agent-panel .agent-btn,
.agent-panel a.agent-btn:visited,
.agent-tip .agent-btn { color: var(--foreground, #111); text-decoration: none; }
.agent-btn:hover,
.agent-panel a.agent-btn:hover { background: var(--accent, #f1f1f1); color: var(--foreground, #111); text-decoration: none; }
.agent-btn--primary,
.agent-panel .agent-btn--primary,
.agent-panel a.agent-btn--primary:visited,
.agent-tip .agent-btn--primary { background: var(--primary, #000); color: var(--primary-foreground, #fff); border-color: var(--primary, #000); }
.agent-btn--primary:hover,
.agent-panel .agent-btn--primary:hover,
.agent-panel a.agent-btn--primary:hover { opacity: 0.88; background: var(--primary, #000); color: var(--primary-foreground, #fff); }
.agent-btn[disabled] { opacity: 0.45; cursor: default; }
.agent-btn--primary[disabled]:hover { opacity: 0.45; }
.agent-btn i { font-size: 12px; }
.agent-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--muted, #eee);
  color: var(--muted-foreground, #555);
  margin-left: 4px;
}
.agent-kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.agent-kv dt { color: var(--muted-foreground, #666); font-weight: 400; }
.agent-kv dd { margin: 0; overflow-wrap: anywhere; }
.agent-total { display: flex; justify-content: space-between; font-weight: 600; font-size: 15px; margin-top: 8px; }
.agent-note { font-size: 12px; color: var(--muted-foreground, #666); margin-top: 6px; }
/* Warnings are a callout, not tinted small print: readable in both themes. */
.agent-note--warn {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  color: hsl(26, 80%, 26%);
  background: hsla(38, 92%, 50%, 0.13);
  border: 1px solid hsla(38, 92%, 50%, 0.35);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 12.5px;
  line-height: 1.45;
}
.agent-note--warn::before { content: "!"; flex: 0 0 16px; height: 16px; border-radius: 50%; background: hsl(38, 92%, 50%); color: #fff; font-weight: 700; font-size: 11px; line-height: 16px; text-align: center; margin-top: 1px; }
.dark .agent-note--warn { color: hsl(40, 95%, 78%); background: hsla(38, 92%, 50%, 0.14); border-color: hsla(38, 92%, 50%, 0.3); }
/* Payment method names: tags, not buttons. */
.agent-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.agent-chips span { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--muted, #f1f1f1); color: var(--foreground, #111); }
.agent-support-text {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--input, #ddd);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  font-size: 13px;
  background: var(--card, #fff);
  color: var(--foreground, #111);
  resize: vertical;
}

.agent-empty { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.agent-disclaimer {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted-foreground, #555);
}
.agent-disclaimer strong { color: var(--foreground, #111); }
.agent-suggest {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 8px 4px;
  font: inherit;
  font-size: 14px;
  color: var(--foreground, #111);
  border-radius: 8px;
  cursor: pointer;
}
.agent-suggest:hover { background: var(--accent, #f1f1f1); }
.agent-suggest i { width: 18px; color: var(--muted-foreground, #666); text-align: center; }

.agent-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--card, #fff);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border, #e5e7eb);
}
.agent-input {
  flex: 1;
  resize: none;
  max-height: 140px;
  min-height: 42px;
  height: 42px;
  overflow-y: hidden; /* autosize() turns scrolling on past max-height */
  border: 1px solid var(--input, #ddd);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: 16px; /* no iOS zoom on focus */
  line-height: 22px;
  box-sizing: border-box;
  background: var(--card, #fff);
  color: var(--foreground, #111);
}
.agent-input::placeholder { color: var(--muted-foreground, #888); }
.agent-input:focus { outline: none; border-color: hsl(255, 75%, 62%); box-shadow: 0 0 0 3px hsla(255, 75%, 62%, 0.18); }
.agent-send { flex: 0 0 42px; width: 42px; height: 42px; padding: 0; border-radius: 10px; }
.agent-send i { font-size: 14px; }

/* Follow-up chips live in a tray between the conversation and the composer:
   always visible, never scrolled under the input. Wraps; capped height. */
.agent-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0;
  max-height: 84px;
  overflow-y: auto;
  background: var(--card, #fff);
  border-top: 1px solid var(--border, #e5e7eb);
}
.agent-tray[hidden] { display: none; }
.agent-tray:not([hidden]) + .agent-form { border-top: 0; }
.agent-tray .agent-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Keyboard focus, visible on every control in the panel. */
.agent-panel :is(.agent-btn, .agent-chip, .agent-suggest, .agent-icon-btn, a):focus-visible,
.agent-tip :is(.agent-btn, .agent-icon-btn):focus-visible {
  outline: 2px solid hsl(255, 75%, 62%);
  outline-offset: 2px;
}
.agent-field-input:focus, .agent-support-text:focus { outline: none; border-color: hsl(255, 75%, 62%); box-shadow: 0 0 0 3px hsla(255, 75%, 62%, 0.18); }

.agent-order-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.agent-field { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.agent-field-label { font-size: 12px; color: var(--muted-foreground, #666); }
.agent-field-input {
  border: 1px solid var(--input, #ddd);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 16px;
  background: var(--card, #fff);
  color: var(--foreground, #111);
  width: 100%;
}

.agent-qty-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -2px; }
.agent-chip {
  border: 1px solid var(--border, #ddd);
  background: var(--card, #fff);
  color: var(--foreground, #111);
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
}
.agent-chip:hover { background: var(--accent, #f1f1f1); border-color: hsla(255, 75%, 62%, 0.45); }
.agent-chip[disabled] { opacity: 0.5; cursor: default; }
.agent-estimate { font-size: 12.5px; color: var(--muted-foreground, #666); min-height: 1em; }
.agent-title .agent-mark { width: 24px; height: 24px; flex-basis: 24px; }

.agent-lead { font-size: 12px; font-weight: 600; color: var(--muted-foreground, #666); text-transform: uppercase; letter-spacing: 0.04em; }
.agent-followups { display: flex; flex-wrap: wrap; gap: 6px; }
.agent-progress { height: 5px; border-radius: 999px; background: var(--muted, #eee); overflow: hidden; margin-top: 7px; }
.agent-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, hsl(258, 85%, 66%), hsl(222, 90%, 60%)); transition: width 0.4s ease; }
.agent-row.is-ending .agent-row-price { color: hsl(25, 90%, 45%); font-weight: 600; }
.agent-hint-btn { margin-left: 8px; }
.agent-tip {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1105;
  width: min(340px, calc(100vw - 32px));
  background: var(--card, #fff);
  color: var(--card-foreground, #111);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  padding: 12px 12px 12px 14px;
  animation: agent-tip-in 0.25s ease;
}
@keyframes agent-tip-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .agent-tip { animation: none; } }
.agent-tip-head { display: flex; align-items: center; gap: 8px; }
.agent-tip-head strong { flex: 1; font-size: 14px; }
.agent-tip-close { width: 28px; height: 28px; }
.agent-tip-text { font-size: 13px; color: var(--muted-foreground, #555); margin: 6px 0 2px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: hsla(255, 75%, 62%, 0.08); border-radius: 6px; padding: 6px 8px; }
.agent-tip-keys { font-size: 12px; color: var(--muted-foreground, #777); align-self: center; }
