/* ============================================================
   CaisseVie POS — register interface
   Palette:  ink #0C1320 · slate #16233A · line #24344F
             gold #E1AD01 (the one number that matters: le rendu)
             emerald #1FB37A (charge) · sky #5FA8E6 (tax/secondary)
   Type:     Poppins (UI) · Space Grotesk (figures, tabular)
   ============================================================ */

.cv-app *,
.cv-app *::before,
.cv-app *::after { box-sizing: border-box; }

.cv-app {
	--ink:    #0C1320;
	--slate:  #16233A;
	--slate2: #1C2C46;
	--line:   #24344F;
	--gold:   #E1AD01;
	--emerald:#1FB37A;
	--sky:    #5FA8E6;
	--text:   #EAF0FA;
	--muted:  #8597B4;
	--danger: #E2614B;

	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	background:
		radial-gradient(1200px 600px at 80% -10%, rgba(95,168,230,.10), transparent 60%),
		radial-gradient(900px 500px at -10% 110%, rgba(225,173,1,.08), transparent 55%),
		var(--ink);
	color: var(--text);
	font-family: 'Poppins', system-ui, sans-serif;
	z-index: 99990;
	overflow: hidden;
}

/* Defensive fallback: the plugin hides the WP admin bar on the register
   screen, but if a site forces it back on, sit the app below it instead
   of letting the bar overlap the POS top bar. */
body.admin-bar .cv-app { top: 32px; }
@media screen and (max-width: 782px) {
	body.admin-bar .cv-app { top: 46px; }
}

.cv-app input,
.cv-app button { font-family: inherit; }

/* numbers everywhere use the figure face + tabular spacing */
.cv-card-price, .cv-totals b, .cv-change-amt, .cv-tender input,
.cv-float-input input, .cv-line-total, .cv-line-qty {
	font-family: 'Space Grotesk', 'Poppins', sans-serif;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum" 1;
}

/* ---------- Top bar ---------- */
.cv-top {
	display: flex; align-items: center; justify-content: space-between;
	padding: 12px 20px; border-bottom: 1px solid var(--line);
	background: linear-gradient(180deg, rgba(255,255,255,.03), transparent);
}
.cv-brand { display: flex; align-items: baseline; gap: 12px; }
.cv-mark { color: var(--gold); font-size: 18px; }
.cv-brand-name { font-weight: 800; letter-spacing: .5px; }
.cv-store { color: var(--muted); font-size: 13px; font-weight: 500; }
.cv-top-right { display: flex; align-items: center; gap: 14px; }
.cv-cashier { color: var(--text); font-size: 13px; font-weight: 600; }
.cv-lang {
	background: var(--slate2); color: var(--text); border: 1px solid var(--line);
	border-radius: 999px; padding: 6px 14px; font-weight: 700; cursor: pointer;
	letter-spacing: 1px; transition: .15s;
}
.cv-lang:hover { border-color: var(--gold); color: var(--gold); }
.cv-manage {
	display: inline-flex; align-items: center; gap: 6px;
	background: rgba(225, 173, 1, .12); color: var(--gold);
	border: 1px solid rgba(225, 173, 1, .42);
	border-radius: 999px; padding: 6px 14px;
	font-size: 13px; font-weight: 700; text-decoration: none;
	transition: background .15s, border-color .15s, transform .12s;
}
.cv-manage:hover { background: rgba(225, 173, 1, .22); border-color: var(--gold); }
.cv-manage:active { transform: translateY(1px); }
.cv-manage-ic { font-size: 14px; line-height: 1; }
.cv-logout { color: var(--muted); font-size: 13px; text-decoration: none; }
.cv-logout:hover { color: var(--danger); }

/* ---------- Session gate ---------- */
.cv-session-gate, .cv-gate {
	flex: 1; display: grid; place-items: center; padding: 24px;
}
.cv-gate { color: var(--muted); }
.cv-session-card {
	background: var(--slate); border: 1px solid var(--line); border-radius: 18px;
	padding: 36px; width: min(440px, 92vw); text-align: center;
	box-shadow: 0 24px 60px rgba(0,0,0,.4);
}
.cv-session-card h2 { margin: 0 0 22px; font-weight: 700; }
.cv-session-card label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; text-align: left; }
.cv-float-input, .cv-tender {
	display: flex; align-items: center; gap: 8px; background: var(--ink);
	border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 18px;
}
.cv-cur { color: var(--gold); font-weight: 700; font-size: 20px; }
.cv-float-input input, .cv-tender input {
	flex: 1; background: transparent; border: 0; color: var(--text);
	font-size: 26px; font-weight: 700; outline: none; width: 100%;
}

/* ---------- Register grid ---------- */
.cv-grid {
	flex: 1; display: grid; grid-template-columns: 1fr 380px;
	gap: 0; min-height: 0;
}

/* Catalog */
.cv-catalog { display: flex; flex-direction: column; min-height: 0; padding: 16px 18px; }
.cv-search-row { margin-bottom: 12px; }
#cv-search {
	width: 100%; background: var(--slate); border: 1px solid var(--line);
	border-radius: 12px; padding: 14px 16px; color: var(--text); font-size: 15px; outline: none;
}
#cv-search:focus { border-color: var(--sky); }
.cv-cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; }
.cv-cat {
	flex: 0 0 auto; background: var(--slate); border: 1px solid var(--line);
	color: var(--muted); border-radius: 999px; padding: 8px 16px; font-weight: 600;
	font-size: 13px; cursor: pointer; transition: .15s; white-space: nowrap;
}
.cv-cat:hover { color: var(--text); }
.cv-cat.active { background: var(--gold); color: #1A1300; border-color: var(--gold); }

.cv-products {
	flex: 1; overflow-y: auto; display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 12px; align-content: start; padding: 4px 2px 24px;
}
.cv-card {
	display: flex; flex-direction: column; gap: 6px; text-align: left;
	background: linear-gradient(180deg, var(--slate2), var(--slate));
	border: 1px solid var(--line); border-radius: 14px; padding: 14px;
	color: var(--text); cursor: pointer; min-height: 96px; position: relative;
	transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.cv-card:hover { transform: translateY(-2px); border-color: var(--sky); box-shadow: 0 10px 24px rgba(0,0,0,.35); }
.cv-card:active { transform: translateY(0) scale(.98); }
.cv-card-name { font-weight: 600; font-size: 14px; line-height: 1.25; flex: 1; }
.cv-card-price { color: var(--gold); font-weight: 700; font-size: 18px; }
.cv-card-stock { font-size: 11px; color: var(--muted); }
.cv-card-stock.low { color: var(--gold); }
.cv-card-stock.oos { color: var(--danger); }
.cv-card.is-oos { opacity: .5; cursor: not-allowed; }
.cv-card.hidden { display: none; }
.cv-card.flash { animation: cvFlash .4s ease; }
@keyframes cvFlash { 0% { box-shadow: 0 0 0 0 var(--sky); } 100% { box-shadow: 0 0 0 12px transparent; } }

/* Ticket / cart */
.cv-ticket {
	display: flex; flex-direction: column; min-height: 0; overflow: hidden;
	background: var(--slate); border-left: 1px solid var(--line);
}
.cv-ticket-head {
	display: flex; align-items: center; justify-content: space-between;
	padding: 16px 18px 10px;
}
.cv-ticket-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .3px; }
.cv-link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; }
.cv-link:hover { color: var(--danger); }

.cv-lines { flex: 1; overflow-y: auto; padding: 0 18px; min-height: 0; }
.cv-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 10px; }
.cv-line {
	display: flex; flex-direction: column; gap: 8px;
	padding: 12px 0; border-bottom: 1px solid var(--line);
}
.cv-line-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cv-line-name {
	font-size: 14.5px; font-weight: 700; color: var(--text); line-height: 1.3;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cv-line-rm {
	flex: none; width: 24px; height: 24px; border-radius: 7px; border: 0;
	background: var(--slate2); color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
	display: grid; place-items: center; transition: color .15s, background .15s;
}
.cv-line-rm:hover { color: #fff; background: var(--danger); }
.cv-line-bottom { display: flex; align-items: center; gap: 10px; }
.cv-qty-ctl { display: flex; align-items: center; gap: 6px; flex: none; }
.cv-qty-btn {
	width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
	background: var(--slate2); color: var(--text); cursor: pointer; font-size: 17px;
	line-height: 1; display: grid; place-items: center;
}
.cv-qty-btn:hover { border-color: var(--sky); }
.cv-line-qty { min-width: 24px; text-align: center; font-weight: 700; font-size: 15px; }
.cv-line-price-wrap {
	display: inline-flex; align-items: baseline; gap: 2px;
	background: var(--slate); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px;
	transition: border-color .15s, color .15s;
}
.cv-line-price-wrap.is-edited { border-color: var(--gold); color: var(--gold); }
.cv-line-price-in {
	width: 58px; background: transparent; border: 0; color: inherit;
	font-family: 'Space Grotesk', monospace; font-size: 13px; font-weight: 700; padding: 0;
	-moz-appearance: textfield;
}
.cv-line-price-in::-webkit-outer-spin-button, .cv-line-price-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cv-line-price-in:focus { outline: none; }
.cv-line-ea { font-size: 10px; color: var(--muted); letter-spacing: .02em; }
.cv-line-price-wrap.is-edited .cv-line-ea { color: var(--gold); }
.cv-line-total {
	margin-left: auto; font-weight: 800; font-size: 16px; color: var(--text);
	font-family: 'Space Grotesk', monospace; font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* Discount box */
.cv-discount { padding: 12px 18px 0; }
.cv-discount-in { display: flex; gap: 8px; }
.cv-discount-in input {
	flex: 1; min-width: 0; background: var(--slate); border: 1px solid var(--line);
	border-radius: 9px; color: var(--text); padding: 9px 12px; font-size: 14px;
	font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
}
.cv-discount-in input:focus { outline: none; border-color: var(--gold); }
.cv-btn-ghost { background: var(--slate2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 9px 16px; font-weight: 700; cursor: pointer; }
.cv-btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.cv-discount-msg { font-size: 12px; margin-top: 6px; min-height: 16px; }
.cv-discount-msg.is-ok { color: var(--emerald); }
.cv-discount-msg.is-err { color: var(--danger); }

/* Totals */
.cv-totals { padding: 14px 18px; border-top: 1px solid var(--line); }
.cv-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--muted); font-size: 14px; }
.cv-row b { color: var(--text); }
.cv-row-discount span { display: inline-flex; align-items: center; gap: 6px; }
.cv-row-discount em { color: var(--gold); font-style: normal; font-size: 12px; font-weight: 700; }
.cv-row-discount b { color: var(--gold); }
.cv-discount-clear { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0; }
.cv-discount-clear:hover { color: var(--danger); }
.cv-row-total { font-size: 20px; margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--line); }
.cv-row-total span, .cv-row-total b { color: var(--text); font-weight: 800; }

/* Payment */
.cv-pay { padding: 14px 18px 18px; border-top: 1px solid var(--line); flex-shrink: 0; }
.cv-pay-methods { display: flex; gap: 8px; margin-bottom: 12px; }
.cv-pm {
	flex: 1; background: var(--slate2); border: 1px solid var(--line); color: var(--muted);
	border-radius: 10px; padding: 9px; font-weight: 600; cursor: pointer; font-size: 13px; transition: .15s;
}
.cv-pm.active { background: var(--sky); border-color: var(--sky); color: #06121F; }
.cv-tender-label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.cv-quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.cv-quick button {
	background: var(--slate2); border: 1px solid var(--line); color: var(--text);
	border-radius: 9px; padding: 9px 4px; font-weight: 600; cursor: pointer; font-size: 13px;
}
.cv-quick button:hover { border-color: var(--gold); color: var(--gold); }

/* Signature: change-due panel */
.cv-change {
	display: flex; align-items: center; justify-content: space-between;
	background:
		linear-gradient(135deg, rgba(225,173,1,.16), rgba(225,173,1,.04));
	border: 1px solid rgba(225,173,1,.35); border-radius: 14px;
	padding: 14px 18px; margin-bottom: 14px;
}
.cv-change-label { color: var(--gold); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.cv-change-amt {
	font-size: 30px; font-weight: 700; color: var(--gold);
	text-shadow: 0 0 24px rgba(225,173,1,.4);
}
.cv-change.pop .cv-change-amt { animation: cvPop .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes cvPop { 0% { transform: scale(.7); opacity: .3; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

/* Buttons */
.cv-btn {
	border: 1px solid var(--line); background: var(--slate2); color: var(--text);
	border-radius: 12px; padding: 12px 18px; font-weight: 700; cursor: pointer;
	font-size: 15px; transition: .15s;
}
.cv-btn:hover { border-color: var(--sky); }
.cv-btn-primary { background: var(--sky); border-color: var(--sky); color: #06121F; width: 100%; }
.cv-btn-charge {
	width: 100%; background: var(--emerald); border-color: var(--emerald); color: #04140C;
	font-size: 18px; padding: 16px; letter-spacing: .3px;
}
.cv-btn-charge:disabled { background: var(--slate2); border-color: var(--line); color: var(--muted); cursor: not-allowed; }
.cv-btn-charge:not(:disabled):hover { box-shadow: 0 10px 26px rgba(31,179,122,.4); }

/* Footer / EOD */
.cv-footer {
	display: flex; align-items: center; justify-content: space-between;
	padding: 10px 20px; border-top: 1px solid var(--line);
	background: rgba(0,0,0,.2);
}
.cv-session-info { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.cv-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 10px var(--emerald); }
.cv-btn-eod { background: transparent; border-color: var(--gold); color: var(--gold); padding: 8px 16px; font-size: 13px; }
.cv-btn-eod:hover { background: var(--gold); color: #1A1300; }

/* ---------- Modal (receipt / EOD) ---------- */
.cv-modal {
	position: fixed; inset: 0; background: rgba(6,12,22,.78);
	display: grid; place-items: center; z-index: 99999; padding: 20px;
	backdrop-filter: blur(4px);
}
.cv-modal[hidden] { display: none; }
.cv-modal-card {
	background: #fff; color: #1A2435; border-radius: 16px; width: min(420px, 94vw);
	max-height: 90vh; overflow-y: auto; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.5);
}

/* Receipt */
.cv-receipt { font-family: 'Space Grotesk', monospace; color: #1A2435; }
.cv-r-head { text-align: center; margin-bottom: 12px; }
.cv-r-store { font-weight: 700; font-size: 18px; }
.cv-r-addr { font-size: 12px; color: #6B7A90; }
.cv-r-meta { display: flex; justify-content: space-between; font-size: 12px; color: #45556B; }
.cv-receipt hr { border: 0; border-top: 1px dashed #C3CDDB; margin: 10px 0; }
.cv-r-items { width: 100%; font-size: 13px; }
.cv-r-items td { padding: 3px 0; vertical-align: top; }
.cv-r-q { color: #6B7A90; width: 34px; }
.cv-r-unit { display: block; font-size: 11px; color: #8A97A8; }
.cv-r-unit s { opacity: .7; }
.cv-r-p { text-align: right; white-space: nowrap; }
.cv-r-tot { width: 100%; font-size: 14px; }
.cv-r-tot td { padding: 3px 0; }
.cv-r-tot td:last-child { text-align: right; }
.cv-r-grand td { font-weight: 800; font-size: 17px; border-top: 1px solid #1A2435; padding-top: 6px; }
.cv-r-change td { color: #B07900; font-weight: 700; }
.cv-r-foot { text-align: center; font-size: 12px; color: #45556B; margin-top: 6px; }
.cv-state-short td { color: #C0392B; }
.cv-state-over td { color: #1F8F5F; }
.cv-state-balanced td { color: #1F8F5F; }

.cv-modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.cv-modal-actions button { flex: 1; }
.cv-mb-print { background: #1A2435; color: #fff; border: 0; border-radius: 10px; padding: 12px; font-weight: 700; cursor: pointer; }
.cv-mb-new { background: var(--emerald); color: #04140C; border: 0; border-radius: 10px; padding: 12px; font-weight: 700; cursor: pointer; }
.cv-mb-close { background: #E7ECF3; color: #1A2435; border: 0; border-radius: 10px; padding: 12px; font-weight: 700; cursor: pointer; }

/* EOD form inside modal */
.cv-eod-form label { display: block; font-size: 13px; color: #45556B; margin: 12px 0 6px; }
.cv-eod-form input, .cv-eod-form textarea {
	width: 100%; border: 1px solid #C3CDDB; border-radius: 10px; padding: 10px 12px; font-size: 15px;
	font-family: 'Space Grotesk', monospace;
}
.cv-eod-summary { background: #F2F5F9; border-radius: 12px; padding: 14px; margin: 8px 0; }
.cv-eod-summary .cv-row { color: #45556B; }
.cv-eod-summary .cv-row b { color: #1A2435; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
	.cv-grid { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
	.cv-ticket { border-left: 0; border-top: 1px solid var(--line); max-height: 60vh; overflow-y: auto; }
	.cv-lines { overflow: visible; }
	.cv-products { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

@media print {
	body * { visibility: hidden; }
	#cv-receipt-print, #cv-receipt-print * { visibility: visible; }
	#cv-receipt-print { position: absolute; left: 0; top: 0; width: 100%; color: #000; }
}

/* Accessibility */
.cv-app button:focus-visible, .cv-app input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .cv-app * { animation: none !important; transition: none !important; } }
