/*
 * YC Giftcart - frontend styles (scoped to plugin wrappers only).
 */

/* ------------------------------------------------------------------ *
 * Redeem panel (cart + checkout — compact, column width)              *
 * ------------------------------------------------------------------ */

.yc-giftcart-redeem-panel {
	box-sizing: border-box;
	display: block;
	width: 100%;
	max-width: 100%;
	padding: 16px;
	background: inherit;
	border: 0;
	border-radius: 0;
}

.yc-giftcart-redeem-panel__new-label {
	margin: 0 0 10px;
	font-size: inherit;
	font-weight: 600;
}

.yc-giftcart-applied-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin: 0 0 14px;
}

.yc-giftcart-applied-card {
	box-sizing: border-box;
	max-width: 100%;
	padding: 14px;
	border-radius: 4px;
	border: 1px solid rgba(0, 0, 0, 0.08);
	background: transparent;
}

.yc-giftcart-applied-card__header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: .5em;
}

.yc-giftcart-applied-card__code {
	font-weight: 600;
	flex: 1 1 auto;
	min-width: 0;
}

.yc-giftcart-applied-card__meta {
	font-size: 0.925em;
	line-height: 1.45;
}

.yc-giftcart-applied-card__meta div {
	margin: 0.15em 0;
}

.yc-giftcart-applied-card__fully-used {
	margin-top: .35em;
	font-size: 0.9em;
	opacity: 0.85;
	font-style: italic;
}

.yc-giftcart-applied-card .yc-giftcart-remove-button {
	flex: 0 0 auto;
}

/* Visible defaults when Elementor / theme styles are not set yet */
.yc-giftcart-redeem-panel .yc-giftcart-remove-button.button {
	display: inline-block;
	cursor: pointer;
	border: 1px solid currentColor;
	background: transparent;
	color: inherit;
	text-decoration: none;
	line-height: 1.4;
	padding: 0.4em 0.75em;
	font-size: 0.88em;
	box-shadow: none;
}

.yc-giftcart-redeem-panel .yc-giftcart-remove-button.button:hover {
	text-decoration: none;
}

/* Hide internal non-taxable giftcard fee row — credit shown as custom totals rows */
.cart_totals tr.fee:has([data-yc-giftcart-internal-fee="1"]),
.woocommerce-checkout-review-order-table tr.fee:has([data-yc-giftcart-internal-fee="1"]) {
	display: none;
}

.yc-giftcart-totals-row--payable th,
.yc-giftcart-totals-row--payable td,
.yc-giftcart-total-row.yc-giftcart-payable-row th,
.yc-giftcart-total-row.yc-giftcart-payable-row td {
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

body.yc-giftcart-has-applied .yc-giftcart-payable-row td .includes_tax {
	display: none !important;
}

.yc-giftcart-redeem-panel .yc-giftcart-redeem-notice,
.yc-giftcart-redeem-panel .yc-giftcart-message {
	margin: 0 0 10px;
	padding: .55em .75em;
	border-radius: 3px;
	font-size: .92em;
}

.yc-giftcart-redeem-panel .yc-giftcart-redeem-notice--success,
.yc-giftcart-redeem-panel .yc-giftcart-message--success {
	background: rgba(70, 180, 80, 0.12);
	color: inherit;
}

.yc-giftcart-redeem-panel .yc-giftcart-redeem-notice--error,
.yc-giftcart-redeem-panel .yc-giftcart-message--error {
	background: rgba(220, 50, 50, 0.1);
	color: inherit;
}

.yc-giftcart-redeem-panel .yc-giftcart-redeem-inline-form {
	display: flex;
	flex-wrap: nowrap;
	gap: 10px;
	align-items: stretch;
	width: 100%;
	margin: 0;
}

.yc-giftcart-redeem-panel .yc-giftcart-redeem-inline-form input[type="text"] {
	flex: 1 1 auto;
	min-width: 0;
	padding: .45em .65em;
	font: inherit;
}

.yc-giftcart-redeem-panel .yc-giftcart-redeem-inline-form button {
	flex: 0 0 auto;
	white-space: nowrap;
}

/* Cart page — compact under totals */
.woocommerce-cart .yc-giftcart-cart-wrapper,
.woocommerce-cart .yc-giftcart-redeem-panel {
	display: block;
	width: 100%;
	box-sizing: border-box;
	clear: both;
}

.woocommerce-cart .yc-giftcart-cart-wrapper {
	margin: 1em 0 0;
}

.woocommerce-cart .yc-giftcart-cart-wrapper .yc-giftcart-redeem-panel {
	margin: 0;
	padding: 12px 0 0;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* Checkout — space above and below giftcard block */
.woocommerce-checkout .yc-giftcart-checkout-wrapper,
.woocommerce-checkout .yc-giftcart-redeem-panel.yc-giftcart-checkout-panel {
	display: block;
	width: 100%;
	box-sizing: border-box;
	margin-top: 24px;
	margin-bottom: 24px;
	clear: both;
}

.woocommerce-checkout .yc-giftcart-checkout-wrapper {
	margin-top: 24px;
	margin-bottom: 24px;
	padding: 0;
}

.woocommerce-checkout .yc-giftcart-checkout-wrapper .yc-giftcart-redeem-panel {
	margin: 0;
	padding: 16px;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.woocommerce-checkout .yc-giftcart-redeem-panel + #payment,
.woocommerce-checkout .yc-giftcart-checkout-wrapper + #payment,
.woocommerce-checkout .yc-giftcart-redeem-panel + .woocommerce-checkout-payment,
.woocommerce-checkout .yc-giftcart-checkout-wrapper + .woocommerce-checkout-payment,
.woocommerce-checkout .yc-giftcart-checkout-wrapper + .payment_methods,
.woocommerce-checkout .yc-giftcart-redeem-panel + .payment_methods {
	margin-top: 24px;
}

@media (max-width: 1024px) {
	.woocommerce-checkout .yc-giftcart-checkout-wrapper,
	.woocommerce-checkout .yc-giftcart-redeem-panel.yc-giftcart-checkout-panel {
		margin-top: 22px;
		margin-bottom: 22px;
	}

	.woocommerce-checkout .yc-giftcart-checkout-wrapper .yc-giftcart-redeem-panel {
		padding: 14px;
	}

	.woocommerce-checkout .yc-giftcart-redeem-panel + #payment,
	.woocommerce-checkout .yc-giftcart-checkout-wrapper + #payment,
	.woocommerce-checkout .yc-giftcart-redeem-panel + .woocommerce-checkout-payment,
	.woocommerce-checkout .yc-giftcart-checkout-wrapper + .woocommerce-checkout-payment,
	.woocommerce-checkout .yc-giftcart-checkout-wrapper + .payment_methods,
	.woocommerce-checkout .yc-giftcart-redeem-panel + .payment_methods {
		margin-top: 22px;
	}
}

@media (max-width: 767px) {
	.woocommerce-checkout .yc-giftcart-checkout-wrapper,
	.woocommerce-checkout .yc-giftcart-redeem-panel.yc-giftcart-checkout-panel {
		margin-top: 18px;
		margin-bottom: 18px;
	}

	.woocommerce-checkout .yc-giftcart-redeem-panel + #payment,
	.woocommerce-checkout .yc-giftcart-checkout-wrapper + #payment,
	.woocommerce-checkout .yc-giftcart-redeem-panel + .woocommerce-checkout-payment,
	.woocommerce-checkout .yc-giftcart-checkout-wrapper + .woocommerce-checkout-payment,
	.woocommerce-checkout .yc-giftcart-checkout-wrapper + .payment_methods,
	.woocommerce-checkout .yc-giftcart-redeem-panel + .payment_methods {
		margin-top: 18px;
	}

	.yc-giftcart-applied-card__header {
		flex-direction: column;
		align-items: stretch;
	}

	.yc-giftcart-applied-card .yc-giftcart-remove-button {
		width: 100%;
	}

	.yc-giftcart-redeem-panel .yc-giftcart-redeem-inline-form,
	.woocommerce-checkout .yc-giftcart-redeem-inline-form {
		flex-direction: column;
		flex-wrap: wrap;
		gap: 8px;
	}

	.yc-giftcart-redeem-panel .yc-giftcart-redeem-inline-form input[type="text"],
	.yc-giftcart-redeem-panel .yc-giftcart-redeem-inline-form button,
	.woocommerce-checkout .yc-giftcart-redeem-inline-form input[type="text"],
	.woocommerce-checkout .yc-giftcart-redeem-inline-form button {
		width: 100%;
	}
}

/* ------------------------------------------------------------------ *
 * Balance check widget (Elementor)                                    *
 * ------------------------------------------------------------------ */

.yc-giftcart-balance-check-wrap {
	max-width: 100%;
}

.yc-giftcart-balance-check {
	box-sizing: border-box;
	max-width: 100%;
	display: flex;
	flex-direction: column;
	gap: .65em;
}

.yc-giftcart-balance-check__title {
	margin: 0 0 .35em;
	font-size: inherit;
	font-weight: 600;
}

.yc-giftcart-balance-check label {
	display: block;
	font-weight: 600;
}

.yc-giftcart-balance-check input[type="text"] {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	padding: .45em .65em;
	font: inherit;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 4px;
}

.yc-giftcart-balance-check button {
	align-self: flex-start;
	cursor: pointer;
}

.yc-giftcart-balance-check button:disabled {
	opacity: 0.65;
	cursor: not-allowed;
}

.yc-giftcart-balance-result {
	margin-top: .35em;
	padding: .65em .75em;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 4px;
	line-height: 1.45;
}

.yc-giftcart-balance-result[hidden] {
	display: none !important;
}

@media (max-width: 480px) {
	.yc-giftcart-balance-check button {
		width: 100%;
		align-self: stretch;
	}
}

/* ------------------------------------------------------------------ *
 * Redeem form (cart/checkout) legacy class wrapper                    *
 * ------------------------------------------------------------------ */

.yc-giftcart-redeem-form {
	margin: 0 0 1em;
	padding: 0;
	background: transparent;
	border: 0;
}

.yc-giftcart-redeem-row {
	display: flex;
	flex-wrap: wrap;
	gap: .5em;
	align-items: center;
}

.yc-giftcart-redeem-row input[type="text"] {
	flex: 1 1 220px;
	min-width: 0;
	padding: .5em .75em;
	font: inherit;
}

.yc-giftcart-applied-notice {
	display: flex;
	flex-wrap: wrap;
	gap: .75em;
	align-items: center;
	justify-content: space-between;
	padding: .6em .75em;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 4px;
	background: transparent;
}

.yc-giftcart-applied-notice p {
	margin: 0;
}

@media (max-width: 480px) {
	.yc-giftcart-redeem-row {
		flex-direction: column;
		align-items: stretch;
	}
	.yc-giftcart-redeem-row input[type="text"] {
		width: 100%;
	}
}

/* ------------------------------------------------------------------ *
 * Giftcard purchase form (Elementor widget + WooCommerce inject)     *
 * ------------------------------------------------------------------ */

.yc-giftcart-form,
.yc-giftcart-standard-fields {
	--yc-giftcart-label-color: currentColor;
	--yc-giftcart-text-color: currentColor;
	--yc-giftcart-muted-color: currentColor;
	--yc-giftcart-input-text-color: #111111;
	--yc-giftcart-input-bg: #ffffff;
	--yc-giftcart-input-border: #d5d5d5;
	--yc-giftcart-input-focus-border: #d1ad4f;
	--yc-giftcart-help-color: currentColor;
	--yc-giftcart-button-bg: var(--e-global-color-primary, #d1ad4f);
	--yc-giftcart-button-color: #ffffff;
	--yc-giftcart-field-gap: 12px;

	box-sizing: border-box;
	color: var(--yc-giftcart-text-color, currentColor);
}

.yc-giftcart-form *,
.yc-giftcart-standard-fields *,
.yc-giftcart-form *::before,
.yc-giftcart-form *::after,
.yc-giftcart-standard-fields *::before,
.yc-giftcart-standard-fields *::after {
	box-sizing: border-box;
}

.yc-giftcart-form--hidden {
	display: none !important;
}

.yc-giftcart-standard-fields {
	display: block;
	width: 100%;
	margin-top: 20px;
	margin-bottom: 20px;
}

.yc-giftcart-fields-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--yc-giftcart-field-gap);
}

.yc-giftcart-form__title {
	margin: 0 0 0.5em;
	color: var(--yc-giftcart-label-color);
}

.yc-giftcart-form__price {
	margin-bottom: 0.75em;
}

.yc-giftcart-field,
.yc-giftcart-form__field {
	display: block;
}

.yc-giftcart-field > label,
.yc-giftcart-form__field > label,
.yc-giftcart-form legend,
.yc-giftcart-recipient-choice legend {
	display: block;
	font-weight: 600;
	color: var(--yc-giftcart-label-color);
	margin-bottom: 0.35em;
}

.yc-giftcart-form input[type="text"],
.yc-giftcart-form input[type="email"],
.yc-giftcart-form textarea,
.yc-giftcart-form select,
.yc-giftcart-standard-fields input[type="text"],
.yc-giftcart-standard-fields input[type="email"],
.yc-giftcart-standard-fields textarea {
	width: 100%;
	max-width: 100%;
	color: var(--yc-giftcart-input-text-color);
	background-color: var(--yc-giftcart-input-bg);
	border: 1px solid var(--yc-giftcart-input-border);
	border-radius: 4px;
	padding: 0.55em 0.75em;
	font: inherit;
	line-height: 1.4;
}

.yc-giftcart-form textarea,
.yc-giftcart-standard-fields textarea {
	resize: vertical;
	min-height: 6em;
}

.yc-giftcart-form input::placeholder,
.yc-giftcart-form textarea::placeholder,
.yc-giftcart-standard-fields input::placeholder,
.yc-giftcart-standard-fields textarea::placeholder {
	color: var(--yc-giftcart-input-text-color);
	opacity: 0.45;
}

.yc-giftcart-form input:focus,
.yc-giftcart-form textarea:focus,
.yc-giftcart-standard-fields input:focus,
.yc-giftcart-standard-fields textarea:focus {
	border-color: var(--yc-giftcart-input-focus-border, var(--yc-giftcart-input-border));
	outline: 2px solid var(--yc-giftcart-input-focus-border, var(--yc-giftcart-input-border));
	outline-offset: 1px;
}

.yc-giftcart-recipient-choice,
.yc-giftcart-form__options {
	border: 0;
	margin: 0 0 0.75em;
	padding: 0;
}

.yc-giftcart-radio-row {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	align-items: center;
}

.yc-giftcart-form__option,
.yc-giftcart-radio-row__option {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	margin: 0;
	font-weight: normal;
	color: var(--yc-giftcart-label-color);
	cursor: pointer;
}

.yc-giftcart-field--hidden {
	display: none !important;
}

.yc-giftcart-helptext,
.yc-giftcart-form__hint {
	margin: 0.35em 0 0;
	font-size: 0.85em;
	color: var(--yc-giftcart-help-color);
	opacity: 0.85;
}

.yc-giftcart-form__actions {
	margin-top: 1em;
}

.yc-giftcart-form__submit,
.yc-giftcart-button {
	cursor: pointer;
	color: var(--yc-giftcart-button-color);
	background-color: var(--yc-giftcart-button-bg);
	border: none;
	padding: 0.65em 1.25em;
	border-radius: 4px;
	height: auto;
	min-height: unset;
	line-height: 1.4;
}

.yc-giftcart-form-notice {
	padding: 0.75em 1em;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 4px;
	background: #f6f6f6;
	color: inherit;
}

.yc-giftcart-form .required {
	color: inherit;
	text-decoration: none;
}

/* ------------------------------------------------------------------ *
 * WooCommerce / Elementor Add To Cart — layout (giftcard products)     *
 * ------------------------------------------------------------------ */

form.cart.yc-giftcart-cart-form .woocommerce-variation-add-to-cart,
form.cart.yc-giftcart-cart-form .variations_button {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 16px;
	width: 100%;
}

form.cart.yc-giftcart-cart-form .yc-giftcart-standard-fields {
	width: 100%;
	max-width: 100%;
	order: 10;
}

form.cart.yc-giftcart-cart-form .yc-giftcart-action-row {
	order: 20;
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: flex-start;
	gap: 16px;
	width: 100%;
	margin-top: 16px;
}

form.cart.yc-giftcart-cart-form .yc-giftcart-action-row .quantity {
	flex: 0 0 auto;
	width: auto;
	max-width: 90px;
	margin: 0;
	height: auto;
	min-height: 0;
}

form.cart.yc-giftcart-cart-form .yc-giftcart-action-row .quantity input.qty {
	width: 70px;
	min-height: 44px;
	height: auto;
	max-height: none;
	box-sizing: border-box;
}

form.cart.yc-giftcart-cart-form .yc-giftcart-action-row .single_add_to_cart_button {
	flex: 0 0 auto;
	width: auto;
	min-height: 44px;
	height: auto;
	margin: 0;
	box-sizing: border-box;
}

@media (max-width: 767px) {
	form.cart.yc-giftcart-cart-form .yc-giftcart-action-row {
		flex-direction: column;
		align-items: stretch;
	}

	form.cart.yc-giftcart-cart-form .yc-giftcart-action-row .quantity,
	form.cart.yc-giftcart-cart-form .yc-giftcart-action-row .single_add_to_cart_button {
		width: 100%;
		max-width: 100%;
	}

	form.cart.yc-giftcart-cart-form .yc-giftcart-action-row .quantity input.qty {
		width: 100%;
	}
}
