/* SECURECHAT Admin - warna mengikuti aplikasi (hijau gaya WhatsApp). */
:root {
  --accent: #1DAB61;
  --accent-strong: #148A4C;
  --accent-soft: #E7F8EE;
  --header: #0B5C3A;
  --bg: #F0F2F5;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --text: #111B21;
  --muted: #667781;
  --border: #E2E6EA;
  --danger: #D93F3F;
  --danger-soft: #FDECEC;
  --warn-soft: #FFF6DB;
  --warn-text: #7A5A00;
  --shadow: 0 1px 2px rgba(11, 20, 26, .06), 0 4px 16px rgba(11, 20, 26, .06);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #21C063;
    --accent-strong: #3DD47C;
    --accent-soft: #123524;
    --header: #111B21;
    --bg: #0B141A;
    --surface: #111B21;
    --surface-2: #182229;
    --text: #E9EDEF;
    --muted: #8696A0;
    --border: #233138;
    --danger: #F15C5C;
    --danger-soft: #3A1D1D;
    --warn-soft: #3A3218;
    --warn-text: #F2D27A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; text-align: center; letter-spacing: .04em; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

.muted { color: var(--muted); margin: 4px 0 0; }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Tombol & input ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.block { width: 100%; padding: 11px 16px; font-size: 15px; }
.btn.on-dark { background: transparent; border-color: rgba(255, 255, 255, .35); color: #fff; }
.btn.on-dark:hover { background: rgba(255, 255, 255, .12); }

input[type="text"], input[type="password"], input[type="search"], input:not([type]) {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input::placeholder { color: var(--muted); }

.field { display: block; margin-top: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; font-weight: 400; }

.input-group { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.input-group:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.input-group input { border: 0; border-radius: 0; min-width: 0; }
.input-group input:focus-visible { outline: none; }
.input-group .affix { display: flex; align-items: center; padding: 0 10px; color: var(--muted); background: var(--surface-2); font-size: 14px; white-space: nowrap; }
.input-group .affix:first-child { border-radius: 10px 0 0 10px; border-right: 1px solid var(--border); }
.input-group .affix:last-child { border-radius: 0 10px 10px 0; border-left: 1px solid var(--border); }
.input-group .btn { border-radius: 0; border: 0; border-left: 1px solid var(--border); }
.input-group .btn:last-child { border-radius: 0 10px 10px 0; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

.alert { border-radius: 10px; padding: 10px 12px; margin: 14px 0 0; font-size: 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn-text); }
.alert.ok { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; padding: 28px 24px 22px; }
.login-card .btn.block { margin-top: 18px; }
.login-card .small { margin-top: 14px; }
.brand-mark {
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 50%; background: var(--accent);
  display: grid; place-items: center;
}
.brand-mark svg { width: 32px; height: 32px; fill: #fff; }

/* ---------- Header ---------- */
.topbar { background: var(--header); color: #fff; }
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: #3DD47C; box-shadow: 0 0 0 3px rgba(61, 212, 124, .25); }
.brand-sub { font-weight: 400; opacity: .75; }
.me { display: flex; align-items: center; gap: 12px; min-width: 0; }
.me-id { opacity: .85; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Halaman ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.stat { padding: 14px 16px; }
.stat .num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type="search"] { flex: 1 1 260px; border-radius: 999px; padding-left: 16px; }

.table-card { overflow: hidden; }
table.users { width: 100%; border-collapse: collapse; }
.users th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.users th.right { text-align: right; }
.users td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users tr:last-child td { border-bottom: 0; }
.users tr.inactive td { opacity: .6; }
.users tr.inactive td.actions { opacity: 1; }

.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--accent);
  text-transform: uppercase;
}
.who-text { min-width: 0; }
.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-id { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you { font-size: 11px; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft); border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: 1px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.badge.admin { background: #E8F0FE; color: #1A56DB; }
.badge.user { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.active { background: var(--accent-soft); color: var(--accent-strong); }
.badge.inactive { background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .badge.admin { background: #172B4D; color: #8AB4F8; }
}

.actions { text-align: right; }
.actions-inner { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; margin: 0; }

/* ---------- Dialog ---------- */
dialog {
  border: 0; padding: 0; border-radius: 16px; width: min(460px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(11, 20, 26, .55); }
.dlg { padding: 22px 22px 18px; }
.dlg p { margin: 10px 0 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.cred {
  margin: 14px 0 0; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border);
  font: 14px/1.6 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap; word-break: break-word; user-select: all;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #111B21; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }

.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* ---------- HP / layar sempit ---------- */
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .me-id { display: none; }
  .page-head .btn { width: 100%; }
  .users thead { display: none; }
  .users, .users tbody, .users tr, .users td { display: block; width: 100%; }
  .users tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .users tr:last-child { border-bottom: 0; }
  .users td { border: 0; padding: 4px 0; }
  .users td[data-label]:not(.cell-user)::before {
    content: attr(data-label); display: inline-block; min-width: 72px; color: var(--muted); font-size: 13px;
  }
  .actions { text-align: left; padding-top: 10px !important; }
  .actions-inner { justify-content: flex-start; }
}
