/**
 * Smart Coupon Viewer — frontend styles (prefixed .scv-*)
 */

.scv-trigger-wrap {
	margin: 0.75em 0 1em;
	display: block;
	clear: both;
}

.coupon .scv-trigger-wrap,
.wc-block-components-totals-coupon + .scv-trigger-wrap,
#woocommerce-checkout-form-coupon + .scv-trigger-wrap,
.scv-trigger-wrap--checkout-before,
.scv-trigger-wrap--checkout-below {
	margin-top: 0.75em;
	width: 100%;
}

.scv-trigger-wrap--checkout-below .scv-trigger-button,
.scv-trigger-wrap--blocks-coupon-form .scv-trigger-button {
	width: 100%;
	max-width: 100%;
}

.wp-block-woocommerce-cart-order-summary-coupon-form-block + .scv-trigger-wrap,
.wp-block-woocommerce-checkout-order-summary-coupon-form-block + .scv-trigger-wrap,
.scv-trigger-wrap--mini-cart-drawer {
	margin-top: 0.75em;
	margin-bottom: 0.5em;
}

.scv-mini-cart-coupon-mount {
	display: block;
	width: 100%;
	box-sizing: border-box;
	margin: 0;
	padding: 0 16px 12px;
	border-bottom: 1px solid var(--wc-separator-color, rgba(0, 0, 0, 0.12));
}

.wp-block-woocommerce-cart-order-summary-block .scv-mini-cart-coupon-mount {
	padding-left: 0;
	padding-right: 0;
	border-bottom: none;
	margin-top: 0.5rem;
}

.wc-block-mini-cart__drawer .scv-mini-cart-coupon-mount .scv-trigger-wrap--mini-cart-drawer,
.widget_shopping_cart_content .scv-mini-cart-coupon-mount .scv-trigger-wrap--mini-cart-drawer {
	padding: 0;
	margin: 0.5rem 0 0;
}

.wc-block-mini-cart__drawer .scv-trigger-wrap--mini-cart-drawer,
.widget_shopping_cart_content .scv-trigger-wrap--mini-cart-drawer {
	padding: 0 1rem 0.75rem;
}

.moderncart-panel .scv-mini-cart-coupon-mount {
	padding: 12px 16px 16px;
	border-bottom: none;
}

.moderncart-panel .scv-mini-cart-coupon-mount .scv-trigger-wrap--mini-cart-drawer {
	margin: 0;
	padding: 0;
}

.moderncart-panel .scv-trigger-button {
	width: 100%;
	text-transform: none;
}

.wc-block-mini-cart__drawer .scv-trigger-button {
	width: 100%;
}

.scv-trigger-inline {
	display: inline-block;
	margin-left: 0.5em;
	vertical-align: middle;
}

.woocommerce-form-coupon-toggle .scv-trigger-inline .scv-trigger-button {
	padding: 0.35em 0.75em;
	font-size: 0.875rem;
}

.scv-trigger-button {
	background: var(--scv-primary, #2271b1) !important;
	color: var(--scv-primary-text, #fff) !important;
	border: none;
	border-radius: 4px;
	padding: 0.65em 1.25em;
	cursor: pointer;
	transition: opacity 0.2s ease, transform 0.15s ease;
}

.scv-trigger-button:hover,
.scv-trigger-button:focus {
	opacity: 0.92;
	transform: translateY(-1px);
}

.scv-root {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.scv-root[hidden] {
	display: none !important;
}

.scv-overlay {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	animation: scv-fade-in 0.2s ease;
}

.scv-modal {
	position: relative;
	width: 100%;
	max-width: 520px;
	max-height: min(90vh, 720px);
	background: var(--scv-modal-background, #fff);
	border-radius: 12px;
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: scv-slide-up 0.25s ease;
	color: var(--scv-text, #1f2937);
}

.scv-display-drawer {
	align-items: stretch;
	justify-content: flex-end;
	padding: 0;
}

.scv-display-drawer .scv-modal {
	max-width: 420px;
	height: 100%;
	max-height: none;
	border-radius: 12px 0 0 12px;
	animation: scv-slide-left 0.25s ease;
}

.scv-modal-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	padding: 1.25rem 1.25rem 0.75rem;
	border-bottom: 1px solid var(--scv-border, #e5e7eb);
}

.scv-modal-title {
	margin: 0;
	font-size: 1.25rem;
	color: var(--scv-modal-header, #111827);
}

.scv-modal-subtitle {
	margin: 0.35rem 0 0;
	font-size: 0.875rem;
	opacity: 0.75;
}

.scv-modal-close {
	background: transparent;
	border: none;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
	color: inherit;
	padding: 0.25rem 0.5rem;
	border-radius: 4px;
}

.scv-modal-close:focus-visible {
	outline: 2px solid var(--scv-primary, #2271b1);
	outline-offset: 2px;
}

.scv-toolbar {
	padding: 0.75rem 1.25rem;
	border-bottom: 1px solid var(--scv-border, #e5e7eb);
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.scv-search-input {
	width: 100%;
	padding: 0.55rem 0.75rem;
	border: 1px solid var(--scv-border, #e5e7eb);
	border-radius: 6px;
}

.scv-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.scv-filter-btn {
	border: 1px solid var(--scv-border, #e5e7eb);
	background: #fff;
	border-radius: 999px;
	padding: 0.35rem 0.75rem;
	font-size: 0.8125rem;
	cursor: pointer;
}

.scv-filter-btn.is-active {
	background: var(--scv-primary, #2271b1);
	color: var(--scv-primary-text, #fff);
	border-color: transparent;
}

.scv-notice {
	margin: 0.75rem 1.25rem 0;
	padding: 0.65rem 0.85rem;
	border-radius: 6px;
	background: #ecfdf5;
	color: #065f46;
	font-size: 0.875rem;
}

.scv-notice.is-error {
	background: #fef2f2;
	color: #991b1b;
}

.scv-modal-body {
	padding: 1rem 1.25rem 1.25rem;
	overflow-y: auto;
	flex: 1;
}

.scv-loading {
	display: none;
	align-items: center;
	gap: 0.75rem;
	padding: 1rem 0;
}

.scv-loading.is-active,
.scv-loading:not([hidden]) {
	display: flex;
}

.scv-loading[hidden] {
	display: none !important;
}

.scv-spinner {
	width: 1.25rem;
	height: 1.25rem;
	border: 2px solid var(--scv-border, #e5e7eb);
	border-top-color: var(--scv-primary, #2271b1);
	border-radius: 50%;
	animation: scv-spin 0.7s linear infinite;
}

.scv-coupon-list {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.scv-coupon-card {
	background: var(--scv-card-background, #fff);
	border: 1px solid var(--scv-border, #e5e7eb);
	border-radius: 10px;
	padding: 1rem;
	position: relative;
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.scv-coupon-card:not(.scv-disabled):hover {
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.scv-coupon-card.scv-disabled {
	opacity: 0.72;
	background: #f9fafb;
}

.scv-coupon-card.scv-applied {
	border-color: var(--scv-success, #059669);
}

.scv-best-badge {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--scv-discount-badge, #059669);
	margin-bottom: 0.35rem;
}

.scv-coupon-code {
	font-weight: 700;
	font-size: 1.05rem;
	letter-spacing: 0.06em;
}

.scv-coupon-discount {
	margin-top: 0.35rem;
	font-weight: 700;
	color: var(--scv-discount-badge, #059669);
}

.scv-coupon-description {
	margin: 0.5rem 0 0;
	font-size: 0.9rem;
	line-height: 1.45;
}

.scv-coupon-meta,
.scv-coupon-reason {
	margin: 0.35rem 0 0;
	font-size: 0.8125rem;
}

.scv-coupon-reason {
	color: var(--scv-disabled, #9ca3af);
}

.scv-coupon-actions {
	margin-top: 0.85rem;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.scv-apply-button {
	background: var(--scv-apply-button, #2271b1);
	color: #fff;
	border: none;
	border-radius: 6px;
	padding: 0.5rem 1.1rem;
	cursor: pointer;
	font-weight: 600;
}

.scv-apply-button:disabled {
	background: var(--scv-disabled, #9ca3af);
	cursor: not-allowed;
}

.scv-applied-label {
	color: var(--scv-success, #059669);
	font-weight: 600;
	font-size: 0.875rem;
}

.scv-remove-button {
	background: transparent;
	color: var(--scv-text, #1f2937);
	border: 1px solid var(--scv-border, #e5e7eb);
}

/* Card style: ticket */
.scv-style-ticket .scv-coupon-card {
	border-left: 4px dashed var(--scv-primary, #2271b1);
	border-radius: 4px;
}

/* Card style: minimal */
.scv-style-minimal .scv-coupon-card {
	border: none;
	border-bottom: 1px solid var(--scv-border, #e5e7eb);
	border-radius: 0;
	padding-left: 0;
	padding-right: 0;
}

/* Card style: compact */
.scv-style-compact .scv-coupon-card {
	padding: 0.65rem 0.85rem;
}

.scv-style-compact .scv-coupon-description {
	display: none;
}

/* Card style: classic */
.scv-style-classic .scv-coupon-card {
	box-shadow: inset 0 0 0 1px var(--scv-border, #e5e7eb);
}

body.scv-modal-open {
	overflow: hidden;
}

@keyframes scv-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes scv-slide-up {
	from { transform: translateY(12px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}

@keyframes scv-slide-left {
	from { transform: translateX(24px); opacity: 0; }
	to { transform: translateX(0); opacity: 1; }
}

@keyframes scv-spin {
	to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
	.scv-root:not(.scv-display-drawer) {
		padding: 0;
		align-items: flex-end;
	}

	.scv-root:not(.scv-display-drawer) .scv-modal {
		max-height: 92vh;
		border-radius: 12px 12px 0 0;
	}

	.scv-display-drawer .scv-modal {
		max-width: 100%;
		border-radius: 0;
	}
}
