/* ==========================================================================
   Karta Ciąży — moduł „Wiadomości” (czat.css) · ETAP 2 · podgląd
   Kolory wyłącznie ze zmiennych style.css (motyw jasny i ciemny).
   Ruch: tylko transform / opacity; [data-noanim] wyłącza wszystko (reguła w style.css).
   ========================================================================== */
.czat { padding: 0; overflow: hidden; }
.czat *, .czat *::before, .czat *::after { min-width: 0; }

/* nagłówek */
.czat__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.czat__hmain { flex: 1 1 260px; }
.czat__title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800; }
.czat__title svg { width: 22px; height: 22px; color: var(--brand); flex: none; }
.czat__sub { margin-top: 4px; font-size: 14px; color: var(--muted); }
.czat__tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.czat__etap { color: var(--info); border-color: var(--info); border-style: solid; background: var(--info-soft); }

/* układ lekarza: lista | rozmowa */
.czat__grid { display: grid; grid-template-columns: minmax(260px, 330px) minmax(0, 1fr); }
.czat__side { border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); }
.czat__search { flex: none; margin: 12px; }
.czat__lwrap { flex: 1 1 auto; overflow-y: auto; max-height: 640px; padding: 0 8px 12px; overscroll-behavior: contain; }
.czat__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.czat__lhead { display: flex; align-items: center; gap: 8px; margin: 14px 8px 6px; font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.czat__none { padding: 18px 12px; font-size: 14px; color: var(--muted); text-align: center; }
.czat__more { margin-top: 6px; }

.czat__item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 66px; padding: 10px; border: 0; border-radius: var(--radius-sm); background: transparent; text-align: left; cursor: pointer; color: var(--text); position: relative; }
.czat__item:hover { background: var(--surface-2); }
.czat__item[aria-current="true"] { background: var(--brand-soft); }
.czat__item[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--brand); }
.czat__av { width: 42px; height: 42px; font-size: 14px; }
.czat__av--clinic { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.czat__av--clinic svg { width: 22px; height: 22px; }
.czat__itxt { flex: 1 1 auto; display: grid; gap: 2px; }
.czat__irow { display: flex; align-items: center; gap: 8px; }
.czat__iname { flex: 1 1 auto; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.czat__itime { flex: none; font-size: 12.5px; color: var(--muted); }
.czat__ilast { flex: 1 1 auto; font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.czat__ilast--none { font-style: italic; }
.czat__item--un .czat__iname, .czat__item--un .czat__ilast { color: var(--text); font-weight: 800; }
.czat__item--un .czat__itime { color: var(--brand); font-weight: 700; }
.czat__count { flex: none; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--brand); color: var(--on-brand); font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.czat__st { flex: none; min-height: 20px; font-size: 11.5px; padding: 1px 8px; }

/* rozmowa */
.czat__pane { display: flex; flex-direction: column; background: var(--surface); }
.czat__conv { display: flex; flex-direction: column; flex: 1 1 auto; }
.czat__chead { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.czat__back { display: none; flex: none; min-height: 44px; padding: 0 10px 0 6px; margin-left: -6px; }
.czat__cwho { flex: 1 1 auto; }
.czat__cname { font-size: 16px; font-weight: 800; overflow-wrap: anywhere; }
.czat__cname:focus { outline: none; }
.czat__cname:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
.czat__csub { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }

.czat__msgs { position: relative; height: clamp(300px, 56vh, 600px); overflow-y: auto; overscroll-behavior: contain; padding: 14px 20px 18px; background: var(--bg); display: flex; flex-direction: column; gap: 4px; }
.czat__msgs:focus { outline: none; }
.czat__msgs:focus-visible { outline: 3px solid var(--info); outline-offset: -3px; }
.czat__day, .czat__new { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.czat__day::before, .czat__day::after, .czat__new::before, .czat__new::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--border); }
.czat__day span { padding: 2px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.czat__new { color: var(--brand); }
.czat__new::before, .czat__new::after { background: var(--brand); opacity: .45; }

.czat__msg { display: flex; flex-direction: column; align-items: flex-start; max-width: min(78%, 560px); }
.czat__msg--me { align-self: flex-end; align-items: flex-end; }
.czat__who { font-size: 12px; font-weight: 700; color: var(--muted); margin: 8px 4px 3px; }
.czat__bubble { padding: 9px 13px 7px; border-radius: 16px 16px 16px 5px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0, 0, 0, .04); max-width: 100%; }
.czat__msg--me .czat__bubble { background: var(--brand); border-color: var(--brand); color: var(--on-brand); border-radius: 16px 16px 5px 16px; }
.czat__text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: 15px; line-height: 1.45; }
.czat__meta { display: flex; justify-content: flex-end; gap: 8px; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.czat__msg--me .czat__meta { color: var(--on-brand); opacity: .88; }
.czat__msg--in { animation: czat-in .3s var(--ease, ease) both; transform-origin: 100% 100%; }
@keyframes czat-in { from { opacity: .4; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }

.czat__empty, .czat__pick { margin: auto; padding: 28px 16px; text-align: center; color: var(--muted); max-width: 360px; display: grid; justify-items: center; gap: 6px; }
.czat__empty strong, .czat__pick strong { color: var(--text); }
.czat__empty svg, .czat__pick svg { width: 38px; height: 38px; color: var(--brand); opacity: .7; margin-bottom: 4px; }
.czat__pick { flex: 1 1 auto; align-content: center; min-height: 360px; }

/* informacja o telefonie (hodowca) */
.czat__urgent { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px 20px; font-size: 13.5px; background: var(--accent-soft); color: var(--text); border-top: 1px solid var(--border); }
.czat__urgent svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--accent); }
.czat__urgent a { font-weight: 800; white-space: nowrap; }

/* pisanie */
.czat__form { padding: 12px 20px 14px; border-top: 1px solid var(--border); background: var(--surface); }
.czat__note { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.czat__note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--info); }
.czat__box { display: flex; gap: 10px; align-items: flex-end; }
textarea.input.czat__ta { flex: 1 1 auto; min-height: 48px; max-height: 168px; resize: none; overflow-y: auto; line-height: 1.45; }

.czat__send { flex: none; min-height: 48px; }
.czat__send:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.czat__foot { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; margin-top: 6px; }
.czat__cnt { font-variant-numeric: tabular-nums; margin-left: auto; }
.czat__cnt--warn { color: var(--danger); font-weight: 700; }
.czat__blocked { display: flex; gap: 10px; align-items: flex-start; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 14px; color: var(--muted); }
.czat__blocked svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }

/* hodowca: jedna rozmowa, węższy układ */
.czat--breeder .czat__msgs { height: clamp(300px, 52vh, 560px); }

/* telefon / wąskie okno: lista albo rozmowa */
@media (max-width: 860px) {
  .czat__head { padding: 12px 16px; }
  .czat__sub { display: none; }
  .czat__grid { grid-template-columns: minmax(0, 1fr); }
  .czat__side { border-right: 0; }
  .czat--vet[data-czat-sel] .czat__side { display: none; }
  .czat--vet:not([data-czat-sel]) .czat__pane { display: none; }
  .czat__lwrap { max-height: none; overflow: visible; }
  .czat__back { display: inline-flex; }
  .czat__chead { padding: 8px 12px; gap: 10px; }
  .czat__msgs { height: clamp(240px, calc(100dvh - 420px), 540px); padding: 10px 12px 14px; }
  .czat--breeder .czat__msgs { height: clamp(220px, calc(100dvh - 460px), 500px); }
  .czat__msg { max-width: 88%; }
  .czat__urgent { padding: 10px 14px; }
  .czat__form { padding: 10px 12px 12px; }
  .czat__blocked { padding: 12px 14px; }
}
@media (max-width: 420px) {
  .czat__sendl { display: none; }
  .czat__send { width: 48px; padding: 0; }
  .czat__back span { display: none; }
  .czat__back { padding: 0 8px; }
  .czat__chead .czat__av { display: none; }
  .czat__foot .hint:first-child { font-size: 12px; }
}
@media print { .czat__form, .czat__search { display: none; } .czat__msgs { height: auto; overflow: visible; } }
