/* Venda POS — application styles (on top of Bootstrap 4) */
:root {
	--brand: #1f8dd6;
	--brand-dark: #166fa9;
	--brand-soft: #e7f3fc;
	--ink: #1e293b;
	--muted: #64748b;
	--line: #e2e8f0;
	--surface: #ffffff;
	--canvas: #f4f6fa;
	--sidebar: #0b2340;
	--sidebar-ink: #cbd5e1;
	--ok: #15803d;
	--warn: #b45309;
	--bad: #b91c1c;
	--radius: 10px;
	--sidebar-w: 236px;
}

html, body { height: 100%; }
body.app {
	background: var(--canvas);
	color: var(--ink);
	font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14.5px;
}
a { color: var(--brand-dark); }
a:hover { color: var(--brand); }

/* ---------- Sidebar ---------- */
.app-sidebar {
	position: fixed; top: 0; bottom: 0; left: 0;
	width: var(--sidebar-w);
	background: var(--sidebar);
	color: var(--sidebar-ink);
	display: flex; flex-direction: column;
	z-index: 1040;
	transition: transform .2s ease;
}
.app-brand {
	display: flex; align-items: center; gap: 10px;
	padding: 18px 18px 14px;
	color: #fff; font-weight: 600; font-size: 16px;
	border-bottom: 1px solid rgba(255,255,255,.07);
}
.app-brand-mark {
	width: 34px; height: 34px; border-radius: 9px;
	background: var(--brand); color: #fff;
	display: inline-flex; align-items: center; justify-content: center;
	font-weight: 700; flex-shrink: 0;
}
.app-brand-name { line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.app-nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.app-nav-link {
	display: flex; align-items: center; gap: 12px;
	padding: 10px 12px; margin-bottom: 2px;
	border-radius: 8px;
	color: var(--sidebar-ink);
	font-weight: 500;
}
.app-nav-link svg { width: 19px; height: 19px; fill: currentColor; opacity: .8; flex-shrink: 0; }
.app-nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.app-nav-link.active { background: var(--brand); color: #fff; }
.app-nav-link.active svg { opacity: 1; }
.app-sidebar-foot { padding: 14px 18px; font-size: 11.5px; color: #64748b; border-top: 1px solid rgba(255,255,255,.07); }

/* ---------- Main ---------- */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar {
	position: sticky; top: 0; z-index: 1020;
	display: flex; align-items: center; gap: 14px;
	height: 60px; padding: 0 24px;
	background: var(--surface);
	border-bottom: 1px solid var(--line);
}
.app-title { font-size: 19px; font-weight: 600; margin: 0; flex: 1; }
.app-user { display: flex; align-items: center; gap: 10px; }
.app-user-name { font-weight: 500; }
.app-role { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.app-menu-btn { display: none; background: none; border: 0; padding: 6px; }
.app-menu-btn svg { width: 24px; height: 24px; fill: var(--ink); }
.app-content { padding: 24px; flex: 1; }
.app-backdrop { display: none; }

@media (max-width: 991px) {
	.app-sidebar { transform: translateX(-100%); }
	.sidebar-open .app-sidebar { transform: none; }
	.sidebar-open .app-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1030; }
	.app-main { margin-left: 0; }
	.app-menu-btn { display: inline-flex; }
	.app-content { padding: 16px; }
	.app-topbar { padding: 0 16px; }
	.app-user-name, .app-role { display: none; }
}

.impersonation-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 24px; background: #fef3c7; color: #78350f; border-bottom: 1px solid #fcd34d; font-size: 14px; }

/* ---------- Cards & panels ---------- */
.card, .panel {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.card-header {
	background: var(--surface);
	border-bottom: 1px solid var(--line);
	font-weight: 600;
	padding: 14px 18px;
	border-radius: var(--radius) var(--radius) 0 0 !important;
}
.panel { padding: 18px; }
.panel-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi-up { color: var(--ok); font-weight: 600; }
.kpi-down { color: var(--bad); font-weight: 600; }
.kpi.kpi-alert .kpi-value { color: var(--bad); }

/* Bar chart */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--brand); }
.chart .bar:hover { fill: var(--brand-dark); }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--line); }

/* Tables */
.table { color: var(--ink); }
.table thead th { border-top: 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.table td { vertical-align: middle; border-top-color: var(--line); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-striped tbody tr:nth-of-type(odd) { background-color: #f8fafc; }

/* Buttons */
.btn { border-radius: 8px; font-weight: 500; }
.btn-primary, .btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover, .btn-primary:focus, .btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-primary:not(:disabled):not(.disabled):active { background: var(--brand-dark); border-color: var(--brand-dark); }
.form-control { border-radius: 8px; border-color: #cbd5e1; }
.form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 .18rem rgba(31,141,214,.18); }
.requiredIcon { color: var(--bad); }

/* Status pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-ok { background: #dcfce7; color: var(--ok); }
.pill-warn { background: #fef3c7; color: var(--warn); }
.pill-bad { background: #fee2e2; color: var(--bad); }
.pill-muted { background: #f1f5f9; color: var(--muted); }

/* Inventory page (legacy tabs) */
.nav-pills .nav-link { color: var(--ink); border-radius: 8px; font-weight: 500; }
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { background: var(--brand); color: #fff; }
.nav-tabs .nav-link.active { color: var(--brand-dark); font-weight: 600; }
.inventory-tabs { gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.inventory-tabs .nav-link { background: var(--surface); border: 1px solid var(--line); }
.blueText { color: var(--brand-dark); }
ul.suggestionsList { background: #fff; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; padding: 0; box-shadow: 0 6px 18px rgba(15,23,42,.08); }
ul.suggestionsList li { padding: 10px 12px; list-style: none; }
ul.suggestionsList li:hover, ul.suggestionsList li.active { background: var(--brand-soft); }
ul.suggestionsList { max-height: 340px; overflow-y: auto; min-width: min(640px, calc(100vw - 48px)); }
.customListDivWidth { position: absolute; z-index: 500; width: 100%; }

/* ---------- POS checkout ---------- */
.pos-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
@media (max-width: 1199px) { .pos-layout { grid-template-columns: 1fr; } }
.pos-search { position: relative; }
.pos-search input { height: 52px; font-size: 17px; padding-left: 46px; }
.pos-search svg { position: absolute; left: 14px; top: 15px; width: 22px; height: 22px; fill: var(--muted); }
.pos-results { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.pos-item {
	text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
	padding: 12px; cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.pos-item:hover, .pos-item:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,141,214,.12); outline: 0; }
.pos-item:disabled { opacity: .5; cursor: not-allowed; }
.pos-item-name { font-weight: 600; line-height: 1.25; min-height: 36px; }
.pos-item-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; }
.pos-item-price { font-weight: 700; color: var(--brand-dark); }
.pos-item-code { color: var(--muted); font-size: 12px; }
.pos-cart { position: sticky; top: 80px; }
.pos-cart-lines { max-height: 46vh; overflow-y: auto; margin: 0 -18px; padding: 0 18px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.cart-line-name { font-weight: 600; }
.cart-line-total { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.cart-line-controls { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.qty-btn { width: 28px; height: 28px; border: 1px solid var(--line); background: #fff; border-radius: 6px; line-height: 1; font-weight: 700; }
.qty-btn:hover { border-color: var(--brand); }
.qty-input { width: 52px; height: 28px; text-align: center; border: 1px solid var(--line); border-radius: 6px; }
.cart-remove { background: none; border: 0; color: var(--bad); font-size: 12.5px; padding: 0 4px; }
.cart-empty { text-align: center; color: var(--muted); padding: 36px 0; }
.cart-totals { padding-top: 12px; }
.cart-totals .row-line { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; }
.cart-totals .grand { font-size: 22px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.pay-methods label { margin: 0; }
.pay-methods input { display: none; }
.pay-methods span { display: block; text-align: center; padding: 9px 4px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; }
.pay-methods input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.btn-checkout { height: 52px; font-size: 17px; font-weight: 700; }
.pos-cart-bar { display: none; }
@media (max-width: 1199px) {
	.pos-cart-bar:not(.d-none) {
		display: flex; justify-content: space-between; align-items: center; gap: 10px;
		position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 1010;
		padding: 14px 18px; border: 0; border-radius: 12px;
		background: var(--brand-dark); color: #fff; font-size: 15px;
		box-shadow: 0 8px 24px rgba(11,35,64,.35);
	}
	.pos-layout { padding-bottom: 70px; }
	.pos-cart { position: static; }
}
kbd.hint { background: #f1f5f9; color: var(--muted); border: 1px solid var(--line); font-size: 11px; padding: 1px 5px; }

/* ---------- Login ---------- */
body.login-page { background: var(--sidebar); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.login-card { background: #fff; border-radius: 14px; width: 100%; max-width: 400px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-card h1 { font-size: 22px; font-weight: 700; margin: 14px 0 4px; }
.login-card p.sub { color: var(--muted); margin-bottom: 22px; }
.login-foot { color: #64748b; font-size: 12px; text-align: center; margin-top: 18px; }

/* DataTables / chosen tidy-up */
.dataTables_wrapper .dataTables_filter input { border: 1px solid #cbd5e1; border-radius: 8px; padding: 4px 8px; }
.chosen-container-single .chosen-single { height: 38px; line-height: 36px; border-radius: 8px; background: #fff; box-shadow: none; border-color: #cbd5e1; }
.chosen-container-single .chosen-single div b { background-position: 0 9px; }

@media print {
	.app-sidebar, .app-topbar, .no-print { display: none !important; }
	.app-main { margin: 0; }
}
