/* ============================================================
   SCHOOLY — Premium Cart Sidebar
============================================================ */

.cart-sidebar-overlay {
	background: rgba(15, 23, 42, 0.38);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1),
		visibility 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.cart-sidebar-overlay.is-open {
	opacity: 1;
	visibility: visible;
}

.cart-sidebar {
	left: auto !important;
	right: 0;
	width: min(400px, 100vw);
	height: 100dvh;
	background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
	box-shadow: -12px 0 48px rgba(15, 23, 42, 0.12);
	transform: translateX(100%);
	transition: transform 0.52s cubic-bezier(0.22, 1, 0.36, 1),
		box-shadow 0.52s cubic-bezier(0.22, 1, 0.36, 1);
	will-change: transform;
}

.cart-sidebar.is-open {
	left: auto !important;
	right: 0 !important;
	transform: translateX(0);
	box-shadow: -20px 0 60px rgba(15, 23, 42, 0.18);
}

html[dir="rtl"] .cart-sidebar {
	right: auto !important;
	left: 0 !important;
	transform: translateX(-100%);
	box-shadow: 12px 0 48px rgba(15, 23, 42, 0.12);
}

html[dir="rtl"] .cart-sidebar.is-open {
	right: auto !important;
	left: 0 !important;
	transform: translateX(0);
	box-shadow: 20px 0 60px rgba(15, 23, 42, 0.18);
}

.cart-sidebar__layout {
	display: flex;
	flex-direction: column;
	grid-template-columns: 1fr !important;
	height: 100%;
}

.cart-sidebar__col--related {
	display: none !important;
}

.cart-sidebar__col--cart {
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 0;
	background: transparent;
}

/* —— Header —— */
.cart-sidebar__header {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 20px 22px 18px;
	border-bottom: 1px solid rgba(226, 232, 240, 0.9);
	background: rgba(255, 255, 255, 0.92);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
}

.cart-sidebar__header-main {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
}

.cart-sidebar__header-icon {
	flex-shrink: 0;
	width: 42px;
	height: 42px;
	display: grid;
	place-items: center;
	border-radius: 12px;
	background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
	color: #2563eb;
	font-size: 17px;
}

.cart-sidebar__header-text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.cart-sidebar__header h3 {
	margin: 0;
	color: #0f172a;
	font-size: 17px;
	font-weight: 900;
	line-height: 1.2;
	letter-spacing: -0.02em;
}

.cart-sidebar__header-count {
	color: #64748b;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.3;
}

.cart-sidebar__close {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	display: inline-grid;
	place-items: center;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	background: #fff;
	color: #64748b;
	font-size: 15px;
	cursor: pointer;
	transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease,
		transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.cart-sidebar__close:hover {
	border-color: #cbd5e1;
	background: #f1f5f9;
	color: #0f172a;
	transform: rotate(90deg) scale(1.04);
}

/* —— Body —— */
.cart-sidebar__body {
	flex: 1 1 auto;
	min-height: 0;
	padding: 18px 20px;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: #cbd5e1 transparent;
}

.cart-sidebar__body::-webkit-scrollbar {
	width: 5px;
}

.cart-sidebar__body::-webkit-scrollbar-thumb {
	border-radius: 999px;
	background: #cbd5e1;
}

.cart-sidebar__body::-webkit-scrollbar-thumb:hover {
	background: #94a3b8;
}

.cart-sidebar__list {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* —— Item card —— */
.cart-sidebar__item {
	display: flex;
	gap: 14px;
	padding: 14px;
	padding-inline-end: 44px;
	border: 1px solid rgba(226, 232, 240, 0.95);
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
	animation: schoolyCartItemIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
	transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
	position: relative;
}

.cart-sidebar__item:nth-child(1) {
	animation-delay: 0.04s;
}
.cart-sidebar__item:nth-child(2) {
	animation-delay: 0.08s;
}
.cart-sidebar__item:nth-child(3) {
	animation-delay: 0.12s;
}
.cart-sidebar__item:nth-child(4) {
	animation-delay: 0.16s;
}
.cart-sidebar__item:nth-child(n + 5) {
	animation-delay: 0.2s;
}

.cart-sidebar__item:hover {
	border-color: #dbeafe;
	box-shadow: 0 2px 4px rgba(15, 23, 42, 0.05), 0 12px 32px rgba(37, 99, 235, 0.08);
	transform: translateY(-1px);
}

.cart-sidebar__item.is-removing {
	opacity: 0;
	transform: scale(0.96) translateX(16px);
	transition: opacity 0.32s ease, transform 0.32s ease;
	pointer-events: none;
}

html[dir="rtl"] .cart-sidebar__item.is-removing {
	transform: scale(0.96) translateX(-16px);
}

@keyframes schoolyCartItemIn {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.cart-sidebar__media {
	position: relative;
	flex: 0 0 88px;
	width: 88px;
	height: 88px;
}

.cart-sidebar__img {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 14px;
	background: linear-gradient(145deg, #f1f5f9, #e2e8f0);
	overflow: hidden;
	transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.cart-sidebar__item:hover .cart-sidebar__img {
	transform: scale(1.02);
}

.cart-sidebar__img img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cart-sidebar__remove {
	position: absolute;
	top: 12px;
	inset-inline-end: 12px;
	inset-inline-start: auto;
	left: auto;
	right: auto;
	z-index: 2;
	width: 28px;
	height: 28px;
	display: inline-grid;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: #94a3b8;
	font-size: 11px;
	box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
	cursor: pointer;
	transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.cart-sidebar__remove:hover {
	background: #fef2f2;
	color: #ef4444;
	transform: scale(1.08);
}

.cart-sidebar__info {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 5px;
}

.cart-sidebar__cat {
	color: #94a3b8;
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.cart-sidebar__name {
	color: #0f172a;
	font-size: 14px;
	font-weight: 800;
	line-height: 1.4;
	text-decoration: none;
	transition: color 0.2s ease;
}

.cart-sidebar__name:hover {
	color: #2563eb;
}

.cart-sidebar__meta {
	display: inline-flex;
	align-self: flex-start;
	margin-top: 1px;
	padding: 4px 10px;
	border-radius: 999px;
	background: linear-gradient(135deg, #eff6ff, #f0f9ff);
	color: #1d4ed8;
	font-size: 11px;
	font-weight: 800;
	line-height: 1.2;
}

.cart-sidebar__qty-row {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	margin-top: auto;
	padding-top: 10px;
}

.cart-qty-control {
	display: inline-flex;
	align-items: center;
	flex: none;
	flex-shrink: 0;
	white-space: nowrap;
	padding: 3px;
	border: 1px solid #e2e8f0;
	border-radius: 999px;
	background: #f8fafc;
}

.cart-qty-btn {
	flex: none;
}

.cart-qty-btn {
	width: 30px;
	height: 30px;
	display: inline-grid;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #475569;
	font-size: 14px;
	font-weight: 800;
	cursor: pointer;
	transition: background 0.22s ease, color 0.22s ease, transform 0.2s ease;
}

.cart-qty-btn:hover:not(:disabled) {
	background: #fff;
	color: #2563eb;
	box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.cart-qty-btn:active:not(:disabled) {
	transform: scale(0.92);
}

.cart-qty-btn:disabled {
	cursor: wait;
	opacity: 0.45;
}

.cart-qty-val {
	min-width: 32px;
	text-align: center;
	color: #0f172a;
	font-size: 14px;
	font-weight: 900;
	transition: opacity 0.2s ease;
}

.cart-qty-val.is-loading {
	font-size: 0;
	opacity: 0.6;
}

.cart-qty-val.is-loading::after {
	content: "";
	width: 14px;
	height: 14px;
	display: inline-block;
	border: 2px solid #e2e8f0;
	border-top-color: #2563eb;
	border-radius: 50%;
	animation: schoolyQtySpin 0.65s linear infinite;
}

@keyframes schoolyQtySpin {
	to {
		transform: rotate(360deg);
	}
}

.cart-sidebar__price-col {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	text-align: start;
	width: 100%;
}

.cart-sidebar__price {
	color: #1550ac;
	font-size: 15px;
	font-weight: 900;
	white-space: nowrap;
	line-height: 1.2;
}

.cart-sidebar__price del {
	color: #4b5c76;
	font-size: 11px;
	font-weight: 600;
	opacity: 1;
	text-decoration-line: line-through;
	text-decoration-thickness: 1.5px;
	text-decoration-color: rgba(75, 92, 118, 0.75);
}

.cart-sidebar__price ins {
	color: #dc2626;
	text-decoration: none;
	opacity: 1;
}

.cart-sidebar__line-total {
	color: #64748b;
	font-size: 11px;
	font-weight: 600;
}

/* —— Empty —— */
.cart-sidebar__empty {
	min-height: min(360px, 50vh);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: 32px 24px;
	text-align: center;
	animation: schoolyCartItemIn 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.cart-sidebar__empty-icon {
	width: 88px;
	height: 88px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: linear-gradient(145deg, #f1f5f9, #e2e8f0);
	color: #94a3b8;
	font-size: 34px;
}

.cart-sidebar__empty p {
	margin: 0;
	color: #64748b;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.5;
}

.cart-sidebar__empty .cart-sidebar__btn {
	min-width: 180px;
	margin-top: 4px;
}

/* —— Footer —— */
.cart-sidebar__footer {
	flex-shrink: 0;
	padding: 18px 20px calc(18px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid rgba(226, 232, 240, 0.95);
	background: rgba(255, 255, 255, 0.94);
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.06);
}

.cart-sidebar__footer:empty {
	display: none;
}

.cart-sidebar__subtotal {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	margin-bottom: 16px;
	padding: 14px 16px;
	border: 1px solid #e2e8f0;
	border-radius: 14px;
	background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.cart-sidebar__subtotal span {
	color: #64748b;
	font-size: 13px;
	font-weight: 700;
	line-height: 1.35;
}

.cart-sidebar__subtotal strong {
	color: #0f172a;
	font-size: 20px;
	font-weight: 900;
	letter-spacing: -0.02em;
	line-height: 1.2;
}

.cart-sidebar__footer-btns {
	display: grid;
	gap: 10px;
}

.cart-sidebar__btn {
	min-height: 50px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 0 20px;
	border: 0;
	border-radius: 14px;
	background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
	color: #fff;
	font-size: 14px;
	font-weight: 900;
	text-decoration: none;
	box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
	transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease,
		filter 0.28s ease;
}

.cart-sidebar__btn:hover {
	color: #fff;
	transform: translateY(-2px);
	box-shadow: 0 8px 24px rgba(37, 99, 235, 0.42);
	filter: brightness(1.05);
}

.cart-sidebar__btn:active {
	transform: translateY(0);
}

.cart-sidebar__btn--outline {
	background: #fff;
	color: #0f172a;
	border: 1.5px solid #e2e8f0;
	box-shadow: none;
}

.cart-sidebar__btn--outline:hover {
	background: #f8fafc;
	border-color: #cbd5e1;
	color: #0f172a;
	box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
	filter: none;
	transform: none;
}

/* —— Badge bounce —— */
.ecommza-cart-count.is-updated,
#cartCount.is-updated {
	animation: schoolyCartBadgePop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes schoolyCartBadgePop {
	0% {
		transform: scale(1);
	}
	40% {
		transform: scale(1.35);
	}
	100% {
		transform: scale(1);
	}
}

@media (max-width: 480px) {
	.cart-sidebar {
		width: 100%;
		max-width: 100%;
	}

	.cart-sidebar__header,
	.cart-sidebar__body,
	.cart-sidebar__footer {
		padding-inline: 16px;
	}

	.cart-sidebar__media {
		flex: 0 0 76px;
		width: 76px;
		height: 76px;
	}
}

body.cart-sidebar-open {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.cart-sidebar,
	.cart-sidebar-overlay,
	.cart-sidebar__item,
	.cart-sidebar__close,
	.cart-sidebar__btn {
		transition-duration: 0.01ms !important;
		animation: none !important;
	}
}
