/* ============================================================
   POS & Inventori — Stylesheet
   Ringan, responsif, mobile-friendly.
   ============================================================ */

:root {
    --bg:        #f4f6fb;
    --surface:   #ffffff;
    --border:    #e2e8f0;
    --text:      #1e293b;
    --muted:     #64748b;
    --primary:   #2563eb;
    --primary-d: #1d4ed8;
    --success:   #16a34a;
    --danger:    #dc2626;
    --warning:   #d97706;
    --radius:    10px;
    --shadow:    0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 230px;
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 40;
    transition: transform .25s ease;
}
.sidebar .brand {
    padding: 18px 20px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar nav { padding: 10px 0; flex: 1; overflow-y: auto; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: #cbd5e1;
    font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav a .ic { width: 18px; text-align: center; }

/* Dropdown group di sidebar */
.nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
}
.nav-group-toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-group-toggle .ic { width: 18px; text-align: center; }
.nav-group-toggle .lbl { flex: 1; }
.nav-group-toggle .caret { font-size: 11px; transition: transform .2s; opacity: .7; }
.nav-group.open > .nav-group-toggle .caret { transform: rotate(180deg); }

.submenu { display: none; background: rgba(0,0,0,.25); }
.nav-group.open > .submenu { display: block; }
.submenu a { padding-left: 42px !important; font-size: 13.5px; }
.sidebar .foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }

.main { flex: 1; margin-left: 230px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 30;
}
.topbar .page-title { font-size: 17px; font-weight: 600; margin: 0; }
.topbar .user-chip { font-size: 13px; color: var(--muted); }
.topbar .user-chip strong { color: var(--text); }

.content { padding: 20px; flex: 1; }

.hamburger {
    display: none;
    background: none; border: none;
    font-size: 22px; cursor: pointer; color: var(--text);
}

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; }
.stat.primary { border-left: 4px solid var(--primary); }
.stat.success { border-left: 4px solid var(--success); }
.stat.warning { border-left: 4px solid var(--warning); }
.stat.danger  { border-left: 4px solid var(--danger); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 8px;
    padding: 9px 16px; font-size: 14px; font-weight: 500;
    cursor: pointer; transition: background .15s;
}
.btn:hover { background: var(--primary-d); text-decoration: none; color: #fff; }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.secondary:hover { background: #cbd5e1; }
.btn.success { background: var(--success); }
.btn.success:hover { background: #15803d; }
.btn.danger  { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.form-control {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; background: #fff; color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }

/* Hilangkan tombol panah pada input number (hanya bisa ketik) */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: #f8fafc; font-weight: 600; font-size: 13px; color: var(--muted); white-space: nowrap; }
table.data tr:hover td { background: #f8fafc; }
table.data td.num, table.data th.num { text-align: right; }
table.data td.center, table.data th.center { text-align: center; }

/* ---------- Pagination ---------- */
.pagination-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.pagination-bar .pg-info { font-size: 13px; color: var(--muted); }
.pagination { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 34px; height: 34px; padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; color: var(--text); background: #fff; text-decoration: none;
}
.pagination a:hover { background: #f1f5f9; text-decoration: none; }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pagination .disabled { color: #cbd5e1; background: #f8fafc; cursor: not-allowed; }
.pagination .gap { border: none; background: none; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.gray { background: #e2e8f0; color: #475569; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.blue { background: #dbeafe; color: #1e40af; }

/* ---------- Alerts / flash ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert.error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert.info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert.warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-head h2 { margin: 0; font-size: 20px; }

/* ---------- Product photo ---------- */
.prod-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #f1f5f9; }
.photo-preview { width: 140px; height: 140px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: #f1f5f9; display: block; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #1e3a8a, #2563eb); }
.login-box { background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.2); padding: 32px; width: 100%; max-width: 380px; }
.login-box h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.login-box .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-box .creds { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: #1f2937; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, box-shadow .15s; }
.btn-google:hover { background: #f8fafc; box-shadow: var(--shadow); text-decoration: none; color: #1f2937; }

/* ============================================================
   POS (Kasir) layout
   ============================================================ */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
.pos-products .search-bar { margin-bottom: 14px; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.pos-item {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px; cursor: pointer; text-align: center;
    transition: transform .1s, box-shadow .1s;
}
.pos-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.pos-item img { width: 100%; height: 90px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; background: #f1f5f9; }
.pos-item .nm { font-size: 13px; font-weight: 600; min-height: 34px; }
.pos-item .pr { color: var(--primary); font-weight: 700; font-size: 14px; }
.pos-item .st { font-size: 11px; color: var(--muted); }
.pos-item.out { opacity: .5; pointer-events: none; }

.cart { position: sticky; top: 80px; }
.cart-items { max-height: 46vh; overflow-y: auto; margin-bottom: 12px; }
.cart-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.cart-row .info { flex: 1; min-width: 0; }
.cart-row .info .nm { font-size: 13px; font-weight: 600; }
.cart-row .info .pr { font-size: 12px; color: var(--muted); }
.cart-row .qty { display: flex; align-items: center; gap: 4px; }
.cart-row .qty button { width: 26px; height: 26px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; }
.cart-row .qty input { width: 40px; text-align: center; padding: 4px; border: 1px solid var(--border); border-radius: 6px; }
.cart-row .rm { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 16px; }
.cart-total .line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.cart-total .grand { font-size: 20px; font-weight: 700; border-top: 2px solid var(--border); padding-top: 8px; margin-top: 6px; }
.cart-empty { text-align: center; color: var(--muted); padding: 24px 0; font-size: 14px; }

/* Segmen POS */
.pos-seg { padding: 12px 0; border-bottom: 1px solid var(--border); }
.pos-seg:last-of-type { border-bottom: none; }
/* Kartu khusus segmen Pembayaran (hijau muda transparan) */
.pos-seg-pay { background: rgba(22,163,74,.08); border: 1px solid rgba(22,163,74,.28); border-radius: 12px; padding: 14px; margin: 10px 0; }
.pos-seg-pay .paytype-opt { background: #fff; }
.pos-seg-head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.pos-badge { background: var(--primary); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 8px; font-weight: 700; letter-spacing: 0; }
.pos-num { width: 130px; text-align: right; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text); }
.pos-num:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.paytype { display: flex; gap: 8px; }
.paytype-opt { flex: 1; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: 14px; transition: border-color .15s, background .15s; }
.paytype-opt:has(input:checked) { border-color: var(--primary); background: rgba(37,99,235,.06); font-weight: 600; }
.recap-sec { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.recap-sec:last-child { border-bottom: none; }
.recap-t { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: 12px; max-width: 440px; width: 100%; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { margin-top: 0; }

/* ---------- Receipt ---------- */
.receipt { font-family: "Courier New", monospace; font-size: 13px; max-width: 300px; margin: 0 auto; }
.receipt .r-center { text-align: center; }
.receipt hr { border: none; border-top: 1px dashed #000; margin: 8px 0; }
.receipt table { width: 100%; }
.receipt td.num { text-align: right; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .pos { grid-template-columns: 1fr; }
    .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); box-shadow: 4px 0 20px rgba(0,0,0,.3); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .hamburger { display: block; }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; display: none; }
    .sidebar-overlay.show { display: block; }
}
@media (max-width: 560px) {
    .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
    .content { padding: 14px; }
}

/* ---------- Print (struk) ---------- */
@media print {
    body * { visibility: hidden; }
    #print-area, #print-area * { visibility: visible; }
    #print-area { position: absolute; left: 0; top: 0; width: 100%; }
    .no-print { display: none !important; }
}
