/**
 * VSH COUPON POPUP
 * Dùng các biến CSS global của Vinsmarthome.
 */

/* =========================================================
   HIDE DEFAULT COUPON FORMS
========================================================= */

body.woocommerce-cart .woocommerce-cart-form .coupon,
body.woocommerce-cart form.ux-cart-coupon,
body.woocommerce-cart .ux-cart-coupon,
body.woocommerce-checkout .woocommerce-form-coupon-toggle,
body.woocommerce-checkout form.checkout_coupon,
body.woocommerce-checkout form.woocommerce-form-coupon {
	display: none !important;
}

/* =========================================================
   TRIGGER UNDER CART SUBTOTAL
========================================================= */

.vsh-coupon-trigger-row > td {
	padding-bottom: 11px !important;
	background: transparent !important;
	border-bottom: 1px solid var(--vsh-border) !important;
}

body.woocommerce-cart .cart_totals .vsh-coupon-trigger-row > td,
body.woocommerce-checkout .woocommerce-checkout-review-order-table .vsh-coupon-trigger-row > td {
	padding-right: 18px !important;
	padding-left: 18px !important;
}

.vsh-coupon-open.button.is-link {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;

	width: 100%;
	min-height: 34px;

	margin: 0 !important;
	padding: 4px 0 !important;

	color: var(--vsh-blue) !important;
	background: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;

	font-size: 13px;
	font-weight: 400;
	line-height: 1.35;
	letter-spacing: 0;
	text-align: left;
	text-transform: none;
}

.vsh-coupon-open.button.is-link:hover {
	color: var(--vsh-blue-hover) !important;
}

.vsh-coupon-open__icon {

	color: var(--vsh-blue);


	font-size: 17px;
	font-weight: 400;
	line-height: 1;
}

/* =========================================================
   MODAL
========================================================= */

html.vsh-coupon-modal-open,
html.vsh-coupon-modal-open body {
	overflow: hidden;
}

.vsh-coupon-modal[hidden] {
	display: none !important;
}

.vsh-coupon-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;

	display: flex;
	align-items: center;
	justify-content: center;

	padding: 20px;
}

.vsh-coupon-modal__backdrop {
	position: absolute;
	inset: 0;

	background: rgba(13, 27, 49, .48);
	backdrop-filter: blur(2px);
}

.vsh-coupon-modal__dialog {
	position: relative;
	z-index: 2;

	display: flex;
	flex-direction: column;

	width: min(100%, 610px);
	max-height: min(86vh, 760px);

	overflow: hidden;

	background: var(--vsh-bg);
	border: 1px solid var(--vsh-border);
	border-radius: 14px;
	box-shadow: var(--vsh-shadow-lg);

	animation: vshCouponIn .2s ease both;
}

@keyframes vshCouponIn {
	from {
		opacity: 0;
		transform: translateY(10px) scale(.985);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.vsh-coupon-modal__header {
	position: relative;

	display: grid;
	grid-template-columns: 38px minmax(0, 1fr) 38px;
	align-items: center;

	min-height: 58px;
	padding: 0 10px;

	background: var(--vsh-bg);
	border-bottom: 1px solid var(--vsh-border);
}

.vsh-coupon-modal__header h3 {
	grid-column: 2;

	margin: 0;

	color: var(--vsh-heading);

	font-size: 17px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: -.01em;
	text-align: center;
	text-transform: none;
}

.vsh-coupon-close,
.vsh-coupon-back {
	display: inline-flex;
	align-items: center;
	justify-content: center;

	width: 34px;
	height: 34px;

	margin: 0;
	padding: 0;

	color: var(--vsh-text-muted);
	background: transparent;
	border: 0;
	border-radius: 50%;
	box-shadow: none;

	cursor: pointer;
}

.vsh-coupon-back {
	grid-column: 1;
	grid-row: 1;

	font-size: 29px;
	font-weight: 300;
}

.vsh-coupon-close {
	grid-column: 3;
	grid-row: 1;

	font-size: 25px;
	font-weight: 300;
}

.vsh-coupon-close:hover,
.vsh-coupon-back:hover {
	color: var(--vsh-blue);
	background: var(--vsh-blue-soft);
}

.vsh-coupon-modal__body {
	padding: 18px;
	overflow-y: auto;
	overflow-x: hidden;

	scrollbar-width: thin;
	scrollbar-color: var(--vsh-scroll-thumb) transparent;
}

.vsh-coupon-modal__body::-webkit-scrollbar {
	width: 5px;
}

.vsh-coupon-modal__body::-webkit-scrollbar-thumb {
	background: var(--vsh-scroll-thumb);
	border-radius: 99px;
}

/* =========================================================
   INPUT FORM
========================================================= */

.vsh-coupon-form {
	margin: 0;
	padding-bottom: 18px;
	border-bottom: 1px solid var(--vsh-border);
}

.vsh-coupon-form > label {
	display: block;
	margin: 0 0 7px;

	color: var(--vsh-heading);

	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
}

.vsh-coupon-form__row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 120px;
	gap: 8px;
}

.vsh-coupon-form input[type=text] {
	width: 100% !important;
	height: 42px !important;
	margin: 0 !important;
	padding: 0 12px !important;

	color: var(--vsh-text) !important;
	background: var(--vsh-bg) !important;

	border: 1px solid var(--vsh-border-strong !important);
	border-radius: var(--vsh-radius-sm) !important;
	box-shadow: none;

	font-size: 13px;
}

.vsh-coupon-form input[type=text]:focus {
	outline: none;
	border-color: var(--vsh-blue);
	box-shadow: var(--vsh-focus-ring);
}

.vsh-coupon-submit.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;

	height: 42px;
	min-height: 42px;

	margin: 0 !important;
	padding: 0 10px;

	color: #fff !important;
	background: var(--vsh-blue) !important;
	border: 1px solid var(--vsh-blue) !important;
	border-radius: var(--vsh-radius-sm) !important;
	box-shadow: none !important;

	font-size: 13px;
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: 0;
	text-transform: none;
}

.vsh-coupon-submit.button:hover {
	background: var(--vsh-blue-hover) !important;
	border-color: var(--vsh-blue-hover) !important;
}

.vsh-coupon-error {
	display: none;
	margin-top: 8px;
	padding: 8px 10px;

	color: #b23b3b;
	background: #fff7f7;

	border: 1px solid #f0cece;
	border-radius: 7px;

	font-size: 11px;
	font-weight: 500;
	line-height: 1.45;
}

.vsh-coupon-error.is-visible {
	display: block;
}

/* =========================================================
   LIST TITLE
========================================================= */

.vsh-coupon-list-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;

	margin: 17px 0 10px;
}

.vsh-coupon-list-heading strong {
	color: var(--vsh-heading);

	font-size: 13px;
	font-weight: 700;
	line-height: 1.4;
}

.vsh-coupon-list-heading span {
	color: var(--vsh-text-muted);
	font-size: 10.5px;
}

.vsh-coupon-list {
	display: grid;
	gap: 9px;
}

/* =========================================================
   COUPON CARD
========================================================= */

.vsh-coupon-card {
	position: relative;

	min-height: 108px;

	background: var(--vsh-bg);
	border: 1px solid var(--vsh-border-strong);
	border-radius: var(--vsh-radius);

	box-shadow: var(--vsh-shadow-sm);

	transition:
		border-color .18s ease,
		box-shadow .18s ease,
		transform .18s ease;
}

.vsh-coupon-card:hover {
	border-color: var(--vsh-blue);
	box-shadow: var(--vsh-shadow-card);
}

.vsh-coupon-card.is-applied {
	background: var(--vsh-blue-soft);
	border-color: var(--vsh-border-hover);
}

.vsh-coupon-card__apply {
	display: grid;
	grid-template-columns: 108px minmax(0, 1fr) 24px;
	align-items: stretch;

	width: 100%;
	min-height: 108px;

	margin: 0;
	padding: 0;

	color: inherit;
	background: transparent;
	border: 0;
	border-radius: inherit;
	box-shadow: none;

	text-align: left;
	cursor: pointer;
}

.vsh-coupon-card__apply:disabled {
	cursor: default;
	opacity: 1;
}

.vsh-coupon-card__image {
	position: relative;

	display: flex;
	align-items: center;
	justify-content: center;

	padding: 9px;
	overflow: hidden;

	background: linear-gradient(145deg, var(--vsh-blue-soft), #fff);
	border-right: 1px dashed var(--vsh-border-hover);
	border-radius: var(--vsh-radius) 0 0 var(--vsh-radius);
}

.vsh-coupon-card__image::before,
.vsh-coupon-card__image::after {
	content: "";
	position: absolute;
	right: -7px;

	width: 13px;
	height: 13px;

	background: var(--vsh-bg-soft);
	border: 1px solid var(--vsh-border-strong);
	border-radius: 50%;
}

.vsh-coupon-card__image::before {
	top: -7px;
}

.vsh-coupon-card__image::after {
	bottom: -7px;
}

.vsh-coupon-card__image img {
	display: block;

	width: 82px;
	height: 82px;

	margin: 0;
	object-fit: contain;
}

.vsh-coupon-card__content {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: flex-start;

	min-width: 0;
	padding: 10px 10px 26px 14px;
}

.vsh-coupon-card__title {
	display: block;
	width: 100%;

	margin-bottom: 0;

	color: var(--vsh-heading);

	font-size: 13px;
	font-weight: 700;
	line-height: 1.35;
}

.vsh-coupon-card__subtitle {
	display: -webkit-box;
	width: 100%;

	overflow: hidden;

	color: var(--vsh-text-muted);

	font-size: 13px;
	font-weight: 400;
	line-height: 1.4;

	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.vsh-coupon-card__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 5px 9px;

	margin-top: 4px;
	margin-bottom: 4px;

	color: var(--vsh-text-muted);

	font-size: 12px;
	line-height: 1.35;
}

.vsh-coupon-card__code {
	color: var(--vsh-blue);
	font-weight: 600;
}

.vsh-coupon-card__status {
	display: flex;
	align-items: center;
	justify-content: center;

	width: 18px;
	height: 18px;

	margin: 11px 9px 0 0;

	color: #fff;
	background: transparent;

	border: 1px solid var(--vsh-border-hover);
	border-radius: 4px;

	font-size: 12px;
	font-weight: 700;
}

.vsh-coupon-card.is-applied .vsh-coupon-card__status {
	background: var(--vsh-blue);
	border-color: var(--vsh-blue);
}

.vsh-coupon-condition {
	position: absolute;
	bottom: 9px;
	left: 122px;
	z-index: 3;

	margin: 0;
	padding: 0;

	color: var(--vsh-blue);
	background: transparent;
	border: 0;
	border-bottom: 1px solid currentColor;
	border-radius: 0 !important;
	box-shadow: none;

	font-size: 12px;
	font-weight: 500;
	line-height: 1.3;
	text-transform: none;

	cursor: pointer;
	min-height: unset !important;
	min-width: unset !important;
}

.vsh-coupon-condition:hover {
	color: var(--vsh-blue-hover);
}

.vsh-coupon-empty {
	padding: 24px 16px;

	color: var(--vsh-text-muted);
	background: var(--vsh-bg-soft);

	border: 1px dashed var(--vsh-border-hover);
	border-radius: var(--vsh-radius);

	font-size: 12px;
	line-height: 1.5;
	text-align: center;
}

/* =========================================================
   DETAIL VIEW
========================================================= */

.vsh-coupon-view[hidden] {
	display: none !important;
}

.vsh-coupon-card.is-detail-card {
	margin-bottom: 17px;
	box-shadow: none;
}

.vsh-coupon-card.is-detail-card:hover {
	transform: none;
}

.vsh-coupon-detail-section {
	padding: 15px 0;
	border-top: 1px solid var(--vsh-border);
}

.vsh-coupon-detail-section:first-of-type {
	border-top: 0;
}

.vsh-coupon-detail-section h4 {
	margin: 0 0 8px;

	color: var(--vsh-heading);

	font-size: 14px;
	font-weight: 700;
	line-height: 1.4;
	text-transform: none;
}

.vsh-coupon-detail-section p,
.vsh-coupon-detail-description {
	margin: 0 0 8px;
	color: var(--vsh-text);
	font-size: 13px;
	line-height: 1.6;
}

.vsh-coupon-detail-description {
	margin-bottom: 8px;
}

.vsh-coupon-detail-description > *:last-child {
	margin-bottom: 0;
}

.vsh-coupon-detail-section ul {
	margin: 7px 0 0;
	padding: 0 0 0 17px;
}

.vsh-coupon-detail-section li {
	margin: 0 0 5px;

	color: var(--vsh-text);

	font-size: 13px;
	line-height: 1.55;
}

/* =========================================================
   LOADING
========================================================= */

.vsh-coupon-modal.is-loading .vsh-coupon-card,
.vsh-coupon-modal.is-loading .vsh-coupon-form {
	pointer-events: none;
}

.vsh-coupon-card__apply.is-applying .vsh-coupon-card__status {
	border-color: var(--vsh-blue);
	animation: vshCouponPulse .8s ease infinite alternate;
}

@keyframes vshCouponPulse {
	to {
		background: var(--vsh-blue-soft);
	}
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 549px) {
	.vsh-coupon-modal {
		padding: 12px;
	}

	.vsh-coupon-modal__dialog {
		width: 100%;
		max-height: 90vh;
		border-radius: 12px;
	}

	.vsh-coupon-modal__header {
		min-height: 54px;
	}

	.vsh-coupon-modal__header h3 {
		font-size: 15px;
	}

	.vsh-coupon-modal__body {
		padding: 14px;
	}

	.vsh-coupon-form__row {
		grid-template-columns: minmax(0, 1fr) 120px;
	}

	.vsh-coupon-form input,
	.vsh-coupon-submit.button {
		height: 40px;
		min-height: 40px;
	}

	.vsh-coupon-card,
	.vsh-coupon-card__apply {
		min-height: 102px;
	}

	.vsh-coupon-card__apply {
		grid-template-columns: 92px minmax(0, 1fr) 22px;
	}

	.vsh-coupon-card__image {
		padding: 7px;
	}

	.vsh-coupon-card__image img {
		width: 72px;
		height: 72px;
	}

	.vsh-coupon-card__content {
		padding: 10px 7px 25px 11px;
	}

	.vsh-coupon-card__title {
		font-size: 13px;
	}

	.vsh-coupon-card__subtitle {
		font-size: 12px;
	}

	.vsh-coupon-card__meta {
		gap: 4px 7px;
		font-size: 11px;
	}

	.vsh-coupon-condition {
		left: 103px;
		bottom: 8px;
	}

	body.woocommerce-cart .cart_totals .vsh-coupon-trigger-row > td,
	body.woocommerce-checkout .woocommerce-checkout-review-order-table .vsh-coupon-trigger-row > td {
		padding-right: 15px !important;
		padding-left: 15px !important;
	}
}
