/**
 * Estilos cuando la app se abre como PWA (standalone) o modo app preferido.
 */
@media (display-mode: standalone) {
	body {
		padding-top: env(safe-area-inset-top, 0px);
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}
	.navbar-fixed-top {
		top: env(safe-area-inset-top, 0px);
	}
}

html.web-app-prefer .navbar-fixed-top {
	top: env(safe-area-inset-top, 0px);
}

html.web-app-prefer body {
	min-height: 100vh;
	min-height: 100dvh;
}

/*
 * Botón flotante "ocultar menú" en POS:
 * Oculto en pantallas muy anchas; visible al reducir ventana (escritorio) o en tablet/móvil.
 */
ul.cbp-vimenu .pos-floating-nav-toggle,
ul.cbp-vimenu2 .pos-floating-nav-toggle,
ul.cbp-vimenu .pos-fullscreen-toggle,
ul.cbp-vimenu2 .pos-fullscreen-toggle {
	display: none !important;
}

/* Pantalla completa POS: sin tooltip Bootstrap (en Chrome móvil el tooltip flotaba mal); mejor toque directo */
ul.cbp-vimenu .pos-fullscreen-toggle a,
ul.cbp-vimenu2 .pos-fullscreen-toggle a {
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

@media (max-width: 1400px) {
	ul.cbp-vimenu .pos-floating-nav-toggle,
	ul.cbp-vimenu2 .pos-floating-nav-toggle,
	ul.cbp-vimenu .pos-fullscreen-toggle,
	ul.cbp-vimenu2 .pos-fullscreen-toggle {
		display: list-item !important;
	}
	body.pos-hide-main-nav .navbar.navbar-fixed-top {
		transform: translateY(-100%);
		visibility: hidden;
		pointer-events: none;
		transition: transform 0.25s ease, visibility 0.25s;
	}
	body.pos-hide-main-nav {
		padding-top: 12px;
	}
	body.pos-hide-main-nav .cbp-vimenu,
	body.pos-hide-main-nav .cbp-vimenu2 {
		top: 12px;
	}
	/* Franja del título (ej. "Cliente sin Registrar") bajo el menú oculto */
	body.pos-hide-main-nav .pos-context-header {
		display: none !important;
	}
}

/*
 * POS (navegador ancho o móvil): totales + botones fijos al pie del viewport; carrito con scroll.
 */
.pos-mobile-checkout-layout .footer-section {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	max-width: 100%;
	z-index: 1025;
	background-color: inherit;
	border-top: 2px solid rgba(0, 0, 0, 0.1);
	box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.14);
	padding: 8px 12px;
	padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
	margin: 0 !important;
	box-sizing: border-box;
}

/* Fila: totales a la izquierda, dos botones compactos en 2 columnas a la derecha */
.pos-mobile-checkout-layout .footer-section .pos-checkout-dock-row {
	display: flex;
	flex-direction: row;
	align-items: stretch;
	gap: 12px;
	width: 100%;
}

/* ~70% totales / ~30% botones (proporción flex 7:3 respecto al ancho disponible) */
.pos-mobile-checkout-layout .pos-checkout-dock-totals {
	flex: 7 1 0;
	min-width: 0;
}

.pos-mobile-checkout-layout .pos-checkout-dock-totals .totalTab {
	margin-bottom: 0;
}

.pos-mobile-checkout-layout .pos-checkout-dock-totals .table {
	margin-bottom: 0;
}

.pos-mobile-checkout-layout .pos-checkout-dock-totals .table > tbody > tr > td {
	padding: 7px 10px;
	font-size: 15px;
	vertical-align: middle;
}

.pos-mobile-checkout-layout .pos-checkout-dock-buttons {
	flex: 3 1 0;
	min-width: 0;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px 10px;
	align-content: center;
}

.pos-mobile-checkout-layout .pos-dock-action-btn {
	min-height: 52px !important;
	height: auto !important;
	padding: 12px 8px !important;
	margin: 0 !important;
	white-space: normal;
	line-height: 1.2;
	border-radius: 6px;
}

.pos-mobile-checkout-layout .pos-dock-action-label {
	display: block;
	font-weight: 700;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	word-break: break-word;
}

.pos-mobile-checkout-layout {
	padding-bottom: calc(200px + env(safe-area-inset-bottom, 0px));
}

.pos-mobile-checkout-layout .left-side {
	margin-bottom: 0 !important;
	padding-bottom: 8px;
}

.pos-mobile-checkout-layout #productList {
	max-height: clamp(120px, calc(100vh - 340px), min(55vh, 520px));
	max-height: clamp(120px, calc(100dvh - 340px), min(55vh, 520px));
	min-height: 100px;
	overflow-y: auto !important;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	width: 100% !important;
}

.pos-mobile-checkout-layout #productList2 {
	overflow: visible !important;
	height: auto !important;
	max-height: none !important;
}

@media (max-width: 991px) {
	.pos-mobile-checkout-layout .pos-checkout-dock-totals .table > tbody > tr > td {
		padding: 6px 8px;
		font-size: 13px;
	}

	.pos-mobile-checkout-layout .pos-checkout-dock-buttons {
		gap: 6px 8px;
	}

	.pos-mobile-checkout-layout .pos-dock-action-btn {
		min-height: 48px !important;
		padding: 10px 6px !important;
	}

	.pos-mobile-checkout-layout .pos-dock-action-label {
		font-size: 11px;
	}

	.pos-mobile-checkout-layout {
		padding-bottom: calc(190px + env(safe-area-inset-bottom, 0px));
	}

	.pos-mobile-checkout-layout #productList {
		max-height: min(42vh, 280px);
		max-height: min(42dvh, 280px);
	}
}

@media (max-width: 360px) {
	.pos-mobile-checkout-layout .pos-checkout-dock-totals,
	.pos-mobile-checkout-layout .pos-checkout-dock-buttons {
		max-width: none;
	}

	.pos-mobile-checkout-layout .pos-checkout-dock-row {
		flex-wrap: wrap;
	}

	.pos-mobile-checkout-layout .pos-checkout-dock-totals {
		flex: 1 1 100%;
	}

	.pos-mobile-checkout-layout .pos-checkout-dock-buttons {
		flex: 1 1 100%;
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/*
 * POS móvil/tablet en horizontal: carrito y catálogo en dos columnas.
 */
@media (max-width: 991px) {
	.pos-mobile-checkout-layout > .row {
		display: flex;
		flex-wrap: wrap;
	}
	.pos-mobile-checkout-layout > .row > .left-side,
	.pos-mobile-checkout-layout > .row > .right-side {
		float: none;
		width: 100%;
		max-width: 100%;
	}

	@media (orientation: landscape) {
		.pos-mobile-checkout-layout > .row {
			flex-wrap: nowrap;
			align-items: flex-start;
		}
		.pos-mobile-checkout-layout > .row > .left-side {
			flex: 0 0 40%;
			max-width: 40%;
			width: 40%;
			padding-left: 8px;
			padding-right: 8px;
		}
		.pos-mobile-checkout-layout > .row > .right-side {
			flex: 0 0 60%;
			max-width: 60%;
			width: 60%;
			padding-left: 4px;
			padding-right: 4px;
		}
		.pos-mobile-checkout-layout #productList {
			max-height: min(68vh, 420px) !important;
			max-height: min(68dvh, 420px) !important;
			overflow-y: auto !important;
			overflow-x: hidden;
			-webkit-overflow-scrolling: touch;
		}
	}
}

/* POS: bloque «Elegir cliente» colapsable si ancho ≤1080px (retrato y apaisado; por defecto oculto) */
@media (min-width: 1081px) {
	.pos-mobile-checkout-layout .pos-mobile-client-toggle {
		display: none !important;
	}
	.pos-mobile-checkout-layout .pos-mobile-client-panel {
		max-height: none !important;
		opacity: 1 !important;
		overflow: visible !important;
	}
}

@media (max-width: 1080px) {
	.pos-mobile-checkout-layout .pos-mobile-client-toggle {
		display: block;
		margin-top: 6px;
		margin-bottom: 8px;
		text-align: left;
		padding: 0 !important;
		border-radius: 8px;
		border: 1px solid rgba(0, 0, 0, 0.12);
		background: #f8f9fa;
		box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
		touch-action: manipulation;
		-webkit-tap-highlight-color: transparent;
	}
	.pos-mobile-client-toggle-row {
		display: flex;
		align-items: center;
		gap: 10px;
		width: 100%;
	}
	.pos-mobile-client-toggle-icon {
		flex-shrink: 0;
		width: 1.2em;
		text-align: center;
		color: #2c7873;
	}
	.pos-mobile-client-toggle-text {
		flex: 1;
		min-width: 0;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 2px;
	}
	.pos-mobile-client-toggle-summary {
		font-size: 14px;
		display: block;
		width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.pos-mobile-checkout-layout .pos-mobile-client-panel {
		max-height: 0;
		overflow: hidden;
		opacity: 0;
		transition: max-height 0.35s ease, opacity 0.2s ease;
		margin-bottom: 0;
	}
	body.pos-mobile-client-expanded .pos-mobile-checkout-layout .pos-mobile-client-panel {
		max-height: 560px;
		opacity: 1;
		overflow: visible;
		margin-bottom: 8px;
	}
}
