/* ============================================================
   SMS Gateway Admin — design system (PancakeSwap CAKE-style)
   Token resmi: pancake-uikit (dark + light)
   dark : bg #08060B · card #27262C · input #372F47 · text #F4EEFF
   light: bg #FAF9FA · card #FFFFFF  · input #EEEAF4 · text #280D5F
   primary #1FC7D4 · success #31D0AA · failure(pink) #ED4B9E
   warning #FFB237 · radius 16/24px · font Kanit
   Tema di-switch via <html data-theme="dark|light"> (lihat app.js).
   ============================================================ */
:root {
  --bg: #08060b;
  --bg-panel: #27262c;      /* backgroundAlt = card */
  --bg-elev: #1e1d20;       /* dropdown */
  --bg-deep: #100c18;       /* dropdownDeep */
  --bg-hover: rgba(244, 238, 255, .05);
  --border: #383241;        /* cardBorder */
  --border-2: #453f52;
  --border-3: #524b63;
  --text: #f4eeff;
  --text-2: #b8add2;        /* textSubtle */
  --text-3: #8d8494;
  --blue: #1fc7d4;          /* primary */
  --blue-btn: #1fc7d4;
  --blue-hover: #53dee9;    /* primaryBright */
  --green: #31d0aa;
  --green-fg: #31d0aa;
  --red: #ed4b9e;           /* failure = pink CAKE */
  --red-fg: #ed4b9e;
  --amber: #ffb237;
  --amber-fg: #ffb237;
  --purple: #9a6aff;        /* secondary (dark) */
  --contrast: #191326;      /* invertedContrast — teks di atas tombol cyan */
  --radius: 24px;           /* radii.card */
  --radius-sm: 16px;        /* radii.default */
  --shadow-card: 0px 2px 12px -8px rgba(25, 19, 38, .1), 0px 1px 1px rgba(25, 19, 38, .05);
  --shadow-btn: inset 0px -2px 0px rgba(25, 19, 38, .25);
  --focus-ring: 0 0 0 1px var(--blue), 0 0 0 4px rgba(31, 199, 212, .25);
  --page-bg:
    radial-gradient(900px 440px at 50% -100px, rgba(118, 69, 217, .22), transparent 65%),
    radial-gradient(700px 400px at 88% -120px, rgba(31, 199, 212, .10), transparent 60%),
    var(--bg);
  --topbar-bg: rgba(8, 6, 11, .75);
  --overlay: rgba(8, 6, 11, .78);
  --input-bg: #372f47;
  --input-focus-bg: #3d3450;
  --tertiary: #353547;
  --row-border: rgba(56, 50, 65, .55);
  --skeleton-a: #1e1d20;
  --skeleton-b: #27262c;
  --shadow-pop: 0 8px 30px rgba(0, 0, 0, .55);
  --chart-grid: #383241;
  --chart-label: #8d8494;
  --ghost-hover: brightness(1.2);
  --ghost-active: brightness(.85);
  --font: "Kanit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;
  --sidebar-w: 232px;
  --topbar-h: 64px;
}

/* ---------- Light theme (token resmi pancake-uikit light) ---------- */
:root[data-theme="light"] {
  --bg: #faf9fa;
  --bg-panel: #ffffff;      /* backgroundAlt */
  --bg-elev: #f6f6f6;       /* dropdown */
  --bg-deep: #eeeeee;       /* dropdownDeep */
  --bg-hover: rgba(40, 13, 95, .05);
  --border: #e7e3eb;        /* cardBorder */
  --border-2: #d8d0e4;
  --border-3: #bdc2c4;      /* textDisabled */
  --text: #280d5f;
  --text-2: #7a6eaa;        /* textSubtle */
  --text-3: #bdc2c4;
  --blue-hover: #0098a1;    /* primaryDark — kontras di atas terang */
  --purple: #7645d9;        /* secondary (light) */
  --contrast: #ffffff;      /* invertedContrast light */
  --page-bg:
    radial-gradient(900px 440px at 50% -100px, rgba(118, 69, 217, .08), transparent 65%),
    var(--bg);
  --topbar-bg: rgba(255, 255, 255, .8);
  --overlay: rgba(25, 19, 38, .45);
  --input-bg: #eeeaf4;
  --input-focus-bg: #f3effa;
  --tertiary: #eff4f5;
  --row-border: #e7e3eb;
  --skeleton-a: #f6f6f6;
  --skeleton-b: #eeeeee;
  --shadow-pop: 0px 0px 2px rgba(0, 0, 0, .2), 0px 4px 12px -8px rgba(14, 14, 44, .1);
  --chart-grid: #e7e3eb;
  --chart-label: #7a6eaa;
  --ghost-hover: brightness(.97);
  --ghost-active: brightness(.92);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--page-bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(31, 199, 212, .35); }

a { color: var(--blue); text-decoration: none; transition: color .12s; }
a:hover { color: var(--blue-hover); text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 8px; }

/* ---------- Theme toggle (floating, ala PancakeSwap) ---------- */
.theme-toggle {
  position: fixed;
  left: 16px;
  bottom: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter .12s, transform .06s;
}
.theme-toggle:hover { filter: brightness(1.1); }
.theme-toggle:active { transform: translateY(1px); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: transparent;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 32px;
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 12px; font-size: 46px; line-height: 1; }
.login-logo svg { display: none; }
.login-logo::before { content: "🐰"; }
.login-title { font-size: 22px; font-weight: 700; text-align: center; letter-spacing: .01em; }
.login-sub { color: var(--text-2); text-align: center; margin: 4px 0 24px; }
.login-error {
  display: none;
  background: rgba(237, 75, 158, .12);
  border: 1px solid rgba(237, 75, 158, .45);
  color: var(--red-fg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.login-error.show { display: block; }
.login-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
}
.login-hint code { font-family: var(--mono); color: var(--text-2); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  inset: 0 auto 0 0;
  background: transparent;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}
.brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--text);
  font-size: 15px;
}
.brand svg { display: none; }
.brand::before { content: "🐰"; font-size: 22px; line-height: 1; }
.brand span { flex: none; }

.nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  padding: 12px 10px 6px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 2px 0;
  border-radius: 14px;
  color: var(--text-2);
  font-size: 14px;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--bg-elev); color: var(--blue); font-weight: 500; }
.nav a svg { flex: none; opacity: .9; }
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px;
}

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; }
.breadcrumb strong { color: var(--text); font-weight: 600; }
.userchip { display: flex; align-items: center; gap: 10px; }
.userchip .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--input-bg);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.userchip .meta { text-align: right; line-height: 1.25; }
.userchip .meta .name { font-size: 13px; }
.userchip .meta .role { font-size: 11px; color: var(--text-3); }

.content { padding: 32px; max-width: 1160px; width: 100%; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: .01em; }
.page-head .desc { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; }

/* ---------- Cards / stats ---------- */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-title .sub { color: var(--text-3); font-weight: 400; font-size: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
}
.stat .label { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: .01em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.stat .value.c-green { color: var(--green-fg); }
.stat .value.c-red { color: var(--red-fg); }
.stat .value.c-amber { color: var(--amber-fg); }
.stat .value.c-blue { color: var(--blue); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Buttons (CAKE: pill + efek 3D inset) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .12s, background .12s, border-color .12s, color .12s, transform .06s, box-shadow .06s;
  white-space: nowrap;
  background: transparent;
  color: var(--text);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary, .btn-blue {
  background: var(--blue-btn);
  color: var(--contrast);
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover:not(:disabled), .btn-blue:hover:not(:disabled) { filter: brightness(1.12); }
.btn-primary:active:not(:disabled), .btn-blue:active:not(:disabled) {
  filter: brightness(.88);
  transform: translateY(1px);
  box-shadow: none;
}
.btn-ghost {
  background: var(--bg-elev);
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--shadow-btn);
}
.btn-ghost:hover:not(:disabled) { filter: var(--ghost-hover); border-color: var(--border-2); }
.btn-ghost:active:not(:disabled) { filter: var(--ghost-active); transform: translateY(1px); box-shadow: none; }
.btn-danger {
  background: transparent;
  border: 2px solid var(--red);
  color: var(--red-fg);
}
.btn-danger:hover:not(:disabled) { background: rgba(237, 75, 158, .12); }
.btn-danger:active:not(:disabled) { transform: translateY(1px); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; border-radius: 12px; }
.btn-block { width: 100%; height: 46px; font-size: 15px; }

/* ---------- Forms (CAKE: input terisi, tanpa outline) ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.input, .select, textarea.input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 0 14px;
  height: 40px;
  outline: none;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
textarea.input { height: auto; padding: 12px 14px; resize: vertical; min-height: 84px; }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--blue);
  background: var(--input-focus-bg);
  box-shadow: var(--focus-ring);
}
.input::placeholder { color: var(--text-3); }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a6eaa' stroke-width='2.4'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; user-select: none; }
.checkbox input { accent-color: var(--blue); width: 16px; height: 16px; cursor: pointer; }

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}
.filter-bar .field { margin-bottom: 0; }
.filter-bar .input, .filter-bar .select { width: auto; min-width: 130px; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow-card);
}
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td { padding: 12px 16px; border-top: 1px solid var(--row-border); vertical-align: middle; }
.tbl tr:first-child td { border-top: none; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--bg-hover); }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl .mono { font-family: var(--mono); font-size: 12.5px; }
.tbl .muted { color: var(--text-2); }
.tbl .faint { color: var(--text-3); }
.tbl .msg { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .actions { display: flex; gap: 6px; justify-content: flex-end; }
.tbl td.right, .tbl th.right { text-align: right; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12.5px;
}
.table-foot .pager { display: flex; gap: 6px; }

/* ---------- Pills / badges (CAKE: soft background) ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  border: none;
  background: var(--tertiary);
  color: var(--text);
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); flex: none; }
.pill.p-green { background: rgba(49, 208, 170, .16); color: var(--green-fg); }
.pill.p-green .dot { background: var(--green-fg); }
.pill.p-red { background: rgba(237, 75, 158, .16); color: var(--red-fg); }
.pill.p-red .dot { background: var(--red-fg); }
.pill.p-amber { background: rgba(255, 178, 55, .16); color: var(--amber-fg); }
.pill.p-amber .dot { background: var(--amber-fg); }
.pill.p-blue { background: rgba(31, 199, 212, .16); color: var(--blue); }
.pill.p-blue .dot { background: var(--blue); }

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ---------- Progress ---------- */
.progress { position: relative; width: 120px; height: 8px; background: var(--tertiary); border-radius: 999px; overflow: hidden; }
.progress .fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #1fc7d4, #53dee9); border-radius: 999px; }
.progress .fill.warn { background: var(--amber); }
.progress .fill.crit { background: var(--red); }

/* ---------- Key/value ---------- */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; font-size: 13.5px; }
.kv .k { color: var(--text-2); }
.kv .v { font-variant-numeric: tabular-nums; word-break: break-all; }
.code-line {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
}
.code-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 24px 24px;
  z-index: 100;
  animation: fadeIn .12s ease;
}
.modal {
  width: 100%;
  max-width: 460px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
  animation: slideUp .16s ease;
}
.modal h3 { font-size: 17px; font-weight: 600; letter-spacing: .01em; margin-bottom: 18px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  min-width: 240px;
  max-width: 380px;
  box-shadow: var(--shadow-pop);
  animation: slideUp .15s ease;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.toast .t-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.toast.ok .t-dot { background: var(--green-fg); }
.toast.err .t-dot { background: var(--red-fg); }
.toast.info .t-dot { background: var(--blue); }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); font-size: 13.5px; }
.empty::before { content: "🐰"; display: block; font-size: 30px; margin-bottom: 10px; }
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
.skeleton {
  background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 50%, var(--skeleton-a) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
  height: 14px;
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border-3);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--blue);
  background: rgba(31, 199, 212, .06);
  color: var(--text);
}
.dropzone .file-name { color: var(--blue); font-family: var(--mono); font-size: 12.5px; margin-top: 6px; }
.dropzone input[type="file"] { display: none; }

.notice {
  border: 1px solid rgba(31, 199, 212, .35);
  background: rgba(31, 199, 212, .08);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 12.5px;
  margin-bottom: 16px;
}

.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.chart-legend .l { display: flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 10px; height: 10px; border-radius: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
}
