/*
 * Percakapan: tampilan elegan & modern (dimuat paling akhir).
 * Prinsip: ruang lega, sudut lembut, satu aksen warna brand, gerakan halus.
 * Header tipis menampilkan siapa yang diajak bicara; tombol aksi tetap di panel Info.
 */
.view.chats { --cx-r: 18px; --cx-glass: rgba(255, 255, 255, .62); --cx-glass-2: rgba(255, 255, 255, .86); --cx-garis: rgba(15, 34, 60, .07); --cx-bayang: 0 10px 30px rgba(20, 40, 90, .08); --cx-pola: rgba(14, 116, 144, .07); }
html[data-theme="dark"] .view.chats { --cx-glass: rgba(22, 26, 52, .55); --cx-glass-2: rgba(30, 35, 68, .82); --cx-garis: rgba(255, 255, 255, .08); --cx-bayang: 0 10px 30px rgba(0, 0, 0, .35); --cx-pola: rgba(160, 175, 255, .07); }

/* ---------- Daftar percakapan ---------- */
.view.chats .side { gap: 0; }
.view.chats .side .sbox { margin: 12px 12px 0; }
.view.chats .side .gsearch { width: 100%; height: 40px; border-radius: 14px; border: 1px solid var(--cx-garis); background-color: var(--cx-glass-2); box-shadow: 0 2px 10px rgba(20, 40, 90, .05); transition: box-shadow .2s, border-color .2s; }
.view.chats .side .gsearch:focus { outline: none; border-color: color-mix(in srgb, var(--brand) 45%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.view.chats .side .tabs { border-radius: 14px; }
.view.chats .side .tab { border-radius: 11px; transition: background .2s, color .2s; }
/* saringan: grid 2 x 2 yang simetris, teks tidak lagi terlipat di dalam tombol */
.view.chats .side .saring { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding-bottom: 10px; }
.view.chats .side .chip-f { justify-content: center; min-width: 0; white-space: nowrap; padding: 6px 10px; border-radius: 99px; transition: background .2s, color .2s, transform .15s; }
.view.chats .side .chip-f:active { transform: scale(.96); }
.view.chats .side .chip-f.on { box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 30%, transparent); }
#list { padding: 4px 0 12px; }
.view.chats .item { position: relative; margin: 4px 10px; width: calc(100% - 20px); padding: 11px 12px; border-radius: 16px; gap: 12px; }
.view.chats .item .avw .av { width: 44px; height: 44px; font-weight: 700; background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 22%, #fff), color-mix(in srgb, var(--brand) 8%, #fff)); color: var(--brand); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 18%, transparent); }
html[data-theme="dark"] .view.chats .item .avw .av { background: linear-gradient(135deg, rgba(122, 140, 255, .35), rgba(122, 140, 255, .12)) !important; color: #E4E8FF !important; }
.view.chats .item .name { font-weight: 700; letter-spacing: -.005em; }
.view.chats .item .preview { font-size: 12.5px; line-height: 1.4; }
.view.chats .item .when { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); }
.view.chats .item .badge { min-width: 20px; height: 20px; line-height: 20px; padding: 0 6px; border-radius: 99px; font-size: 11px; font-weight: 800; text-align: center; background: var(--pu-grad, var(--brand)); color: #fff; box-shadow: 0 4px 10px color-mix(in srgb, var(--brand) 35%, transparent); }
/* menunggu balasan: aksen tipis di kiri + titik, bukan blok warna penuh */
.view.chats .item.waiting, .view.chats .item.waiting.hot { background: transparent; box-shadow: none; }
.view.chats .item.waiting::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--amber, #F5A524); }
.view.chats .item.waiting.hot::before { background: var(--alert, #E5484D); }
.view.chats .item.waiting:hover, .view.chats .item.waiting.hot:hover { background: var(--cx-glass); }
.view.chats .item.active, .view.chats .item.waiting.active { background: var(--cx-glass-2); box-shadow: var(--cx-bayang), inset 0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent); transform: none; }
.view.chats .item .wait { color: var(--alert, #E5484D); font-weight: 600; }
.view.chats .item .done { color: color-mix(in srgb, var(--brand) 85%, var(--ink)); }

/* ---------- Header percakapan (tipis, kaca) ---------- */
@media (min-width: 901px) {
  #chatHead:not(.hidden) { display: flex !important; }
  #chatHead #back, #chatHead #chips, #chatHead > button { display: none !important; }
  .view.chats .chat-head { flex-wrap: nowrap; }
}
.view.chats .chat-head { min-height: 64px; padding: 10px 24px; gap: 10px 12px; background: var(--cx-glass) !important; -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%); border-bottom: 1px solid var(--cx-garis); }
.view.chats .chat-head .av { width: 40px; height: 40px; font-weight: 700; background: var(--pu-grad, var(--brand)); color: #fff; box-shadow: 0 6px 14px color-mix(in srgb, var(--brand) 30%, transparent); }
.view.chats .chat-head h2 { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.view.chats .chat-head small { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }

/* ---------- Area pesan ---------- */
.view.chats #messages {
  padding: 26px clamp(18px, 4vw, 48px) 18px; gap: 4px;
  background-image: radial-gradient(var(--cx-pola) 1px, transparent 1.2px) !important; background-size: 22px 22px !important;
}
.view.chats .msg { max-width: min(62%, 560px); }
.view.chats .msg.customer + .msg.admin, .view.chats .msg.admin + .msg.customer { margin-top: 10px; }
.view.chats .bubble { padding: 10px 14px; font-size: 14px; line-height: 1.5; }
.view.chats .msg.customer .bubble { background: var(--cx-glass-2); border: 1px solid var(--cx-garis); box-shadow: 0 4px 14px rgba(20, 40, 90, .06); border-radius: 18px 18px 18px 6px; }
.view.chats .msg.admin .bubble { box-shadow: 0 8px 18px color-mix(in srgb, var(--brand) 28%, transparent); border-radius: 18px 18px 6px 18px; }
.view.chats .msg.customer + .msg.customer .bubble { border-top-left-radius: 8px; }
.view.chats .msg.admin + .msg.admin .bubble { border-top-right-radius: 8px; }
.view.chats .meta { font-size: 11px; opacity: .8; margin: 3px 6px 0; font-variant-numeric: tabular-nums; }
.view.chats .msg-sys { font-size: 11.5px; padding: 5px 14px; border-radius: 99px; border: 1px solid var(--cx-garis); box-shadow: none; margin: 12px 0 4px; }
@media (prefers-reduced-motion: no-preference) {
  .view.chats .msg { animation: cxMasuk .32s cubic-bezier(.2, .8, .2, 1) both; }
  .view.chats .item { transition: background .2s ease, box-shadow .25s ease, transform .2s ease; }
}
@keyframes cxMasuk { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }

/* keadaan kosong: ikon dalam lingkaran bergradasi */
.view.chats .placeholder { display: grid; justify-items: center; gap: 14px; max-width: 300px; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.view.chats .placeholder::before {
  content: ""; width: 72px; height: 72px; border-radius: 24px;
  background-color: var(--brand, #0E7490);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3Cpath d='M8 9h8M8 13h5'/%3E%3C/svg%3E"), var(--pu-grad, linear-gradient(135deg, #0E7490, #2563EB));
  background-size: 30px 30px, cover; background-position: center; background-repeat: no-repeat;
  box-shadow: 0 16px 34px color-mix(in srgb, var(--brand) 32%, transparent);
}

/* ---------- Kotak tulis: kapsul melayang ---------- */
.view.chats .composer-wrap { background: transparent !important; -webkit-backdrop-filter: none; backdrop-filter: none; border-top: 0 !important; padding: 0 clamp(14px, 3vw, 36px) 16px; }
.view.chats .composer { align-items: center; gap: 6px; padding: 6px 6px 6px 10px; border-radius: 26px; background: var(--cx-glass-2); border: 1px solid var(--cx-garis); box-shadow: var(--cx-bayang); -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%); transition: box-shadow .2s, border-color .2s; }
.view.chats .composer:focus-within { border-color: color-mix(in srgb, var(--brand) 40%, transparent); box-shadow: var(--cx-bayang), 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent); }
.view.chats .composer input[type="text"] { background: transparent !important; border: 0 !important; box-shadow: none !important; height: 40px; padding: 0 8px; font-size: 14px; }
.view.chats .composer input[type="text"]:focus { outline: none; }
.view.chats .composer > button:not(.btn) { width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; transition: background .2s, color .2s; }
.view.chats .composer > button:not(.btn):hover { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); }
.view.chats .composer .btn { height: 40px; padding: 0 20px; border-radius: 99px; border: 0; background: var(--pu-grad, var(--brand)); color: #fff; font-weight: 700; box-shadow: 0 8px 18px color-mix(in srgb, var(--brand) 32%, transparent); transition: transform .15s, box-shadow .2s; }
.view.chats .composer .btn:hover { transform: translateY(-1px); }
.view.chats .composer .btn:active { transform: scale(.97); }

/* ---------- Panel info ---------- */
.view.chats .info-who .av { width: 68px; height: 68px; font-size: 24px; font-weight: 700; background: var(--pu-grad, var(--brand)); color: #fff; box-shadow: 0 0 0 4px var(--cx-glass-2), 0 0 0 6px color-mix(in srgb, var(--brand) 25%, transparent), 0 14px 28px color-mix(in srgb, var(--brand) 25%, transparent); }
.view.chats .info-who h3 { font-weight: 800; letter-spacing: -.01em; }
.view.chats .info-sec { border-color: var(--cx-garis) !important; }
.view.chats .info-sec h4 { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.view.chats .info-acts > button { border-color: var(--cx-garis); background: var(--cx-glass-2); }
.view.chats .info .note, .view.chats .info .lb-add input { border-radius: 12px; border: 1px solid var(--cx-garis); background: var(--cx-glass-2); }

/* ---------- Modul WhatsApp CS & WhatsApp Center (hero Percakapan) ---------- */
@media (min-width: 1101px) {
  .chat-hero .ch-body { grid-template-columns: minmax(0, 1.15fr) minmax(0, .7fr) minmax(0, .85fr) minmax(0, 1.8fr) minmax(0, 1fr) !important; }
}
/* satu kartu, dua bagian (CS | Center) dipisah garis tipis */
.ch-wa.ch-wa2 { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; padding: 0 !important; overflow: hidden; }
.wam { position: relative; min-width: 0; display: flex; flex-direction: column; gap: 5px; padding: 9px 12px; background: transparent; color: #E6F4FA; overflow: hidden; }
.wam + .wam { border-left: 1px solid rgba(255, 255, 255, .14); }
.wam::after { content: ""; position: absolute; inset: auto -30% -60% auto; width: 120px; height: 120px; border-radius: 50%; pointer-events: none; opacity: .5; background: radial-gradient(circle, rgba(34, 197, 94, .22), transparent 65%); transition: background .4s; }
.wam[data-st="off"]::after { background: radial-gradient(circle, rgba(239, 68, 68, .2), transparent 65%); }
.wam[data-st="tunggu"]::after { background: radial-gradient(circle, rgba(245, 158, 11, .22), transparent 65%); }
.wam.pengirim { background: rgba(125, 211, 252, .07); }
.wam-h { display: flex; align-items: center; gap: 7px; min-width: 0; }
.wam-h h4 { margin: 0 !important; font-size: 11.5px !important; font-weight: 800; color: #F1FAFF !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* lampu status: hijau berdenyut = terhubung, merah berkedip = terputus, kuning = menyambung / scan QR */
.wam-led { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #9CA3AF; position: relative; }
.wam-led.on { background: #22C55E; box-shadow: 0 0 0 0 rgba(34, 197, 94, .6), 0 0 8px rgba(34, 197, 94, .9); animation: ledHijau 1.6s ease-out infinite; }
.wam-led.off { background: #EF4444; box-shadow: 0 0 8px rgba(239, 68, 68, .9); animation: ledMerah 1s steps(2, jump-none) infinite; }
.wam-led.tunggu { background: #F59E0B; box-shadow: 0 0 8px rgba(245, 158, 11, .8); animation: ledKuning 1.2s ease-in-out infinite; }
@keyframes ledHijau { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .65), 0 0 8px rgba(34, 197, 94, .9); opacity: 1; } 50% { opacity: .55; } 70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0), 0 0 8px rgba(34, 197, 94, .9); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0), 0 0 8px rgba(34, 197, 94, .9); opacity: 1; } }
@keyframes ledMerah { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
@keyframes ledKuning { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .wam-led.on, .wam-led.off, .wam-led.tunggu { animation: none; } }
.wam-st { font-size: 10.5px; color: rgba(230, 244, 250, .72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wam-st .wam-st-t { font-weight: 700; }
.wam-st .wam-no:not(:empty)::before { content: " · "; }
.wam[data-st="on"] .wam-st-t { color: #4ADE80; }
.wam[data-st="off"] .wam-st-t { color: #F87171; }
.wam[data-st="tunggu"] .wam-st-t { color: #FBBF24; }
.wam-n { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: end; }
.wam-n b { grid-row: 1; font-size: 20px; font-weight: 800; line-height: 1; color: #FFFFFF; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.wam-n small { grid-row: 2; grid-column: 1 / -1; font-size: 9.5px; color: rgba(230, 244, 250, .65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wam-spark { grid-row: 1; grid-column: 2; justify-self: end; width: 100%; max-width: 80px; height: 22px; }
.wam-spark rect { fill: rgba(125, 211, 252, .38); }
.wam-spark rect.kini { fill: #7DD3FC; }
.wam-sehat { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; font-size: 9.5px; cursor: help; }
.wam-sehat-l { color: rgba(230, 244, 250, .65); }
.wam-sehat em { height: 5px; border-radius: 5px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.wam-sehat em i { display: block; height: 100%; width: 0; border-radius: 5px; background: #4ADE80; transition: width .6s ease, background .3s; }
.wam-sehat.waspada em i { background: #FBBF24; } .wam-sehat.buruk em i { background: #F87171; }
.wam-sehat b { font-weight: 800; color: #4ADE80; white-space: nowrap; }
.wam-sehat.waspada b { color: #FBBF24; } .wam-sehat.buruk b { color: #F87171; }
.wam .cw-btn { align-self: flex-start; margin-top: auto; }
@media (max-width: 1100px) { .ch-wa.ch-wa2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Jendela WhatsApp Center */
.wac-dlg { width: min(380px, calc(100vw - 32px)); border: 0; border-radius: 22px; padding: 20px; box-shadow: 0 30px 70px rgba(15, 23, 42, .3); }
.wac-dlg::backdrop { background: rgba(15, 23, 42, .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.wac-dlg h3 { margin: 0 0 12px; font-size: 17px; }
.wac-isi { display: grid; gap: 12px; }
.wac-st { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.wac-st span { color: var(--muted); font-size: 12px; }
.wac-qr { width: 240px; max-width: 100%; justify-self: center; border-radius: 14px; box-shadow: 0 10px 26px rgba(15, 23, 42, .15); }
.wac-p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.wac-err { margin: 0; font-size: 12px; color: var(--alert, #DC2626); }
.wac-dlg .act { display: flex; justify-content: flex-end; gap: 8px; }

/* HP: pratinjau pesan panjang tidak lagi melebarkan daftar chat melewati layar (dipotong dengan "…") */
.view.chats > *, .view.chats .side, #list, #list > li { min-width: 0; }
.view.chats .item .mid { flex: 1 1 auto; min-width: 0; }
.view.chats .item .preview, .view.chats .item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Susunan atas-bawah: Center di atas, CS di bawah. Tiap baris: [lampu+nama | status | tombol] / [angka | grafik | kesehatan] */
.ch-wa.ch-wa2 { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: repeat(2, minmax(0, 1fr)); }
.wam + .wam { border-left: 0; border-top: 1px solid rgba(255, 255, 255, .14); }
.wam { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "h st btn" "n spark sehat"; align-items: center; column-gap: 10px; row-gap: 4px; padding: 7px 12px; }
.wam > .wam-h { grid-area: h; }
.wam > .wam-st { grid-area: st; }
.wam > .cw-btn { grid-area: btn; margin: 0 !important; align-self: center; }
.wam > .wam-n { grid-area: n; display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.wam > .wam-n b { font-size: 19px; }
.wam > .wam-n small { white-space: nowrap; }
.wam > .wam-spark { grid-area: spark; justify-self: stretch; width: 100%; max-width: 110px; height: 20px; }
.wam > .wam-sehat { grid-area: sehat; min-width: 120px; }
.wam > .wam-sehat em { min-width: 40px; }
.wam::after { inset: auto -8% -120% auto; }
@media (min-width: 1101px) { .chat-hero .ch-body { grid-template-columns: minmax(0, 1.15fr) minmax(0, .7fr) minmax(0, .85fr) minmax(0, 1.6fr) minmax(0, 1fr) !important; } }
@media (max-width: 900px) {
  .ch-wa.ch-wa2 { grid-template-rows: auto auto; height: auto !important; max-height: none !important; }
  .wam { padding: 9px 12px; }
}
@media (max-width: 520px) {
  .wam > .wam-sehat { min-width: 0; grid-template-columns: 1fr auto; }
  .wam > .wam-sehat .wam-sehat-l { display: none; }
  .wam > .wam-n small { display: none; }
  .wam > .wam-n::after { content: "terkirim"; font-size: 9.5px; color: rgba(230, 244, 250, .65); }
}
