/**
 * Skaner kodów kreskowych ISBN – style (samodzielny plik, bez builda)
 * Kolory zgodne z motywem: #FAD807 (yellowDark), #F8F6E1 (pole), #000
 */

/* ------------------------------------------------------------------ */
/* Przycisk w formularzu                                              */
/* ------------------------------------------------------------------ */

.isbn-scan-trigger {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	width: 100%;
	margin: 1.2rem 0;
	padding: 2rem 4rem;
	background-color: #FAD807;
	border: 0;
	color: #000;
	font-family: inherit;
	font-size: 2rem;
	line-height: 2.8rem;
	font-weight: 700;
	text-transform: uppercase;
	cursor: pointer;
	transition: all 0.4s;
}

.isbn-scan-trigger:hover {
	background-color: #000;
	color: #fff;
}

.isbn-scan-trigger svg {
	flex: 0 0 auto;
}

.isbn-scan-trigger__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 26px;
	height: 26px;
	padding: 0 7px;
	border-radius: 500px;
	background-color: #000;
	color: #FAD807;
	font-size: 14px;
	line-height: 1;
}

.isbn-scan-trigger:hover .isbn-scan-trigger__badge {
	background-color: #FAD807;
	color: #000;
}

.isbn-scan-trigger__badge[hidden] {
	display: none;
}


/* ------------------------------------------------------------------ */
/* Modal skanera                                                      */
/* ------------------------------------------------------------------ */

html.isbn-scan-open,
html.isbn-scan-open body {
	overflow: hidden;
}

.isbn-scan {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	background-color: #000;
	font-family: "Public Sans", sans-serif;
	color: #000;
	-webkit-tap-highlight-color: transparent;
}

.isbn-scan[hidden],
.isbn-scan [hidden] {
	display: none !important;
}

.isbn-scan button {
	font-family: inherit;
	cursor: pointer;
}

/* --- obraz z aparatu --- */

.isbn-scan__camera {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
	background-color: #000;
}

.isbn-scan__video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ramka celownika – rozmiar odpowiada obszarowi analizowanemu w JS */
.isbn-scan__frame {
	position: absolute;
	left: 50%;
	top: 50%;
	width: min(86%, 520px);
	aspect-ratio: 5 / 3;
	max-height: 45%;
	transform: translate(-50%, -50%);
	border-radius: 18px;
	box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55);
	transition: box-shadow 0.25s;
}

.isbn-scan__frame::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 18px;
	border: 3px solid #FAD807;
	transition: border-color 0.25s;
}

.isbn-scan__line {
	position: absolute;
	left: 6%;
	right: 6%;
	top: 50%;
	height: 2px;
	background-color: #FAD807;
	box-shadow: 0 0 12px 2px rgba(250, 216, 7, 0.7);
	animation: isbn-scan-line 2s ease-in-out infinite;
}

@keyframes isbn-scan-line {
	0%, 100% { transform: translateY(-40px); opacity: 0.6; }
	50% { transform: translateY(40px); opacity: 1; }
}

.isbn-scan__camera.is-hit .isbn-scan__frame::before {
	animation: isbn-scan-hit 0.6s ease-out;
}

@keyframes isbn-scan-hit {
	0% { border-color: #2ecc71; box-shadow: inset 0 0 0 200px rgba(46, 204, 113, 0.25); }
	100% { border-color: #FAD807; box-shadow: inset 0 0 0 200px rgba(46, 204, 113, 0); }
}

/* górny pasek */
.isbn-scan__bar {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
	color: #fff;
}

.isbn-scan__title {
	font-size: 16px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.isbn-scan__icon-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background-color: rgba(255, 255, 255, 0.18);
	color: #fff;
	transition: all 0.3s;
}

.isbn-scan__icon-btn:hover,
.isbn-scan__icon-btn.is-active {
	background-color: #FAD807;
	color: #000;
}

/* placeholder, żeby tytuł był wyśrodkowany gdy brak latarki */
.isbn-scan__bar::after {
	content: "";
	width: 44px;
}

.isbn-scan__bar:has([data-scan-torch]:not([hidden]))::after {
	display: none;
}

.isbn-scan__hint {
	position: absolute;
	left: 16px;
	right: 16px;
	bottom: 44px;
	margin: 0;
	text-align: center;
	color: #fff;
	font-size: 15px;
	line-height: 1.4;
	text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* komunikat po zeskanowaniu */
.isbn-scan__toast {
	position: absolute;
	left: 50%;
	top: calc(76px + env(safe-area-inset-top));
	transform: translate(-50%, -10px);
	max-width: calc(100% - 32px);
	padding: 10px 18px;
	border-radius: 500px;
	background-color: #fff;
	color: #000;
	font-size: 14px;
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s, transform 0.25s;
}

.isbn-scan__toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

.isbn-scan__toast.is-success { background-color: #FAD807; }
.isbn-scan__toast.is-error { background-color: #c00000; color: #fff; }

/* stan: ładowanie / błąd */
.isbn-scan__status {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 18px;
	padding: 24px;
	background-color: rgba(0, 0, 0, 0.85);
	text-align: center;
}

.isbn-scan__status-txt {
	max-width: 340px;
	margin: 0;
	color: #fff;
	font-size: 16px;
	line-height: 1.5;
}

.isbn-scan__retry {
	padding: 14px 28px;
	border: 0;
	border-radius: 500px;
	background-color: #FAD807;
	color: #000;
	font-size: 15px;
	font-weight: 700;
	text-transform: uppercase;
}


/* --- panel z listą --- */

.isbn-scan__panel {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	max-height: 46vh;
	max-height: 46dvh;
	padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
	border-radius: 24px 24px 0 0;
	margin-top: -24px;
	position: relative;
	background-color: #fff;
}

.isbn-scan__panel-top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
}

.isbn-scan__panel-top h3 {
	margin: 0;
	font-size: 17px;
	line-height: 1.3;
	font-weight: 700;
	white-space: nowrap;
}

@media (min-width: 992px) {
	.isbn-scan__hint {
		bottom: 24px;
	}
}

.isbn-scan__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 26px;
	height: 26px;
	margin-left: 6px;
	padding: 0 7px;
	border-radius: 500px;
	background-color: #FAD807;
	font-size: 14px;
	vertical-align: 1px;
}

.isbn-scan__sum {
	font-size: 14px;
	white-space: nowrap;
}

.isbn-scan__empty {
	margin: 4px 0 14px;
	color: #6D737A;
	font-size: 14px;
	line-height: 1.5;
}

.isbn-scan__list {
	flex: 1 1 auto;
	min-height: 0;
	margin: 0 0 12px;
	padding: 0;
	list-style: none;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.isbn-scan__item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 0;
	border-bottom: 1px solid #E6E6E6;
}

.isbn-scan__item.is-new {
	animation: isbn-scan-in 0.3s ease-out;
}

@keyframes isbn-scan-in {
	from { opacity: 0; transform: translateY(-6px); background-color: #FCF7ED; }
	to { opacity: 1; transform: none; }
}

.isbn-scan__item-body {
	display: flex;
	flex-direction: column;
	gap: 2px;
	flex: 1 1 auto;
	min-width: 0;
}

.isbn-scan__item-isbn {
	font-size: 13px;
	font-weight: 700;
}

.isbn-scan__item-isbn span {
	color: #6D737A;
	font-weight: 400;
}

.isbn-scan__item-title {
	font-size: 14px;
	line-height: 1.35;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.isbn-scan__item-info {
	font-size: 13px;
	line-height: 1.35;
	color: #6D737A;
}

.isbn-scan__item.is-ok .isbn-scan__item-info strong {
	color: #000;
	background-color: #FAD807;
	padding: 0 4px;
}

.isbn-scan__item.is-rejected .isbn-scan__item-isbn {
	text-decoration: line-through;
	color: #6D737A;
}

.isbn-scan__item.is-rejected .isbn-scan__item-info {
	color: #c00000;
}

.isbn-scan__qty {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
	border: 1px solid #E6E6E6;
	border-radius: 500px;
}

.isbn-scan__qty button {
	width: 32px;
	height: 32px;
	border: 0;
	background: none;
	font-size: 18px;
	line-height: 1;
	color: #000;
}

.isbn-scan__qty span {
	min-width: 18px;
	text-align: center;
	font-size: 14px;
	font-weight: 700;
}

.isbn-scan__remove {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	border: 0;
	border-radius: 50%;
	background-color: #F8F6E1;
	color: #000;
	transition: all 0.3s;
}

.isbn-scan__remove svg {
	width: 16px;
	height: 16px;
}

.isbn-scan__remove:hover {
	background-color: #c00000;
	color: #fff;
}

.isbn-scan .isbn-scan__submit {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	padding: 18px 24px;
	border: 0;
	background-color: #000;
	color: #fff;
	font-size: 17px;
	line-height: 24px;
	font-weight: 700;
	text-transform: uppercase;
	transition: all 0.4s;
}

.isbn-scan .isbn-scan__submit svg {
	margin: 0;
}

.isbn-scan .isbn-scan__submit svg path {
	fill: currentColor;
}

.isbn-scan .isbn-scan__submit:hover {
	background-color: #FAD807;
	color: #000;
}

.isbn-scan .isbn-scan__submit:disabled {
	opacity: 0.35;
	pointer-events: none;
}

.isbn-scan__submit-icon {
	display: inline-flex;
}

.isbn-scan__submit-icon:empty {
	display: none;
}


/* --- desktop: obraz i lista obok siebie --- */

@media (min-width: 992px) {
	.isbn-scan {
		flex-direction: row;
	}

	.isbn-scan__panel {
		width: 420px;
		max-height: none;
		margin-top: 0;
		border-radius: 0;
		padding: 32px 28px;
	}
}
