/* ===== Panel Admin — King Mamat ===== */

/* Layout — pakai .dash-body dari style.css, override hanya apa yang perlu */
.admin-denied {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: url("../images/hero-bg.png") center/cover no-repeat, var(--bg-deep);
}
.admin-denied[hidden] {
  display: none;
}

.admin-denied-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
}

.admin-app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.admin-app[hidden] {
  display: none;
}

/* ===== Toolbar ===== */
.admin-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.admin-toolbar input[type="text"] {
  flex: 1;
  min-width: 160px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--panel-line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.admin-toolbar input[type="text"]:focus {
  border-color: var(--accent);
}

.admin-toolbar select {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.admin-toolbar input[type="text"] {
  flex: 1;
  min-width: 160px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--panel-line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.admin-toolbar input[type="text"]:focus {
  border-color: var(--accent);
}
.admin-add-btn {
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid rgba(122,168,255,0.35);
  background: linear-gradient(135deg, rgba(122,168,255,0.16), rgba(122,168,255,0.06));
  color: #bcd3ff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}
.admin-add-btn:hover {
  background: linear-gradient(135deg, rgba(122,168,255,0.28), rgba(122,168,255,0.1));
  color: #fff;
  transform: translateY(-1px);
}
.admin-add-btn:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

/* Indikator sinkronisasi DB di toolbar katalog */
.prd-sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--panel-line);
  background: var(--bg-elev);
  color: var(--muted);
  white-space: nowrap;
}
.prd-sync-status .prd-sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.prd-sync-status[data-state="on"] { color: #7ee0a3; border-color: rgba(126,224,163,0.4); }
.prd-sync-status[data-state="on"] .prd-sync-dot { background: #3ecf7a; box-shadow: 0 0 6px rgba(62,207,122,0.8); }
.prd-sync-status[data-state="pending"] { color: #ffd97a; border-color: rgba(255,217,122,0.4); }
.prd-sync-status[data-state="pending"] .prd-sync-dot { background: #ffcc4d; box-shadow: 0 0 6px rgba(255,204,77,0.8); }
.prd-sync-status[data-state="off"] { color: #ff8f8f; border-color: rgba(255,143,143,0.4); }
.prd-sync-status[data-state="off"] .prd-sync-dot { background: #ff5c5c; box-shadow: 0 0 6px rgba(255,92,92,0.8); }

/* Dot sinkron per baris di kolom Aksi */
.prd-row-sync {
  margin-left: 8px;
  font-size: 11px;
  cursor: help;
  user-select: none;
}
.prd-row-sync.is-on { color: #3ecf7a; }
.prd-row-sync.is-pending { color: #ffcc4d; }

/* ===== Tabel ===== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--panel-line);
}
.admin-table tbody tr {
  border-bottom: 1px solid var(--panel-line);
  transition: background 0.15s;
}
.admin-table tbody tr:hover {
  background: rgba(122,168,255,0.04);
}
.admin-table td {
  padding: 12px;
  vertical-align: middle;
}

.th-actions {
  text-align: right !important;
}

.admin-user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.role-badge-x {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.role-badge-x[data-role="buyer"] {
  background: rgba(100,200,150,0.12);
  color: #7de8a8;
  border-color: rgba(100,200,150,0.3);
}
.role-badge-x[data-role="reseller"] {
  background: rgba(122,168,255,0.12);
  color: #9ac4ff;
  border-color: rgba(122,168,255,0.3);
}
.role-badge-x[data-role="admin"] {
  background: rgba(255,140,100,0.12);
  color: #ffb088;
  border-color: rgba(255,140,100,0.3);
}
.role-badge-x:hover {
  transform: scale(1.04);
  filter: brightness(1.2);
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7de8a8;
}
.status-dot.is-off::before {
  background: #ff9090;
}

/* Toggle status (bisa diklik di tabel) */
.status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid transparent;
  background: rgba(125,232,168,0.1);
  color: #7de8a8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}
.status-toggle .status-dot { gap: 5px; font-size: 0; }
.status-toggle .status-dot::before { content: ""; }
.status-toggle .status-text { font-size: 12px; }
.status-toggle.is-off {
  background: rgba(255,144,144,0.1);
  color: #ff9090;
}
.status-toggle.is-off .status-dot::before { background: #ff9090; }
.status-toggle:hover { filter: brightness(1.15); }

/* Tombol kelola user (P / N / hapus) */
.th-actions { white-space: nowrap; }
.th-actions .admin-edit-btn,
.th-actions .admin-del-btn {
  margin-left: 6px;
  width: 30px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--panel-line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s;
}
.th-actions .admin-edit-btn:hover {
  background: rgba(122,168,255,0.18);
  border-color: rgba(122,168,255,0.5);
  color: #bcd3ff;
}
.th-actions .admin-del-btn {
  background: rgba(255,100,100,0.08);
  border-color: rgba(255,100,100,0.25);
  color: #ff9090;
}
.th-actions .admin-del-btn:hover {
  background: rgba(255,100,100,0.2);
  border-color: rgba(255,100,100,0.45);
}

.admin-table-empty {
  text-align: center;
  color: var(--muted);
  padding: 32px;
  font-size: 14px;
}

/* ===== Modal ===== */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(5,8,17,0.85);
}
.admin-modal-overlay[hidden] {
  display: none;
}

.admin-modal {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 28px 26px;
  position: relative;
}
.admin-modal h3 {
  font-size: 17px;
  margin-bottom: 18px;
}
.admin-modal .field {
  margin-bottom: 14px;
}
.admin-modal select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.admin-role-target {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}
.admin-role-target strong {
  color: var(--text);
}

.admin-modal .btn-primary {
  width: 100%;
  margin-top: 8px;
}

/* ===== Orders view ===== */
.admin-orders-note {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  padding: 10px 14px;
  background: rgba(122,168,255,0.06);
  border: 1px solid rgba(122,168,255,0.15);
  border-radius: 8px;
}

.admin-orders-table .admin-order-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}
.admin-order-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.admin-order-price {
  font-weight: 600;
  color: var(--text);
}
.admin-order-ref {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.admin-order-note {
  font-size: 11px;
  color: #ffaa5a;
  font-style: italic;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-order-date {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
}

/* Status badge di kolom tanggal (reuse definisi dari style.css) */
.admin-order-date .status-badge {
  font-size: 10px;
  padding: 3px 9px;
}

.btn-order-del {
  background: rgba(255,100,100,0.1);
  color: #ff9090;
  border: 1px solid rgba(255,100,100,0.25);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-order-del:hover {
  background: rgba(255,100,100,0.2);
  border-color: rgba(255,100,100,0.4);
}
.btn-order-edit {
  background: rgba(122,168,255,0.1);
  color: #9ac4ff;
  border: 1px solid rgba(122,168,255,0.3);
  border-radius: 6px;
  padding: 5px 12px;
  margin-right: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-order-edit:hover {
  background: rgba(122,168,255,0.24);
  border-color: rgba(122,168,255,0.5);
  color: #bcd3ff;
}

/* ===== Modal ubah order ===== */
#ord-edit-overlay .admin-modal {
  max-width: 440px;
}
.ord-edit-statuses {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}
.ord-edit-statuses label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-line);
  background: var(--bg-elev);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.ord-edit-statuses input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}
.ord-edit-statuses label:has(input:checked) {
  border-color: rgba(122,168,255,0.5);
  background: rgba(122,168,255,0.12);
}

/* ---- Saldo User ---- */
.bal-amount {
  font-weight: 700;
  color: #6ee7a8;
}
.btn-balance-add {
  background: rgba(110,231,168,0.12);
  color: #6ee7a8;
  border: 1px solid rgba(110,231,168,0.3);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-balance-add:hover {
  background: rgba(110,231,168,0.22);
  border-color: rgba(110,231,168,0.5);
}
.bal-modal-preview {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 0;
}
.bal-modal-preview strong {
  color: #6ee7a8;
}

/* ===== Katalog Produk ===== */
.admin-table code {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(122,168,255,0.1);
  padding: 2px 8px;
  border-radius: 5px;
}

/* Badge stok */
.stok-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.stok-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.stok-badge.stok-ada {
  background: rgba(100,220,140,0.14);
  color: #7de8a8;
  border: 1px solid rgba(100,220,140,0.3);
}
.stok-badge.stok-ada::before { background: #7de8a8; }
.stok-badge.stok-habis {
  background: rgba(255,100,100,0.12);
  color: #ff9090;
  border: 1px solid rgba(255,100,100,0.3);
}
.stok-badge.stok-habis::before { background: #ff9090; }

/* Tag channel */
.prd-chan-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.prd-chan-tag.prd-chan-rdp {
  background: rgba(122,168,255,0.14);
  color: #9ac4ff;
  border: 1px solid rgba(122,168,255,0.3);
}
.prd-chan-tag.prd-chan-other {
  background: rgba(255,180,100,0.14);
  color: #ffb088;
  border: 1px solid rgba(255,180,100,0.3);
}

/* Status on/off */
.prd-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.prd-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.prd-status-on {
  color: #7de8a8;
}
.prd-status-on::before { background: #7de8a8; }
.prd-status-off {
  color: var(--muted);
}
.prd-status-off::before { background: var(--muted); }

/* Layout field row 2 kolom di modal produk */
.prd-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.prd-field-row .field {
  margin-bottom: 0;
}

/* Label "Aktif" checkbox */
.prd-active-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.prd-active-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Modal produk — lebih lebar karena form 2 kolom */
#prd-modal-overlay .admin-modal {
  max-width: 440px;
}

/* ===== Command log (riwayat perintah admin) ===== */
.admin-cmdlog {
  margin-top: 22px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  padding: 18px 20px;
}
.admin-cmdlog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.admin-cmdlog-head h3 {
  font-size: 14px;
  margin: 0;
  color: var(--text);
}
.admin-cmdlog-clear {
  padding: 5px 12px;
  border-radius: 7px;
  border: 1px solid var(--panel-line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.16s;
}
.admin-cmdlog-clear:hover {
  color: var(--text);
  border-color: var(--text);
}
.admin-cmdlog-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.admin-cmdlog-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--panel-line);
}
.cmd-badge {
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cmd-badge-role { background: rgba(255,140,100,0.15); color: #ffb088; }
.cmd-badge-status { background: rgba(125,232,168,0.15); color: #7de8a8; }
.cmd-badge-password { background: rgba(122,168,255,0.15); color: #9ac4ff; }
.cmd-badge-rename { background: rgba(154,196,255,0.15); color: #9ac4ff; }
.cmd-badge-tambah { background: rgba(189,211,255,0.15); color: #bcd3ff; }
.cmd-badge-hapus { background: rgba(255,100,100,0.15); color: #ff9090; }
.cmd-badge-katalog { background: rgba(189,211,255,0.15); color: #bcd3ff; }
.cmd-badge-saldo { background: rgba(110,231,168,0.15); color: #6ee7a8; }
.cmd-target { color: var(--text); font-weight: 600; }
.cmd-detail { color: var(--muted); flex: 1; }
.cmd-meta { color: var(--muted); font-size: 11px; }

/* ===== Responsive ===== */
/* Table overflow — semua tabel admin scroll horizontal di mobile */
.admin-table {
  min-width: 640px;
}
.dash-main .dash-view {
  overflow-x: auto;
}
.admin-table th,
.admin-table td {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .admin-app {
    grid-template-columns: 1fr;
  }
  .admin-app .dash-sidebar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--panel-line);
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .admin-app .dash-sidebar .brand {
    display: none;
  }
  .admin-app .dash-nav {
    display: flex;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .admin-app .dash-nav::-webkit-scrollbar {
    display: none;
  }
  .admin-app .dash-nav-link {
    white-space: nowrap;
    padding: 7px 11px;
    font-size: 14px;
  }
  .admin-app .dash-user {
    margin-left: auto;
    flex-shrink: 0;
  }
  .admin-app .dash-user-meta {
    display: none;
  }
}

/* ===== Notifikasi toast ===== */
.admin-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast-item {
  pointer-events: auto;
  min-width: 260px;
  max-width: 400px;
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  background: #0f172a;
  color: #f1f5f9;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  border-left: 4px solid #64748b;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast-item.visible {
  opacity: 1;
  transform: translateY(0);
}
.toast-item.success { border-left-color: #22c55e; }
.toast-item.error   { border-left-color: #ef4444; }
.toast-item.info    { border-left-color: #3b82f6; }
.toast-item-title {
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.toast-item.success .toast-item-title { color: #4ade80; }
.toast-item.error .toast-item-title   { color: #f87171; }
.toast-item.info .toast-item-title    { color: #60a5fa; }
