/* fz-chat.css — Team chat floating button + panel (7 Okt 2026).
   Positioned stacked ABOVE the assistant FAB (ops-theme.css .fsw-assist-fab,
   right:20px bottom:20px, 54px) — never the same spot, never overlapping.
   Mobile (≤768) FIRST tried following the assistant FAB into the top icon
   row (ops-theme.css ~2281, B4-cacat.md §A1's fix for the bell+assistant),
   but the owner rejected that for chat specifically (7 Okt 2026 follow-up):
   it read as "stuck at the top", not a floating button. Chat now stays a
   plain bottom-right FAB on mobile too, just pushed up above the bottom tab
   bar (.fsw-bbar, z 75) when one is present — same 94px clearance precedent
   already used for .xcs-fab-wa (ops-theme.css ~886). */

.fsw-chat-fab {
  position: fixed; right: 20px; bottom: 86px; z-index: 39; /* one below the assistant FAB's 40 */
  width: 54px; height: 54px; border-radius: var(--fz-r-pill);
  background: var(--fz-surface-1); color: var(--fz-text-1);
  border: 1px solid var(--fz-border-strong);
  display: grid; place-items: center; cursor: pointer; padding: 0;
  box-shadow: var(--fz-shadow-pop);
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.fsw-chat-fab:hover { transform: translateY(-2px); }
.fsw-chat-fab:active { transform: scale(.96); }
.fsw-chat-fab.is-open { opacity: 0; pointer-events: none; }
.fsw-chat-badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: var(--fz-r-pill); background: var(--fz-crit); color: #fff;
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--fz-bg, var(--fz-surface-1));
}
@media (max-width: 768px) {
  .fsw-chat-fab { right: 16px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  body.has-fsw-bottombar .fsw-chat-fab { bottom: calc(94px + env(safe-area-inset-bottom, 0px)); }
  .fsw-chat-fab:hover { transform: none; }
}

.fsw-chat-panel {
  position: fixed; right: 20px; bottom: 86px; z-index: 1200;
  width: 380px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 120px);
  background: var(--fz-surface-1); border: 1px solid var(--fz-border);
  border-radius: var(--fz-r-lg); box-shadow: var(--fz-shadow-pop);
  display: flex; flex-direction: column; overflow: hidden;
}
@media (max-width: 768px) {
  .fsw-chat-panel {
    right: 16px; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: auto; height: min(640px, calc(100vh - 100px));
  }
}

.fsw-chat-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--fz-s-3) var(--fz-s-4); border-bottom: 1px solid var(--fz-border);
  flex: 0 0 auto;
}
.fsw-chat-h-t { display: flex; align-items: center; gap: var(--fz-s-2); font-weight: 650; font-size: 14.5px; color: var(--fz-text-1); }

.fsw-chat-list {
  flex: 1 1 auto; overflow-y: auto; padding: var(--fz-s-3) var(--fz-s-3) var(--fz-s-2);
  display: flex; flex-direction: column; gap: var(--fz-s-2);
}
.fsw-chat-empty, .fsw-chat-empty-sm {
  margin: auto; color: var(--fz-text-3); font-size: 13px; text-align: center; padding: var(--fz-s-4);
  display: flex; flex-direction: column; gap: var(--fz-s-2); align-items: center;
}
.fsw-chat-empty-sm { padding: var(--fz-s-2); }

.fsw-chat-row { display: flex; align-items: flex-end; gap: var(--fz-s-2); }
.fsw-chat-row.is-grouped { margin-top: -6px; }
.fsw-chat-row-sp { width: 24px; flex: 0 0 auto; }
.fsw-chat-row.is-mine { flex-direction: row-reverse; }
.fsw-chat-row.is-mine .fsw-chat-row-sp { display: none; }
.fsw-chat-bub-wrap { display: flex; flex-direction: column; max-width: 76%; }
.fsw-chat-row.is-mine .fsw-chat-bub-wrap { align-items: flex-end; }
.fsw-chat-bub {
  background: var(--fz-surface-2); color: var(--fz-text-1);
  border-radius: var(--fz-r-md); padding: 7px 11px; font-size: 13.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.fsw-chat-row.is-mine .fsw-chat-bub { background: var(--fz-accent); color: var(--fz-text-on-accent); }
.fsw-chat-bub.is-deleted { font-style: italic; color: var(--fz-text-3); background: transparent; border: 1px dashed var(--fz-border-strong); }
.fsw-chat-mention { font-weight: 700; }
.fsw-chat-row.is-mine .fsw-chat-mention { color: var(--fz-text-on-accent); }
.fsw-chat-row:not(.is-mine) .fsw-chat-mention { color: var(--fz-accent-ink); }
.fsw-chat-mention.is-all {
  background: var(--fz-warn-soft); color: var(--fz-warn-ink);
  padding: 1px 6px; border-radius: var(--fz-r-sm);
}
.fsw-chat-row.is-mine .fsw-chat-mention.is-all { background: rgba(255,255,255,.22); color: var(--fz-text-on-accent); }
.fsw-chat-ts { font-size: 10.5px; color: var(--fz-text-3); margin: 2px var(--fz-s-2) 0; }
.fsw-chat-ts-who { font-weight: 650; color: var(--fz-text-2); }
.fsw-chat-sticker { width: 96px; height: 96px; object-fit: contain; }
/* 9 Okt 2026 — gambar tempel (paste) di dalam gelembung: lebar penuh
   gelembung, tinggi otomatis lewat aspect-ratio (imageW/imageH dari server)
   supaya tidak ada lompatan tata letak sebelum gambarnya termuat. Caption
   (body ikut terkirim) mengikuti di bawahnya, padding sendiri — bukan
   .fsw-chat-bub biasa (itu untuk teks polos). */
.fsw-chat-bub-img { padding: 4px; max-width: 220px; overflow: hidden; }
.fsw-chat-img { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: calc(var(--fz-r-md) - 3px); background: var(--fz-surface-3); }
.fsw-chat-img-cap { padding: 6px 5px 2px; font-size: 13.5px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
/* Tombol pembungkus gambar terkirim — reset tombol polos, murni supaya bisa
   diklik (buka OpsChatImageModal) tanpa terlihat seperti tombol. */
.fsw-chat-img-btn { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; }

/* Aksi baris (Edit/Hapus) — menumpang baris cap waktu, muncul saat disentuh/
   hover supaya baris pesan tidak ramai saat tidak diperlukan. Selalu
   terlihat di sentuhan (tidak ada hover di HP) lewat :focus-within juga. */
.fsw-chat-row-act {
  display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 4px;
  border: 0; background: transparent; color: var(--fz-text-3); cursor: pointer; border-radius: var(--fz-r-sm);
  opacity: 0; vertical-align: -3px; transition: opacity .12s ease;
}
.fsw-chat-row:hover .fsw-chat-row-act, .fsw-chat-row:focus-within .fsw-chat-row-act { opacity: 1; }
.fsw-chat-row-act:hover { color: var(--fz-text-1); background: var(--fz-surface-hover); }
.fsw-chat-row-act.is-danger:hover { color: var(--fz-crit-ink, var(--fz-crit)); }
.fsw-chat-edited { font-style: italic; }

/* Pita "sedang menyunting" di atas komposer — pengingat komposer dipakai
   ulang untuk menyunting pesan LAMA, bukan menulis baru (lihat `editing`). */
.fsw-chat-editing {
  display: flex; align-items: center; gap: 6px; margin-bottom: var(--fz-s-2);
  font-size: 12px; color: var(--fz-text-2); background: var(--fz-surface-2);
  border-radius: var(--fz-r-sm); padding: 5px 8px;
}
.fsw-chat-editing-x { margin-left: auto; background: transparent; border: 0; color: var(--fz-accent-ink); font-weight: 650; cursor: pointer; padding: 2px 4px; }
.fsw-chat-editing-x:hover { text-decoration: underline; }

.fsw-chat-compose { flex: 0 0 auto; border-top: 1px solid var(--fz-border); padding: var(--fz-s-2) var(--fz-s-3); position: relative; }
/* Pratinjau gambar yang sedang ditempel/diunggah — di atas baris komposer,
   bisa dibatalkan (×) sebelum Kirim ditekan. */
.fsw-chat-imgpreview { position: relative; display: inline-flex; margin-bottom: var(--fz-s-2); }
.fsw-chat-imgpreview img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--fz-r-md); border: 1px solid var(--fz-border-strong); display: block; }
.fsw-chat-imgpreview-up { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); border-radius: var(--fz-r-md); }
.fsw-chat-imgpreview-x {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: var(--fz-r-pill);
  border: 1px solid var(--fz-border-strong); background: var(--fz-surface-1); color: var(--fz-text-2);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.fsw-chat-imgpreview-x:hover { color: var(--fz-text-1); background: var(--fz-surface-hover); }
.fsw-chat-compose-row { display: flex; align-items: flex-end; gap: var(--fz-s-2); }
.fsw-chat-input {
  flex: 1 1 auto; resize: none; max-height: 110px; min-height: 36px;
  border: 1px solid var(--fz-border-strong); border-radius: var(--fz-r-md);
  background: var(--fz-surface-sunken); color: var(--fz-text-1);
  padding: 8px 10px; font-size: 13.5px; font-family: inherit; line-height: 1.4;
}
.fsw-chat-input:focus { outline: none; border-color: var(--fz-focus, var(--fz-accent-line)); }
.fsw-chat-send {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: var(--fz-r-pill); border: 0;
  background: var(--fz-accent); color: var(--fz-text-on-accent); display: grid; place-items: center; cursor: pointer;
}
.fsw-chat-send:disabled { opacity: .45; cursor: not-allowed; }

.fsw-chat-mentionbox {
  position: absolute; left: var(--fz-s-3); right: var(--fz-s-3); bottom: 100%;
  margin-bottom: 6px; background: var(--fz-surface-1); border: 1px solid var(--fz-border-strong);
  border-radius: var(--fz-r-md); box-shadow: var(--fz-shadow-pop);
  max-height: 224px; overflow-y: auto; /* tim bisa >6 orang — dulu overflow:hidden diam-diam memotong daftar */
}
.fsw-chat-mention-opt {
  display: flex; align-items: center; gap: var(--fz-s-2); width: 100%; text-align: left;
  padding: 7px var(--fz-s-3); background: transparent; border: 0; cursor: pointer;
  font-size: 13px; color: var(--fz-text-1);
}
.fsw-chat-mention-opt.is-sel, .fsw-chat-mention-opt:hover { background: var(--fz-surface-hover); }
.fsw-chat-mention-opt.is-all { border-bottom: 1px solid var(--fz-border); }
.fsw-chat-mention-all-ic {
  width: 22px; height: 22px; border-radius: var(--fz-r-pill); flex: 0 0 auto;
  background: var(--fz-warn-soft); color: var(--fz-warn-ink); display: grid; place-items: center;
}
.fsw-chat-mention-all-sub { color: var(--fz-text-3); font-size: 11.5px; }

/* ── Laci stiker ala WhatsApp (9 Nov 2026) ─────────────────────────────
   Acuan pemilik: laci stiker WhatsApp — baris tab ikon (garis bawah pada
   yang aktif), kotak cari bulat, petak "Create" bergaris putus paling depan,
   kisi stiker. Selebar komposer penuh (margin negatif menembus padding
   .fsw-chat-compose), tinggi tetap supaya daftar pesan di atasnya tidak
   melompat saat berganti tab. */
.fsw-stk {
  margin: var(--fz-s-2) calc(-1 * var(--fz-s-3)) calc(-1 * var(--fz-s-2));
  border-top: 1px solid var(--fz-border);
  display: flex; flex-direction: column; height: min(300px, 44vh);
}
.fsw-stk-tabs { flex: 0 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--fz-border); }
.fsw-stk-tab {
  position: relative; height: 42px; display: grid; place-items: center; padding: 0;
  border: 0; background: transparent; color: var(--fz-text-3); cursor: pointer;
}
.fsw-stk-tab:hover, .fsw-stk-tab.is-on { color: var(--fz-text-1); }
.fsw-stk-tab.is-on::after {
  content: ''; position: absolute; left: 50%; bottom: -1px; width: 36px; margin-left: -18px; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--fz-accent);
}
.fsw-stk-addring { width: 20px; height: 20px; border-radius: var(--fz-r-pill); border: 1.75px solid currentColor; display: grid; place-items: center; }
.fsw-stk-search {
  flex: 0 0 auto; margin: var(--fz-s-2) var(--fz-s-3) 0; height: 36px; padding: 0 12px;
  display: flex; align-items: center; gap: 8px; color: var(--fz-text-3);
  border: 1.5px solid var(--fz-border-strong); border-radius: var(--fz-r-pill); background: var(--fz-surface-sunken);
}
.fsw-stk-search:focus-within { border-color: var(--fz-accent); }
/* Pemilih kuat sengaja: gaya input global (tinggi, bingkai, latar) tidak boleh menggambar kotak kedua di dalam pil. */
.fsw-chat-panel .fsw-stk-search input.fsw-stk-q {
  appearance: none; -webkit-appearance: none; flex: 1 1 auto; min-width: 0; width: auto; height: 100%; min-height: 0;
  margin: 0; padding: 0; border: 0; border-radius: 0; outline: none; box-shadow: none; background: transparent;
  color: var(--fz-text-1); font: inherit; font-size: 13px;
}
.fsw-chat-panel .fsw-stk-search input.fsw-stk-q::placeholder { color: var(--fz-text-3); }
.fsw-stk-qx { flex: 0 0 auto; width: 22px; height: 22px; padding: 0; display: grid; place-items: center; border: 0; border-radius: var(--fz-r-pill); background: var(--fz-surface-hover); color: var(--fz-text-2); cursor: pointer; }
/* Laci terbuka = panel lebih tinggi, supaya percakapan di atasnya tetap terbaca (max-height tetap membatasi di layar pendek). */
.fsw-chat-panel.has-stk { height: 680px; }
@media (max-width: 768px) { .fsw-chat-panel.has-stk { height: calc(100vh - 100px); } }
.fsw-stk-grid {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--fz-s-2) var(--fz-s-3);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; align-content: start;
}
.fsw-stk-create {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px dashed var(--fz-border-strong); border-radius: var(--fz-r-lg); background: transparent;
  color: var(--fz-text-2); font-size: 12px; cursor: pointer; padding: 0;
}
.fsw-stk-create:hover { color: var(--fz-text-1); border-color: var(--fz-text-3); background: var(--fz-surface-hover); }
.fsw-stk-empty { grid-column: 2 / -1; align-self: center; margin: 0; padding: 0 var(--fz-s-2); font-size: 12.5px; line-height: 1.45; color: var(--fz-text-3); }
.fsw-stk-cell { position: relative; aspect-ratio: 1; min-width: 0; }
.fsw-stk-img {
  width: 100%; height: 100%; padding: 4px; border: 0; border-radius: var(--fz-r-md); background: transparent; cursor: pointer;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.fsw-stk-img:hover { background: var(--fz-surface-hover); }
.fsw-stk-img:active { transform: scale(.94); }
.fsw-stk-img img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
/* ☆ di pojok — simpan ke "My stickers" tanpa membuka pop-up. Muncul saat
   hover; selalu terlihat di layar sentuh dan pada stiker yang sudah disimpan. */
.fsw-stk-star {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: var(--fz-r-pill); cursor: pointer;
  background: rgba(0, 0, 0, .5); color: #fff; opacity: 0; transition: opacity .12s ease;
}
.fsw-stk-cell:hover .fsw-stk-star, .fsw-stk-star:focus-visible, .fsw-stk-star.is-on { opacity: 1; }
.fsw-stk-star.is-on { color: #f7c948; }
@media (hover: none) { .fsw-stk-star { opacity: .9; } }
.fsw-stk-hint { flex: 0 0 auto; margin: 0; padding: 0 var(--fz-s-3) var(--fz-s-2); font-size: 11px; color: var(--fz-text-3); text-align: center; }
/* Stiker terkirim = tombol (buka pop-up simpan), tanpa tampang tombol. */
.fsw-chat-sticker-btn { display: block; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: var(--fz-r-md); -webkit-touch-callout: none; }
.fsw-chat-sticker-btn:hover .fsw-chat-sticker { transform: scale(1.04); }
.fsw-chat-sticker { display: block; transition: transform .12s ease; }

/* Pop-up stiker (simpan / kirim / hapus) & pratinjau stiker baru. */
.fz-chat-stkmodal { max-width: 420px; }
.fz-chat-stk-stage {
  display: grid; place-items: center; padding: var(--fz-s-4); border-radius: var(--fz-r-md);
  background: repeating-conic-gradient(var(--fz-surface-2) 0 25%, var(--fz-surface-sunken) 0 50%) 0 0 / 16px 16px;
}
.fz-chat-stk-stage img { display: block; width: 200px; height: 200px; max-width: 100%; object-fit: contain; }
.fz-chat-stk-meta { margin: var(--fz-s-2) 0 0; font-size: 12.5px; color: var(--fz-text-3); text-align: center; }
.fz-chat-stkmodal .fsw-modal-b > .fsw-field, .fz-chat-stkmodal .fsw-modal-b > label { margin-top: var(--fz-s-3); }
.fz-chat-stk-del {
  width: fit-content; margin: var(--fz-s-2) auto 0; display: flex; align-items: center; gap: 6px; padding: 4px 8px;
  border: 0; border-radius: var(--fz-r-sm); background: transparent; color: var(--fz-crit-ink, var(--fz-crit)); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.fz-chat-stk-del:hover { background: var(--fz-crit-soft, var(--fz-surface-hover)); }
