/* Enterprise UI Layer — aligned with design-system/MASTER.md */
:root {
  --primary: #0F766E;
  --primary-hover: #0D9488;
  --secondary: #64748B;
  --success: #15803D;
  --warning: #B45309;
  --danger: #B91C1C;
  --info: #0369A1;
  --light: #F8FAFC;
  --dark: #0F172A;
  --radius-xl: 16px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --sidebar-collapsed-w: 76px;
  color-scheme: light;
}

[data-theme="dark"] {
  --brand: #2DD4BF;
  --brand-hover: #5EEAD4;
  --brand-press: #14B8A6;
  --brand-soft: rgba(45, 212, 191, .14);
  --brand-muted: rgba(45, 212, 191, .08);
  --accent: #4ADE80;
  --text: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --border: #334155;
  --border-light: #1E293B;
  --surface: #0F172A;
  --surface-2: #020617;
  --surface-3: #1E293B;
  --sidebar-bg: #020617;
  --sidebar-elev: #0F172A;
  --sidebar-text: #E2E8F0;
  --sidebar-muted: #94A3B8;
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-active: #0F766E;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, .45);
  --ring: 0 0 0 3px rgba(45, 212, 191, .28);
  color-scheme: dark;
}

[data-theme="dark"] .dash-sidebar {
  background: var(--sidebar-bg);
}
/* Plate putih HANYA di gambar logo — jangan di .dash-brand-logo (ada teks di samping) */
.brand-logo-plate,
.login-logo-wrap,
.dash-logo-img,
.dash-brand-logo img,
.app-logo-img,
.login-logo-img,
[data-theme="dark"] .brand-logo-plate,
[data-theme="dark"] .login-logo-wrap,
[data-theme="dark"] .dash-logo-img,
[data-theme="dark"] .dash-brand-logo img,
[data-theme="dark"] .app-logo-img,
[data-theme="dark"] .login-logo-img {
  background: #ffffff !important;
}
/* Link brand sidebar: transparan supaya teks kelihatan di bg gelap */
.dash-brand-logo,
[data-theme="dark"] .dash-brand-logo {
  background: transparent !important;
}
.dash-brand-text,
[data-theme="dark"] .dash-brand-text {
  color: #f8fafc !important;
}
.dash-brand-rs,
[data-theme="dark"] .dash-brand-rs {
  color: #ffffff !important;
}
.dash-brand-sub,
[data-theme="dark"] .dash-brand-sub {
  color: #cbd5e1 !important;
}
.dash-brand-text em,
.dash-brand-sub em,
[data-theme="dark"] .dash-brand-text em,
[data-theme="dark"] .dash-brand-sub em {
  color: #5eead4 !important;
}
[data-theme="dark"] .pub-header,
[data-theme="dark"] .dash-topbar {
  background: rgba(15, 23, 42, .94);
}

[data-theme="dark"] .data-table th {
  background: var(--surface-3);
}

[data-theme="dark"] .ql-toolbar.ql-snow,
[data-theme="dark"] .ql-container.ql-snow {
  border-color: var(--border);
  background: var(--surface);
}

[data-theme="dark"] .ql-editor.ql-blank::before {
  color: var(--text-muted);
}

/* Focus & a11y */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Button variants */
.btn-secondary {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-light); }

.btn-warning {
  background: var(--warn);
  color: #fff;
  box-shadow: 0 4px 14px rgba(217, 119, 6, .25);
}
.btn-warning:hover { filter: brightness(1.05); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, .25);
}
.btn-danger:hover { filter: brightness(1.05); }

.btn-info {
  background: var(--info);
  color: #fff;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn.is-loading {
  pointer-events: none;
  opacity: .75;
  position: relative;
}
.btn.is-loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ui-spin .7s linear infinite;
  margin-left: 6px;
}

@keyframes ui-spin { to { transform: rotate(360deg); } }

/* Breadcrumb */
.dash-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.dash-breadcrumb a {
  color: var(--text-muted);
  transition: color .2s var(--ease);
}
.dash-breadcrumb a:hover { color: var(--brand); }
.dash-breadcrumb .sep { opacity: .45; }
.dash-breadcrumb .current { color: var(--text-secondary); font-weight: 600; }

/* Topbar actions */
.dash-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all .2s var(--ease);
  position: relative;
}
.topbar-btn:hover {
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.topbar-btn svg { width: 18px; height: 18px; }
.topbar-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 40px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  min-width: 200px;
  transition: border-color .2s, box-shadow .2s;
}
.topbar-search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .1);
  background: var(--surface);
}
.topbar-search svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  width: 100%;
  color: var(--text);
}
.topbar-search input::placeholder { color: var(--text-muted); }

/* Sidebar collapse */
.dash-sidebar-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.dash-sidebar-toggle svg { width: 18px; height: 18px; }

@media (min-width: 1025px) {
  .dash-sidebar-toggle { display: inline-flex; }
  .dash-app.sidebar-collapsed { --sidebar-w: var(--sidebar-collapsed-w); }
  .dash-app.sidebar-collapsed .dash-sidebar-brand span,
  .dash-app.sidebar-collapsed .dash-brand-text,
  .dash-app.sidebar-collapsed .dash-nav-section,
  .dash-app.sidebar-collapsed .dash-nav-link span,
  .dash-app.sidebar-collapsed .dash-sidebar-footer { display: none; }
  .dash-app.sidebar-collapsed .dash-nav-link { justify-content: center; padding: 12px; }
  .dash-app.sidebar-collapsed .dash-sidebar-brand { justify-content: center; padding: 10px 8px; }
  .dash-app.sidebar-collapsed .dash-brand-logo { padding: 8px; border-radius: 12px; justify-content: center; gap: 0; }
  .dash-app.sidebar-collapsed .dash-logo-img { max-height: 40px !important; max-width: 40px !important; }
}

/* Enhanced sidebar (dark shell) */
.dash-nav-link {
  border: 1px solid transparent;
}
.dash-nav-link.active {
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(15,118,110,.35), inset 3px 0 0 #5EEAD4;
}

/* ── QR Scanner (workstation) ── */
.qr-scan-panel { margin-bottom: 0; }
.qr-scan-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.qr-scan-body { padding-top: 8px; }
.qr-reader {
  width: 100%; max-width: 420px; margin: 0 auto 12px;
  border-radius: 14px; overflow: hidden;
  border: 2px solid var(--border); background: #000;
  min-height: 240px;
}
.qr-reader video { border-radius: 12px !important; }
.qr-manual-row { max-width: 520px; }
.qr-manual-input { display: flex; gap: 8px; flex-wrap: wrap; }
.qr-manual-input .form-control { flex: 1; min-width: 180px; }
.qr-scan-status {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
}
.qr-scan-status.ok { background: var(--brand-muted); color: var(--brand-press, #115E59); }
.qr-scan-status.err { background: var(--danger-soft); color: var(--danger); }

/* ── QR Admin ── */
.qr-admin-grid {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; margin-bottom: 4px;
}
@media (max-width: 1024px) { .qr-admin-grid { grid-template-columns: 1fr; } }
.qr-howto { margin: 0 0 14px; padding-left: 18px; color: var(--text-secondary); font-size: 13.5px; line-height: 1.55; }
.qr-howto li { margin-bottom: 6px; }
.qr-howto-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.qr-unit-details {
  border: 1px dashed var(--border); border-radius: 12px; padding: 10px 12px;
  background: var(--surface-2);
}
.qr-unit-details summary { cursor: pointer; color: var(--brand); font-size: 13px; }
.qr-thumb {
  width: 72px; height: 72px; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; display: grid; place-items: center; overflow: hidden;
}
.qr-thumb img, .qr-thumb canvas { max-width: 100% !important; height: auto !important; }
.qr-row-actions { display: flex; gap: 2px; }
.qr-row-hi td { background: rgba(15,118,110,.08) !important; }
.qr-batch-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--border-light);
  background: var(--surface-2);
}
.qr-batch-bar .table-pagination { margin-left: auto; border: 0; padding: 0; background: transparent; }

/* Chart empty */
.chart-empty {
  min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 6px; color: var(--text-muted); padding: 24px;
  background: var(--surface-2); border-radius: var(--radius-sm); border: 1px dashed var(--border);
}
.chart-empty strong { color: var(--text-secondary); font-size: 13px; }
.chart-empty span { font-size: 12px; }
.chart-body { min-height: 200px; }

/* Welcome + quick actions */
.dash-welcome {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px; margin-bottom: 16px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(15,118,110,.1), rgba(15,118,110,.03) 55%, #fff);
  border: 1px solid rgba(15,118,110,.12);
}
.dash-welcome-greet { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.dash-welcome-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; line-height: 1.45; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.quick-actions a,
.quick-action,
.qa-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 12px; border-radius: 10px; font-size: 12.5px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border-light); color: var(--text-secondary);
  text-decoration: none; transition: .15s var(--ease); box-shadow: var(--shadow-xs);
}
.quick-actions a:hover,
.quick-action:hover,
.qa-chip:hover {
  border-color: var(--brand); color: var(--brand); background: var(--brand-muted);
  transform: translateY(-1px);
}
.quick-actions a svg, .quick-action svg, .qa-chip svg,
.quick-actions a i, .quick-action i, .qa-chip i { width: 15px; height: 15px; }

/* Content polish */
.dash-content .panel + .panel { margin-top: 0; }
.dash-content .ws-kpi + .ws-tabs { margin-top: 2px; }
.table-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border-light);
  background: var(--surface);
}
.table-toolbar .form-control,
.table-toolbar .form-select,
.table-toolbar input[type="search"] {
  min-height: 38px; padding: 8px 12px; font-size: 13px;
}
.table-pagination,
.table-pagination-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border-light);
  font-size: 13px; color: var(--text-muted); background: var(--surface-2);
}
.page-btn, .pager-btn, .table-pagination a, .table-pagination button {
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  text-decoration: none;
}
.page-btn.active, .pager-btn.active, .table-pagination .active {
  background: var(--brand); border-color: var(--brand); color: #fff;
}

/* Empty states */
.ws-empty, .empty-state {
  padding: 48px 24px; text-align: center; color: var(--text-muted);
}
.ws-empty strong, .empty-state strong { display: block; color: var(--text); margin-bottom: 4px; }

/* Role chip in topbar */
.role-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--brand-muted); color: var(--brand);
  border: 1px solid rgba(15,118,110,.15);
}

/* Login demo accounts — klik untuk isi form */
.login-demo {
  margin-top: 20px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border-light);
  font-size: 12px; color: var(--text-muted); line-height: 1.55;
}
.login-demo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.login-demo-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s, color .15s;
}
.login-demo-chip:hover {
  border-color: var(--brand);
  background: var(--brand-muted, #f0fdf4);
  color: var(--text-secondary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .1);
}
.login-demo-chip.is-active {
  border-color: var(--brand);
  background: var(--brand-muted, #f0fdf4);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .14);
  color: var(--text);
}
.login-demo-chip code {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--brand);
  font-weight: 700;
}
.login-demo-chip span {
  opacity: .85;
  font-size: 11px;
}
@media (max-width: 420px) {
  .login-demo-grid { grid-template-columns: 1fr; }
}

/* Fix stacked title + breadcrumb density */
.dash-topbar { min-height: var(--topbar-h); height: auto; padding-top: 10px; padding-bottom: 10px; }
.dash-topbar .dash-page-sub { display: none; } /* subtitle lives in content if needed */

/* Mobile ops */
@media (max-width: 1024px) {
  .dash-user-info { display: none; }
  .topbar-search { min-width: 0; width: 140px; }
  .dash-content { padding: 16px; }
}
@media (max-width: 640px) {
  .ws-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .ws-tab { flex-shrink: 0; }
  .topbar-search { display: none; }
  .dash-page-title { max-width: 55vw; font-size: 15px; }
}

/* Cards premium */
.kpi-card,
.panel,
.form-shell,
.export-card {
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.kpi-card:hover { transform: translateY(-2px); }
.panel:hover { box-shadow: var(--shadow-sm); }

/* Sticky table header */
.table-wrap { max-height: none; }
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--border);
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--border-light) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Form helpers */
.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .1);
}
.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 6px;
  display: none;
}
.form-control.is-invalid + .form-error,
.form-group.has-error .form-error { display: block; }

/* Modal */
.ui-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .2s var(--ease);
}
.ui-modal-overlay.open { display: flex; }
.ui-modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(480px, 100%);
  max-height: 90vh;
  overflow: auto;
  animation: slideUp .25s var(--ease);
}
.ui-modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ui-modal-body { padding: 24px; }
.ui-modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Pagination enhanced */
.table-pagination-info strong { color: var(--text); }
.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.page-jump input {
  width: 48px;
  height: 32px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
}

/* NProgress */
#nprogress .bar { background: var(--brand) !important; height: 3px !important; }
#nprogress .peg { box-shadow: 0 0 10px var(--brand), 0 0 5px var(--brand) !important; }

/* Notyf */
.notyf__toast { border-radius: 12px !important; font-family: var(--font) !important; }
.notyf__toast--success { background: #166534 !important; }
.notyf__toast--error { background: #991B1B !important; }

.login-form-side { position: relative; }

/* Pub header upgrade */
.pub-header-inner { gap: 20px; }
.pub-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* Quick actions bar (dashboard) */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.quick-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all .2s var(--ease);
  box-shadow: var(--shadow-xs);
}
.quick-action:hover {
  border-color: var(--brand);
  color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.quick-action svg { width: 16px; height: 16px; }

@media (max-width: 1024px) {
  .topbar-search { display: none; }
  .dash-topbar-right { gap: 6px; }
}

@media (max-width: 640px) {
  .dash-user-info { display: none; }
}