/* ============================================================
   POS Móvil — Hoja de estilos de la PWA
   Paleta basada en el design-system del plugin (azul #007cba)
   Mobile-first · Safe areas iOS · Modo claro
   ============================================================ */

:root {
	--primary:        #007cba;
	--primary-dark:   #005a87;
	--primary-soft:   #e6f3f9;
	--success:        #28a745;
	--danger:         #dc3545;
	--warning:        #ffc107;
	--info:           #17a2b8;
	--bg:             #f2f4f7;
	--surface:        #ffffff;
	--text:           #1e293b;
	--text-soft:      #64748b;
	--border:         #dee2e6;
	--radius:         12px;
	--shadow:         0 2px 8px rgba(15, 23, 42, .08);
	--nav-h:          62px;
	--safe-bottom:    env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
	height: 100%;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	background: var(--bg);
	color: var(--text);
	font-size: 15px;
	overscroll-behavior-y: none;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

button { font-family: inherit; cursor: pointer; border: none; background: none; font-size: inherit; }
input, select, textarea {
	font-family: inherit; font-size: 16px; /* evita zoom iOS */
	border: 1px solid var(--border); border-radius: var(--radius);
	padding: 12px 14px; width: 100%; background: var(--surface); color: var(--text);
	outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ── Splash de arranque ── */
.boot-splash {
	flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
	min-height: 100vh; gap: 14px; background: #0f172a; color: #cbd5e1;
}
.boot-logo { font-size: 56px; }
.boot-text { font-size: 14px; }

/* ── Pantalla de login ── */
.login-screen {
	min-height: 100vh; display: flex; flex-direction: column;
	align-items: center; justify-content: center; padding: 24px;
	background: linear-gradient(160deg, #0f172a 0%, #005a87 100%);
}
.login-card {
	width: 100%; max-width: 380px; background: var(--surface);
	border-radius: 18px; padding: 28px 22px; box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.login-logo { text-align: center; font-size: 46px; margin-bottom: 6px; }
.login-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.login-sub { text-align: center; color: var(--text-soft); font-size: 13px; margin-bottom: 22px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; color: var(--text-soft); }
.login-error {
	background: #fdecea; color: var(--danger); border-radius: var(--radius);
	padding: 10px 12px; font-size: 13px; margin-top: 14px; display: none;
}
.login-error.show { display: block; }

/* ── Botones ── */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	border-radius: var(--radius); padding: 13px 18px; font-weight: 600;
	transition: opacity .15s, transform .05s; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:disabled { opacity: .6; }
.btn-success { background: var(--success); color: #fff; width: 100%; }
.btn-outline { border: 1.5px solid var(--border); color: var(--text); background: var(--surface); }
.btn-danger-soft { background: #fdecea; color: var(--danger); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 9px; }

/* ── Layout principal ── */
.app-header {
	position: sticky; top: 0; z-index: 40;
	background: var(--primary); color: #fff;
	padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
	display: flex; align-items: center; justify-content: space-between; gap: 10px;
	box-shadow: var(--shadow);
}
.app-header h1 { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .header-sub { font-size: 11px; opacity: .85; font-weight: 400; }
.offline-pill {
	background: var(--warning); color: #5d4a00; font-size: 11px; font-weight: 700;
	border-radius: 20px; padding: 4px 10px; display: none; white-space: nowrap;
}
.offline-pill.show { display: inline-block; }
.pending-pill {
	background: #fff; color: var(--primary); font-size: 11px; font-weight: 700;
	border-radius: 20px; padding: 4px 10px; display: none; white-space: nowrap;
}
.pending-pill.show { display: inline-block; }

.view { flex: 1; padding: 14px 14px calc(var(--nav-h) + var(--safe-bottom) + 90px); }

/* ── Navegación inferior ── */
.bottom-nav {
	position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
	background: var(--surface); border-top: 1px solid var(--border);
	display: flex; padding-bottom: var(--safe-bottom);
}
.bottom-nav button {
	flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
	padding: 9px 4px 7px; color: var(--text-soft); font-size: 10.5px; font-weight: 600;
}
.bottom-nav button .nav-ico { font-size: 21px; line-height: 1; }
.bottom-nav button.active { color: var(--primary); }

/* ── Tarjetas y secciones ── */
.card {
	background: var(--surface); border-radius: var(--radius);
	box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.section-title { font-size: 14px; font-weight: 700; margin: 18px 0 10px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .4px; }

/* ── POS: buscador y grid de productos ── */
.pos-search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.pos-search-row input { flex: 1; }
.btn-scan {
	background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
	width: 50px; flex: none; font-size: 20px;
}
.cat-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.cat-chips button {
	flex: none; background: var(--surface); border: 1.5px solid var(--border);
	border-radius: 20px; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--text-soft);
}
.cat-chips button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.product-card {
	background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
	padding: 12px; display: flex; flex-direction: column; gap: 4px; text-align: left;
}
.product-card:active { background: var(--primary-soft); }
.product-card .p-name { font-size: 13px; font-weight: 600; line-height: 1.25; min-height: 32px; }
.product-card .p-price { font-size: 15px; font-weight: 800; color: var(--primary); }
.product-card .p-stock { font-size: 11px; color: var(--text-soft); }
.product-card .p-stock.low { color: var(--danger); font-weight: 700; }

/* ── Barra flotante del carrito ── */
.cart-bar {
	position: fixed; left: 12px; right: 12px;
	bottom: calc(var(--nav-h) + var(--safe-bottom) + 10px); z-index: 45;
	background: var(--primary-dark); color: #fff; border-radius: 14px;
	display: none; align-items: center; justify-content: space-between;
	padding: 13px 16px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-weight: 700;
}
.cart-bar.show { display: flex; }

/* ── Modal genérico (hoja inferior) ── */
.sheet-backdrop {
	position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 60;
	display: none; align-items: flex-end;
}
.sheet-backdrop.show { display: flex; }
.sheet {
	background: var(--surface); width: 100%; max-height: 88vh; overflow-y: auto;
	border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom));
	animation: sheetUp .22s ease;
}
@keyframes sheetUp { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 44px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 14px; }
.sheet h2 { font-size: 17px; margin-bottom: 14px; }

/* ── Carrito ── */
.cart-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--bg); }
.cart-item .ci-info { flex: 1; min-width: 0; }
.cart-item .ci-name { font-size: 13.5px; font-weight: 600; }
.cart-item .ci-price { font-size: 12px; color: var(--text-soft); }
.qty-controls { display: flex; align-items: center; gap: 2px; }
.qty-controls button {
	width: 34px; height: 34px; border-radius: 9px; background: var(--bg);
	font-size: 18px; font-weight: 700; color: var(--primary); display: flex; align-items: center; justify-content: center;
}
.qty-controls .qty-num { min-width: 34px; text-align: center; font-weight: 700; font-size: 14px; }
.ci-total { font-weight: 800; font-size: 13.5px; min-width: 74px; text-align: right; }

.totals-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.totals-row.grand { font-size: 19px; font-weight: 800; border-top: 2px solid var(--bg); padding-top: 10px; margin-top: 6px; }
.totals-row .muted { color: var(--text-soft); }

.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 14px; }
.pay-methods button {
	border: 1.5px solid var(--border); border-radius: var(--radius); padding: 11px 6px;
	font-size: 12.5px; font-weight: 600; background: var(--surface); color: var(--text);
}
.pay-methods button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

/* ── Listas (ventas, stock bajo) ── */
.list-item {
	background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
	padding: 13px 14px; margin-bottom: 9px; display: flex; justify-content: space-between; gap: 10px; align-items: center;
	width: 100%; text-align: left;
}
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-size: 14px; font-weight: 700; }
.list-item .li-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.list-item .li-amount { font-size: 15px; font-weight: 800; color: var(--primary-dark); white-space: nowrap; }
.badge { font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.badge-success { background: #e6f6ea; color: var(--success); }
.badge-warning { background: #fff6d9; color: #8a6d00; }
.badge-pending { background: var(--primary-soft); color: var(--primary-dark); }

/* ── Dashboard ── */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.kpi {
	background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
	padding: 14px;
}
.kpi .kpi-label { font-size: 11.5px; color: var(--text-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.kpi .kpi-value { font-size: 21px; font-weight: 800; margin-top: 4px; color: var(--primary-dark); }
.kpi .kpi-extra { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 110px; padding-top: 8px; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-chart .bar { width: 100%; max-width: 34px; background: var(--primary); border-radius: 5px 5px 0 0; min-height: 3px; }
.bar-chart .bar-label { font-size: 9.5px; color: var(--text-soft); }

/* ── Notificaciones toast ── */
.toast-wrap { position: fixed; top: calc(70px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px; z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
	border-radius: var(--radius); padding: 12px 14px; color: #fff; font-size: 13.5px; font-weight: 600;
	box-shadow: 0 6px 18px rgba(0,0,0,.2); animation: slideDown .25s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
@keyframes slideDown { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Recibo de venta exitosa ── */
.receipt-ok { text-align: center; padding: 8px 0 4px; }
.receipt-ok .rk-icon { font-size: 52px; }
.receipt-ok .rk-total { font-size: 30px; font-weight: 800; color: var(--success); margin: 6px 0; }
.receipt-ok .rk-inv { color: var(--text-soft); font-size: 13px; margin-bottom: 16px; }

/* ── Utilidades ── */
.empty-state { text-align: center; color: var(--text-soft); padding: 44px 20px; font-size: 14px; }
.empty-state .es-ico { font-size: 42px; display: block; margin-bottom: 10px; }
.mt-8 { margin-top: 8px; } .mt-14 { margin-top: 14px; }
.row-gap { display: flex; gap: 8px; }
.row-gap > * { flex: 1; }
.spin {
	width: 26px; height: 26px; border: 3px solid var(--primary-soft); border-top-color: var(--primary);
	border-radius: 50%; margin: 30px auto; animation: rot .8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }
