/* RobimyWeb · asystent AI (czat na każdej stronie). Tokeny z style.css */

/* ---------- Przycisk „Zapytaj AI” ---------- */
.rwc-launch {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 61;
  display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 20px 0 16px; border-radius: 999px;
  background: var(--surface); color: var(--ink); font-size: 14.5px; font-weight: 500; letter-spacing: -.01em;
  box-shadow: inset 0 0 0 1px var(--line-2), 0 18px 40px -18px rgba(28,44,92,.45);
  transition: transform .35s var(--ease), bottom .45s var(--ease), background-color .25s;
}
.rwc-launch:hover { background: #fff; transform: translateY(-2px); }
.rwc-launch:active { transform: scale(.97); }
.rwc-launch i { font-size: 18px; color: var(--accent); }
body.has-basket .rwc-launch { bottom: 84px; }   /* nad „Twoje zapytanie” (20 + 52 + 12) */
.mmenu:not([hidden]) ~ .rwc-launch { display: none; }

/* ---------- Panel ---------- */
.rwc {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 90;
  width: 380px; height: min(560px, calc(100vh - 40px)); height: min(560px, calc(100dvh - 40px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: 0 40px 90px -30px rgba(28,44,92,.5), 0 2px 8px -2px rgba(28,44,92,.08);
  font-size: 14.5px; line-height: 1.55; color: var(--ink);
  transition: bottom .45s var(--ease), height .45s var(--ease);
}
.rwc:focus { outline: none; }
body.has-basket .rwc { bottom: 84px; height: min(560px, calc(100vh - 104px)); height: min(560px, calc(100dvh - 104px)); }

.rwc__head { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-bottom: 1px solid var(--line); }
.rwc__av { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 19px; }
.rwc__who { flex: 1; min-width: 0; }
.rwc__title { display: flex; align-items: center; gap: 7px; font-size: 15.5px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; }
.rwc__ai { padding: 2px 6px; border-radius: 6px; background: var(--ink); color: #fff; font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .06em; line-height: 1.3; }
.rwc__sub { font-size: 12.5px; color: var(--ink-3); line-height: 1.35; }
.rwc__btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; color: var(--ink-2); font-size: 19px; transition: background-color .2s, color .2s; }
.rwc__btn:hover { background: var(--surface-2); color: var(--ink); }

.rwc__body { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; align-content: start; gap: 12px; padding: 14px 14px 18px; background: var(--bg); scrollbar-width: thin; }
.rwc__note { display: flex; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--accent-soft); color: var(--ink-2); font-size: 12.5px; line-height: 1.5; }
.rwc__note i { flex: none; margin-top: 2px; color: var(--accent); font-size: 16px; }
.rwc__note b { color: var(--ink); font-weight: 600; }
.rwc__note a { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.rwc__log { display: grid; gap: 10px; }

/* ---------- Wiadomości ---------- */
.rwc-msg { display: grid; gap: 8px; min-width: 0; }
.rwc-msg--me { justify-self: end; max-width: 85%; }
.rwc-msg--bot { justify-self: stretch; }
.rwc-msg__txt { padding: 10px 14px; border-radius: 18px 18px 18px 6px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow-wrap: anywhere; }
.rwc-msg--bot .rwc-msg__txt { justify-self: start; max-width: 92%; }
.rwc-msg--me .rwc-msg__txt { background: var(--ink); color: #fff; border-radius: 18px 18px 6px 18px; box-shadow: none; }
.rwc-msg__txt p + p { margin-top: 8px; }
.rwc-msg__txt b { font-weight: 600; }
.rwc-msg__txt a { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color .2s; }
.rwc-msg__txt a:hover { color: var(--accent); }
.rwc-msg__note { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding-left: 4px; font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }
.rwc-retry { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); font-size: 13px; font-weight: 500; transition: background-color .2s; }
.rwc-retry:hover { background: #fff; }

.rwc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rwc-chip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid #C9CED8; background: var(--surface); font-size: 13.5px; font-weight: 500; transition: border-color .2s, color .2s, background-color .2s; }
.rwc-chip:hover { border-color: var(--accent); color: var(--accent-ink); background: #fff; }

/* ---------- Karty usług ---------- */
.rwc-cards { display: grid; gap: 8px; }
.rwc-card { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 8px 12px; padding: 12px 12px 8px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line), 0 10px 24px -22px rgba(28,44,92,.5); }
.rwc-card__ic { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 20px; }
.rwc-card__main { display: grid; gap: 1px; min-width: 0; }
.rwc-card__main b { font-size: 14px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.rwc-card__main span { font-size: 13px; color: var(--ink-3); }
.rwc-card__act { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
.rwc-add { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); font-size: 13.5px; font-weight: 500; transition: background-color .25s, color .25s, transform .3s var(--ease); }
.rwc-add:hover { background: #E3E6EC; }
.rwc-add:active { transform: scale(.97); }
.rwc-add[aria-pressed="true"] { background: var(--ink); color: #fff; }
.rwc-more { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding: 0 12px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); transition: color .2s; }
.rwc-more:hover { color: var(--accent); }

/* ---------- Pisanie ---------- */
.rwc-typing { justify-self: start; }
.rwc-dots { display: inline-flex; gap: 4px; padding: 15px 16px; border-radius: 18px 18px 18px 6px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.rwc-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: rwc-dot 1.2s ease-in-out infinite; }
.rwc-dots i:nth-child(2) { animation-delay: .15s; }
.rwc-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes rwc-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Pole wiadomości ---------- */
.rwc__form { padding: 10px 12px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.rwc__field { display: flex; align-items: flex-end; gap: 6px; padding: 4px 4px 4px 16px; border-radius: 26px; border: 1px solid #C9CED8; background: #fff; transition: border-color .2s, box-shadow .2s; }
.rwc__field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(45,91,255,.15); }
.rwc__in { flex: 1; min-width: 0; min-height: 44px; max-height: 120px; padding: 11px 0; border: 0; background: none; resize: none; font: inherit; font-size: 16px; line-height: 1.4; color: var(--ink); }
.rwc__in:focus { outline: none; }
.rwc__in::placeholder { color: var(--ink-3); }
.rwc__count { align-self: center; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.rwc__send { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-size: 18px; box-shadow: inset 0 1px 0 rgba(255,255,255,.14); transition: background-color .25s, transform .3s var(--ease), opacity .2s; }
.rwc__send:hover { background: #1B2030; }
.rwc__send:active { transform: scale(.95); }
.rwc__send:disabled { opacity: .35; cursor: not-allowed; transform: none; }

/* ---------- Responsywność ---------- */
@media (max-width: 980px) {
  /* kalkulator w cenniku ma własny pasek na dole ekranu */
  .cn-in-calc .rwc-launch { visibility: hidden; opacity: 0; }
}
@media (max-width: 767px) {
  .rwc-launch { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); height: 48px; padding: 0 18px 0 14px; }
  body.has-basket .rwc-launch { bottom: 74px; }   /* koszyk na całą szerokość: 12 + 52 + 10 */
  .rwc { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); height: min(560px, calc(100vh - 24px)); height: min(560px, calc(100dvh - 24px)); }
  body.has-basket .rwc { bottom: 74px; height: min(560px, calc(100vh - 86px)); height: min(560px, calc(100dvh - 86px)); }
}
@media (max-width: 600px) {
  /* telefon: panel na cały ekran */
  .rwc, body.has-basket .rwc { inset: 0; width: auto; height: auto; border: 0; border-radius: 0; box-shadow: none; padding-top: env(safe-area-inset-top, 0px); }
  .rwc__form { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-height: 520px) and (min-width: 600px) {
  /* telefon poziomo: kompaktowy koszyk (44 px) po prawej */
  .rwc-launch { right: 12px; bottom: 12px; height: 44px; }
  body.has-basket .rwc-launch { bottom: 66px; }
  .rwc, body.has-basket .rwc { right: 12px; bottom: 12px; height: calc(100vh - 24px); height: calc(100dvh - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  .rwc-dots i { animation: none; opacity: .6; }
  .rwc-launch:hover, .rwc-add:active, .rwc__send:active, .rwc-launch:active { transform: none; }
}
