/* =========================================================
   Toko PETIR - POS Sembako
   Design system inti (sidebar gelap navy + teal accent)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --navy-950: #0a1220;
  --navy-900: #0d1626;
  --navy-800: #131f36;
  --navy-700: #1b2b4a;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-50:  #ecfdf9;
  --amber-500:#f59e0b;
  --amber-50: #fffbeb;
  --amber-100:#fef3c7;
  --rose-500: #f43f5e;
  --rose-50:  #fff1f2;
  --green-500:#22c55e;
  --red-600:  #dc2626;

  --bg-app:    #f2f4f7;
  --bg-card:   #ffffff;
  --text-main: #101828;
  --text-muted:#667085;
  --text-soft: #98a2b3;
  --border:    #e4e7ec;

  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-pop: 0 8px 24px rgba(16,24,40,.12), 0 2px 6px rgba(16,24,40,.08);

  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
table { border-collapse: collapse; width: 100%; }
input, select, textarea { font-family: inherit; }

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900) 60%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 24px 22px 20px;
}
.sidebar-brand .logo-box {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--teal-400), var(--teal-600));
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex: none;
  box-shadow: 0 4px 10px rgba(20,184,166,.35);
}
.sidebar-brand .logo-box svg { width: 22px; height: 22px; }
.sidebar-brand .brand-name { font-size: 17px; font-weight: 800; color: #fff; line-height: 1.1; }
.sidebar-brand .brand-tag { font-size: 10.5px; letter-spacing: .08em; color: var(--teal-400); font-weight: 700; }

.sidebar-nav { flex: 1; padding: 8px 14px; overflow-y: auto; }
.sidebar-nav .nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 4px;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 14.5px; font-weight: 600;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.sidebar-nav .nav-item svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,.04); color: #e2e8f0; }
.sidebar-nav .nav-item.active {
  background: rgba(20,184,166,.14);
  color: #fff;
  border-left-color: var(--teal-400);
}
.sidebar-nav .nav-item.active svg { opacity: 1; color: var(--teal-400); }
.sidebar-nav .nav-item kbd {
  margin-left: auto; font-size: 10px; color: #64748b;
  border: 1px solid #2a3852; border-radius: 5px; padding: 1px 5px;
}

.sidebar-footer { padding: 16px 18px 20px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sidebar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--navy-700); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex: none;
}
.sidebar-user .u-name { font-size: 13.5px; font-weight: 700; color: #fff; }
.sidebar-user .u-role { font-size: 11.5px; color: #7c8aa0; text-transform: capitalize; }
.mode-badge {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: #86efac; font-weight: 600;
  padding: 8px 10px; border-radius: 8px; background: rgba(34,197,94,.1);
}
.mode-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green-500); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.btn-logout {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin-top: 10px; padding: 8px 10px; border-radius: 8px;
  background: transparent; border: 1px solid rgba(255,255,255,.08);
  color: #94a3b8; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn-logout:hover { color: #fca5a5; border-color: rgba(244,63,94,.3); background: rgba(244,63,94,.08); }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
}

/* ---------------- Page header ---------------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-header .eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .09em; color: var(--teal-600); text-transform: uppercase; margin-bottom: 6px; }
.page-header h1 { font-size: 27px; font-weight: 800; margin: 0 0 6px; color: var(--text-main); }
.page-header p { margin: 0; color: var(--text-muted); font-size: 14px; }
.date-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--text-main);
  box-shadow: var(--shadow-card); white-space: nowrap;
}
.date-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-500); }

/* ---------------- Card ---------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
  margin-bottom: 22px;
}
.card-title { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; margin: 0 0 16px; }
.card-title.warn { color: #b45309; }
.card-title.danger { color: #be123c; }

/* stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-tile { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-card); }
.stat-tile .label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.stat-tile .value { font-size: 24px; font-weight: 800; color: var(--text-main); }
.stat-tile .sub { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
.stat-tile.accent-teal { border-top: 3px solid var(--teal-500); }
.stat-tile.accent-amber { border-top: 3px solid var(--amber-500); }
.stat-tile.accent-rose { border-top: 3px solid var(--rose-500); }
.stat-tile.accent-navy { border-top: 3px solid var(--navy-700); }

/* ---------------- Table ---------------- */
.table-wrap { overflow-x: auto; }
table.data-table thead th {
  text-align: left; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-soft); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table thead th.text-right { text-align: right; }
table.data-table tbody td {
  padding: 13px 14px; font-size: 14px; color: var(--text-main); border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: #fafbfc; }
table.data-table tbody tr.row-warn { background: var(--amber-50); }
table.data-table tbody tr.row-warn:hover { background: var(--amber-100); }
table.data-table tbody tr.row-danger { background: var(--rose-50); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.num-warn { color: #b45309; font-weight: 800; }
.num-danger { color: var(--rose-500); font-weight: 800; }
table.data-table tbody td.num-warn { color: #b45309; font-weight: 800; }
table.data-table tbody td.num-danger { color: var(--rose-500); font-weight: 800; }
.num-danger { color: #be123c; font-weight: 800; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-amber { background: var(--amber-100); color: #92400e; }
.badge-rose  { background: var(--rose-50); color: #9f1239; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray  { background: #f2f4f7; color: #475467; }
.badge-teal  { background: var(--teal-50); color: var(--teal-600); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-soft); font-size: 14px; }

/* ---------------- Buttons / forms ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 700;
  border: 1px solid transparent; cursor: pointer; transition: filter .1s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal-500); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:focus-visible { outline: 3px solid rgba(20,184,166,.35); outline-offset: 1px; }
.btn-dark { background: var(--navy-900); color: #fff; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text-main); }
.btn-outline:hover { border-color: var(--teal-500); color: var(--teal-600); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: #f2f4f7; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 700; color: var(--text-main); margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text-main); background: #fff; transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(20,184,166,.15);
}
.input-hint { font-size: 12px; color: var(--text-soft); margin-top: 5px; }
.input-error { border-color: var(--rose-500) !important; }
.error-text { color: var(--rose-500); font-size: 12px; margin-top: 5px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; justify-content: space-between; }
.toolbar .toolbar-left { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-soft); }
.search-box input { padding-left: 36px; min-width: 260px; }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,18,32,.5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-soft); font-size: 20px; line-height: 1; padding: 4px; }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ---------------- Toast ---------------- */
.toast-stack { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy-900); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-pop); display: flex; align-items: center; gap: 10px; min-width: 240px;
  animation: toast-in .18s ease;
}
.toast.success { border-left: 4px solid var(--green-500); }
.toast.error { border-left: 4px solid var(--rose-500); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px);} to { opacity: 1; transform: translateY(0);} }

/* focus ring helper for keyboard nav */
:focus-visible { outline: 2px solid var(--teal-500); outline-offset: 1px; }

/* scrollbars */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

@media (max-width: 960px) {
  :root { --sidebar-w: 220px; }
  .main { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
}

/* =========================================================
   TAMPILAN HP (mobile friendly) - menu samping jadi laci, isi selebar layar
   ========================================================= */
.mobile-topbar, .sidebar-backdrop { display: none; }
@media (max-width: 860px) {
  .mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 50;
    padding: 0 12px; background: var(--navy-950); color: #fff;
    box-shadow: 0 2px 8px rgba(10,18,32,.25);
  }
  .menu-toggle {
    width: 42px; height: 42px; flex: none; border: none; border-radius: 10px; cursor: pointer;
    background: rgba(255,255,255,.08); color: #fff; display: flex; align-items: center; justify-content: center;
  }
  .menu-toggle svg { width: 22px; height: 22px; }
  .mobile-topbar .mt-title { font-size: 16px; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-topbar .mt-brand { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--teal-400); white-space: nowrap; }

  .sidebar {
    width: 272px; max-width: 84vw; z-index: 70;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 30px rgba(0,0,0,.35);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(10,18,32,.5); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  body.sidebar-open { overflow: hidden; }
  .sidebar-nav .nav-item { padding: 13px 14px; font-size: 15px; }
  .sidebar-nav .nav-item kbd { display: none; }

  .main { margin-left: 0; padding: 72px 12px 40px; width: 100%; }

  .page-header { gap: 10px; margin-bottom: 16px; }
  .page-header h1 { font-size: 22px; }
  .page-header p { font-size: 13px; }
  .page-header .eyebrow { font-size: 11px; margin-bottom: 4px; }
  .date-pill { padding: 6px 12px; font-size: 12px; }

  .card { padding: 16px 14px; margin-bottom: 16px; border-radius: 14px; }
  .card-title { font-size: 15px; margin-bottom: 12px; flex-wrap: wrap; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; margin-bottom: 16px; }
  .stat-tile { padding: 12px 12px; min-width: 0; }
  .stat-tile .label { font-size: 11.5px; margin-bottom: 4px; }
  .stat-tile .value { font-size: 18px; overflow-wrap: anywhere; }
  .stat-tile .sub { font-size: 11px; overflow-wrap: anywhere; }

  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.data-table thead th { padding: 9px 10px; font-size: 11px; }
  table.data-table tbody td { padding: 10px 10px; font-size: 13px; }

  .toolbar { gap: 8px; margin-bottom: 14px; }
  .toolbar .toolbar-left { width: 100%; gap: 8px; }
  .toolbar .toolbar-left > * { flex: 1 1 140px; min-width: 0 !important; }
  .toolbar .input, .toolbar select.input { min-width: 0 !important; }
  .search-box { flex: 1 1 100%; }
  .search-box input { min-width: 0; width: 100%; }

  /* input 16px supaya HP tidak otomatis zoom saat mengetik */
  .input, select.input, textarea.input, .qty-input { font-size: 16px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .btn { padding: 11px 16px; }
  .btn-sm { padding: 8px 12px; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal, .modal.modal-lg { max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-head { padding: 16px 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }

  .toast-stack { top: 64px; left: 12px; right: 12px; }
  .toast { min-width: 0; }

  /* grafik Produk Terlaris di Laporan: nama & jumlah di atas, batang di bawah */
  .main .bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "nama val" "bar bar"; gap: 3px 10px; padding: 7px 0; }
  .main .bar-nama { grid-area: nama; width: auto; }
  .main .bar-val { grid-area: val; width: auto; }
  .main .bar-track { grid-area: bar; height: 12px; }

  /* elemen dengan susunan menyamping (tombol/teks) boleh turun ke baris berikut */
  .main .card[style*="display:flex"], .main .card [style*="display:flex"], .main .toolbar [style*="display:flex"] { flex-wrap: wrap; }
  table.data-table td.empty-state[colspan] { text-align: left; }
}
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr !important; }
}
@media print {
  .mobile-topbar, .sidebar-backdrop { display: none !important; }
}
