/* ============================================================
   Hijabpolkadot POS - CSS
   ============================================================ */

:root {
  --c-bg:        #f1f5f9;
  --c-surface:   #ffffff;
  --c-sidebar:   #0f172a;
  --c-sidebar2:  #1e293b;
  --c-primary:   #6366f1;
  --c-primary-h: #4f46e5;
  --c-success:   #10b981;
  --c-warning:   #f59e0b;
  --c-danger:    #ef4444;
  --c-info:      #3b82f6;
  --c-text:      #1e293b;
  --c-muted:     #64748b;
  --c-border:    #e2e8f0;
  --c-kasir:     #3b82f6;
  --c-gudang:    #f59e0b;
  --c-bo:        #10b981;
  --c-admin:     #ef4444;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--c-bg); color: var(--c-text); min-height: 100vh; }

/* ---- SPLASH ---- */
.splash { position: fixed; inset: 0; background: var(--c-sidebar); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.splash-inner { text-align: center; }
.splash-logo { width: 72px; height: 72px; border-radius: 20px; background: var(--c-primary); color: #fff; font-size: 28px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.splash-name { color: #fff; font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.spinner { width: 28px; height: 28px; border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- LOGIN ---- */
.login-card { background: var(--c-surface); border-radius: var(--radius); padding: 36px 32px; width: 100%; max-width: 380px; margin: auto; box-shadow: 0 4px 24px rgba(0,0,0,.12); }
.login-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--c-primary); color: #fff; font-size: 22px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.login-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--c-muted); text-align: center; margin-bottom: 24px; }
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }

/* ---- APP SHELL ---- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ---- SIDEBAR ---- */
.sidebar { width: 240px; background: var(--c-sidebar); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo { width: 32px; height: 32px; border-radius: 8px; background: var(--c-primary); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-title { color: #fff; font-size: 14px; font-weight: 600; flex: 1; }
.sidebar-close { display: none; background: none; border: none; color: rgba(255,255,255,.5); font-size: 16px; cursor: pointer; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav .nav-section { font-size: 10px; font-weight: 600; color: rgba(255,255,255,.35); padding: 12px 8px 4px; letter-spacing: .06em; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: rgba(255,255,255,.7); font-size: 13px; text-decoration: none; transition: all .15s; margin-bottom: 2px; }
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: var(--c-primary); color: #fff; }
.sidebar-nav a .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--c-primary); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-username { color: #fff; font-size: 13px; font-weight: 500; }
.sidebar-role { color: rgba(255,255,255,.5); font-size: 11px; }
.btn-logout { width: 100%; padding: 8px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); border-radius: 8px; color: rgba(255,255,255,.7); font-size: 12px; cursor: pointer; transition: all .15s; }
.btn-logout:hover { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }

/* ---- MAIN CONTENT ---- */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 20px; height: 56px; background: var(--c-surface); border-bottom: 1px solid var(--c-border); flex-shrink: 0; }
.btn-menu { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--c-muted); padding: 4px; }
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-branch { font-size: 12px; color: var(--c-muted); background: var(--c-bg); padding: 4px 10px; border-radius: 20px; }
.topbar-time { font-size: 12px; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.page-content { flex: 1; overflow-y: auto; padding: 20px; }

/* ---- SIDEBAR OVERLAY (mobile) ---- */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; }

/* ---- CARDS & LAYOUT ---- */
.card { background: var(--c-surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ---- STAT CARDS ---- */
.stat-card { background: var(--c-surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--c-muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-sub { font-size: 11px; color: var(--c-muted); margin-top: 3px; }
.stat-card.blue  { border-left: 3px solid var(--c-info); }
.stat-card.green { border-left: 3px solid var(--c-success); }
.stat-card.amber { border-left: 3px solid var(--c-warning); }
.stat-card.red   { border-left: 3px solid var(--c-danger); }

/* ---- FORMS ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--c-muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1.5px solid var(--c-border); border-radius: 8px; font-size: 14px; color: var(--c-text); background: var(--c-surface); transition: border-color .15s; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-primary); }
textarea { resize: vertical; min-height: 80px; }

/* ---- BUTTONS ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all .15s; font-family: inherit; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-h); }
.btn-success { background: var(--c-success); color: #fff; }
.btn-danger  { background: var(--c-danger);  color: #fff; }
.btn-warning { background: var(--c-warning); color: #fff; }
.btn-ghost   { background: transparent; border: 1.5px solid var(--c-border); color: var(--c-text); }
.btn-ghost:hover { background: var(--c-bg); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--c-bg); padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 600; color: var(--c-muted); border-bottom: 1px solid var(--c-border); white-space: nowrap; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--c-bg); }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef9c3; color: #92400e; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-gray   { background: #f1f5f9; color: var(--c-muted); }

/* ---- ALERTS ---- */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-danger  { background: #fee2e2; color: #b91c1c; }
.alert-success { background: #dcfce7; color: #15803d; }
.alert-warning { background: #fef9c3; color: #92400e; }
.alert-info    { background: #dbeafe; color: #1d4ed8; }

/* ---- TOAST ---- */
.toast { position: fixed; bottom: 24px; right: 24px; background: #1e293b; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 13px; z-index: 9999; max-width: 320px; box-shadow: 0 4px 20px rgba(0,0,0,.2); animation: slideup .2s ease; }
.toast.success { background: var(--c-success); }
.toast.danger  { background: var(--c-danger); }
@keyframes slideup { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---- MODAL ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--c-surface); border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--c-border); display: flex; justify-content: space-between; align-items: center; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--c-muted); }

/* ---- KASIR PANEL ---- */
.kasir-gate { max-width: 440px; margin: 40px auto; text-align: center; }
.kasir-gate h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.kasir-gate p { font-size: 13px; color: var(--c-muted); margin-bottom: 20px; }
.pos-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; height: calc(100vh - 96px); }
.pos-items { overflow-y: auto; }
.sku-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.sku-card { background: var(--c-surface); border: 1.5px solid var(--c-border); border-radius: 8px; padding: 12px; cursor: pointer; transition: all .12s; }
.sku-card:hover { border-color: var(--c-primary); background: #f0f0ff; }
.sku-card .sku-name { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.sku-card .sku-price { font-size: 13px; color: var(--c-primary); font-weight: 600; }
.sku-card .sku-stock { font-size: 11px; color: var(--c-muted); }
.sku-card.out-of-stock { opacity: .45; cursor: not-allowed; }
.pos-cart { background: var(--c-surface); border-radius: var(--radius); display: flex; flex-direction: column; height: 100%; box-shadow: var(--shadow); }
.cart-header { padding: 14px 16px; border-bottom: 1px solid var(--c-border); font-weight: 600; font-size: 14px; }
.cart-items { flex: 1; overflow-y: auto; padding: 8px; }
.cart-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; margin-bottom: 4px; }
.cart-item:hover { background: var(--c-bg); }
.cart-item-name { flex: 1; font-size: 13px; }
.cart-item-qty { display: flex; align-items: center; gap: 6px; }
.qty-btn { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--c-border); background: var(--c-bg); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.cart-item-price { font-size: 13px; font-weight: 500; min-width: 70px; text-align: right; }
.cart-footer { padding: 14px 16px; border-top: 1px solid var(--c-border); }
.cart-total { display: flex; justify-content: space-between; font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.payment-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.pay-method { padding: 8px; border: 1.5px solid var(--c-border); border-radius: 8px; text-align: center; font-size: 12px; cursor: pointer; transition: all .12s; }
.pay-method.active { border-color: var(--c-primary); background: #f0f0ff; color: var(--c-primary); font-weight: 500; }
.session-bar { background: var(--c-primary); color: #fff; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; font-size: 13px; }

/* ---- DISTRIBUSI FORM ---- */
.dist-items-list { border: 1px solid var(--c-border); border-radius: 8px; overflow: hidden; }
.dist-item-row { display: grid; grid-template-columns: 1fr 80px 32px; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--c-border); }
.dist-item-row:last-child { border-bottom: none; }

/* ---- STATUS CHIPS ---- */
.status-open    { color: #059669; background: #d1fae5; }
.status-pending { color: #92400e; background: #fef3c7; }
.status-closed  { color: var(--c-muted); background: var(--c-bg); }
.status-approved { color: #1d4ed8; background: #dbeafe; }
.status-rejected { color: #b91c1c; background: #fee2e2; }

/* ---- PRINT ---- */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .page-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -240px; top: 0; bottom: 0; z-index: 200; transition: left .25s; }
  .sidebar.open { left: 0; }
  .sidebar-close { display: block; }
  .btn-menu { display: flex; }
  .sidebar-overlay { display: block !important; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .pos-cart { height: auto; }
}
@media (max-width: 480px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-content { padding: 12px; }
}

/* ---- UTILS ---- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.text-muted { color: var(--c-muted); font-size: 12px; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.divider { border: none; border-top: 1px solid var(--c-border); margin: 16px 0; }
.empty-state { text-align: center; padding: 40px 16px; color: var(--c-muted); }
.empty-state p { font-size: 13px; }
.rupiah::before { content: 'Rp '; }
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input { flex: 1; }
