/* =============================================
 * Category Products Widget
 * ============================================= */
.cpw-widget {
	width: 100%;
}

/* =============================================
 * Toolbar
 * ============================================= */
.cpw-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 0;
	margin-bottom: 8px;
}

/* Category trigger (mobile only) */
.cpw-cat-trigger {
	display: none;
	align-items: center;
	gap: 5px;
	padding: 6px 14px;
	font-size: 14px;
	font-weight: 500;
	color: #333;
	background: #fff;
	border: 1px solid #ddd;
	cursor: pointer;
	white-space: nowrap;
}

.cpw-cat-trigger svg {
	flex-shrink: 0;
}

.cpw-sort-wrap {
	position: relative;
}

.cpw-sort-select {
	appearance: none;
	-webkit-appearance: none;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 20px;
	padding: 6px 32px 6px 16px;
	font-size: 14px;
	color: #333;
	cursor: pointer;
	outline: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
}

.cpw-sort-select:hover {
	border-color: #999;
}

/* Layout Toggle */
.cpw-layout-toggle {
	display: flex;
	align-items: center;
	gap: 6px;
}

.cpw-col-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	cursor: pointer;
	color: #ccc;
	border-radius: 4px;
	transition: color 0.2s ease, background-color 0.2s ease;
}

.cpw-col-btn:hover {
	color: #666;
}

.cpw-col-btn.cpw-col-active {
	color: #333;
}

/* =============================================
 * Product Grid
 * ============================================= */
.cpw-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
}

.cpw-cols-3 { grid-template-columns: repeat(3, 1fr); }
.cpw-cols-4 { grid-template-columns: repeat(4, 1fr); }
.cpw-cols-5 { grid-template-columns: repeat(5, 1fr); }

/* =============================================
 * Product Card
 * ============================================= */
.cpw-item {
	display: flex;
	flex-direction: column;
}

.cpw-card {
	display: flex;
	flex-direction: column;
	text-decoration: none;
	border: 1px solid #e8e8e8;
	overflow: hidden;
	flex: 1;
	border-radius: 8px;
}

.cpw-card:hover {
	text-decoration: none;
}

/* =============================================
 * Product Image
 * ============================================= */
.cpw-image {
	display: block;
	width: 100%;
	height: 220px;
	overflow: hidden;
	flex-shrink: 0;
}

.cpw-image img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
	object-position: center;
	transition: transform 0.3s ease;
}

.cpw-card:hover .cpw-image img {
	transform: scale(1.05);
}

.cpw-placeholder {
	display: block;
	width: 100%;
	height: 100%;
	background: #f5f5f5;
}

/* =============================================
 * Product Info
 * ============================================= */
.cpw-info {
	display: flex;
	flex-direction: column;
	padding: 10px 12px;
	flex: 1;
}

.cpw-title {
	font-size: 13px;
	line-height: 1.5;
	color: #333;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-bottom: 6px;
}

/* =============================================
 * Price
 * ============================================= */
.cpw-price-row {
	display: flex;
	align-items: baseline;
	gap: 6px;
	margin-bottom: 4px;
}

.cpw-price-current {
	font-size: 16px;
	font-weight: 700;
	color: #222;
	white-space: nowrap;
	line-height: 1.3;
}

.cpw-price-old {
	font-size: 12px;
	color: #999;
	text-decoration: line-through;
	white-space: nowrap;
}

/* =============================================
 * MOQ
 * ============================================= */
.cpw-moq {
	font-size: 12px;
	color: #999;
	line-height: 1.4;
}

/* =============================================
 * Inquiry Button
 * ============================================= */
.cpw-inquiry-btn {
	display: block;
	text-align: center;
	padding: 8px 12px;
	margin: 8px 12px 12px;
	font-size: 13px;
	color: #333;
	background: #fff;
	border: 1px solid #e0e0e0;
	margin-top: auto;
	transition: all 0.2s ease;
}

.cpw-card:hover .cpw-inquiry-btn {
	background: #333;
	color: #fff;
	border-color: #333;
}

/* =============================================
 * Pagination
 * ============================================= */
.cpw-pagination {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
	padding: 24px 0;
}
.cpw-pag-num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 8px;
	border: 1px solid #e0e0e0;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 500;
	color: #333;
	background: #fff;
	cursor: pointer;
	transition: all 0.25s ease;
	user-select: none;
}
.cpw-pag-num:hover {
	border-color: #333;
}
.cpw-pag-num.active {
	background: #333;
	border-color: #333;
	color: #fff;
	cursor: default;
}
.cpw-pag-arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border: 1px solid #e0e0e0;
	border-radius: 6px;
	background: #fff;
	cursor: pointer;
	transition: all 0.25s ease;
	user-select: none;
	color: #333;
}
.cpw-pag-arrow:hover {
	border-color: #333;
}
.cpw-pag-arrow.disabled {
	opacity: 0.35;
	cursor: default;
	pointer-events: none;
}
.cpw-pag-arrow i,
.cpw-pag-arrow svg,
.cpw-pag-arrow img {
	width: 16px;
	height: 16px;
	font-size: 16px;
	line-height: 1;
	display: block;
	color: inherit;
}
.cpw-widget.cpw-loading .cpw-grid {
	opacity: 0.5;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

/* =============================================
 * Mobile Responsive
 * ============================================= */
@media (max-width: 768px) {
	.cpw-grid {
		grid-template-columns: repeat(2, 1fr) !important;
	}

	.cpw-layout-toggle {
		display: none;
	}

	.cpw-image {
		height: 160px;
	}

	.cpw-title {
		font-size: 12px;
	}

	.cpw-price-current {
		font-size: 14px;
	}

	.cpw-inquiry-btn {
		font-size: 12px;
		padding: 6px 0;
	}
}

/* =============================================
 * Inquiry Modal Overlay
 * ============================================= */
.cpw-modal-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(0,0,0,0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.cpw-modal {
	position: relative;
	background: #fff;
	border-radius: 12px;
	max-width: 860px;
	width: 100%;
	max-height: 90vh;
	overflow-y: auto;
	box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.cpw-modal-close {
	position: absolute;
	top: 12px;
	right: 16px;
	font-size: 28px;
	line-height: 1;
	color: #999;
	cursor: pointer;
	z-index: 2;
	transition: color 0.2s;
}

.cpw-modal-close:hover {
	color: #333;
}

/* Modal Body: left 40% + right 60% */
.cpw-modal-body {
	display: flex;
	min-height: 420px;
}

.cpw-modal-left {
	width: 40%;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 32px 24px;
	background: #f8f8f8;
	border-radius: 12px 0 0 12px;
}

.cpw-modal-product-img {
	width: 100%;
	max-width: 240px;
	aspect-ratio: 1;
	overflow: hidden;
	background: #eee;
	margin-bottom: 16px;
}

.cpw-modal-product-img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.cpw-modal-product-name {
	font-size: 14px;
	color: #333;
	text-align: center;
	line-height: 1.5;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	word-break: break-word;
}

/* Modal Right: Form */
.cpw-modal-right {
	width: 60%;
	padding: 32px 28px;
}

.cpw-modal-title {
	font-size: 20px;
	font-weight: 600;
	color: #333;
	margin: 0 0 20px;
}

.cpw-form-fields {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
}

.cpw-field-wrap {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.cpw-field-half {
	width: calc(50% - 8px);
}

.cpw-field-full {
	width: 100%;
}

.cpw-field-label {
	font-size: 13px;
	font-weight: 600;
	color: #555;
}

.cpw-field-input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #d0d0d0;
	border-radius: 4px;
	font-size: 14px;
	color: #333;
	outline: none;
	transition: border-color 0.2s;
	box-sizing: border-box;
}

.cpw-field-input:focus {
	border-color: #666;
}

.cpw-textarea {
	min-height: 120px;
	resize: vertical;
}

.cpw-modal-submit {
	display: inline-block;
	margin-top: 20px;
	padding: 12px 35px;
	font-size: 14px;
	font-weight: 600;
	color: #fff;
	background: #000;
	border: none;
	cursor: pointer;
	transition: opacity 0.2s;
}

.cpw-modal-submit:hover {
	opacity: 0.85;
}

.cpw-form-message {
	margin-top: 12px;
	padding: 10px 14px;
	border-radius: 4px;
	font-size: 13px;
}

.cpw-form-message.cpw-msg-success {
	background: #f0faf0;
	color: #2e7d32;
	border: 1px solid #c8e6c9;
}

.cpw-form-message.cpw-msg-error {
	background: #fef0f0;
	color: #c62828;
	border: 1px solid #ffcdd2;
}

/* Toolbar Mobile */
@media (max-width: 768px) {
	.cpw-cat-trigger {
		display: inline-flex;
	}
}

/* Modal Mobile */
@media (max-width: 768px) {
	.cpw-modal-body {
		flex-direction: column;
	}

	.cpw-modal-left {
		width: 100%;
		border-radius: 12px 12px 0 0;
		padding: 20px;
		flex-direction: row;
		gap: 16px;
	}

	.cpw-modal-product-img {
		width: 80px;
		max-width: 80px;
		aspect-ratio: 1;
		margin-bottom: 0;
		flex-shrink: 0;
	}

	.cpw-modal-product-name {
		text-align: left;
		-webkit-line-clamp: 2;
	}

	.cpw-modal-right {
		width: 100%;
		padding: 20px;
	}

	.cpw-field-half {
		width: 100%;
	}
}
