/*
 * Ngăn kéo giỏ hàng. Viết mới hoàn toàn — không lấy gì từ CheckoutWC.
 *
 * Màu bám theo bảng màu đang có của site (xanh #1b254f, đỏ #e01e26) qua biến,
 * để theme đổi màu là ngăn kéo đổi theo mà không phải sửa file này.
 */

:root {
	--ptc-fab-bottom: 20px;
	--ptc-fab-right: 24px;
	--ptc-icon-width: 30px;
	--ptc-icon-color: #222;
	--ptc-accent: #1b254f;
	--ptc-accent-2: #e01e26;
	--ptc-width: 380px;
	--ptc-radius: 6px;
	--ptc-border: #e5e7eb;
}

/* --------------------------------------------------------------------- *
 * Nút giỏ nổi
 * --------------------------------------------------------------------- */

.ptc-fab {
	position: fixed;
	bottom: var(--ptc-fab-bottom);
	right: var(--ptc-fab-right);
	z-index: 9998;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: var(--ptc-icon-color);
	box-shadow: 0 2px 12px rgb(0 0 0 / 18%);
	cursor: pointer;
}

.ptc-fab:hover,
.ptc-fab:focus-visible {
	box-shadow: 0 4px 18px rgb(0 0 0 / 26%);
}

.ptc-fab__icon {
	width: var(--ptc-icon-width);
	height: auto;
}

.ptc-fab__count {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 10px;
	background: var(--ptc-accent-2);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
}

/* --------------------------------------------------------------------- *
 * Lớp phủ + ngăn kéo
 * --------------------------------------------------------------------- */

.ptc-overlay {
	position: fixed;
	inset: 0;
	z-index: 9998;
	background: rgb(0 0 0 / 45%);
}

/* Khoá cuộn nền khi ngăn kéo mở. Đặt trên <html> chứ không phải <body> để
   không đụng vào các plugin khác cũng thích sửa style của body. */
.ptc-open {
	overflow: hidden;
}

.ptc-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 9999;
	display: flex;
	flex-direction: column;
	width: min(var(--ptc-width), 100vw);
	background: #fff;
	box-shadow: -2px 0 18px rgb(0 0 0 / 20%);
}

/* Thanh quản trị của WordPress là `position:fixed` với z-index cao hơn — không
   đẩy ngăn kéo xuống thì phần đầu (tiêu đề + nút đóng) nằm khuất dưới nó. Chỉ
   ảnh hưởng người đã đăng nhập, nhưng đó chính là người quản trị site. */
.admin-bar .ptc-drawer {
	top: 32px;
}

@media screen and (max-width: 782px) {
	.admin-bar .ptc-drawer {
		top: 46px;
	}
}

/* `hidden` phải thắng `display:flex` — nếu không thì ngăn kéo hiện thường trực. */
.ptc-drawer[hidden],
.ptc-overlay[hidden],
.ptc-fab[hidden],
.ptc-fab__count[hidden] {
	display: none;
}

.ptc-drawer__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px;
	border-bottom: 1px solid var(--ptc-border);
}

.ptc-drawer__title {
	margin: 0;
	font-size: 17px;
	font-weight: 700;
	text-transform: uppercase;
	color: var(--ptc-accent);
}

.ptc-drawer__close {
	flex: none;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	background: none;
	color: #6b7280;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.ptc-drawer__body {
	flex: 1;
	overflow-y: auto;
	padding: 16px 18px 24px;
}

.ptc-drawer__error {
	margin: 0;
	padding: 10px 18px;
	background: #fef2f2;
	color: #b91c1c;
	font-size: 13px;
}

/* --------------------------------------------------------------------- *
 * Danh sách sản phẩm
 * --------------------------------------------------------------------- */

.ptc-cart__list {
	margin: 0 0 16px;
	padding: 0;
	list-style: none;
}

.ptc-cart__item {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 12px 0;
	border-bottom: 1px solid var(--ptc-border);
}

.ptc-cart__item.is-busy {
	opacity: 0.5;
	pointer-events: none;
}

.ptc-cart__thumb {
	flex: none;
	width: 64px;
}

.ptc-cart__thumb img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--ptc-radius);
}

.ptc-cart__body {
	flex: 1;
	min-width: 0;
}

.ptc-cart__name {
	display: block;
	margin-bottom: 6px;
	color: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.35;
	text-decoration: none;
}

.ptc-cart__price {
	display: block;
	margin-bottom: 6px;
	font-size: 13px;
}

.ptc-cart__remove {
	flex: none;
	width: 24px;
	height: 24px;
	padding: 0;
	border: 0;
	background: none;
	color: #9ca3af;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.ptc-cart__remove:hover {
	color: var(--ptc-accent-2);
}

.ptc-cart__empty {
	margin: 0 0 14px;
	color: #6b7280;
}

.ptc-cart__total {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin: 0 0 14px;
	font-weight: 700;
}

/* --------------------------------------------------------------------- *
 * Bộ đếm số lượng
 * --------------------------------------------------------------------- */

.ptc-qty {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--ptc-border);
	border-radius: 999px;
	overflow: hidden;
}

.ptc-qty__btn {
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	background: none;
	color: #374151;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
}

.ptc-qty__btn:hover {
	background: #f3f4f6;
}

.ptc-qty__value {
	min-width: 28px;
	font-size: 13px;
	font-weight: 600;
	text-align: center;
}

/* Ô gõ số lượng: trông như chữ, bỏ mũi tên tăng/giảm của trình duyệt. */
.ptc-qty input.ptc-qty__value {
	width: 3.25em;
	height: 28px;
	margin: 0;
	padding: 0 2px;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font-family: inherit;
	-moz-appearance: textfield;
	appearance: textfield;
}

.ptc-qty input.ptc-qty__value::-webkit-inner-spin-button,
.ptc-qty input.ptc-qty__value::-webkit-outer-spin-button {
	margin: 0;
	-webkit-appearance: none;
}

.ptc-qty input.ptc-qty__value:focus {
	outline: 2px solid var(--ptc-accent, #2563eb);
	outline-offset: -2px;
}

.ptc-qty.is-locked {
	border-color: transparent;
}

/* --------------------------------------------------------------------- *
 * Nút
 * --------------------------------------------------------------------- */

.ptc-btn {
	display: block;
	padding: 12px 18px;
	border-radius: var(--ptc-radius);
	font-size: 14px;
	font-weight: 600;
	text-align: center;
	text-decoration: none;
}

.ptc-btn--primary {
	background: var(--ptc-accent);
	color: #fff;
}

.ptc-btn--primary:hover {
	background: #16204a;
	color: #fff;
}

.ptc-btn--ghost {
	border: 1px solid var(--ptc-border);
	background: #f9fafb;
	color: #374151;
}

@media (max-width: 480px) {
	:root {
		--ptc-width: 100vw;
	}
}
