/* NexAlePOS - Lightweight stylesheet (no framework) */
:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --border: #e6eaf0;
    --text: #1c2433;
    --muted: #6b7689;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.04);
}
[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --shadow: 0 1px 2px rgba(0,0,0,.25), 0 4px 12px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 600; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; }

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    display: flex; flex-direction: column;
}
.sidebar .brand {
    padding: 0 20px 16px;
    font-size: 18px; font-weight: 700;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px;
    color: var(--text);
    border-left: 3px solid transparent;
    font-weight: 500;
}
.sidebar nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar nav a.active {
    border-left-color: var(--primary);
    background: var(--bg);
    color: var(--primary);
}
.sidebar .nav-section {
    padding: 12px 20px 4px;
    font-size: 11px; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted);
}
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.topbar .user { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.content { padding: 20px; flex: 1; }
.content.no-padding { padding: 0; }

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-body { padding: 16px; }
.card-header {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; transform: translateX(-100%); z-index: 999; height: 100vh; width: 240px; transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
}

.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
}
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

table.data {
    width: 100%; border-collapse: collapse; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: var(--bg); font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: rgba(79,70,229,.04); }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-weight: 500; cursor: pointer; font-size: 14px;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
    width: 100%; padding: 8px 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-muted   { background: #e2e8f0; color: #475569; }

.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.gap-sm { gap: 6px; } .gap-lg { gap: 24px; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pagination a, .pagination span {
    padding: 6px 10px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* POS layout */
.pos {
    display: grid;
    grid-template-columns: 1fr 380px;
    height: calc(100vh - 50px);
    overflow: hidden;
}
.pos-products { padding: 16px; overflow-y: auto; }
.pos-cart {
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
}
.pos-search {
    position: sticky; top: 0; background: var(--bg); z-index: 10;
    padding-bottom: 12px;
}
.pos-search input {
    font-size: 16px; padding: 12px 14px;
}
.pos-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}
.pos-product {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px; cursor: pointer;
    transition: transform .1s, border-color .15s; user-select: none;
}
.pos-product:hover { border-color: var(--primary); transform: translateY(-1px); }
.pos-product .pname { font-weight: 600; font-size: 13px; line-height: 1.3; min-height: 34px; }
.pos-product .pprice { color: var(--primary); font-weight: 700; margin-top: 6px; }
.pos-product .pmeta { font-size: 11px; color: var(--muted); margin-top: 2px; }

.cart-list { flex: 1; overflow-y: auto; padding: 12px; }
.cart-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.cart-item .nm { font-weight: 500; font-size: 13px; }
.cart-item .pr { color: var(--muted); font-size: 12px; }
.qty-ctl { display: flex; gap: 4px; align-items: center; }
.qty-ctl button {
    width: 26px; height: 26px; border-radius: 4px; border: 1px solid var(--border);
    background: var(--surface); cursor: pointer; font-weight: 700; color: var(--text);
}
.qty-ctl input { width: 40px; text-align: center; padding: 4px; }
.cart-summary {
    padding: 12px 16px; border-top: 1px solid var(--border);
    background: var(--bg);
}
.cart-summary .row { display: flex; justify-content: space-between; padding: 4px 0; }
.cart-summary .row.total { font-size: 18px; font-weight: 700; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; }
.pos-actions { padding: 12px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border-top: 1px solid var(--border); }
.pos-actions .btn-checkout { grid-column: 1 / -1; padding: 14px; font-size: 16px; }

/* Modal */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: none; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--radius);
    width: 95%; max-width: 480px; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.modal-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 16px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal-close { background: transparent; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); }

/* Receipt */
.receipt-page {
    background: #fff; color: #000;
    max-width: 320px; margin: 30px auto;
    padding: 20px; font-family: "Courier New", monospace; font-size: 13px;
    border: 1px dashed #999;
}
.receipt-page h2 { text-align: center; margin: 0 0 4px; }
.receipt-page .center { text-align: center; }
.receipt-page hr { border: 0; border-top: 1px dashed #555; margin: 10px 0; }
.receipt-page table { width: 100%; }
.receipt-page table td { padding: 2px 0; vertical-align: top; }
.receipt-page .right { text-align: right; }
.receipt-actions { text-align: center; margin: 16px 0; }
@media print {
    body * { visibility: hidden; }
    .receipt-page, .receipt-page * { visibility: visible; }
    .receipt-page { position: absolute; left: 0; top: 0; border: 0; margin: 0; }
    .receipt-actions { display: none; }
}

/* Login */
.auth-wrap {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px; background: var(--bg);
}
.auth-card {
    width: 100%; max-width: 380px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.auth-card h1 { text-align: center; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); text-align: center; margin-bottom: 20px; font-size: 13px; }

.toggle-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.menu-btn { display: none; background: transparent; border: 0; font-size: 22px; cursor: pointer; color: var(--text); }
@media (max-width: 900px) {
    .menu-btn { display: block; }
    .pos { grid-template-columns: 1fr; height: auto; }
    .pos-cart { height: auto; }
}
