/* Toko Online - POS UI Styles */
:root {
  --primary: #1e40af;
  --primary-hover: #1e3a8a;
  --primary-light: #eff6ff;
  --primary-lighter: #dbeafe;
  --sidebar-bg: #ffffff;
  --sidebar-border: #e5e7eb;
  --text-primary: #0f172a;
  --text-muted: #64748b;
  --border: #e5e7eb;
  --bg-page: #f8fafc;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
}

* {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 14px;
  margin: 0;
}

/* Bootstrap primary override */
.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background-color: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
}
.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  background-color: var(--primary);
  border-color: var(--primary);
}
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }
.link-primary { color: var(--primary) !important; }
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.12);
}
.page-link { color: var(--primary); }
.page-item.active .page-link {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* Layout wrapper */
.pos-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  transition: grid-template-columns .2s ease;
}
/* Desktop: collapsed sidebar (hidden) */
@media (min-width: 992px) {
  .pos-layout.sidebar-collapsed { grid-template-columns: 0 1fr; }
  .pos-layout.sidebar-collapsed .pos-sidebar { display: none; }
}
@media (max-width: 991.98px) {
  .pos-layout { grid-template-columns: 1fr; }
  .pos-sidebar { display: none; }
  .pos-sidebar.open {
    display: block;
    position: fixed; top: 0; left: 0; bottom: 0; width: 260px; z-index: 1050;
    box-shadow: 4px 0 24px rgba(15,23,42,.15);
  }
}

/* Sidebar */
.pos-sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 20px 16px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.pos-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 20px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.pos-brand .logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.pos-brand .brand-text { line-height: 1.1; }
.pos-brand .brand-text strong { font-size: 15px; color: var(--text-primary); }
.pos-brand .brand-text small { color: var(--text-muted); font-size: 11px; }

.sidebar-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); font-weight: 600;
  margin: 18px 12px 8px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: #475569; text-decoration: none;
  font-weight: 500; font-size: 14px;
  transition: background .15s, color .15s;
}
.sidebar-link i { font-size: 17px; width: 20px; text-align: center; }
.sidebar-link:hover { background: var(--primary-light); color: var(--primary); }
.sidebar-link.active {
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 12px rgba(30,64,175,.25);
}

/* Main content */
.pos-main { min-width: 0; }
.pos-topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 24px; position: sticky; top: 0; z-index: 20;
}
.pos-topbar .search-box { max-width: 380px; width: 100%; }
.pos-topbar .search-box .form-control { border-radius: 999px; padding-left: 40px; }
.pos-topbar .search-box .search-icon {
  position: absolute; top: 50%; left: 14px; transform: translateY(-50%); color: var(--text-muted);
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; display: inline-flex; align-items: center; justify-content: center;
  color: #475569; position: relative;
}
.topbar-icon-btn .dot {
  position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%;
}
.topbar-user { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.topbar-user .avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--primary-lighter);
  color: var(--primary); font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.topbar-user .info { line-height: 1.1; }
.topbar-user .info strong { font-size: 13px; }
.topbar-user .info small { color: var(--text-muted); font-size: 11px; }

.page-content { padding: 24px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-header .subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* Cards */
.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
}
.card-header { background: #fff; border-bottom: 1px solid var(--border); padding: 16px 20px; }
.card-body { padding: 20px; }

.stat-card { padding: 20px; }
.stat-card .stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.stat-card .stat-value { font-size: 24px; font-weight: 700; margin: 10px 0 2px; }
.stat-card .stat-label { color: var(--text-muted); font-size: 13px; }
.stat-card .stat-delta { font-size: 12px; font-weight: 600; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }
.icon-blue { background: var(--primary-lighter); color: var(--primary); }
.icon-green { background: #dcfce7; color: #16a34a; }
.icon-orange { background: #ffedd5; color: #d97706; }
.icon-red { background: #fee2e2; color: #dc2626; }

/* Tables */
.table { --bs-table-hover-bg: var(--primary-light); font-size: 14px; }
.table thead th {
  background: #f8fafc; color: var(--text-muted); font-weight: 600;
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); padding: 12px 14px;
}
.table tbody td { padding: 14px; vertical-align: middle; border-color: var(--border); }
.table-actions { display: inline-flex; gap: 6px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 8px;
}

/* Badges */
.badge-status {
  padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.badge-active { background: #dcfce7; color: #16a34a; }
.badge-inactive { background: #fee2e2; color: #dc2626; }
.badge-low { background: #ffedd5; color: #d97706; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-role-admin { background: #ede9fe; color: #6d28d9; }
.badge-role-cashier { background: var(--primary-lighter); color: var(--primary); }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: grid; grid-template-columns: 1fr 1fr;
  background: #fff;
}
@media (max-width: 991.98px) { .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; } }
.login-hero {
  background: linear-gradient(160deg, #1e40af 0%, #1e3a8a 60%, #0f172a 100%);
  color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-hero::before {
  content: ''; position: absolute; width: 500px; height: 500px; border-radius: 50%;
  background: rgba(255,255,255,.06); top: -180px; right: -180px;
}
.login-hero::after {
  content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%;
  background: rgba(255,255,255,.05); bottom: -80px; left: -80px;
}
.login-form-wrap {
  display: flex; align-items: center; justify-content: center; padding: 40px;
}
.login-form { width: 100%; max-width: 400px; }
.login-form h2 { font-size: 26px; font-weight: 700; }
.login-form .form-label { font-weight: 500; font-size: 13px; }

/* POS Cashier Layout */
.pos-cashier {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px;
}
@media (max-width: 1199.98px) { .pos-cashier { grid-template-columns: 1fr; } }
.product-search-panel, .cart-panel { display: flex; flex-direction: column; }
.cart-panel { position: sticky; top: 80px; max-height: calc(100vh - 100px); }
.cart-items { max-height: 340px; overflow-y: auto; }
.cart-summary-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.cart-summary-row.total { border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 12px; font-size: 18px; font-weight: 700; color: var(--primary); }
.qty-input { width: 68px; text-align: center; }
.wholesale-highlight { background: #fef3c7 !important; }

/* Receipt page */
.receipt-page { background: #e2e8f0; min-height: 100vh; padding: 40px 20px; }
.receipt {
  width: 300px; margin: 0 auto; background: #fff; padding: 20px 18px;
  font-family: 'Courier Prime', 'Courier New', monospace; font-size: 12px;
  box-shadow: 0 20px 40px rgba(15,23,42,.15);
}
.receipt .center { text-align: center; }
.receipt .divider { border-top: 1px dashed #94a3b8; margin: 8px 0; }
.receipt table { width: 100%; font-size: 12px; }
.receipt table td { padding: 2px 0; vertical-align: top; }
.receipt-actions { max-width: 300px; margin: 20px auto 0; display: flex; gap: 8px; }

@media print {
  @page { margin: 0; }
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }
  .receipt-page { padding: 0 !important; background: #fff !important; min-height: 0 !important; }
  .receipt-actions { display: none !important; }
  .receipt {
    width: 72mm;
    margin: 0 auto;
    padding: 1mm 2mm;
    box-shadow: none;
    background: #fff;
    font-size: 11px;
  }
  .receipt .divider { border-top: 1px dashed #000; margin: 6px 0; }
  .receipt table { width: 100%; font-size: 11px; }
}

/* Utility */
.divider-h { height: 1px; background: var(--border); margin: 16px 0; }
.text-muted-sm { color: var(--text-muted); font-size: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: #f1f5f9; color: #475569;
}
.chip.active { background: var(--primary); color: #fff; }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: .5; }
