/* ==========================================================================
   JADIBOT PANEL — style.css
   Prinsip desain: solid colors, clean border, hierarki tipografi.
   TANPA: gradient, glow, neon, glassmorphism, animasi berlebihan.
   Mobile-first; desktop memakai sidebar lewat media query min-width 900px.
   ========================================================================== */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #1f2937;
  --text-dim: #5b6472;
  --text-faint: #8a929e;
  --accent: #1d7a5f;      /* hijau tua — tombol utama */
  --accent-press: #155c47;
  --danger: #b3372f;
  --danger-press: #8f2a24;
  --warn-bg: #fdf3e0;
  --warn-border: #e5c98a;
  --warn-text: #7a5a17;
  --ok-bg: #e5f3ec;
  --ok-border: #b9dcc9;
  --ok-text: #1d6b4c;
  --err-bg: #fbeae9;
  --err-border: #e7b6b2;
  --err-text: #8f2a24;
  --info-bg: #e8effa;
  --info-border: #b9cbe8;
  --info-text: #2c4a7c;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
/* cegah horizontal overflow di layar sempit */
html, body { max-width: 100%; overflow-x: hidden; }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }

/* ---------- layout ---------- */

.layout { min-height: 100vh; }
.sidebar {
  display: none;
}
.content {
  padding: 1rem;
  max-width: 720px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand {
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .01em;
}
.topbar .brand span { color: var(--text-faint); font-weight: 400; }

/* bottom nav mobile */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1;
  text-align: center;
  padding: .6rem 0 .55rem;
  font-size: .72rem;
  color: var(--text-dim);
  text-decoration: none;
  border-top: 2px solid transparent;
}
.tabbar a strong { display: block; font-size: 1.05rem; font-weight: 400; }
.tabbar a.active { color: var(--accent); border-top-color: var(--accent); }
.content { padding-bottom: 5rem; }

/* desktop: sidebar */
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 220px 1fr; }
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 1rem .75rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
    min-height: 100vh;
  }
  .sidebar .brand {
    font-weight: 700;
    padding: .25rem .5rem 1rem;
  }
  .sidebar a {
    display: block;
    padding: .5rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: .92rem;
  }
  .sidebar a:hover { background: var(--bg); color: var(--text); }
  .sidebar a.active { background: var(--ok-bg); color: var(--ok-text); font-weight: 600; }
  .sidebar .spacer { flex: 1; }
  .content { padding: 2rem 2.5rem; max-width: 960px; margin: 0; }
  .tabbar { display: none; }
  .topbar { border: none; background: transparent; position: static; padding: 0 0 1.25rem; }
}

/* ---------- komponen ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}
.card h2, .card h3 { margin-bottom: .75rem; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: .75rem; }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
}
@media (min-width: 720px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem .9rem;
}
.stat .num { font-size: 1.35rem; font-weight: 700; }
.stat .lbl { font-size: .78rem; color: var(--text-dim); }

/* badges status */
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.CONNECTED { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.badge.PAIRING, .badge.CONNECTING { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.badge.RECONNECTING { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.badge.STOPPED, .badge.STOPPING, .badge.FAILED, .badge.REMOVED { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.badge.neutral { background: var(--bg); border-color: var(--border); color: var(--text-dim); }
.badge.self { background: var(--bg); border-color: var(--border-strong); color: var(--text-dim); }
.badge.public { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }

/* form */
label { display: block; font-size: .85rem; font-weight: 600; margin: .75rem 0 .3rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"], select, textarea {
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

/* tombol — touch target >= 44px di mobile */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .55rem 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-press); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:active { background: var(--danger-press); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: .3rem .7rem; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.btn-row .btn { flex: 1 1 auto; }
@media (min-width: 640px) { .btn-row .btn { flex: 0 1 auto; } }

/* banner */
.banner {
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-text);
  padding: .7rem .9rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.banner.info { border-color: var(--info-border); background: var(--info-bg); color: var(--info-text); }
.banner.error { border-color: var(--err-border); background: var(--err-bg); color: var(--err-text); }
.banner.ok { border-color: var(--ok-border); background: var(--ok-bg); color: var(--ok-text); }

/* bot card */
.bot-card .row1 {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
}
.bot-card .number { font-size: 1.15rem; font-weight: 700; font-family: var(--mono); }
.bot-card .meta { color: var(--text-dim); font-size: .85rem; margin-top: .35rem; }
.pairing-code {
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-align: center;
  padding: .9rem;
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin: .75rem 0;
  user-select: all;
}

/* tabel → card/list di mobile */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-dim); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 639px) {
  .table-cards thead { display: none; }
  .table-cards tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem .75rem;
    margin-bottom: .6rem;
    background: var(--surface);
  }
  .table-cards td { display: flex; justify-content: space-between; gap: 1rem; border: none; padding: .25rem 0; }
  .table-cards td::before {
    content: attr(data-lbl);
    color: var(--text-dim);
    font-size: .78rem;
    font-weight: 600;
  }
}

/* log list */
.log-list { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.log-list li {
  display: flex; gap: .75rem; padding: .4rem 0;
  border-bottom: 1px solid var(--border);
}
.log-list time { color: var(--text-faint); font-family: var(--mono); font-size: .78rem; white-space: nowrap; padding-top: .1rem; }
.log-list .who { color: var(--text-dim); }
.log-list pre {
  margin: .25rem 0 0; white-space: pre-wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .4rem .6rem; font-size: .8rem;
  overflow-x: auto;
}

/* toast */
.toast-stack {
  position: fixed;
  left: 50%; bottom: calc(4.6rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 100;
  width: min(92vw, 420px);
}
@media (min-width: 900px) { .toast-stack { bottom: 1.5rem; } }
.toast {
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: .65rem .9rem;
  font-size: .9rem;
  box-shadow: 0 4px 14px rgba(16,24,40,.18);
}
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warn-text); }

/* modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  z-index: 90;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-width: 420px; width: 100%;
  padding: 1.1rem;
}
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

/* donasi */
.qris-box {
  text-align: center;
}
.qris-box img, .qris-box .placeholder {
  max-width: 320px; width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.qris-box .placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 320px; color: var(--text-faint); font-size: .9rem;
}

/* auth page */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { text-align: center; margin-bottom: 1rem; }
.auth-card .brand small { display: block; color: var(--text-dim); font-weight: 400; }
.auth-alt { text-align: center; font-size: .88rem; color: var(--text-dim); margin-top: .9rem; }

.empty {
  text-align: center; color: var(--text-dim);
  padding: 2rem 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty .btn { margin-top: .9rem; }

.muted { color: var(--text-dim); font-size: .85rem; }
.mono { font-family: var(--mono); }
.mt { margin-top: 1rem; }
.section-gap { margin-top: 1.5rem; }
