/* css/chat.css */
/* Webomat — jeden czat w całej aplikacji (decyzja 04.10.2026): rozmowa wstępna, plan strony i poprawki
   wyglądają i działają tak samo. Okno wypełnia wysokość ekranu, rozmowa przewija się w środku.
   Tokeny wspólne dla frontu (site.css) i panelu (app.css): --blue, --line, --soft, --ink, --ink-2, --muted. */
.chat { --chat-line-2: var(--line-2, var(--line-strong, #c0c4d0)); --chat-col: 860px;
  display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; background: #fff; border-radius: 16px; }
.chat [hidden] { display: none !important; }

/* Wypełnienie wysokości: w panelu pod górnym paskiem, przyklejone przy przewijaniu strony. */
.chat--fill { position: sticky; top: calc(var(--top-h, 60px) + 16px); height: calc(100vh - var(--top-h, 60px) - 32px); height: calc(100dvh - var(--top-h, 60px) - 32px); }
@media (max-width: 1023px) { .chat--fill { position: relative; top: 0; height: calc(100dvh - var(--top-h, 60px) - 40px); min-height: 420px; } }

/* Nagłówek */
.chat-head { flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: #fff; }
.chat-head-txt { flex: 1; min-width: 0; }
.chat-title { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; color: var(--ink); }
.chat-sub { margin: 2px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.chat-head-aside { flex: none; display: flex; align-items: center; gap: 8px; }
.chat-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--soft); font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }

.chat-ava { flex: none; width: 32px; height: 32px; border-radius: 9px; display: block; overflow: hidden; box-shadow: 0 6px 14px -10px rgba(42, 60, 255, .55); }
.chat-ava img { width: 100%; height: 100%; display: block; }

/* Rozmowa (przewija się w środku okna) */
.chat-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; margin: 0; padding: 20px 18px 12px; display: flex; flex-direction: column; gap: 14px; background: var(--soft); scroll-behavior: smooth; }
.chat--wide .chat-log, .chat--wide .chat-dock { padding-inline: max(18px, calc((100% - var(--chat-col)) / 2)); }
.chat-msg { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; }
.chat-msg--user { flex-direction: row-reverse; }
.chat-msg--user .chat-ava { display: none; }
.chat-body { display: grid; gap: 4px; min-width: 0; max-width: min(640px, 86%); }
.chat-msg--user .chat-body { justify-items: end; }
.chat-msg--wide .chat-body { max-width: min(720px, 100%); width: 100%; }
.chat-bubble { padding: 11px 15px; border-radius: 18px; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; color: var(--ink); background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.chat-text { white-space: pre-wrap; }
.chat-msg--user .chat-bubble { background: var(--blue); color: #fff; border-color: var(--blue); border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; box-shadow: 0 8px 20px -12px rgba(42, 60, 255, .7); }
.chat-msg--user .chat-bubble a { color: #fff; text-decoration: underline; }
.chat-time { font-size: 11px; color: var(--muted); padding: 0 6px; }
.chat-msg--pending .chat-bubble { opacity: .7; }
.chat-msg.is-new { animation: chat-in .35s var(--ease, ease) both; }
@keyframes chat-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.chat-sys { align-self: center; max-width: 92%; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); text-align: center; }

/* Pliki w wiadomości (miniatury zdjęć, PDF) */
.chat-media { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; max-width: min(420px, 100%); }
.chat-media li { position: relative; width: 96px; height: 96px; flex: none; border-radius: 12px; overflow: hidden; background: #e9ebf3; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
.chat-media li:only-child { width: min(240px, 100%); height: auto; aspect-ratio: 4 / 3; }
.chat-media a { cursor: zoom-in; }
.chat-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-media a { display: block; width: 100%; height: 100%; }
.chat-media .chat-more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(16, 24, 40, .55); color: #fff; font-weight: 700; font-size: 15px; }
.chat-media .chat-pdf { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 100%; padding: 6px; font-size: 11px; color: var(--ink-2); text-align: center; overflow: hidden; }
.chat-media .chat-pdf .ico { width: 22px; height: 22px; color: var(--blue); }
.chat-msg--user .chat-media { justify-self: end; justify-content: flex-end; }

/* Przeglądarka zdjęć z czatu (chat-ui.js): zdjęcie na całym ekranie, strzałki między zdjęciami wiadomości. */
.wlb { padding: 0; border: 0; background: transparent; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; overflow: hidden; }
.wlb::backdrop { background: rgba(10, 12, 24, .88); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.wlb-stage { position: absolute; inset: 56px 72px 64px; display: grid; place-items: center; }
.wlb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .8); background: #fff; }
.wlb-btn { position: absolute; display: grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; transition: background .15s; }
.wlb-btn:hover { background: rgba(255, 255, 255, .26); }
.wlb-close { top: 14px; right: 16px; }
.wlb-prev { left: 14px; top: 50%; margin-top: -23px; }
.wlb-next { right: 14px; top: 50%; margin-top: -23px; }
.wlb-bar { position: absolute; left: 0; right: 0; bottom: 18px; display: flex; justify-content: center; gap: 14px; color: rgba(255, 255, 255, .85); font: 500 14px/1.4 var(--font, inherit); }
.wlb-bar a { color: #fff; text-decoration: underline; }
@media (max-width: 640px) { .wlb-stage { inset: 56px 8px 64px; } .wlb-prev, .wlb-next { top: auto; bottom: 8px; margin: 0; } }

/* Karta w wiadomości agenta (plan strony, „zrozumiałem tak”) */
.chat-card { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.chat-bubble .chat-card { margin-top: 10px; padding: 12px; box-shadow: none; background: var(--soft); }
.chat-card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.chat-card-h b { font-size: 15px; }
.chat-card-h small { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.chat-card.is-old { opacity: .55; }
.chat-card.is-old .chat-card-act { display: none; }
.chat-card-act { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Agent pisze */
.chat-typing { display: flex; gap: 10px; align-items: flex-end; }
.chat-dots { display: inline-flex; align-items: center; gap: 5px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 18px; border-bottom-left-radius: 6px; }
.chat-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--chat-line-2, var(--line-2, var(--line-strong, #c0c4d0))); animation: chat-dot 1.1s ease-in-out infinite; }
.chat-dots i:nth-child(2) { animation-delay: .15s; }
.chat-dots i:nth-child(3) { animation-delay: .3s; }
.chat-dots em { margin-left: 6px; font-style: normal; font-size: 13px; color: var(--muted); }
@keyframes chat-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Szybkie odpowiedzi */
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 42px; }
.chat-chip { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--blue) 35%, var(--line)); background: #fff; color: var(--blue); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.chat-chip:hover { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Pole wiadomości */
.chat-dock { flex: none; display: grid; gap: 6px; padding: 10px 18px 14px; background: var(--soft); border-top: 1px solid var(--line); }
.chat-box { display: flex; align-items: flex-end; gap: 8px; padding: 7px 7px 7px 8px; background: #fff; border: 1px solid var(--chat-line-2, var(--line-2, var(--line-strong, #c0c4d0))); border-radius: 16px; transition: border-color .15s, box-shadow .15s; }
.chat-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(42, 60, 255, .12); }
.chat-box textarea { flex: 1; min-width: 0; min-height: 40px; max-height: 180px; resize: none; border: 0; outline: none; background: none; padding: 9px 4px; font: inherit; font-size: 15.5px; line-height: 1.45; color: var(--ink); box-shadow: none; }
.chat-box textarea:focus, .chat-box textarea:focus-visible { outline: none; box-shadow: none; border: 0; }
.chat-box textarea:disabled { background: none; }
.chat-attach, .chat-send { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; }
.chat-attach { border: 1px solid var(--line); background: var(--soft); color: var(--ink-2); }
.chat-attach:hover { background: #fff; color: var(--blue); border-color: var(--blue); }
.chat-attach .ico { width: 18px; height: 18px; }
.chat-send, .chat .chat-send, .ic .chat-send { border: 0; background: var(--blue); color: #fff; } /* .chat / .ic (czat wstępny) — mocniejsze niż `.app button { color: inherit }` w panelu */
.chat-send:hover { filter: brightness(.92); }
.chat-send:active { transform: scale(.95); }
.chat-send:disabled { background: var(--chat-line-2, var(--line-2, var(--line-strong, #c0c4d0))); cursor: default; filter: none; }
.chat-send .ico { width: 18px; height: 18px; transform: rotate(-90deg); }
.chat-hint { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: 0; padding: 0 4px; font-size: 12.5px; color: var(--muted); }
.chat-err { margin: 0; padding: 0 4px; font-size: 13.5px; color: var(--err, #d92d20); }
.chat-err:empty { display: none; }
.chat.is-drop .chat-box { border-color: var(--blue); border-style: dashed; background: color-mix(in srgb, var(--blue) 5%, #fff); }

/* Pliki przed wysłaniem (z paskiem wgrywania) */
.chat-tray { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chat-tray li { position: relative; flex: none; width: 58px; height: 58px; border-radius: 10px; overflow: hidden; background: #e9ebf3; border: 1px solid var(--line); }
.chat-tray img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-tray .chat-pdf { display: grid; place-items: center; height: 100%; font-size: 11px; font-weight: 700; color: var(--ink-2); }
.chat-tray-rm { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(16, 24, 40, .7); color: #fff; font-size: 13px; line-height: 1; cursor: pointer; }
.chat-tray .chat-prog { position: absolute; left: 4px; right: 4px; bottom: 4px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .7); overflow: hidden; }
.chat-tray .chat-prog i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .2s; }
.chat-tray li.is-done .chat-prog { display: none; }
.chat-tray li.is-bad { outline: 2px solid var(--err, #d92d20); outline-offset: -2px; }
.chat-tray-sum { flex: none; align-self: center; padding: 0 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

@media (max-width: 600px) {
  .chat-head { padding: 12px 14px; }
  .chat-sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .chat-hint span + span { display: none; }
  .chat-log { padding: 16px 12px 10px; }
  .chat-dock { padding: 8px 10px 10px; }
  .chat-body { max-width: 90%; }
  .chat-chips { padding-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .chat-msg.is-new, .chat-dots i { animation: none; } .chat-log { scroll-behavior: auto; } }
.chat-hint .linkbtn { padding: 0; border: 0; background: none; color: var(--blue); font: inherit; font-weight: 600; cursor: pointer; }
.chat-hint .linkbtn:hover { text-decoration: underline; }

/* Pliki z podpisem (czat poprawek, 16.10.2026): miniatura + pole „Podpis linku” — tekst, pod którym plik będzie na stronie. */
.chat-tray li.chat-tray-item { width: auto; height: auto; display: flex; align-items: stretch; gap: 0; background: #fff; overflow: visible; border-radius: 12px; }
.chat-tray-thumb { position: relative; flex: none; width: 58px; height: 58px; border-radius: 11px 0 0 11px; overflow: hidden; background: #e9ebf3; }
.chat-tray-thumb .chat-pdf { display: grid; place-items: center; height: 100%; font-size: 10.5px; font-weight: 750; letter-spacing: .03em; color: var(--blue); background: color-mix(in srgb, var(--blue) 9%, #fff); }
.chat-tray-label { display: grid; align-content: center; gap: 2px; width: 196px; padding: 6px 30px 6px 10px; border-left: 1px solid var(--line); cursor: text; }
.chat-tray-cap { font-size: 10.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.chat-tray-label input { width: 100%; min-width: 0; border: 0; outline: none; padding: 2px 0; background: none; font: inherit; font-size: 13.5px; font-weight: 550; color: var(--ink); text-overflow: ellipsis; border-bottom: 1px dashed var(--chat-line-2, #c0c4d0); }
.chat-tray-label input:focus { border-bottom: 1px solid var(--blue); }
.chat-tray-item:focus-within { border-color: color-mix(in srgb, var(--blue) 50%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 14%, transparent); }
.chat-tray-item .chat-tray-rm { top: 6px; right: 6px; }
.chat-tray li.chat-tray-item.is-bad { outline-offset: 0; }
.chat-media .chat-pdf .chat-pdf-ext { font-size: 10.5px; font-weight: 750; letter-spacing: .04em; color: var(--blue); }
.chat-media .chat-pdf span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
@media (max-width: 560px) { .chat-tray-label { width: 160px; } }
/* Szersze kafelki z podpisem nie mogą rozpychać doku (element siatki ma domyślnie min-width: auto) — pasek przewija się w poziomie. */
.chat-dock { grid-template-columns: minmax(0, 1fr); }
.chat-dock .chat-form, .chat-tray { min-width: 0; }
.chat-text--note { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(0, 0, 0, .08); }

