/* =========================================================
   DummyMail UI
   Font: Plus Jakarta Sans (UI) + JetBrains Mono (alamat & kode)
   Tanpa animasi / transisi.
   ========================================================= */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f5f7f9;
  --ink: #17212b;
  --muted: #667380;
  --line: #dde3e9;
  --accent: #0b7a83;
  --accent-hover: #09656c;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1f2;
  --mark: #ffe27a;
  --danger: #c8372d;
  --danger-soft: #fbe9e7;
  --ok: #1e7b4b;
  --radius-s: 6px;
  --radius-m: 10px;
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, "Courier New", monospace;
  color-scheme: light;
}

body.dark {
  --bg: #0e1316;
  --surface: #151c20;
  --surface-2: #1b242a;
  --ink: #e4eaee;
  --muted: #8c9aa4;
  --line: #26323a;
  --accent: #4cc3cb;
  --accent-hover: #6fd2d8;
  --accent-ink: #06282b;
  --accent-soft: #12343a;
  --mark: #8a6d00;
  --danger: #f07167;
  --danger-soft: #3a1e1c;
  --ok: #5fd39a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mono { font-family: var(--mono); }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark .bg { fill: var(--accent); }
.brand-mark .fg { fill: none; stroke: var(--accent-ink); stroke-width: 2; stroke-linejoin: round; }
.brand-tag { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 20px; }

/* ---------- buttons ---------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border: 0; border-radius: var(--radius-s);
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary.block { width: 100%; height: 44px; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); font-weight: 500; font-size: 13px; white-space: nowrap;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-s); background: none; color: var(--muted);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }

/* ---------- form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); }
.input {
  height: 42px; width: 100%; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.input-affix { display: flex; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); overflow: hidden; }
.input-affix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-affix .input { border: 0; box-shadow: none; min-width: 0; height: 40px; }
.input-affix .affix { display: grid; place-items: center; padding: 0 12px; background: var(--surface-2); color: var(--muted); border-left: 1px solid var(--line); font-family: var(--mono); font-size: 13px; white-space: nowrap; }

/* =========================================================
   LOGIN (user & admin)
   ========================================================= */
body.auth-page { display: grid; place-items: center; min-height: 100%; padding: 24px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 32px;
}
.auth-card .brand { margin-bottom: 28px; }
.auth-card h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.auth-sub { color: var(--muted); margin: 4px 0 24px; }
.auth-sub .mono { color: var(--ink); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form .btn-primary { margin-top: 4px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--muted); }

/* =========================================================
   LAYOUT APLIKASI (sidebar + konten)
   ========================================================= */
body.app-page, .admin-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: 100%; }
body.admin-page { height: 100%; }
.admin-layout { min-height: 100%; }

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px 14px;
}
.sidebar .brand { padding: 0 8px 20px; }

.account { margin: 0 0 20px; padding: 12px; border-radius: var(--radius-m); background: var(--surface-2); }
.account-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.account-row { display: flex; align-items: center; gap: 4px; }
.account-email { font-family: var(--mono); font-size: 12.5px; font-weight: 600; overflow-wrap: break-word; flex: 1; min-width: 0; line-height: 1.45; }
.account .icon-btn { width: 28px; height: 28px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 12px; color: var(--muted); padding: 14px 10px 6px; }
.nav-label:first-child { padding-top: 0; }
.nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: var(--radius-s);
  background: none; font-weight: 500; text-align: left;
}
.nav-btn:hover { background: var(--surface-2); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-btn.danger { color: var(--danger); }
.nav-btn .count {
  margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; text-align: center;
}
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }

.main { min-width: 0; min-height: 0; height: 100%; overflow: hidden; }

/* =========================================================
   INBOX
   ========================================================= */
.mail-view { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); height: 100%; }

.list-pane { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.list-head { padding: 20px 16px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.list-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list-title-row h1 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.head-actions { display: flex; align-items: center; gap: 6px; }
.mobile-account { display: none; align-items: center; gap: 4px; margin-top: -6px; font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--muted); }
.mobile-account span { overflow-wrap: anywhere; }
.search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-2); color: var(--muted); }
.search:focus-within { border-color: var(--accent); background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); }

.msg-list { flex: 1; overflow-y: auto; }
.msg-item { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 12px 16px 12px 28px; border-bottom: 1px solid var(--line); cursor: pointer; }
.msg-item:hover { background: var(--surface-2); }
.msg-item.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.msg-item.unread::before { content: ""; position: absolute; left: 12px; top: 19px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.msg-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.msg-from { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-item.unread .msg-from { color: var(--ink); font-weight: 700; }
.msg-date { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.msg-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-item.unread .msg-subject { font-weight: 600; }
.msg-code { align-self: flex-start; margin-top: 3px; font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 0 6px; border-radius: 4px; background: var(--mark); color: var(--ink); }
body.dark .msg-code { color: #fff5cc; }

.list-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; text-align: center; color: var(--muted); }
.list-empty strong { color: var(--ink); font-weight: 600; }

.pager { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 8px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pager-nav { display: flex; align-items: center; gap: 2px; }
.pager-nav span { min-width: 24px; text-align: center; color: var(--ink); font-weight: 600; }

/* preview */
.preview-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 16px; }
.preview-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); text-align: center; }
.preview-empty .brand-mark { width: 56px; height: 56px; opacity: .25; }
.preview-card { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.preview-toolbar { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.preview-toolbar .spacer { flex: 1; }
.preview-toolbar .back { display: none; }
.preview-head { padding: 22px 24px 18px; }
.preview-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; line-height: 1.35; overflow-wrap: anywhere; margin-bottom: 14px; }
.meta { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.meta dd.mono { font-size: 12px; }

/* kode verifikasi: satu-satunya elemen yang "berani" */
.code-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 0 24px 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface-2);
}
.code-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.code-value {
  font-family: var(--mono); font-size: 30px; font-weight: 600; letter-spacing: .14em; line-height: 1.2;
  background: linear-gradient(transparent 58%, var(--mark) 58%, var(--mark) 92%, transparent 92%);
  padding: 0 4px; overflow-wrap: anywhere;
}
body.dark .code-value { color: #fff; }

.preview-frame { flex: 1; width: 100%; min-height: 200px; border: 0; border-top: 1px solid var(--line); background: #fff; color-scheme: light; }
body.dark .preview-frame { background: var(--surface); }

/* =========================================================
   PENGATURAN & ADMIN (halaman konten)
   ========================================================= */
.page { height: 100%; overflow-y: auto; }
.page-inner { max-width: 1040px; padding: 32px; }
.page-inner.narrow { max-width: 680px; }
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-family: var(--mono); font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 22px 24px; margin-bottom: 20px; }
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card .card-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.form-stack { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.form-stack .btn-primary { align-self: flex-start; margin-top: 4px; }

.info-list { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px 16px; margin: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; overflow-wrap: anywhere; }

/* stats admin */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 20px; }
.stat { padding: 18px 22px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }

.gen-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 14px; align-items: end; }
.gen-row .btn-primary { height: 42px; }
.gen-output { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.gen-output-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.gen-output-head strong { font-weight: 700; }
.gen-output-head div { display: flex; gap: 6px; }
.gen-output textarea { width: 100%; resize: vertical; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-2); font-family: var(--mono); font-size: 13px; line-height: 1.7; outline: none; }
.gen-note { margin-top: 8px; font-size: 12px; color: var(--muted); }
.gen-note b { color: var(--ink); }

.table-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.table-head h2 { margin: 0; }
.table-head .search { width: 280px; max-width: 100%; }
.table-wrap { overflow-x: auto; margin: 0 -24px; }
.acc-table { width: 100%; border-collapse: collapse; }
.acc-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.acc-table td { padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.acc-table th:first-child, .acc-table td:first-child { padding-left: 24px; }
.acc-table th:last-child, .acc-table td:last-child { padding-right: 24px; }
.acc-table tbody tr:hover td { background: var(--surface-2); }
.acc-table td.email { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.acc-table td.muted { color: var(--muted); }
.acc-table .unread-pill { margin-left: 6px; font-size: 12px; font-weight: 600; color: var(--accent); }
.acc-table td.actions { text-align: right; }
.acc-table td.actions .btn-ghost { margin-left: 6px; }
.acc-table td.empty { text-align: center; color: var(--muted); padding: 40px 24px; white-space: normal; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; font-size: 13px; color: var(--muted); }
.table-foot div { display: flex; gap: 6px; }

/* =========================================================
   TOAST (tanpa animasi, hilang otomatis 3 detik via JS)
   ========================================================= */
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  display: none; align-items: center; gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: var(--radius-s);
  background: var(--ink); color: var(--bg); font-weight: 500;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}
.toast.show { display: flex; }
.toast.success { background: var(--ok); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
body.dark .toast.success, body.dark .toast.error { color: #0e1316; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1100px) {
  body.app-page, .admin-layout { grid-template-columns: 216px minmax(0, 1fr); }
  .mail-view { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
}

@media (max-width: 860px) {
  body.app-page, .admin-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { flex-direction: row; align-items: center; gap: 4px; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .sidebar .brand { padding: 0 6px 0 0; }
  .sidebar .brand span:not(.brand-tag) { display: none; }
  .sidebar .account, .nav-label { display: none; }
  .nav, .sidebar-foot { flex-direction: row; gap: 2px; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .nav-btn { width: auto; padding: 8px 10px; white-space: nowrap; }
  .nav-btn > span:not(.count) { display: none; }
  .nav-btn { padding: 8px; }
  .mobile-account { display: flex; }

  .mail-view { grid-template-columns: 1fr; }
  .mail-view .preview-pane { display: none; padding: 0; }
  .mail-view.show-preview .preview-pane { display: flex; }
  .mail-view.show-preview .list-pane { display: none; }
  .preview-card { border: 0; border-radius: 0; }
  .preview-toolbar .back { display: inline-flex; }
  .preview-toolbar .label { display: none; }
  .preview-head { padding: 18px 16px 14px; }
  .code-card { margin: 0 16px 14px; }

  .page-inner { padding: 20px 16px; }
  .stats { grid-template-columns: 1fr; }
  .stat { border-left: 0; border-top: 1px solid var(--line); }
  .stat:first-child { border-top: 0; }
  .gen-row { grid-template-columns: 1fr; }
  .info-list { grid-template-columns: 1fr; gap: 2px; }
  .info-list dd { margin-bottom: 10px; }
  .card { padding: 18px 16px; }
  .table-wrap { margin: 0 -16px; }
  .acc-table th:first-child, .acc-table td:first-child { padding-left: 16px; }
  .acc-table th:last-child, .acc-table td:last-child { padding-right: 16px; }
}
