/* ============ 2hand PC Builder ============ */
.pcb-app{
	--pcb-primary: var(--mauchudao, #1e3a8a);
	--pcb-primary-2: var(--mauchudao2, #2743b3);
	--mauchudao2: #2743b3;
	--pcb-bg: #f4f5f9;
	--pcb-border: #e6e8ef;
	--pcb-muted: #6b7280;
	--pcb-radius: 10px;
	background: var(--pcb-bg);
	padding: 16px;
	border-radius: 12px;
	color: #1a1a1a;
	font-size: 14px;
}
.pcb-app *{ box-sizing: border-box; }
.pcb-app button{ cursor: pointer; font-family: inherit; }

/* ---- Toolbar ---- */
.pcb-toolbar{
	display: flex; align-items: center; justify-content: space-between;
	gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.pcb-configs{ display: flex; gap: 10px; }
.pcb-config-btn{
	border: 1px solid var(--pcb-border); background: #eef0f6; color: #374151;
	padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 13px;
}
.pcb-config-btn.is-active{ background: var(--mauchudao2); color: #fff; border-color: var(--mauchudao2); }
.pcb-actions-top{ display: flex; gap: 10px; align-items: center; }
.pcb-reset{
	background: var(--mauchudao2); color: #fff; border: none;
	padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 13px;
}
.pcb-load{ position: relative; }
.pcb-load-btn{
	background: #fff; color: #374151; border: 1px solid var(--pcb-border);
	padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 13px;
}
.pcb-load-menu{
	position: absolute; right: 0; top: calc(100% + 4px); margin: 0; padding: 6px;
	list-style: none; background: #fff; border: 1px solid var(--pcb-border);
	border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 20; min-width: 160px;
}
.pcb-load-menu li{ padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.pcb-load-menu li:hover{ background: #f1f3f9; }

/* ---- Body layout ---- */
.pcb-body{ display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 900px){ .pcb-body{ grid-template-columns: 1fr; } }

/* ---- Slot rows ---- */
.pcb-slots{ display: flex; flex-direction: column; gap: 12px; }
.pcb-slot{
	display: grid;
	grid-template-columns: 110px 84px 1fr 150px 130px 90px;
	align-items: center; gap: 12px;
	background: #fff; border: 1px solid var(--pcb-border);
	border-radius: var(--pcb-radius); padding: 14px 16px;
}
.pcb-slot__name{ font-weight: 700; color: #111827; display: flex; align-items: center; gap: 8px; }
.pcb-slot__name i{ color: var(--mauchudao2); font-size: 16px; width: 20px; text-align: center; }
.pcb-slot__thumb{ width: 72px; height: 72px; border: 1px solid var(--pcb-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #fff; }
.pcb-slot__thumb img{ max-width: 100%; max-height: 100%; object-fit: contain; }
.pcb-slot__thumb-ph{ color: #cbd0dc; font-size: 26px; }
.pcb-slot__info{ min-width: 0; }
.pcb-slot__empty{ color: var(--pcb-muted); }
.pcb-slot__title{ font-weight: 600; color: #111827; text-decoration: none; display: block; line-height: 1.35; }
.pcb-slot__title:hover{ color: var(--mauchudao2); }
.pcb-slot__sku{ color: var(--pcb-muted); font-size: 12px; margin-top: 2px; }
.pcb-slot__qty{ display: flex; align-items: center; gap: 8px; }
.pcb-qty-del, .pcb-qty-plus{
	width: 30px; height: 30px; border: 1px solid var(--pcb-border); background: #fff;
	border-radius: 6px; font-size: 14px; line-height: 1; color: #374151;
}
.pcb-qty-val{ min-width: 24px; text-align: center; font-weight: 600; }
.pcb-qty-remove{ color: var(--mauchudao2); font-size: 12px; text-decoration: none; margin-left: 4px; }
.pcb-slot__price{ font-weight: 700; color: var(--pcb-primary); text-align: right; }
.pcb-slot__cta{ text-align: right; }
.pcb-choose{
	background: var(--mauchudao2); color: #fff; border: none; padding: 8px 18px;
	border-radius: 8px; font-weight: 600;
}
.pcb-slot.is-filled .pcb-choose{ background: #fff; color: var(--mauchudao2); border: 1px solid var(--mauchudao2); }
@media (max-width: 720px){
	.pcb-slot{ grid-template-columns: 60px 1fr auto; grid-template-areas:
		"thumb name cta" "thumb info info" "thumb qty price"; }
	.pcb-slot__name{ grid-area: name; } .pcb-slot__thumb{ grid-area: thumb; width: 56px; height: 56px; }
	.pcb-slot__info{ grid-area: info; } .pcb-slot__qty{ grid-area: qty; } .pcb-slot__price{ grid-area: price; text-align: left; }
	.pcb-slot__cta{ grid-area: cta; }
}

/* ---- Summary ---- */
.pcb-summary{ position: sticky; top: 20px; display: flex; flex-direction: column; gap: 12px; }
.pcb-summary__box{ background: #fff; border: 1px solid var(--pcb-border); border-radius: var(--pcb-radius); padding: 18px; }
.pcb-summary__total-label{ text-align: center; font-weight: 600; margin-bottom: 14px; }
.pcb-summary__total{ color: var(--pcb-primary); font-size: 20px; font-weight: 800; }
.pcb-buy-now, .pcb-add-cart{ display: block; width: 100%; text-align: center; border-radius: 8px; padding: 12px; font-weight: 700; border: none; }
.pcb-buy-now{ background: var(--mauchudao2); color: #fff; margin-bottom: 10px; }
.pcb-add-cart{ background: #e8ecfb; color: var(--mauchudao2); }
.pcb-consult{ display: block; text-align: center; background: var(--mauchudao2); color: #fff !important; border-radius: 8px; padding: 12px; font-weight: 700; text-decoration: none; }

/* ---- Modal ---- */
/* Khai báo biến lại vì modal/loading có thể được chuyển ra ngoài .pcb-app (append vào body). */
.pcb-modal, .pcb-loading, .pcb-toast{
	--pcb-primary: var(--mauchudao, #1e3a8a);
	--mauchudao2: #2743b3;
	--pcb-border: #e6e8ef;
	--pcb-muted: #6b7280;
}
.pcb-modal{ position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.pcb-modal[hidden]{ display: none; }
.pcb-modal__overlay{ position: absolute; inset: 0; background: rgba(15,23,42,.5); }
.pcb-modal__dialog{
	position: relative; z-index: 1; width: min(1080px, 96vw); max-height: 86vh;
	background: #fff; border-radius: 14px;
	display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.pcb-modal__head{ display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--pcb-border); }
.pcb-modal__title{ font-size: 18px; font-weight: 700; white-space: nowrap; }
.pcb-modal__search{ flex: 1; display: flex; align-items: center; gap: 8px; background: #f4f5f9; border: 1px solid var(--pcb-border); border-radius: 24px; padding: 8px 16px; }
.pcb-modal__search i{ color: var(--pcb-muted); }
.pcb-modal__search input{ flex: 1; border: none; background: transparent; outline: none; font-size: 14px; }
.pcb-modal__close{ background: none; border: none; font-size: 20px; color: #374151; }
.pcb-modal__main{ flex: 1; display: grid; grid-template-columns: 240px 1fr; min-height: 0; }
.pcb-modal__filters{ border-right: 1px solid var(--pcb-border); padding: 20px; overflow-y: auto; }
.pcb-filter__title{ font-weight: 700; margin-bottom: 12px; }
.pcb-price-inputs{ display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.pcb-price-inputs input{ width: 100%; border: 1px solid var(--pcb-border); border-radius: 8px; padding: 8px; text-align: center; font-size: 12px; background: #fff; }

/* dual range */
.pcb-range{ position: relative; height: 32px; margin-bottom: 14px; }
.pcb-range__track{ position: absolute; top: 14px; left: 0; right: 0; height: 4px; background: #e0e3ee; border-radius: 3px; }
.pcb-range__fill{ position: absolute; height: 100%; background: var(--mauchudao2); border-radius: 3px; }
.pcb-range input[type=range]{ position: absolute; top: 8px; left: 0; width: 100%; margin: 0; -webkit-appearance: none; appearance: none; background: none; pointer-events: none; height: 16px; }
.pcb-range input[type=range]::-webkit-slider-thumb{ -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--mauchudao2); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--mauchudao2); pointer-events: auto; cursor: pointer; }
.pcb-range input[type=range]::-moz-range-thumb{ width: 16px; height: 16px; border-radius: 50%; background: var(--mauchudao2); border: 2px solid #fff; pointer-events: auto; cursor: pointer; }
.pcb-price-apply{ background: var(--mauchudao2); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-weight: 600; width: 100%; }

.pcb-modal__content{ padding: 16px 20px; overflow-y: auto; }
.pcb-sort{ display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.pcb-sort__label{ color: var(--pcb-muted); font-weight: 600; }
.pcb-sort__opts{ display: flex; gap: 8px; flex-wrap: wrap; }
.pcb-sort-btn{ border: 1px solid var(--pcb-border); background: #fff; border-radius: 8px; padding: 8px 14px; font-size: 13px; color: #374151; }
.pcb-sort-btn.is-active{ background: var(--mauchudao2); color: #fff; border-color: var(--mauchudao2); }

.pcb-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.pcb-card{ border: 1px solid var(--pcb-border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; background: #fff; }
.pcb-card__media{ position: relative; height: 140px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.pcb-card__media img{ max-width: 100%; max-height: 100%; object-fit: contain; }
.pcb-card__badge{ position: absolute; left: 0; top: 8px; background: #7c3aed; color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px; }
.pcb-card__brand{ color: var(--pcb-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.pcb-card__title{ font-size: 13px; line-height: 1.4; margin: 4px 0 8px; min-height: 36px; color: #111827; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcb-card__price{ font-weight: 700; color: var(--pcb-primary); font-size: 14px; }
.pcb-card__price del{ color: var(--pcb-muted); font-weight: 400; font-size: 12px; }
.pcb-card__off{ color: #e23b3b; font-weight: 700; font-size: 12px; margin-left: 4px; }
.pcb-card__spec{ margin: 8px 0; font-size: 11px; color: #4b5563; background: #f4f5f9; border-radius: 6px; padding: 6px 8px; }
.pcb-card__choose{ margin-top: auto; background: #fff; color: var(--mauchudao2); border: 1px solid var(--mauchudao2); border-radius: 8px; padding: 8px; font-weight: 600; }
.pcb-card__choose:hover{ background: var(--mauchudao2); color: #fff; }

.pcb-modal__status{ text-align: center; color: var(--pcb-muted); padding: 30px; }
.pcb-pagination{ display: flex; justify-content: center; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pcb-pagination button{ min-width: 34px; height: 34px; border: 1px solid var(--pcb-border); background: #fff; border-radius: 8px; color: #374151; }
.pcb-pagination button.is-active{ background: var(--mauchudao2); color: #fff; border-color: var(--mauchudao2); }
.pcb-pagination button[disabled]{ opacity: .4; cursor: default; }

@media (max-width: 720px){ .pcb-modal__main{ grid-template-columns: 1fr; } .pcb-modal__filters{ border-right: none; border-bottom: 1px solid var(--pcb-border); } }

/* ---- Loading ---- */
.pcb-loading{ position: fixed; inset: 0; background: rgba(255,255,255,.55); z-index: 100001; display: flex; align-items: center; justify-content: center; }
.pcb-loading[hidden]{ display: none; }
.pcb-spinner{ width: 40px; height: 40px; border: 4px solid #d5d9e6; border-top-color: var(--mauchudao2); border-radius: 50%; animation: pcb-spin .8s linear infinite; }
@keyframes pcb-spin{ to{ transform: rotate(360deg); } }

/* toast */
.pcb-toast{ position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #111827; color: #fff; padding: 12px 20px; border-radius: 8px; z-index: 100002; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 14px; }
