/**
 * RKR AI Shop Advisor - front office.
 *
 * @author    Rekire
 * @copyright 2026 Rekire
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 */

/* ---------- Search drop-down ---------- */
.rkraia-dd {
  position: fixed; z-index: 99980;
  background: #fff; color: #222; border: 1px solid #e3e3e3; border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14); max-height: 70vh; overflow-y: auto; min-width: 280px;
  font-size: 14px; line-height: 1.35; text-align: left;
}
.rkraia-dd[hidden] { display: none; }
.rkraia-has-dd .js-search-dropdown, .rkraia-has-dd .ps-searchbar__dropdown { display: none !important; }
.rkraia-dd__list { list-style: none; margin: 0; padding: 4px 0; }
.rkraia-dd__item {
  display: grid; grid-template-columns: 48px 1fr auto; grid-template-rows: auto auto; column-gap: 10px;
  align-items: center; padding: 6px 12px; color: inherit; text-decoration: none;
}
.rkraia-dd__item:hover, .rkraia-dd__item.is-active { background: #f5f5f5; text-decoration: none; color: inherit; }
.rkraia-dd__item img, .rkraia-dd__noimg { grid-row: 1 / span 2; width: 48px; height: 48px; object-fit: contain; border-radius: 4px; background: #f7f7f7; }
.rkraia-dd__name { grid-column: 2; font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rkraia-dd__ref { grid-column: 2; font-size: 12px; color: #777; }
.rkraia-dd__price { grid-column: 3; grid-row: 1 / span 2; font-weight: 700; white-space: nowrap; }
.rkraia-dd mark { background: transparent; color: inherit; font-weight: 800; padding: 0; text-decoration: underline; text-decoration-thickness: 2px; }
.rkraia-dd__note, .rkraia-dd__empty { margin: 0; padding: 8px 12px; color: #555; font-size: 13px; }
.rkraia-dd__all { display: block; padding: 10px 12px; border-top: 1px solid #eee; font-weight: 600; }
.rkraia-dd__ask {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border: 0; border-top: 1px solid #eee;
  background: #fafafa; color: #222; font: inherit; font-weight: 600; text-align: left; cursor: pointer;
}
.rkraia-dd__ask:hover { background: #f0f0f0; }
.rkraia-dd__ask svg { flex: none; }

/* ---------- Button next to the search box ---------- */
.rkraia-search-host { position: relative; }
.rkraia-search-btn {
  position: absolute; top: 50%; right: 40px; transform: translateY(-50%); z-index: 3;
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%; background: var(--rkraia-accent, #222); color: #fff; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.rkraia-search-btn:hover, .rkraia-search-btn:focus-visible { filter: brightness(1.15); outline: none; }
/* Inside the window of RKR Free Visual Search, left of its clear button and ESC hint. */
.rkfvs-search-box .rkraia-search-btn { right: 92px; }
.rkfvs-search-box.rkraia-search-host .rkfvs-search-box__input { padding-right: 128px; }
@media (max-width: 767px) {
  .rkfvs-search-box .rkraia-search-btn { right: 46px; }
  .rkfvs-search-box.rkraia-search-host .rkfvs-search-box__input { padding-right: 84px; }
}

/* ---------- Blocks (product, cart) ---------- */
.rkraia-block { margin: 16px 0; padding: 12px 14px; border: 1px solid #e6e6e6; border-radius: 10px; background: #fafafa; }
.rkraia-block[hidden] { display: none !important; }
.rkraia-block__title { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-weight: 700; color: #222; }
.rkraia-block__icon {
  width: 18px; height: 18px; flex: none; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l1.9 5.6L19.5 9.5l-5.6 1.9L12 17l-1.9-5.6L4.5 9.5l5.6-1.9L12 2z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l1.9 5.6L19.5 9.5l-5.6 1.9L12 17l-1.9-5.6L4.5 9.5l5.6-1.9L12 2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.rkraia-block__chips, .rkraia-panel__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rkraia-chip {
  padding: 6px 12px; border: 1px solid #d5d5d5; border-radius: 999px; background: #fff; color: #222;
  font: inherit; font-size: 13px; line-height: 1.3; cursor: pointer; text-align: left;
}
.rkraia-chip:hover, .rkraia-chip:focus-visible { border-color: #222; outline: none; }
.rkraia-chip--open { background: #222; color: #fff; border-color: #222; }

/* ---------- Floating widget ---------- */
.rkraia { --rkraia-accent: #222; position: fixed; bottom: 20px; z-index: 99990; font-size: 14px; line-height: 1.45; color: #222; }
.rkraia--right { right: 20px; }
.rkraia--left { left: 20px; }
.rkraia *, .rkraia *::before, .rkraia *::after { box-sizing: border-box; }
.rkraia-launcher {
  display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 18px; border: 0; border-radius: 999px;
  background: var(--rkraia-accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22); transition: transform .15s ease;
}
.rkraia-launcher:hover { transform: translateY(-2px); }
.rkraia-launcher:focus-visible { outline: 3px solid rgba(0, 0, 0, .25); outline-offset: 2px; }
.rkraia.is-open .rkraia-launcher { display: none; }

.rkraia-bubble {
  position: absolute; bottom: 60px; width: 260px; padding: 12px 34px 12px 14px; border-radius: 12px; background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18); animation: rkraia-in .2s ease-out;
}
.rkraia--right .rkraia-bubble { right: 0; }
.rkraia--left .rkraia-bubble { left: 0; }
.rkraia-bubble[hidden] { display: none; }
.rkraia-bubble__text { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.rkraia-bubble__close { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 20px; line-height: 1; color: #777; cursor: pointer; }

.rkraia-panel {
  position: absolute; bottom: 0; width: 380px; height: min(600px, calc(100vh - 40px)); display: flex; flex-direction: column;
  background: #fff; border-radius: 14px; box-shadow: 0 16px 48px rgba(0, 0, 0, .25); overflow: hidden; animation: rkraia-in .18s ease-out;
}
.rkraia--right .rkraia-panel { right: 0; }
.rkraia--left .rkraia-panel { left: 0; }
.rkraia-panel[hidden] { display: none; }
.rkraia-panel__head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: var(--rkraia-accent); color: #fff; }
.rkraia-panel__avatar { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 50%; background: rgba(255, 255, 255, .18); }
.rkraia-panel__name { flex: 1; font-size: 15px; }
.rkraia-panel__btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: transparent; color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
}
.rkraia-panel__btn:hover, .rkraia-panel__btn:focus-visible { background: rgba(255, 255, 255, .18); outline: none; }
.rkraia-panel__list { flex: 1; overflow-y: auto; padding: 14px; background: #f7f7f8; overscroll-behavior: contain; }
.rkraia-panel__chips { padding: 8px 12px 0; background: #fff; }
.rkraia-panel__chips:empty { display: none; }
.rkraia-panel__form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid #eee; }
.rkraia-panel__form textarea {
  flex: 1; min-height: 40px; max-height: 120px; padding: 9px 12px; border: 1px solid #d9d9d9; border-radius: 20px; resize: none;
  font: inherit; color: #222; background: #fff;
}
.rkraia-panel__form textarea:focus { border-color: var(--rkraia-accent); outline: none; }
.rkraia-panel__send {
  display: inline-flex; flex: none; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--rkraia-accent); color: #fff; cursor: pointer;
}
.rkraia-panel__notice { margin: 0; padding: 0 12px 8px; background: #fff; font-size: 11px; color: #888; }
.rkraia-panel__off { margin: 0; padding: 12px; border-top: 1px solid #eee; background: #fafafa; font-size: 13px; color: #555; }

.rkraia-msg { display: flex; flex-direction: column; margin-bottom: 10px; }
.rkraia-msg__text { max-width: 88%; padding: 9px 12px; border-radius: 14px; word-wrap: break-word; overflow-wrap: anywhere; }
.rkraia-msg__text p, .rkraia-msg__text li { margin: 0 0 6px; color: inherit; font-size: inherit; line-height: inherit; }
.rkraia-msg__text p:last-child { margin-bottom: 0; }
.rkraia-msg__text ul { margin: 4px 0 6px; padding-left: 18px; }
.rkraia-msg__text a { text-decoration: underline; }
.rkraia-msg--assistant .rkraia-msg__text { color: #222; align-self: flex-start; background: #fff; border: 1px solid #ececec; border-bottom-left-radius: 4px; }
.rkraia-msg--user .rkraia-msg__text { align-self: flex-end; background: var(--rkraia-accent); color: #fff; border-bottom-right-radius: 4px; }
.rkraia-msg.is-waiting .rkraia-msg__text { color: #888; font-style: italic; animation: rkraia-pulse 1.2s ease-in-out infinite; }

.rkraia-cards { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.rkraia-card {
  flex: 0 0 150px; display: flex; flex-direction: column; padding: 8px; border: 1px solid #ececec; border-radius: 10px; background: #fff;
  scroll-snap-align: start;
}
.rkraia-card__img { display: block; aspect-ratio: 1 / 1; margin-bottom: 6px; border-radius: 6px; background: #f6f6f6; overflow: hidden; }
.rkraia-card__img img { width: 100%; height: 100%; object-fit: contain; }
.rkraia-card__name {
  color: #222; font-size: 13px; font-weight: 600; line-height: 1.3; text-decoration: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 34px;
}
.rkraia-card__price { margin: 4px 0 8px; font-weight: 700; }
.rkraia-card__price s { color: #999; font-weight: 400; font-size: 12px; }
.rkraia-card__add {
  margin-top: auto; padding: 7px 8px; border: 0; border-radius: 8px; background: var(--rkraia-accent); color: #fff;
  font: inherit; font-size: 12px; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer;
}
.rkraia-card__add:hover { color: #fff; text-decoration: none; filter: brightness(1.15); }
.rkraia-card__add--link { background: #fff; color: #222; border: 1px solid #d5d5d5; }
.rkraia-card__add--link:hover { color: #222; }
.rkraia-card__add.is-done { background: #2e7d32; }

@keyframes rkraia-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rkraia-pulse { 50% { opacity: .45; } }

@media (max-width: 575px) {
  .rkraia { bottom: 14px; }
  .rkraia--right { right: 14px; }
  .rkraia--left { left: 14px; }
  .rkraia-launcher { width: 52px; height: 52px; padding: 0; justify-content: center; }
  .rkraia-launcher__label { display: none; }
  .rkraia.is-open { inset: 0; bottom: 0; }
  .rkraia-panel { position: fixed; inset: 0; width: auto; height: 100%; border-radius: 0; }
  .rkraia-panel__form textarea { font-size: 16px; }
  .rkraia-search-btn { right: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .rkraia-panel, .rkraia-bubble, .rkraia-launcher { animation: none; transition: none; }
}
