/* ===========================================================================
   AI Consultant PRO - the chat panel on the storefront.
   Author: mstkalenko, https://ocmod.net
   ---------------------------------------------------------------------------
   Layout only: colours, corners and the spacing step are the variables of
   ocmod-ui-1.1 (matched to the theme by ocmod-ui-theme.css). Every selector
   starts with .ocmod-ai; buttons and fields carry the theme's Bootstrap
   classes in the markup. No shadows, gradients or translucency.
   =========================================================================== */

/* ---------- launcher ------------------------------------------------------ */
.ocmod-ai__launcher {
  position: fixed;
  z-index: 999;
  bottom: var(--ocmod-ai-offset, 20px);
  right: var(--ocmod-ai-offset, 20px);
  gap: 8px;
  border-radius: 999px;
}
.ocmod-ai--left .ocmod-ai__launcher { right: auto; left: var(--ocmod-ai-offset, 20px); }
.ocmod-ai__launcher .ocm-icon { width: 22px; height: 22px; }
.ocmod-ai--open .ocmod-ai__launcher { display: none; }
/* on the right the launcher stands in the shared corner of ocmod-ui (ocm-dock) with the floating buttons of other modules */
.ocm-dock .ocmod-ai__launcher { position: static; }

.ocmod-ai__hint {
  position: fixed;
  z-index: 999;
  bottom: calc(var(--ocmod-ai-offset, 20px) + 56px);
  right: var(--ocmod-ai-offset, 20px);
  max-width: min(280px, calc(100vw - 32px));
  padding: 10px 36px 10px 14px;
  border: 1px solid var(--ocm-line-strong);
  border-radius: var(--ocm-r);
  background: var(--ocm-surface);
  color: var(--ocm-ink);
}
.ocmod-ai--left .ocmod-ai__hint { right: auto; left: var(--ocmod-ai-offset, 20px); }
.ocmod-ai__hint[hidden] { display: none; }
.ocmod-ai__hint .ocm-close { top: 6px; margin-top: 0; width: 24px; height: 24px; line-height: 24px; font-size: 18px; }
.ocmod-ai__hint-text { margin: 0; cursor: pointer; }

/* ---------- panel --------------------------------------------------------- */
.ocmod-ai__panel {
  position: fixed;
  z-index: 1001;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: 100vw;
  border-left: 1px solid var(--ocm-line-strong);
  background: var(--ocm-surface);
}
.ocmod-ai--left .ocmod-ai__panel { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--ocm-line-strong); }
.ocmod-ai__panel[hidden] { display: none; }

.ocmod-ai__head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px var(--ocm-gap);
  border-bottom: 1px solid var(--ocm-line);
}
.ocmod-ai__title {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  color: var(--ocm-ink);
  font-size: 1.07em;
  font-weight: 700;
  line-height: 1.3;
}
.ocmod-ai__title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ocmod-ai__tool {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--ocm-r-sm);
  background: none;
  color: var(--ocm-muted);
  cursor: pointer;
}
.ocmod-ai__tool:hover, .ocmod-ai__tool:focus-visible { background: var(--ocm-subtle); color: var(--ocm-ink); }
.ocmod-ai__tool[hidden] { display: none; }

.ocmod-ai__body {
  position: relative;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--ocm-gap);
}
.ocmod-ai__foot {
  flex: 0 0 auto;
  padding: 8px var(--ocm-gap) var(--ocm-gap);
  border-top: 1px solid var(--ocm-line);
}
.ocmod-ai__form { display: flex; align-items: flex-end; gap: 8px; }
.ocmod-ai__input { flex: 1 1 auto; min-height: 40px; max-height: 120px; resize: none; }
.ocmod-ai__send { flex: 0 0 auto; padding-left: 12px; padding-right: 12px; }
.ocmod-ai__foot-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 8px; margin-top: 6px; color: var(--ocm-muted); font-size: var(--ocm-fs-sm); }
.ocmod-ai__link { padding: 0; border: 0; background: none; color: var(--ocm-accent-dark); font: inherit; text-decoration: underline; cursor: pointer; }

.ocmod-ai__down {
  position: sticky;
  bottom: 0;
  left: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0 0 0 auto;
  padding: 0;
  border: 1px solid var(--ocm-line-strong);
  border-radius: 50%;
  background: var(--ocm-surface);
  color: var(--ocm-ink);
  cursor: pointer;
}
.ocmod-ai__down[hidden] { display: none; }

/* ---------- messages ------------------------------------------------------ */
.ocmod-ai__msg { margin: 0 0 var(--ocm-gap); }
.ocmod-ai__msg--user { display: flex; justify-content: flex-end; }
.ocmod-ai__bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: var(--ocm-r);
  background: var(--ocm-accent-tint);
  color: var(--ocm-ink);
  overflow-wrap: anywhere;
}
.ocmod-ai__text { color: var(--ocm-text); overflow-wrap: anywhere; }
.ocmod-ai__text p { margin: 0 0 8px; }
.ocmod-ai__text ul, .ocmod-ai__text ol { margin: 0 0 8px; padding-left: 20px; }
.ocmod-ai__text > :last-child { margin-bottom: 0; }
.ocmod-ai__text a { color: var(--ocm-accent-dark); }
.ocmod-ai__status { display: flex; align-items: center; gap: 8px; color: var(--ocm-muted); }
.ocmod-ai__spin { animation: ocmod-ai-spin 1s linear infinite; }
@keyframes ocmod-ai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ocmod-ai__spin { animation: none; } }
.ocmod-ai__error { margin: 8px 0 0; color: var(--ocm-bad); }
.ocmod-ai__blocks > * { margin-top: 8px; }

.ocmod-ai__rate { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin-top: 6px; color: var(--ocm-muted); font-size: var(--ocm-fs-sm); }
.ocmod-ai__rate .ocmod-ai__tool { width: 28px; height: 28px; }
.ocmod-ai__rate .ocmod-ai__tool.is-on { color: var(--ocm-accent-dark); background: var(--ocm-accent-tint); }
.ocmod-ai__thumb-down .ocm-icon { transform: rotate(180deg); }
.ocmod-ai__rate-note { margin-left: auto; }
.ocmod-ai__reasons { margin-top: 8px; }
.ocmod-ai__reasons .ocm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ocmod-ai__reason { cursor: pointer; }
.ocmod-ai__reason.is-on { border-color: var(--ocm-accent); background: var(--ocm-accent-tint); color: var(--ocm-accent-dark); }

/* ---------- buttons of scenarios, choices and follow-ups ----------------- */
.ocmod-ai__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ocmod-ai__chips .ocm-btn { white-space: normal; text-align: left; }
.ocmod-ai__question { margin: 0 0 6px; color: var(--ocm-ink); font-weight: 600; }
.ocmod-ai__more[hidden] { display: none; }

/* ---------- product cards ------------------------------------------------- */
.ocmod-ai__cards { display: grid; gap: 8px; }
.ocmod-ai__card {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 4px 10px;
  padding: 8px;
  border: 1px solid var(--ocm-line);
  border-radius: var(--ocm-r);
  background: var(--ocm-surface);
}
.ocmod-ai__card--gone { grid-template-columns: minmax(0, 1fr); color: var(--ocm-muted); }
.ocmod-ai__thumb { grid-row: span 3; display: block; width: 72px; height: 72px; }
.ocmod-ai__thumb img { display: block; width: 72px; height: 72px; object-fit: contain; }
.ocmod-ai__name { padding-right: 28px; color: var(--ocm-ink); font-weight: 600; line-height: 1.3; text-decoration: none; overflow-wrap: anywhere; }
.ocmod-ai__name:hover { color: var(--ocm-accent-dark); text-decoration: underline; }
.ocmod-ai__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: var(--ocm-fs-sm); }
.ocmod-ai__reason-line { grid-column: 1 / -1; margin: 0; color: var(--ocm-text); font-size: var(--ocm-fs-sm); }
.ocmod-ai__card .ocm-actions { grid-column: 1 / -1; }
.ocmod-ai__menu { position: absolute; top: 4px; right: 4px; }
.ocmod-ai__menu > summary { list-style: none; }
.ocmod-ai__menu > summary::-webkit-details-marker { display: none; }
.ocmod-ai__menu-list {
  position: absolute;
  z-index: 2;
  top: 34px;
  right: 0;
  min-width: 200px;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--ocm-line-strong);
  border-radius: var(--ocm-r);
  background: var(--ocm-surface);
}
.ocmod-ai__menu-list button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--ocm-r-sm);
  background: none;
  color: var(--ocm-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ocmod-ai__menu-list button:hover, .ocmod-ai__menu-list button:focus-visible { background: var(--ocm-subtle); }

/* ---------- comparison: the first column stays while the table scrolls --- */
.ocmod-ai__compare { margin-bottom: 0; }
.ocmod-ai__compare table { min-width: 100%; }
.ocmod-ai__compare th, .ocmod-ai__compare td { min-width: 112px; max-width: 160px; font-size: var(--ocm-fs-sm); vertical-align: top; white-space: normal; overflow-wrap: anywhere; }
.ocmod-ai__compare th:first-child, .ocmod-ai__compare td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 104px;
  max-width: 120px;
  overflow-wrap: normal;
  border-right: 1px solid var(--ocm-line);
  background: var(--ocm-subtle);
  color: var(--ocm-muted);
}
.ocmod-ai__compare tr.is-diff td:not(:first-child) { color: var(--ocm-ink); font-weight: 600; }
.ocmod-ai__compare th { text-transform: none; letter-spacing: 0; color: var(--ocm-ink); }
.ocmod-ai__compare th a { display: block; color: var(--ocm-ink); text-decoration: none; overflow: visible; white-space: normal; text-overflow: clip; }
.ocmod-ai__compare-hint { margin: 0 0 6px; color: var(--ocm-muted); font-size: var(--ocm-fs-sm); text-align: right; }
.ocmod-ai__compare-hint[hidden] { display: none; }

/* ---------- a screen over the chat: history, report, contact -------------- */
.ocmod-ai__screen { padding: var(--ocm-gap); }
.ocmod-ai__screen[hidden], .ocmod-ai__list[hidden] { display: none; }
.ocmod-ai__back-icon { transform: rotate(90deg); }
.ocmod-ai__form-box { margin: 0; }
.ocmod-ai__form-box .ocm-input { margin-top: 8px; }
.ocmod-ai__reasons .ocmod-ai__form-box .ocm-chips { margin: 8px 0 0; }

/* ---------- the product of the page changed ------------------------------ */
.ocmod-ai__divider { display: flex; align-items: center; gap: 8px; margin: var(--ocm-gap) 0; color: var(--ocm-muted); font-size: var(--ocm-fs-sm); }
.ocmod-ai__divider::before, .ocmod-ai__divider::after { content: ""; flex: 1 1 auto; border-top: 1px solid var(--ocm-line); }
.ocmod-ai__compare th img { display: block; width: 56px; height: 56px; margin-bottom: 4px; object-fit: contain; }

/* ---------- a person in the chat ----------------------------------------- */
.ocmod-ai__msg--operator { padding: 8px 12px; border: 1px solid var(--ocm-good-tint); border-radius: var(--ocm-r); background: var(--ocm-surface); }
.ocmod-ai__who { margin: 0 0 4px; color: var(--ocm-good); font-size: var(--ocm-fs-sm); font-weight: 700; }
.ocmod-ai__notice { margin: 0 0 var(--ocm-gap); color: var(--ocm-muted); font-size: var(--ocm-fs-sm); text-align: center; }
.ocmod-ai__manager { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ocmod-ai--manager .ocmod-ai__beta { display: none; }
.ocmod-ai__manager[hidden] { display: none; }

/* ---------- start of a chat and history ---------------------------------- */
.ocmod-ai__hello { margin: 0 0 8px; color: var(--ocm-ink); font-size: var(--ocm-fs-title); font-weight: 700; }
.ocmod-ai__history { margin: 0; padding: 0; list-style: none; }
.ocmod-ai__history li { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--ocm-line); }
.ocmod-ai__history-open {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 4px;
  border: 0;
  background: none;
  color: var(--ocm-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ocmod-ai__history-open:hover .ocmod-ai__history-title { color: var(--ocm-accent-dark); }
.ocmod-ai__history-title { display: block; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ocmod-ai__history-date { display: block; color: var(--ocm-muted); font-size: var(--ocm-fs-sm); }
.ocmod-ai__contacts { margin: 10px 0 0; padding: 0; list-style: none; }
.ocmod-ai__contacts li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.ocmod-ai__contacts li + li { margin-top: 6px; }
.ocmod-ai__contact-name { flex: 0 0 76px; color: var(--ocm-muted); font-size: var(--ocm-fs-sm); }
.ocmod-ai__contact-value { color: var(--ocm-ink); }

/* ---------- blocks on the page: product page, reviews, empty search ----- */
.ocmod-ai-product { margin: var(--ocm-gap) 0; }
.ocmod-ai-product .ocm-actions { margin-top: 8px; }
.ocmod-ai-reviews { margin: 0 0 var(--ocm-gap); }
.ocmod-ai-search { margin: 0 0 calc(var(--ocm-gap) * 2); }
.ocmod-ai-product[hidden], .ocmod-ai-reviews[hidden], .ocmod-ai-search[hidden] { display: none; }

/* ---------- rhythm of the panel ------------------------------------------
   One spacing step (--ocm-gap) between the parts of a message, half a step
   inside a block, a step and a half between messages. Only the module's own
   containers get margins here; the library's classes stay as they are. */
.ocmod-ai__panel .ocmod-ai__msg { margin-bottom: calc(var(--ocm-gap) * 1.5); }
.ocmod-ai__msg > .ocmod-ai__cards,
.ocmod-ai__msg > .ocmod-ai__chips,
.ocmod-ai__msg > .ocm-note,
.ocmod-ai__blocks > * { margin-top: var(--ocm-gap); }
.ocmod-ai__msg > .ocm-note:first-child { margin-top: 0; }
/* a note inside the panel sits in the message flow: no margin of its own below */
.ocmod-ai__panel .ocm-note { margin-bottom: 0; }
.ocmod-ai__hello + .ocmod-ai__text { margin-top: 0; }

/* buttons of scenarios: a real gap between rows and columns */
.ocmod-ai__panel .ocmod-ai__chips { gap: 8px; }
.ocmod-ai__panel .ocmod-ai__chips .ocm-btn { margin: 0; }

/* a product card: room inside and between the facts and the buttons */
.ocmod-ai__panel .ocmod-ai__card { gap: 6px 12px; padding: var(--ocm-gap); }
.ocmod-ai__panel .ocmod-ai__card .ocm-actions { margin-top: 6px; }
.ocmod-ai__panel .ocmod-ai__card .ocm-btn { margin: 0; }
.ocmod-ai__panel .ocmod-ai__menu { top: 6px; right: 6px; }
.ocmod-ai__panel .ocmod-ai__meta .ocm-price { margin: 0; }

/* title, text, field and buttons of a note and of the small forms */
.ocmod-ai__panel .ocm-note__title + .ocm-note__text { margin-top: 4px; }
.ocmod-ai__panel .ocm-note__title + .ocm-actions,
.ocmod-ai__panel .ocm-note__text + .ocm-actions,
.ocmod-ai__panel .ocm-input + .ocm-actions { margin-top: var(--ocm-gap); }
.ocmod-ai__panel .ocmod-ai__form-box .ocm-input { margin-top: var(--ocm-gap); }
.ocmod-ai__panel .ocm-note .ocm-btn { margin: 0; }
/* the shop's contacts under the "leave a contact" button: a thin line apart */
.ocmod-ai__panel .ocm-actions + .ocmod-ai__contacts {
  margin-top: var(--ocm-gap);
  padding-top: var(--ocm-gap);
  border-top: 1px solid var(--ocm-line);
}
.ocmod-ai__panel .ocm-note__title + .ocmod-ai__contacts { margin-top: var(--ocm-gap); }
.ocmod-ai__panel .ocmod-ai__contacts li + li { margin-top: 8px; }

/* rating row and follow-up buttons under an answer */
.ocmod-ai__panel .ocmod-ai__rate { margin-top: 8px; }
.ocmod-ai__panel .ocmod-ai__question { margin-bottom: 8px; }

/* ---------- phones: the panel takes the whole screen --------------------- */
@media (max-width: 767px) {
  .ocmod-ai__panel { left: 0; width: 100%; height: var(--ocmod-ai-vh, 100%); bottom: auto; border: 0; }
  .ocmod-ai__launcher-text { display: none; }
  .ocmod-ai__launcher { width: 52px; height: 52px; padding: 0; }
  .ocmod-ai__hint { bottom: calc(var(--ocmod-ai-offset, 20px) + 60px); }
  .ocmod-ai__input { font-size: 16px; }
}
.ocmod-ai-lock, .ocmod-ai-lock body { overflow: hidden; }
