/* Sales Admin UI adapted from the supplied WBS project design. */
body.sales-admin-body {
  background: var(--theme-bg);
  color: var(--theme-text);
  display: flex;
  min-height: 100vh;
}

.sales-sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--theme-sidebar-start) 0%, var(--theme-sidebar-end) 100%);
  color: var(--theme-sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1000;
  transition: width .2s ease, transform .2s ease;
}
.sales-sidebar-header {
  min-height: 104px;
  padding: var(--space-xl) 46px var(--space-xl) var(--space-md);
  border-bottom: 1px solid color-mix(in srgb, var(--theme-sidebar-text) 14%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.sales-brand {
  color: var(--theme-sidebar-active-text) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
}
.sales-brand img { height: 28px; width: auto; object-fit: contain; flex: 0 0 auto; }
.sales-brand strong { font-family: var(--font-sans); letter-spacing: .01em; }
.sales-brand small { display:block; font-size:.66rem; font-weight:500; opacity:.78; letter-spacing:.02em; margin-top:1px; }
.sidebar-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 1px solid color-mix(in srgb, var(--theme-sidebar-text) 28%, transparent);
  background: color-mix(in srgb, var(--theme-sidebar-text) 10%, transparent);
  color: var(--theme-sidebar-active-text);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sidebar-toggle:hover { background: color-mix(in srgb, var(--theme-sidebar-text) 16%, transparent); }
.sidebar-toggle svg { transition: transform .2s ease; }

.sales-sidebar-menu {
  list-style:none;
  padding: var(--space-md) 0;
  margin:0;
  display:flex;
  flex-direction:column;
  gap:var(--space-2xs);
  flex:1 1 auto;
  overflow-y:auto;
}
.sales-sidebar-menu::-webkit-scrollbar { width:5px; }
.sales-sidebar-menu::-webkit-scrollbar-thumb { background:color-mix(in srgb,var(--theme-sidebar-text) 18%,transparent); border-radius:10px; }
.sidebar-section-title {
  font-size:.7rem;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.1em;
  color:var(--theme-sidebar-muted);
  padding:var(--space-md) var(--space-md) var(--space-2xs);
}
.sales-sidebar-item a {
  display:flex;
  align-items:center;
  gap:var(--space-sm);
  padding:var(--space-sm) var(--space-md);
  min-height:48px;
  color:var(--theme-sidebar-text);
  font-size:.93rem;
  font-weight:600;
  border-left:4px solid transparent;
  overflow:hidden;
}
.sales-sidebar-item a svg { flex:0 0 19px; }
.sales-sidebar-item a:hover,
.sales-sidebar-item.active a {
  color:var(--theme-sidebar-active-text);
  background:var(--theme-sidebar-active-bg);
  border-left-color:var(--theme-sidebar-active-border);
}
.sidebar-link-text,.sidebar-brand-text,.logout-text { white-space:nowrap; }

.sales-sidebar-footer {
  padding:var(--space-md);
  border-top:1px solid color-mix(in srgb,var(--theme-sidebar-text) 14%,transparent);
}
.sales-sidebar-footer .sidebar-theme-switcher { margin-bottom:10px; position:relative; }
.sales-sidebar-footer .theme-switcher { width:100%; }
.sales-sidebar-footer .theme-switcher-button {
  width:100%; min-height:42px; justify-content:flex-start;
  background:color-mix(in srgb,var(--theme-sidebar-text) 8%,transparent);
  border-color:color-mix(in srgb,var(--theme-sidebar-text) 26%,transparent);
  color:var(--theme-sidebar-active-text); box-shadow:none;
}
.sales-sidebar-footer .theme-switcher-button [data-theme-label] { flex:1 1 auto; text-align:left; }
.sales-sidebar-footer .theme-switcher-menu { top:auto; right:auto; left:0; bottom:calc(100% + 8px); width:288px; z-index:3000; }
.sidebar-footer-row { display:flex; align-items:center; gap:8px; min-width:0; }
.sidebar-user { flex:1 1 auto; min-width:0; }
.sidebar-user-name { display:block; font-size:.82rem; font-weight:700; color:var(--theme-sidebar-active-text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sidebar-user-role { display:block; font-size:.68rem; color:var(--theme-sidebar-muted); text-transform:uppercase; letter-spacing:.05em; }
.logout-button { flex:0 0 auto; padding:9px 11px !important; min-width:0; display:flex; align-items:center; gap:6px; }

.sales-main {
  margin-left:260px;
  flex:1 1 auto;
  min-width:0;
  padding:var(--space-xl);
  transition:margin-left .2s ease;
}
.sales-topbar {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  margin-bottom:var(--space-md);
  background:var(--theme-surface);
  padding:var(--space-sm) var(--space-md);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-sm);
  border:1px solid var(--theme-border);
}
.sales-topbar h1 { font-family:var(--font-sans); font-size:1.35rem; font-weight:800; margin:0; color:var(--theme-text); letter-spacing:0; }
.sales-topbar .page-subtitle { margin:3px 0 0; color:var(--theme-muted); font-size:.8rem; }
.sales-topbar-profile { display:flex; align-items:center; gap:10px; color:var(--theme-muted); font-size:.83rem; }
.sales-topbar-profile .avatar {
  width:36px; height:36px; border-radius:50%; background:var(--theme-soft); color:var(--theme-primary); display:flex; align-items:center; justify-content:center; font-weight:800;
}
.mobile-sidebar-button { display:none; border:1px solid var(--theme-border); background:var(--theme-surface); color:var(--theme-text); border-radius:8px; width:40px; height:40px; align-items:center; justify-content:center; }
.sidebar-overlay { display:none; }

.page-toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:var(--space-md); }
.page-toolbar-actions { display:flex; align-items:center; gap:12px; flex:0 0 auto; }
.page-toolbar h2,.page-toolbar h3 { font-family:var(--font-sans); font-weight:800; margin:0; color:var(--theme-text); }
.page-toolbar .toolbar-subtitle { color:var(--theme-muted); font-size:.85rem; margin:4px 0 0; }

.admin-card {
  background:var(--theme-surface);
  border-radius:var(--radius-md);
  padding:var(--space-md);
  border:1px solid var(--theme-border);
  box-shadow:var(--shadow-sm);
  margin-bottom:var(--space-md);
}
.admin-card-title { font-family:var(--font-sans); font-weight:800; font-size:1.05rem; color:var(--theme-text); margin:0 0 var(--space-md); padding-bottom:var(--space-xs); border-bottom:1px solid var(--theme-border); }
.admin-card-subtitle { color:var(--theme-muted); font-size:.85rem; margin:-12px 0 18px; }

.dashboard-stats { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:var(--space-md); margin-bottom:var(--space-md); }
.dashboard-stats.report-stats { grid-template-columns:repeat(5,minmax(0,1fr)); }
.stat-card {
  background:var(--theme-surface); border:1px solid var(--theme-border); box-shadow:var(--shadow-sm); border-radius:var(--radius-md); padding:var(--space-md); min-width:0;
  position:relative; overflow:hidden;
}
.stat-card::after { content:""; position:absolute; width:72px; height:72px; border-radius:50%; right:-22px; top:-26px; background:var(--theme-soft); opacity:.75; }
.stat-card-title { color:var(--theme-muted); font-size:.76rem; text-transform:uppercase; letter-spacing:.06em; font-weight:800; margin-bottom:7px; }
.stat-card-value { color:var(--theme-text); font-size:1.65rem; font-weight:800; line-height:1.25; word-break:break-word; }
.stat-card-meta { color:var(--theme-muted); font-size:.8rem; margin-top:4px; }
.stat-card.danger .stat-card-value { color:#b91c1c; }
.stat-card.success .stat-card-value { color:#047857; }
.stat-card.primary .stat-card-value { color:var(--theme-primary); }

.table-container { background:var(--theme-surface); border-radius:var(--radius-md); border:1px solid var(--theme-border); box-shadow:var(--shadow-sm); overflow-x:auto; margin-bottom:var(--space-md); }
.admin-table { width:100%; border-collapse:collapse; text-align:left; font-size:.9rem; min-width:720px; }
.admin-table th { background:var(--theme-surface-alt); color:var(--theme-text); padding:13px 16px; font-weight:800; border-bottom:1px solid var(--theme-border-strong); white-space:nowrap; }
.admin-table td { padding:13px 16px; border-bottom:1px solid var(--theme-border); color:var(--theme-text); vertical-align:middle; }
.admin-table tbody tr:last-child td { border-bottom:0; }
.admin-table tbody tr:hover td { background:var(--theme-surface-alt); }
.table-empty { text-align:center; padding:32px !important; color:var(--theme-muted) !important; }
.table-code { font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace; font-weight:800; color:var(--theme-primary); }
.table-money { white-space:nowrap; font-weight:700; }
.table-actions { display:flex; gap:7px; align-items:center; justify-content:flex-end; flex-wrap:wrap; }

.badge { display:inline-flex; align-items:center; justify-content:center; padding:.28rem .55rem; border-radius:999px; font-size:.68rem; font-weight:800; text-transform:uppercase; letter-spacing:.03em; white-space:nowrap; }
.badge-success,.badge-active { background:#d1fae5; color:#065f46; }
.badge-danger,.badge-void { background:#fee2e2; color:#991b1b; }
.badge-info { background:var(--theme-soft); color:var(--theme-primary); }
.badge-warning { background:#fef3c7; color:#92400e; }
.badge-muted { background:var(--theme-surface-alt); color:var(--theme-muted); border:1px solid var(--theme-border); }

.btn { display:inline-flex; align-items:center; justify-content:center; gap:7px; text-decoration:none; }
.btn-sm { padding:.45rem .75rem; font-size:.72rem; }
.btn-danger { background:#dc2626; color:#fff; border-color:#dc2626; }
.btn-danger:hover { background:#b91c1c; color:#fff; transform:translateY(-2px); }
.btn-muted { background:var(--theme-surface-alt); color:var(--theme-text); border-color:var(--theme-border); }
.btn-muted:hover { background:var(--theme-soft); color:var(--theme-primary); border-color:var(--theme-primary); transform:translateY(-2px); }
.btn-link { background:transparent; border:0; padding:0; text-transform:none; letter-spacing:0; color:var(--theme-primary); font-size:.85rem; }
.btn-link:hover { color:var(--theme-primary-hover); transform:none; box-shadow:none; }

.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 var(--space-md); }
.form-group.full { grid-column:1 / -1; }
.form-label .required { color:#dc2626; }
.form-control { background:var(--theme-surface); color:var(--theme-text); border-color:var(--theme-border-strong); }
.form-control:focus { border-color:var(--theme-primary); background:var(--theme-surface); box-shadow:0 0 0 3px color-mix(in srgb,var(--theme-primary) 15%,transparent); }
select.form-control { min-height:50px; }
.form-actions { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-top:4px; }
.form-help { color:var(--theme-muted); font-size:.78rem; margin-top:5px; }
.filter-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; align-items:end; }
.filter-grid.products-filter { grid-template-columns:2fr 1.2fr auto auto; }
.filter-actions { display:flex; gap:8px; align-items:center; }

.form-feedback { margin:0 0 var(--space-md); }
.form-feedback ul { margin:0; padding-left:1.25rem; }

.pagination-wrapper { padding:0 var(--space-md) var(--space-md); }

.summary-box { max-width:480px; margin:18px 0 0 auto; background:var(--theme-surface-alt); border:1px solid var(--theme-border); border-radius:var(--radius-md); padding:12px 16px; }
.summary-line { display:flex; justify-content:space-between; gap:20px; padding:8px 0; border-bottom:1px dashed var(--theme-border-strong); color:var(--theme-text); }
.summary-line:last-child { border-bottom:0; }
.summary-line.total { font-size:1.1rem; font-weight:800; color:var(--theme-primary); }
.text-danger { color:#b91c1c !important; }
.text-success { color:#047857 !important; }
.text-muted { color:var(--theme-muted) !important; }

.detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px 22px; }
.detail-item { display:grid; grid-template-columns:130px 1fr; gap:8px; font-size:.88rem; }
.detail-item .label { color:var(--theme-muted); font-weight:700; }
.detail-item .value { color:var(--theme-text); font-weight:600; min-width:0; word-break:break-word; }
.void-panel { border-color:#fecaca; }
.void-panel .admin-card-title { color:#991b1b; }

.login-page {
  background:var(--theme-login-bg);
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}
.login-card { width:100%; max-width:430px; padding:var(--space-xl); background:var(--theme-surface); border:1px solid var(--theme-border); border-radius:var(--radius-lg); box-shadow:var(--shadow-lg); }
.login-header { text-align:center; margin-bottom:var(--space-xl); }
.login-logo { display:flex; align-items:center; justify-content:center; gap:10px; margin-bottom:10px; }
.login-logo img { height:34px; width:auto; }
.login-logo strong { font-size:1.3rem; font-weight:800; color:var(--theme-text); }
.login-header p { color:var(--theme-muted); font-size:.86rem; margin:0; }
.theme-switcher-floating { position:fixed; top:20px; right:20px; z-index:20; }

html.sales-sidebar-collapsed .sales-sidebar { width:78px; }
html.sales-sidebar-collapsed .sales-main { margin-left:78px; }
html.sales-sidebar-collapsed .sales-sidebar-header { padding-left:0; padding-right:0; }
html.sales-sidebar-collapsed .sales-brand { width:100%; }
html.sales-sidebar-collapsed .sidebar-brand-text,
html.sales-sidebar-collapsed .sidebar-link-text,
html.sales-sidebar-collapsed .sidebar-section-title,
html.sales-sidebar-collapsed .sidebar-user,
html.sales-sidebar-collapsed .logout-text { display:none; }
html.sales-sidebar-collapsed .sidebar-toggle { right:-16px; background:var(--theme-sidebar-end); border-color:var(--theme-sidebar-active-border); box-shadow:var(--shadow-sm); }
html.sales-sidebar-collapsed .sidebar-toggle svg { transform:rotate(180deg); }
html.sales-sidebar-collapsed .sales-sidebar-item a { justify-content:center; gap:0; padding-left:0; padding-right:0; }
html.sales-sidebar-collapsed .sales-sidebar-footer { padding:12px 10px; }
html.sales-sidebar-collapsed .sidebar-footer-row { justify-content:center; }
html.sales-sidebar-collapsed .logout-button { width:100%; padding:10px 0 !important; }
html.sales-sidebar-collapsed .sidebar-theme-switcher .theme-switcher-button { width:100%; padding:9px 0; justify-content:center; }
html.sales-sidebar-collapsed .sidebar-theme-switcher .theme-switcher-button [data-theme-label],
html.sales-sidebar-collapsed .sidebar-theme-switcher .theme-chevron { display:none; }
html.sales-sidebar-collapsed .sidebar-theme-switcher .theme-current-swatch { margin:0; }

@media (max-width:1200px) {
  .dashboard-stats.report-stats { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .filter-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:900px) {
  .dashboard-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .sales-main { padding:var(--space-md); }
  .sales-topbar-profile .profile-text { display:none; }
}
@media (max-width:760px) {
  .sales-sidebar { transform:translateX(-100%); width:260px !important; }
  .sales-sidebar.mobile-open { transform:translateX(0); }
  .sales-main, html.sales-sidebar-collapsed .sales-main { margin-left:0; }
  .mobile-sidebar-button { display:inline-flex; }
  .sidebar-toggle { display:none; }
  .sidebar-overlay { position:fixed; inset:0; background:rgba(15,23,42,.45); z-index:990; }
  .sidebar-overlay.show { display:block; }
  .sales-topbar { align-items:flex-start; }
  .sales-topbar-title { display:flex; gap:10px; align-items:flex-start; }
  .sales-topbar h1 { font-size:1.1rem; }
  .form-grid,.detail-grid { grid-template-columns:1fr; }
  .form-group.full { grid-column:auto; }
  .detail-item { grid-template-columns:110px 1fr; }
  .filter-grid,.filter-grid.products-filter { grid-template-columns:1fr; }
  .filter-actions { width:100%; }
  .filter-actions .btn { flex:1 1 auto; }
  .page-toolbar { align-items:flex-start; flex-direction:column; }
  .page-toolbar-actions { width:100%; }
  .page-toolbar-actions .btn { flex:1; width:auto; justify-content:center; }
}
@media (max-width:520px) {
  .dashboard-stats,.dashboard-stats.report-stats { grid-template-columns:1fr; }
  .sales-main { padding:12px; }
  .admin-card { padding:16px; }
  .login-card { padding:24px 18px; }
}
