/* POS Sate Gajah — admin UI foundation (no frameworks, responsive) */

:root {
    --primary: #1f4e3d;
    --primary-dark: #16382c;
    --accent: #d97706;
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #c0392b;
    --success: #1f7a4d;
    --sidebar-w: 240px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, "Segoe UI", 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 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary-dark);
    color: #e7efe9;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: transform .2s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand-mark {
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    border-radius: 8px;
    padding: 6px 9px;
    font-size: 15px;
}
.brand-name { font-weight: 700; }
.brand-sub { font-size: 12px; opacity: .75; }

.nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-link {
    display: block;
    color: #e7efe9;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
}
.nav-link:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-logout { color: #f3c5b4; }
.sidebar-foot { padding: 12px 8px; border-top: 1px solid rgba(255,255,255,.12); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar-title { font-weight: 700; font-size: 17px; flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
}

.content { padding: 24px 20px; max-width: 1280px; width: 100%; }

/* ---------- components ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }

.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); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat { text-align: center; }
.stat .stat-value { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat .stat-label { font-size: 13px; color: var(--muted); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-role { background: #e8eef7; color: #24568a; }
.badge-active { background: #e3f4ea; color: var(--success); }
.badge-inactive { background: #fdeaea; color: var(--danger); }
.badge-owner { background: #fdf0dc; color: #9a5b05; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--card);
}
table.data th, table.data td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data th { background: #fafbfc; font-weight: 600; color: #374151; white-space: nowrap; }
table.data tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.row-inactive td { color: var(--muted); }

/* ---------- forms ---------- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.form-group .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

input[type=text], input[type=password], input[type=number], input[type=email], input[type=date], input[type=month], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font: inherit;
    background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d6c6; border-color: var(--primary); }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.form-actions { display: flex; gap: 10px; margin-top: 18px; }

.checkbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.checkbox-list label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checkbox-list input { width: auto; }

/* ---------- flash ---------- */
.flash {
    padding: 11px 16px;
    border-radius: 8px;
    margin: 14px 20px 0;
    font-size: 14px;
}
.flash-success { background: #e3f4ea; color: #125c38; border: 1px solid #b5dfc6; }
.flash-error { background: #fdeaea; color: #8e2b1d; border: 1px solid #f2c1b8; }

/* ---------- auth pages ---------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark), #2c6b52);
    padding: 16px;
}
.auth-card {
    background: #fff;
    border-radius: 14px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.auth-brand { border-bottom: none; padding: 0 0 18px; }
.auth-brand .brand-name, .auth-brand .brand-sub { color: var(--text); }

/* ---------- responsive sidebar ---------- */
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-block; }
}

/* ---------- tablet-oriented POS screens ---------- */
.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.table-card { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #fff; }
.table-card button, .table-card a { display: block; width: 100%; }
.table-card > form { margin: 0; }
.table-card button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 22px 12px;
    text-align: center;
    font: inherit;
    color: inherit;
    width: 100%;
}
.table-card { display: block; text-decoration: none; color: inherit; padding: 22px 12px; text-align: center; }
.table-available { background: #eef7f0; border-color: #bfe0c9; }
.table-occupied { background: #fdf3e2; border-color: #f0d5a4; }
.table-code { font-size: 24px; font-weight: 800; }
.table-status { font-weight: 700; margin-top: 2px; }
.table-available .table-status { color: var(--success); }
.table-occupied .table-status { color: #9a5b05; }
.table-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.order-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .order-layout { grid-template-columns: 1fr; } }
.order-total { font-size: 26px; font-weight: 800; color: var(--primary); margin-top: 8px; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.product-card { border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; }
.product-card button {
    width: 100%; border: none; background: none; cursor: pointer; padding: 14px;
    font: inherit; text-align: left; color: inherit;
}
.product-card:hover { border-color: var(--primary); }
.product-name { font-weight: 700; font-size: 15px; }
.product-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.batch-row { border-bottom: 1px solid var(--border); padding: 10px 0; }
.batch-row:last-child { border-bottom: none; }

.kitchen-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .kitchen-columns { grid-template-columns: 1fr; } }
.kitchen-column { background: #eef0f2; border-radius: 12px; padding: 10px; min-height: 200px; }
.kitchen-col-head { margin: 0 0 10px; padding: 8px 10px; }
.ticket {
    background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary);
    border-radius: 8px; padding: 12px; margin-bottom: 10px;
}
.ticket-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 16px; }
.ticket-items { margin: 8px 0; }
.ticket-item { font-size: 15px; padding: 2px 0; }
.ticket-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---------- receipt (customer document; browser print, printer-agnostic) ---------- */
.receipt-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.receipt-paper {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    max-width: 420px;
    margin: 0 auto;
    padding: 22px 18px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.45;
}
.receipt-header { text-align: center; }
.receipt-business { font-size: 17px; font-weight: 700; }
.receipt-branch { font-weight: 600; margin-top: 2px; }
.receipt-meta { font-size: 12px; }
.receipt-custom-header { font-size: 12px; margin-top: 4px; white-space: pre-line; }
.receipt-divider { text-align: center; font-size: 12px; color: #444; margin: 8px 0; }
.receipt-items { width: 100%; border-collapse: collapse; }
.receipt-items td { padding: 1px 0; }
.receipt-qty { font-size: 12px; }
.receipt-num { text-align: right; font-variant-numeric: tabular-nums; }
.receipt-totals > div { display: flex; justify-content: space-between; }
.receipt-total-row { font-size: 15px; font-weight: 700; margin-top: 4px; }
.receipt-pay-row { font-size: 12px; }
.receipt-pay-row.muted, .receipt-pay-row.muted span { color: var(--muted); }
.receipt-footer { text-align: center; margin-top: 8px; font-size: 12px; white-space: pre-line; }

@media print {
    .sidebar, .topbar, .flash, .no-print, .receipt-actions { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; max-width: none !important; }
    .receipt-paper { border: none; border-radius: 0; max-width: 100%; padding: 0; }
    body { background: #fff; }
    @page { margin: 6mm; }
}

/* ---------- misc ---------- */
.pagination { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 6px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
code.mono { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
pre.code { background: #111827; color: #d1fae5; padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }

/* ---------- B-1 CSP remediation (Phase 3H-1) ----------
   Classes replacing former inline style="" attributes in views/.
   Declared AFTER the component rules on purpose: same-specificity
   conflicts (e.g. .m-0 vs .form-group, .btn-block vs .btn) are won by
   later declaration, exactly as the removed inline styles always won. */
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.fs-14 { font-size: 14px; }
.fs-18 { font-size: 18px; }
.fw-800 { font-weight: 800; }
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 2px; }
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-10 { margin-top: 10px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 4px; }
.mb-6 { margin-bottom: 6px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-14 { margin-bottom: 14px; }
.ml-20 { margin-left: 20px; }
.w-auto { width: auto; }
.w-full { width: 100%; }
.mw-340 { max-width: 340px; }
.mw-640 { max-width: 640px; }
.mw-680 { max-width: 680px; }
.mw-760 { max-width: 760px; }
.mw-860 { max-width: 860px; }
.min-w-44 { min-width: 44px; }
.min-w-140 { min-width: 140px; }
.min-w-160 { min-width: 160px; }
.d-inline { display: inline; }
.inline-flex { display: inline-flex; gap: 4px; align-items: center; }
.flex-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flex-row-6 { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.flex-row-10 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex-center { display: flex; gap: 10px; align-items: center; }
.flex-row-end { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.flex-1 { flex: 1; }
.row-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.row-between-tight { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.row-between-top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.nowrap { white-space: nowrap; }
.break-all { word-break: break-all; }
.text-center { text-align: center; }
.btn-block { width: 100%; font-size: 17px; padding: 12px; }
.btn-block-16 { width: 100%; font-size: 16px; padding: 12px; }
.btn-lg { font-size: 16px; padding: 10px 20px; }
.btn-xl { font-size: 18px; padding: 14px 28px; }
.form-grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.list-row { border-bottom: 1px solid var(--border); padding: 10px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card-edge-success { border-left: 4px solid var(--success); }
.card-edge-accent { border-left: 4px solid var(--accent); }
.card-edge-primary { border-left: 4px solid var(--primary); }
.card-edge-danger { border-left: 4px solid var(--danger); }
.card-primary { border: 2px solid var(--primary); }
.card-warning { border: 2px solid #d97706; }
.card-plain { display: flex; gap: 8px; flex-wrap: wrap; border: none; padding: 0; background: none; }
/* Element-qualified widths: input/select rules (specificity 0,1,1) set
   width:100%; these must win for the specific-width fields. */
input.w-110, select.w-110 { width: 110px; }
input.w-140, select.w-140 { width: 140px; }
input.w-180, select.w-180 { width: 180px; }
input.w-280, select.w-280 { width: 280px; }
input.w-auto, select.w-auto { width: auto; }
