/* =========================================================
   SecureChat — gaya utama (mobile-first)
   ========================================================= */
:root {
  --brand: #0b5e57;
  --brand-600: #094d47;
  --brand-50: #e6f2f1;
  --accent: #12a58f;
  --bubble-me: #d9f4ee;
  --bubble-me-text: #10302c;
  --bubble-other: #ffffff;
  --chat-bg: #eef2f1;
  --side-bg: #ffffff;
  --line: rgba(0, 0, 0, .07);
  --muted: #6b7a78;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
[data-bs-theme="dark"] {
  --brand-50: #12302d;
  --bubble-me: #105047;
  --bubble-me-text: #e8f6f3;
  --bubble-other: #1f2a2c;
  --chat-bg: #0f1719;
  --side-bg: #141d1f;
  --line: rgba(255, 255, 255, .07);
  --muted: #94a5a2;
}

html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--chat-bg);
}
.min-w-0 { min-width: 0; }
.bg-brand { background: var(--brand) !important; color: #fff; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-brand:disabled { background: var(--brand); border-color: var(--brand); opacity: .55; color: #fff; }
a { color: var(--brand); }
[data-bs-theme="dark"] a { color: var(--accent); }

/* ---------- Layout utama ---------- */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}
.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--side-bg);
  border-right: 1px solid var(--line);
  min-height: 0;
}
.chat {
  display: none;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--chat-bg);
  position: relative;
}
/* Mobile: tampilkan salah satu panel saja */
.app.show-chat .sidebar { display: none; }
.app.show-chat .chat { display: flex; }

@media (min-width: 768px) {
  .sidebar { width: 340px; flex-shrink: 0; }
  .chat { display: flex; }
  .app.show-chat .sidebar { display: flex; }
  .back-btn { display: none !important; }
  .fab { display: none !important; }
}
@media (min-width: 1200px) { .sidebar { width: 380px; } }

/* ---------- Header ---------- */
.side-header, .chat-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: calc(.6rem + var(--safe-top)) .75rem .6rem;
  background: var(--brand);
  color: #fff;
  min-height: 60px;
  flex-shrink: 0;
}
.icon-btn {
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: transparent; color: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
  transition: background .15s;
}
.icon-btn:hover, .icon-btn:active { background: rgba(255,255,255,.15); }
.side-header .avatar, .chat-header .avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
.chat-title-btn {
  display: flex; align-items: center; gap: .6rem;
  background: none; border: 0; color: inherit; padding: 0;
  min-width: 0; flex: 1; text-align: left;
}
.chat-status { opacity: .8; }
.chat-status.typing { color: #b8f5e8; opacity: 1; font-style: italic; }

/* ---------- Avatar ---------- */
.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 1.1rem;
  flex-shrink: 0; position: relative; user-select: none;
}
.avatar-sm { width: 40px; height: 40px; font-size: 1rem; }
.avatar-xs { width: 28px; height: 28px; font-size: .75rem; }
.avatar-xl { width: 88px; height: 88px; font-size: 2.2rem; }
.avatar .dot {
  position: absolute; right: 0; bottom: 0;
  width: 13px; height: 13px; border-radius: 50%;
  background: #22c55e; border: 2px solid var(--side-bg);
}

/* ---------- Pencarian & filter ---------- */
.side-search { padding: .6rem .75rem .25rem; border-bottom: 1px solid var(--line); }
.search-box {
  display: flex; align-items: center; gap: .5rem;
  background: var(--bs-tertiary-bg); border-radius: 999px;
  padding: 0 .9rem; height: 40px;
}
.search-box i { color: var(--muted); }
.search-box input {
  border: 0; outline: 0; background: transparent; flex: 1;
  font-size: 16px; /* cegah auto-zoom iOS */ color: var(--bs-body-color); min-width: 0;
}
.filter-chips { display: flex; gap: .4rem; padding: .55rem 0 .35rem; overflow-x: auto; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--bs-tertiary-bg);
  color: var(--bs-body-color); border-radius: 999px;
  padding: .3rem .85rem; font-size: .82rem; white-space: nowrap;
}
.chip.active { background: var(--brand-50); color: var(--brand); border-color: transparent; font-weight: 600; }
[data-bs-theme="dark"] .chip.active { color: var(--accent); }

/* ---------- Daftar percakapan ---------- */
.conv-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(90px + var(--safe-bottom)); }
.conv-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .9rem; width: 100%;
  background: none; border: 0; text-align: left; color: inherit;
  border-bottom: 1px solid var(--line);
  transition: background .12s;
}
.conv-item:hover { background: var(--bs-tertiary-bg); }
.conv-item.active { background: var(--brand-50); }
.conv-item .top { display: flex; align-items: baseline; gap: .5rem; }
.conv-item .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .time { font-size: .74rem; color: var(--muted); flex-shrink: 0; }
.conv-item .bottom { display: flex; align-items: center; gap: .5rem; margin-top: 2px; }
.conv-item .preview { font-size: .87rem; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.unread .preview { color: var(--bs-body-color); font-weight: 500; }
.conv-item.unread .time { color: var(--accent); font-weight: 600; }
.unread-badge {
  background: var(--accent); color: #fff; border-radius: 999px;
  min-width: 21px; height: 21px; padding: 0 6px; font-size: .72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.list-empty { text-align: center; color: var(--muted); padding: 3rem 1.5rem; }
.list-empty i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .5; }
.skeleton { height: 58px; border-radius: 12px; margin-bottom: .6rem; background: linear-gradient(90deg, var(--bs-tertiary-bg) 25%, var(--line) 50%, var(--bs-tertiary-bg) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Tombol mengambang (mobile) ---------- */
.fab {
  position: absolute; right: 1.1rem; bottom: calc(1.1rem + var(--safe-bottom));
  width: 58px; height: 58px; border-radius: 18px; border: 0;
  background: var(--accent); color: #fff; font-size: 1.45rem;
  box-shadow: 0 6px 18px rgba(18,165,143,.4); z-index: 5;
}
.fab:active { transform: scale(.95); }
.conn-banner {
  display: none; position: absolute; left: 0; right: 0; bottom: 0;
  background: #b45309; color: #fff; text-align: center; font-size: .82rem; padding: .4rem;
  padding-bottom: calc(.4rem + var(--safe-bottom)); z-index: 6;
}
.conn-banner.show { display: block; }

/* ---------- Area chat ---------- */
.chat-active { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-empty {
  margin: auto; text-align: center; padding: 2rem; max-width: 420px;
}
.empty-icon {
  width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 1rem;
  background: var(--brand-50); color: var(--brand); font-size: 2.6rem;
  display: flex; align-items: center; justify-content: center;
}
.messages {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: .75rem .65rem 1rem;
  background-color: var(--chat-bg);
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 768px) { .messages { padding: 1rem 6% 1.25rem; } }
.enc-note {
  margin: .25rem auto .75rem; max-width: 330px; text-align: center;
  background: #fff7d6; color: #6b5a12; font-size: .76rem;
  border-radius: 10px; padding: .4rem .7rem;
}
[data-bs-theme="dark"] .enc-note { background: #2c2a1a; color: #e6d892; }
.day-sep { text-align: center; margin: .9rem 0 .6rem; position: sticky; top: 0; z-index: 2; }
.day-sep span {
  display: inline-block; background: var(--side-bg); color: var(--muted);
  font-size: .74rem; font-weight: 600; padding: .25rem .75rem; border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.sys-msg { text-align: center; margin: .5rem 0; }
.sys-msg span { display: inline-block; background: var(--brand-50); color: var(--muted); font-size: .76rem; padding: .25rem .75rem; border-radius: 8px; max-width: 90%; }
.load-more { text-align: center; padding: .25rem 0 .5rem; }

/* Gelembung pesan */
.msg { display: flex; gap: .4rem; margin-top: 2px; align-items: flex-end; }
.msg.first { margin-top: .55rem; }
.msg.me { justify-content: flex-end; }
.msg .avatar-slot { width: 28px; flex-shrink: 0; }
.bubble {
  position: relative; max-width: min(78%, 560px);
  padding: .4rem .65rem .3rem; border-radius: var(--radius);
  background: var(--bubble-other); color: var(--bs-body-color);
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
  word-wrap: break-word; overflow-wrap: anywhere;
  animation: pop .16s ease-out;
}
.msg.me .bubble { background: var(--bubble-me); color: var(--bubble-me-text); }
.msg.first:not(.me) .bubble { border-top-left-radius: 6px; }
.msg.first.me .bubble { border-top-right-radius: 6px; }
.bubble .sender { font-size: .78rem; font-weight: 700; margin-bottom: 1px; }
.bubble .text { white-space: pre-wrap; font-size: .95rem; line-height: 1.38; }
.bubble .text a { color: inherit; text-decoration: underline; }
.bubble .meta {
  float: right; margin: .35rem 0 -2px .6rem; font-size: .68rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
}
.msg.me .bubble .meta { color: color-mix(in srgb, var(--bubble-me-text) 60%, transparent); }
.bubble .meta .read { color: #0ea5e9; }
.bubble.pending { opacity: .7; }
.bubble.failed { outline: 1px solid #dc3545; }
@keyframes pop { from { transform: scale(.96); opacity: .3; } to { transform: none; opacity: 1; } }

.scroll-down {
  position: absolute; right: 14px; bottom: calc(80px + var(--safe-bottom));
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: var(--side-bg); color: var(--bs-body-color);
  box-shadow: 0 2px 8px rgba(0,0,0,.18); z-index: 5;
}
.scroll-down .badge { position: absolute; top: -6px; right: -4px; background: var(--accent); border-radius: 999px; font-size: .68rem; }
.scroll-down .badge:empty { display: none; }

/* ---------- Kotak tulis pesan ---------- */
.composer {
  display: flex; align-items: flex-end; gap: .5rem;
  padding: .5rem .6rem calc(.5rem + var(--safe-bottom));
  background: var(--chat-bg); flex-shrink: 0;
}
.composer-input {
  flex: 1; background: var(--side-bg); border-radius: 24px;
  padding: .55rem 1rem; box-shadow: 0 1px 2px rgba(0,0,0,.08); min-width: 0;
}
.composer-input textarea {
  width: 100%; border: 0; outline: 0 !important; box-shadow: none; resize: none; background: transparent; -webkit-appearance: none;
  color: var(--bs-body-color); font-size: 16px; line-height: 1.35;
  max-height: 140px; display: block; padding: 0;
}
.send-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; flex-shrink: 0;
  background: var(--brand); color: #fff; font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, opacity .12s;
}
.send-btn:disabled { opacity: .45; }
.send-btn:not(:disabled):active { transform: scale(.92); }

/* ---------- Modal & daftar pengguna ---------- */
.brand-header { background: var(--brand); color: #fff; border-bottom: 0; padding-top: calc(1rem + var(--safe-top)); }
@media (min-width: 576px) { .brand-header { padding-top: 1rem; } }
.modal-fullscreen-sm-down .modal-footer { padding-bottom: calc(.75rem + var(--safe-bottom)); }
.user-list .user-item, .list-action {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  padding: .65rem 1rem; background: none; border: 0; text-align: left; color: inherit;
}
.list-action { padding: .5rem 0; font-weight: 600; }
.user-item:hover { background: var(--bs-tertiary-bg); }
.user-item .info { flex: 1; min-width: 0; }
.user-item .info .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-item .info .u { font-size: .82rem; color: var(--muted); }
.user-item .check {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted);
  display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0;
}
.user-item.selected .check { background: var(--accent); border-color: var(--accent); }
.user-item.selected .check::after { content: "✓"; font-size: .8rem; font-weight: 700; }
.selected-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.sel-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--brand-50); border-radius: 999px; padding: .2rem .25rem .2rem .2rem; font-size: .82rem;
}
.sel-chip button { border: 0; background: none; color: var(--muted); padding: 0 .35rem; }
.info-hero { text-align: center; padding: 1.5rem 1rem 1rem; border-bottom: 8px solid var(--bs-tertiary-bg); }
.info-section-title { font-size: .8rem; font-weight: 700; color: var(--accent); padding: .9rem 1rem .25rem; text-transform: uppercase; letter-spacing: .03em; }
.role-badge { font-size: .68rem; background: var(--brand-50); color: var(--brand); border-radius: 6px; padding: .1rem .4rem; font-weight: 600; }
[data-bs-theme="dark"] .role-badge { color: var(--accent); }

/* ---------- Toast ---------- */
#toast { background: #1f2a2c; color: #fff; }
#toast .btn-close { filter: invert(1); }

/* ---------- Halaman login / daftar ---------- */
.auth-body {
  overflow-y: auto;
  min-height: 100dvh;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand) 38%, var(--chat-bg) 38%);
}
.auth-wrap {
  width: 100%; max-width: 420px; margin: 0 auto;
  padding: calc(2.5rem + var(--safe-top)) 1rem calc(1.5rem + var(--safe-bottom));
}
.auth-brand { text-align: center; color: #fff; margin-bottom: 1.5rem; }
.auth-logo {
  width: 72px; height: 72px; border-radius: 22px; margin: 0 auto .8rem;
  background: rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; font-size: 2.2rem;
}
.auth-card { border-radius: 22px; }
.auth-card .form-control { font-size: 16px; }
.auth-foot { color: var(--muted); }

/* Pengguna yang memilih animasi minimal */
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* =========================================================
   Emoji, lampiran, penampil gambar
   ========================================================= */
.chat-active { position: relative; }
.composer-input { display: flex; align-items: flex-end; gap: .15rem; padding: .3rem .35rem; }
.composer-input textarea { flex: 1; padding: .3rem .25rem; align-self: center; }
.cbtn {
  width: 38px; height: 38px; border: 0; border-radius: 50%; flex-shrink: 0;
  background: transparent; color: var(--muted); font-size: 1.3rem;
  display: inline-flex; align-items: center; justify-content: center; transition: color .15s, background .15s;
}
.cbtn:hover { color: var(--brand); background: var(--brand-50); }
.cbtn.on { color: var(--accent); }
.cam-only { display: none; }
@media (pointer: coarse) { .cam-only { display: inline-flex; } }
.composer-input:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }

/* Panel emoji */
.emoji-panel {
  display: none; flex-direction: column; flex-shrink: 0;
  height: 290px; background: var(--side-bg); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.emoji-panel.open { display: flex; }
.chat-active.emoji-open .composer { padding-bottom: .5rem; }
.emoji-tabs { display: flex; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tab {
  flex: 1 0 44px; height: 42px; border: 0; background: none; color: var(--muted); font-size: 1.1rem;
  border-bottom: 3px solid transparent;
}
.emoji-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.emoji-grid { flex: 1; overflow-y: auto; padding: .25rem .4rem .5rem; overscroll-behavior: contain; }
.emoji-cat { font-size: .74rem; font-weight: 700; color: var(--muted); padding: .55rem .3rem .25rem; position: sticky; top: 0; background: var(--side-bg); z-index: 1; }
.emoji-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
.emoji-cells button {
  border: 0; background: none; font-size: 1.65rem; line-height: 1; height: 44px; border-radius: 10px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.emoji-cells button:hover, .emoji-cells button:active { background: var(--bs-tertiary-bg); }
@media (min-width: 768px) { .emoji-panel { height: 320px; } }

/* Emoji besar bila pesan hanya berisi emoji */
.bubble.jumbo { background: transparent !important; box-shadow: none; padding: 0 .2rem; }
.bubble.jumbo .text { font-size: 2.6rem; line-height: 1.15; }
.bubble.jumbo .meta { background: var(--side-bg); border-radius: 8px; padding: 1px 6px; margin-top: .2rem; }

/* Menu lampiran */
.attach-menu {
  position: absolute; left: .6rem; right: .6rem; bottom: calc(66px + var(--safe-bottom));
  display: flex; justify-content: space-around; gap: .5rem;
  background: var(--side-bg); border-radius: 18px; padding: 1rem .5rem .8rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(14px) scale(.98); pointer-events: none; transition: opacity .16s, transform .16s; z-index: 8;
}
.attach-menu.open { opacity: 1; transform: none; pointer-events: auto; }
@media (min-width: 768px) { .attach-menu { left: auto; right: 4.5rem; width: 300px; } }
.attach-opt { border: 0; background: none; color: var(--bs-body-color); font-size: .8rem; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.ao-ic { width: 54px; height: 54px; border-radius: 50%; color: #fff; font-size: 1.4rem; display: flex; align-items: center; justify-content: center; }
.attach-opt:active .ao-ic { transform: scale(.93); }

/* Gambar dalam gelembung */
.bubble.has-media { padding: 3px; }
.bubble.has-media .sender { padding: .2rem .45rem 0; }
.bubble.has-media .text { padding: .3rem .45rem .1rem; }
.bubble.has-media.no-caption .text { padding: 0; }
.media-img {
  display: block; position: relative; border-radius: 14px; overflow: hidden; cursor: zoom-in;
  background: var(--bs-tertiary-bg); width: min(280px, 64vw); max-height: 360px;
}
.media-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bubble.no-caption .media-img + .text .meta {
  position: absolute; right: 8px; bottom: 8px; margin: 0; float: none;
  background: rgba(0,0,0,.45); color: #fff !important; border-radius: 9px; padding: 1px 7px;
}
.bubble.no-caption .media-img + .text .meta .read { color: #7dd3fc; }
.bubble.has-media { position: relative; }

/* Kartu dokumen */
.file-card {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .6rem; border-radius: 12px;
  background: color-mix(in srgb, var(--bs-body-color) 6%, transparent); color: inherit; text-decoration: none;
  min-width: min(240px, 60vw); max-width: 300px;
}
.file-card:hover { background: color-mix(in srgb, var(--bs-body-color) 10%, transparent); color: inherit; }
.file-ic {
  width: 40px; height: 46px; border-radius: 7px; color: #fff; flex-shrink: 0; position: relative;
  display: flex; align-items: flex-end; justify-content: center; font-size: .6rem; font-weight: 800; padding-bottom: 5px; text-transform: uppercase;
}
.file-ic i { position: absolute; top: 6px; font-size: 1.05rem; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-all; }
.file-meta { font-size: .74rem; color: var(--muted); }
.file-dl { font-size: 1.35rem; color: var(--muted); flex-shrink: 0; }

/* Progres upload */
.up-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35); color: #fff; border-radius: inherit;
}
.up-ring { width: 48px; height: 48px; position: relative; }
.up-ring svg { transform: rotate(-90deg); }
.up-ring .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; }
.file-card .up-bar { height: 3px; background: var(--line); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.file-card .up-bar span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .15s; }

/* Pratinjau lampiran (layar penuh di area chat) */
.attach-preview {
  position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column;
  background: #0b1416; color: #fff; animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.ap-header { display: flex; align-items: center; gap: .5rem; padding: calc(.5rem + var(--safe-top)) .6rem .5rem; }
.ap-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: .5rem 1rem; }
.ap-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.ap-doc { text-align: center; max-width: 320px; }
.ap-doc .file-ic { width: 76px; height: 90px; margin: 0 auto 1rem; font-size: .85rem; padding-bottom: 10px; }
.ap-doc .file-ic i { font-size: 2rem; top: 14px; }
.ap-doc .n { font-weight: 600; word-break: break-all; }
.ap-doc .m { color: #9fb3b0; font-size: .85rem; }
.ap-bottom { padding: .4rem .6rem calc(.6rem + var(--safe-bottom)); }
.ap-thumbs { display: flex; gap: .45rem; overflow-x: auto; padding: .3rem 0 .6rem; scrollbar-width: none; }
.ap-thumb {
  width: 54px; height: 54px; flex-shrink: 0; border-radius: 10px; overflow: hidden; border: 2px solid transparent;
  background: #1d2a2d; color: #fff; display: flex; align-items: center; justify-content: center; font-size: .62rem; font-weight: 700; padding: 0;
}
.ap-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ap-thumb.active { border-color: var(--accent); }
.ap-thumb.add { border: 2px dashed #557; font-size: 1.3rem; background: transparent; }
.ap-send-row { display: flex; gap: .5rem; align-items: flex-end; }
.ap-send-row .composer-input { background: #1d2a2d; color: #fff; }
.ap-send-row textarea { color: #fff; }
.ap-send-row .cbtn { color: #9fb3b0; }
.ap-send-row .send-btn { background: var(--accent); }
.attach-preview .emoji-panel { color: var(--bs-body-color); }

/* Tarik & lepas file (desktop) */
.drop-overlay {
  position: absolute; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--brand) 85%, transparent); color: #fff; text-align: center; font-weight: 600;
  border: 3px dashed rgba(255,255,255,.6); border-radius: 12px; margin: 10px;
}
.drop-overlay i { font-size: 3rem; }
.drop-overlay.show { display: flex; }

/* Penampil gambar */
.viewer { background: #000; color: #fff; border: 0; border-radius: 0; }
.viewer-bar { display: flex; align-items: center; gap: .5rem; padding: calc(.5rem + var(--safe-top)) .6rem .5rem; background: rgba(0,0,0,.6); }
.viewer-bar a.icon-btn { color: #fff; }
.viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: auto; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; touch-action: pinch-zoom; }
.viewer-caption { text-align: center; padding: .6rem 1rem calc(.8rem + var(--safe-bottom)); white-space: pre-wrap; }
.viewer-caption:empty { display: none; }

/* Galeri media di info grup */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 0 1rem .5rem; }
.media-grid button { aspect-ratio: 1; border: 0; padding: 0; overflow: hidden; border-radius: 6px; background: var(--bs-tertiary-bg); }
.media-grid img { width: 100%; height: 100%; object-fit: cover; }
.doc-list .file-card { margin: 0 1rem .45rem; max-width: none; }

/* =========================================================
   Lokasi saat login
   ========================================================= */
.loc-box {
  display: flex; align-items: center; gap: .7rem;
  border: 1px solid var(--line); border-radius: 14px; padding: .65rem .75rem; margin-bottom: .75rem;
  background: var(--bs-tertiary-bg); transition: background .2s, border-color .2s;
}
.loc-ic {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
  background: var(--line); color: var(--muted);
}
.loc-title { font-weight: 600; font-size: .9rem; line-height: 1.25; }
.loc-sub { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.loc-box.ok { border-color: color-mix(in srgb, #16a34a 40%, transparent); background: color-mix(in srgb, #16a34a 8%, var(--bs-body-bg)); }
.loc-box.ok .loc-ic { background: #16a34a; color: #fff; }
.loc-box.warn { border-color: color-mix(in srgb, #d97706 45%, transparent); background: color-mix(in srgb, #d97706 8%, var(--bs-body-bg)); }
.loc-box.warn .loc-ic { background: #d97706; color: #fff; }
.loc-box.err { border-color: color-mix(in srgb, #dc3545 45%, transparent); background: color-mix(in srgb, #dc3545 7%, var(--bs-body-bg)); }
.loc-box.err .loc-ic { background: #dc3545; color: #fff; }
.loc-box .btn { flex-shrink: 0; white-space: nowrap; }
.loc-help { font-size: .8rem; background: var(--bs-tertiary-bg); border-radius: 12px; padding: .6rem .8rem; margin: -.25rem 0 .75rem; }
.loc-notice { font-size: .74rem; color: var(--muted); text-align: center; margin: .6rem 0 0; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Halaman admin log lokasi */
.admin-body { overflow: auto; height: auto; min-height: 100%; }
.admin-top { position: sticky; top: 0; z-index: 10; }
.loc-card { border: 1px solid var(--line); border-radius: 14px; padding: .75rem .85rem; background: var(--side-bg); }
.loc-card + .loc-card { margin-top: .6rem; }
.loc-badge { font-size: .7rem; font-weight: 700; border-radius: 6px; padding: .12rem .45rem; }
.loc-badge.success { background: color-mix(in srgb, #16a34a 15%, transparent); color: #15803d; }
.loc-badge.failed { background: color-mix(in srgb, #dc3545 15%, transparent); color: #c22d3a; }
[data-bs-theme="dark"] .loc-badge.success { color: #4ade80; }
[data-bs-theme="dark"] .loc-badge.failed { color: #f87171; }
.loc-map {
  display: block; width: 100%; height: 160px; border: 0; border-radius: 10px; margin-top: .55rem; background: var(--bs-tertiary-bg);
}
@media (max-width: 480px) {
  .loc-box { flex-wrap: wrap; }
  .loc-box > .flex-grow-1 { flex-basis: calc(100% - 38px - .7rem); }
  .loc-box .btn { flex-basis: 100%; }
}
