/**
 * EasyClass Checkout — 쿠폰 목록 팝업
 *
 * 결제 폼의 CSS 변수를 그대로 쓰므로 Elementor에서 색을 바꾸면 같이 따라온다.
 * 변수가 없는 곳(장바구니 등)에서도 쓰이므로 모든 var()에 대체값을 둔다.
 */

.ecc-coupon-list-bar {
	display: flex;
	justify-content: flex-end;
	margin: 0 0 8px;
}

/**
 * 이 버튼은 주문요약(#order_review) 안에 놓인다. 그 안의 button 은
 * "주문하기" 계열로 간주돼 테마·Elementor 쪽에서 꽉 찬 배경색을 입힌다.
 * 여기서는 그런 상속을 끊고 보조 버튼 모양을 직접 지정한다.
 * 셀렉터를 두 벌 쓰는 이유도 같다. 짧은 쪽만으로는 특이도에서 밀린다.
 */
.ecc-coupon-list-toggle,
.ecc-checkout-form .woocommerce #order_review button.ecc-coupon-list-toggle,
.ecc-cart-form button.ecc-coupon-list-toggle {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	width: auto;
	min-height: 0;
	padding: 6px 12px;
	background: none;
	background-color: transparent;
	background-image: none;
	border: 1px solid var( --ecc-field-border-color, #d4d4d4 );
	border-radius: 4px;
	box-shadow: none;
	color: var( --ecc-primary-color, #4959ff );
	font-size: 13px;
	font-family: inherit;
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ecc-coupon-list-toggle:hover,
.ecc-coupon-list-toggle:focus-visible,
.ecc-checkout-form .woocommerce #order_review button.ecc-coupon-list-toggle:hover,
.ecc-checkout-form .woocommerce #order_review button.ecc-coupon-list-toggle:focus-visible {
	border-color: var( --ecc-primary-color, #4959ff );
	background: none;
	background-color: rgba( 0, 0, 0, 0.02 );
	color: var( --ecc-primary-color, #4959ff );
	opacity: 1;
}

/* 주문 버튼에 붙은 자물쇠 아이콘이 여기까지 따라오지 않게 한다. */
.ecc-coupon-list-toggle::before,
.ecc-coupon-list-toggle::after {
	content: none;
}

/* 티켓 모양 아이콘. 이미지 요청을 만들지 않으려고 마스크로 그린다. */
.ecc-coupon-list-toggle__icon {
	width: 1em;
	height: 1em;
	flex: none;
	background-color: currentColor;
	-webkit-mask: url( "data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 6h16a1 1 0 0 1 1 1v3a2 2 0 0 0 0 4v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-3a2 2 0 0 0 0-4V7a1 1 0 0 1 1-1zm10 2v1h2V8h-2zm0 3v1h2v-1h-2zm0 3v1h2v-1h-2z'/%3E%3C/svg%3E" ) no-repeat center / contain;
	mask: url( "data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 6h16a1 1 0 0 1 1 1v3a2 2 0 0 0 0 4v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-3a2 2 0 0 0 0-4V7a1 1 0 0 1 1-1zm10 2v1h2V8h-2zm0 3v1h2v-1h-2zm0 3v1h2v-1h-2z'/%3E%3C/svg%3E" ) no-repeat center / contain;
}

/* ------------------------------------------------------------------ 팝업 */

/**
 * 팝업은 wp_footer 에서 문서 맨 끝에 출력되므로 결제 폼 스타일이 닿지 않는다.
 * 그래도 테마가 button 전역에 색을 칠하는 경우가 있어 아래에서 되돌려 놓는다.
 */
.ecc-coupon-modal button {
	background: none;
	background-color: transparent;
	background-image: none;
	border: 0;
	box-shadow: none;
	text-shadow: none;
	text-transform: none;
	letter-spacing: normal;
	font-family: inherit;
	width: auto;
	min-height: 0;
}

.ecc-coupon-modal button::before,
.ecc-coupon-modal button::after {
	content: none;
}

.ecc-coupon-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.ecc-coupon-modal[hidden] {
	display: none;
}

.ecc-coupon-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 15, 23, 42, 0.55 );
}

.ecc-coupon-modal__panel {
	position: relative;
	width: 100%;
	max-width: 420px;
	max-height: 80vh;
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 20px 50px rgba( 15, 23, 42, 0.25 );
	overflow: hidden;
}

.ecc-coupon-modal__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid #e5e7eb;
}

.ecc-coupon-modal__title {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	color: var( --ecc-heading-color, #1a1e23 );
}

.ecc-coupon-modal button.ecc-coupon-modal__close {
	flex: none;
	width: 32px;
	height: 32px;
	padding: 0;
	border-radius: 4px;
	font-size: 24px;
	line-height: 1;
	color: #6b7280;
	cursor: pointer;
}

.ecc-coupon-modal button.ecc-coupon-modal__close:hover {
	background-color: #f3f4f6;
	color: #111827;
}

.ecc-coupon-modal__body {
	padding: 8px;
	overflow-y: auto;
}

/* ------------------------------------------------------------ 목록 항목 */

.ecc-coupon-modal button.ecc-coupon-item {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	padding: 12px 14px;
	margin: 0;
	border: 1px solid transparent;
	border-radius: 6px;
	font-family: inherit;
	font-weight: 400;
	text-align: left;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ecc-coupon-modal button.ecc-coupon-item:hover,
.ecc-coupon-modal button.ecc-coupon-item:focus-visible {
	background-color: #f8fafc;
	border-color: var( --ecc-primary-color, #4959ff );
}

.ecc-coupon-item__main {
	flex: 1 1 auto;
	min-width: 0;
}

.ecc-coupon-item__amount {
	display: block;
	font-size: 15px;
	font-weight: 600;
	color: var( --ecc-heading-color, #1a1e23 );
}

.ecc-coupon-item__desc {
	display: block;
	margin-top: 2px;
	font-size: 13px;
	color: var( --ecc-text-color, #566376 );
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ecc-coupon-item__meta {
	display: block;
	margin-top: 4px;
	font-size: 12px;
	color: #94a3b8;
}

.ecc-coupon-item__code {
	flex: none;
	padding: 4px 10px;
	border: 1px dashed var( --ecc-field-border-color, #d4d4d4 );
	border-radius: 4px;
	font-size: 12px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	color: var( --ecc-text-color, #566376 );
	letter-spacing: 0.02em;
}

/* ------------------------------------------------------- 상태 메시지 */

.ecc-coupon-modal__status {
	padding: 28px 20px;
	text-align: center;
	font-size: 14px;
	color: var( --ecc-text-color, #566376 );
}

.ecc-coupon-modal__status--error {
	color: #dc2626;
}

@media only screen and ( max-width: 480px ) {

	.ecc-coupon-modal {
		align-items: flex-end;
		padding: 0;
	}

	.ecc-coupon-modal__panel {
		max-width: none;
		max-height: 85vh;
		border-radius: 12px 12px 0 0;
	}

	.ecc-coupon-item {
		flex-wrap: wrap;
	}
}
