/* ============================================================
   ProjectQ Panel — Unified Professional Theme (SPA & Embed Login)
   ============================================================ */

:root {
  --brand: #16456d;
  --brand-dark: #16456d;
  --brand-light: #eef2ff;
  --bg-main: #f8fafc;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #dc2626;
  --ok: #059669;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.1);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.spacer { flex: 1; }

/* ---------------- 1. Center Screen & Auth Page ---------------- */

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: 
    radial-gradient(circle at 10% 20%, rgba(40, 31, 224, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(124, 58, 237, 0.05) 0%, transparent 40%),
    linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand) 0%, #6366f1 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(40, 31, 224, 0.3);
  flex-shrink: 0;
}

.auth-brand strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.auth-brand span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.auth-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tabs button.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}

/* ---------------- 2. Embed Login Mandiri (.toko-auth) Terintegrasi ---------------- */

.toko-auth {
  box-sizing: border-box;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  font-size: 14px;
  text-align: left;
}

.toko-auth *,
.toko-auth *::before,
.toko-auth *::after {
  box-sizing: border-box;
}

.toko-auth .ta-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.toko-auth .ta-logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand), #16456d);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.toko-auth .ta-brand-text strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.toko-auth .ta-brand-text span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.toko-auth .ta-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.toko-auth .ta-tabs button {
  flex: 1;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toko-auth .ta-tabs button:hover { color: var(--ink); }
.toko-auth .ta-tabs button.active {
  background: #fff;
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}

.toko-auth .ta-field { margin-bottom: 14px; }
.toko-auth .ta-field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
}

.toko-auth .ta-field > input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.toko-auth .ta-field > input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(40, 31, 224, 0.12);
}

.toko-auth .ta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toko-auth .ta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.06s;
}

.toko-auth .ta-btn:hover:not(:disabled) { background: var(--brand-dark); }
.toko-auth .ta-btn:active:not(:disabled) { transform: translateY(1px); }
.toko-auth .ta-btn:disabled { opacity: 0.65; cursor: not-allowed; }

.toko-auth .ta-btn.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.toko-auth .ta-btn.ghost:hover:not(:disabled) { background: var(--bg-main); }

.toko-auth .ta-btn.danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #fecaca;
}
.toko-auth .ta-btn.danger:hover:not(:disabled) { background: #fef2f2; }

.toko-auth .ta-alert {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  border: 1px solid;
}
.toko-auth .ta-alert.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.toko-auth .ta-alert.ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.toko-auth .ta-hint {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.toko-auth .ta-member { text-align: center; }
.toko-auth .ta-avatar {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #16456d);
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
}
.toko-auth .ta-member h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
}
.toko-auth .ta-member p {
  margin: 0 0 16px;
  font-size: 0.82rem;
  color: var(--muted);
}
.toko-auth .ta-badge {
  display: inline-block;
  margin-bottom: 16px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}
.toko-auth .ta-badge.admin { background: #eef2ff; color: #16456d; }
.toko-auth .ta-badge.user { background: #ecfdf5; color: #047857; }
.toko-auth .ta-actions { display: grid; gap: 8px; }

.toko-auth .ta-loading {
  padding: 20px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}
.toko-auth .ta-spin {
  width: 24px;
  height: 24px;
  margin: 0 auto 8px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: ta-spin 0.7s linear infinite;
}
@keyframes ta-spin { to { transform: rotate(360deg); } }

.toko-auth-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  z-index: 2147483000;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toko-auth-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toko-auth-toast.ok { background: var(--ok); }
.toko-auth-toast.err { background: var(--danger); }

/* ---------------- 3. Layout Aplikasi Utama (Shell & Sidebar) ---------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar .brand {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 16px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}

.nav-item:hover { background: #f1f5f9; color: var(--brand); }
.nav-item.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--line); background: #fafafa; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-chip .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem;
}
.user-chip .meta { overflow: hidden; }
.user-chip .meta strong { display: block; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta span { display: block; font-size: 0.75rem; color: var(--muted); text-transform: capitalize; }

.main { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 1.25rem; font-weight: 700; }
.content { padding: 28px; flex: 1; }

/* ---------------- 4. Komponen Global & Tabel ---------------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="url"],
select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.9rem;
  color: var(--ink); background: var(--surface);
  transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(40, 31, 224, 0.12);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-pad { padding: 20px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.product-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.product-thumb { height: 160px; background-color: #f1f5f9; background-position: center; background-size: cover; display: grid; place-items: center; font-size: 2rem; }
.product-body { padding: 16px; display: flex; flex-direction: column; flex: 1; }
.product-body h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 4px; }
.product-body .desc { font-size: 0.8rem; color: var(--muted); margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-body .price { font-weight: 700; font-size: 1.05rem; color: var(--brand); margin-top: auto; }
.product-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.88rem; }
th { background: #f8fafc; padding: 12px 16px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
td { padding: 14px 16px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
td .sub { display: block; font-size: 0.75rem; color: var(--muted); }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-warn { background: #fef9c3; color: #a16207; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0e7ff; color: #16456d; }
.badge-neutral { background: #f1f5f9; color: #475569; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease; text-decoration: none; gap: 6px;
}
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-soft { background: var(--brand-light); color: var(--brand); }
.btn-soft:hover:not(:disabled) { background: #e0e7ff; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover:not(:disabled) { background: #fecaca; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px);
  z-index: 100; display: grid; place-items: center; padding: 20px;
}
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 500px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--line); background: #fafafa; display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: var(--radius-md);
  background: var(--ink); color: #fff; font-size: 0.88rem; font-weight: 500; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px); transition: all 0.2s ease; z-index: 110; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px; }
.stat .label { font-size: 0.82rem; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 1.5rem; font-weight: 700; color: var(--ink); margin-top: 4px; }
.stat .value.small { font-size: 1.15rem; }

.summary-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 0.9rem; }
.summary-row.total { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; font-weight: 700; font-size: 1.05rem; }
.mobile-only { display: none; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 45; }
  .main { margin-left: 0; }
  .mobile-only { display: inline-flex; }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 45; }
  .main { margin-left: 0; }
  .mobile-only { display: inline-flex; }

  /* Paksa grid-2 dan grid-4 menjadi 1 kolom di HP, menimpa inline style JS */
  .grid-2, 
  .grid-4,
  div[class*="grid-2"] {
    grid-template-columns: 1fr !important;
  }
}