/**
 * TAPP Gift Cards - Frontend Styles
 *
 * Uses WoodMart theme CSS variables for consistent styling.
 * Follows TAPP Campaign Management Suite patterns.
 *
 * @package TAPP_Gift_Cards
 */

/* ----------------------------------------
   FORM INPUTS - WoodMart Integration
   Uses theme CSS variables for consistent styling
   ---------------------------------------- */
.tapp-gc-apply-form input[type="text"],
.tapp-gc-apply-form input[type="email"],
.tapp-gc-checkout-form input[type="text"],
.tapp-gc-checkout-form input[type="email"],
.tapp-gc-product-fields input[type="text"],
.tapp-gc-product-fields input[type="email"],
.tapp-gc-product-fields textarea {
	height: var(--wd-form-height, 42px);
	padding: 0 15px;
	border: var(--wd-form-brd-width, 2px) solid var(--wd-form-brd-color, rgba(0, 0, 0, 0.1));
	border-radius: var(--wd-form-brd-radius, 0);
	background-color: var(--wd-form-bg, transparent);
	color: var(--wd-form-color, inherit);
	font-size: 14px;
	transition: border-color 0.4s ease;
	outline: none;
	width: 100%;
	box-sizing: border-box;
}

.tapp-gc-product-fields textarea {
	height: auto;
	min-height: 80px;
	padding: 10px 15px;
	resize: vertical;
}

.tapp-gc-apply-form input:focus,
.tapp-gc-checkout-form input:focus,
.tapp-gc-product-fields input:focus,
.tapp-gc-product-fields textarea:focus {
	border-color: var(--wd-form-brd-color-focus, rgba(0, 0, 0, 0.15));
}

.tapp-gc-apply-form input::placeholder,
.tapp-gc-checkout-form input::placeholder,
.tapp-gc-product-fields input::placeholder,
.tapp-gc-product-fields textarea::placeholder {
	color: var(--wd-form-placeholder-color, inherit);
	opacity: 0.7;
}

/* Gift Card Apply Form */
.tapp-gc-apply-form,
.tapp-gc-checkout-form {
	background: var(--wd-form-bg, #f8f9fa);
	border: var(--wd-form-brd-width, 1px) solid var(--wd-form-brd-color, rgba(0, 0, 0, 0.1));
	border-radius: var(--wd-form-brd-radius, 0);
	padding: 15px;
	margin-bottom: 20px;
}

.tapp-gc-apply-form h3,
.tapp-gc-checkout-form h3 {
	margin-top: 0;
	margin-bottom: 15px;
	font-size: 16px;
	color: var(--wd-title-color, #333);
}

.tapp-gc-form {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: flex-end;
}

.tapp-gc-form .form-row {
	margin-bottom: 0;
}

.tapp-gc-form .form-row-wide {
	flex: 1;
	min-width: 200px;
}

.tapp-gc-form input[type="text"] {
	width: 100%;
}

.tapp-gc-apply-btn {
	white-space: nowrap;
	height: var(--wd-form-height, 42px);
}

.tapp-gc-message {
	margin-top: 10px;
	padding: 10px 15px;
	border-radius: 4px;
}

.tapp-gc-message.success {
	background: #d4edda;
	color: #155724;
	border: 1px solid #c3e6cb;
}

.tapp-gc-message.error {
	background: #f8d7da;
	color: #721c24;
	border: 1px solid #f5c6cb;
}

/* Applied Gift Cards - Cart Row Display */
.tapp-gc-cart-row th {
	font-weight: 600;
}

.tapp-gc-cart-subtitle {
	line-height: 1.4;
	font-size: 80%;
	font-weight: 300;
	color: #6c757d;
	margin-top: 4px;
}

.tapp-gc-cart-row td {
	text-align: right;
}

.tapp-gc-remove {
	color: #dc3545 !important;
	text-decoration: none;
	font-size: 13px;
	margin-left: 8px;
}

.tapp-gc-remove:hover {
	text-decoration: underline;
}

/* Checkout gift card toggle (coupon-style) */
.tapp-gc-checkout-wrapper {
	margin-bottom: 20px;
}

.tapp-gc-info-toggle {
	cursor: pointer;
}

.tapp-gc-showcoupon {
	cursor: pointer;
}

.tapp-gc-checkout-form.checkout_coupon {
	border: 1px solid #d3ced2;
	padding: 20px;
	margin-bottom: 20px;
	text-align: left;
	border-radius: 5px;
}

/* Balance Check Form */
.tapp-gc-balance-check {
	max-width: 400px;
}

.tapp-gc-balance-form .form-row {
	margin-bottom: 15px;
}

.tapp-gc-balance-form label {
	display: block;
	margin-bottom: 5px;
	font-weight: 600;
}

.tapp-gc-balance-form input {
	width: 100%;
	padding: 10px;
	border: 1px solid #ced4da;
	border-radius: 4px;
}

.tapp-gc-check-balance-btn {
	width: 100%;
}

.tapp-gc-balance-result {
	margin-top: 20px;
	text-align: center;
}

.tapp-gc-balance-card {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: #fff;
	padding: 30px;
	border-radius: 12px;
	margin-bottom: 15px;
}

.tapp-gc-balance-label {
	display: block;
	font-size: 14px;
	opacity: 0.9;
	margin-bottom: 8px;
}

.tapp-gc-balance-amount {
	font-size: 36px;
	font-weight: 700;
}

.tapp-gc-balance-expiry {
	font-size: 14px;
	color: #6c757d;
}

.tapp-gc-balance-error {
	background: #f8d7da;
	color: #721c24;
	padding: 15px;
	border-radius: 4px;
	text-align: center;
}

/* ----------------------------------------
   GIFT CARD AMOUNT SWATCHES / PILLS
   Label + Pills layout with proper alignment
   ---------------------------------------- */

/* Fix the variations table row to align label with pills */
.variations tr[data-attribute_name="attribute_gift-card-amount"] th.label,
.variations tr th.label {
	vertical-align: middle;
	padding-top: 0;
	padding-bottom: 0;
}

.variations tr[data-attribute_name="attribute_gift-card-amount"] td.value,
.variations tr td.value {
	vertical-align: middle;
}

/* Swatches container - inline with proper alignment */
.tapp-gc-swatches {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	margin: 0;
}

/* Individual swatch pill - uses WoodMart form styling */
.tapp-gc-swatch {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 50px;
	height: var(--wd-form-height, 42px);
	padding: 0 16px;
	background: var(--bgcolor-white, #fff);
	border: var(--wd-form-brd-width, 2px) solid var(--wd-form-brd-color, rgba(0, 0, 0, 0.1));
	border-radius: var(--wd-form-brd-radius, 0);
	font-size: 14px;
	font-weight: 600;
	color: var(--wd-title-color, #333);
	cursor: pointer;
	transition: all 0.3s ease;
	user-select: none;
}

.tapp-gc-swatch:hover {
	border-color: var(--wd-form-brd-color-focus, rgba(0, 0, 0, 0.25));
}

.tapp-gc-swatch.wd-active,
.tapp-gc-swatch.active {
	border-color: var(--wd-primary-color, #83b735);
	background: var(--wd-primary-color, #83b735);
	color: #fff;
}

/* Clear/Reset link - position at end of swatches row */
.reset_variations {
	display: inline-flex;
	align-items: center;
	height: var(--wd-form-height, 42px);
	margin-left: 8px;
	padding: 0 12px;
	font-size: 13px;
	color: var(--wd-text-color, #767676);
	text-decoration: none;
	transition: color 0.3s ease;
}

.reset_variations:hover {
	color: var(--wd-primary-color, #83b735);
}

/* Hide dropdown when swatches are active */
.tapp-gc-swatches-active select#gift-card-amount {
	position: absolute !important;
	left: -9999px !important;
	visibility: hidden !important;
}

/* Move reset link into the value cell for better alignment */
.tapp-gc-swatches-active .reset_variations {
	order: 10;
}

/* ----------------------------------------
   PRODUCT PAGE GIFT CARD FIELDS
   "Send to someone else" toggle + recipient form
   ---------------------------------------- */
.tapp-gc-product-fields {
	width: 100%;
	flex-basis: 100% !important;
	margin: 15px 0;
}

/* Modern Toggle Switch - matching campaign management style */
.tapp-gc-toggle-container {
	margin-bottom: 15px;
}

.tapp-gc-toggle-label {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	color: var(--wd-text-color, #666);
}

.tapp-gc-toggle-label input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.tapp-gc-toggle-switch {
	position: relative;
	width: 44px;
	height: 24px;
	background: var(--brdcolor-gray-300, #ddd);
	border-radius: 12px;
	transition: all 0.3s ease;
	flex-shrink: 0;
}

.tapp-gc-toggle-switch::after {
	content: '';
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	background: #fff;
	border-radius: 50%;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
	transition: all 0.3s ease;
}

.tapp-gc-toggle-label input[type="checkbox"]:checked + .tapp-gc-toggle-switch {
	background: var(--wd-primary-color, #83b735);
}

.tapp-gc-toggle-label input[type="checkbox"]:checked + .tapp-gc-toggle-switch::after {
	left: 23px;
}

.tapp-gc-toggle-text {
	color: var(--wd-title-color, #333);
}

/* Recipient Fields Container */
.tapp-gc-recipient-fields {
	display: none;
	margin-top: 15px;
}

.tapp-gc-recipient-fields.active {
	display: block;
}

/* Field containers inside recipient form */
.tapp-gc-field-container {
	margin-bottom: 16px;
}

.tapp-gc-field-container:last-child {
	margin-bottom: 0;
}

.tapp-gc-label {
	display: block;
	margin-bottom: 8px;
	font-size: 14px;
	font-weight: 600;
	color: var(--wd-title-color, #333);
}

.tapp-gc-label abbr {
	color: var(--wd-red-color, #dc3545);
	text-decoration: none;
	border: none;
	margin-left: 2px;
}

.tapp-gc-label .optional-text {
	font-weight: normal;
	color: var(--wd-text-color, #767676);
}

/* Input styling is handled above in form inputs section */

.tapp-gc-subtitle {
	font-size: 12px;
	line-height: 1.5;
	color: var(--wd-text-color, #767676);
	margin-top: 6px;
}

#tapp-gc-message-chars {
	font-weight: 600;
}

/* Invalid input state */
.tapp-gc-product-fields input.invalid {
	border-color: var(--wd-red-color, #dc3545);
}

/* Ensure add to cart wrapper allows proper layout */
.single-product .add_to_cart_wrapper,
.single-product .woocommerce-variation-add-to-cart {
	flex-wrap: wrap !important;
}

/* Loading States */
.tapp-gc-loading {
	opacity: 0.6;
	pointer-events: none;
}

.tapp-gc-loading button {
	position: relative;
}

.tapp-gc-loading button::after {
	content: '';
	position: absolute;
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
	width: 16px;
	height: 16px;
	border: 2px solid transparent;
	border-top-color: currentColor;
	border-radius: 50%;
	animation: tapp-gc-spin 0.8s linear infinite;
}

@keyframes tapp-gc-spin {
	to {
		transform: translateY(-50%) rotate(360deg);
	}
}

/* ----------------------------------------
   RESPONSIVE STYLES
   ---------------------------------------- */
@media screen and (max-width: 768px) {
	/* Swatches wrap nicely on mobile */
	.tapp-gc-swatches {
		gap: 6px;
	}

	.tapp-gc-swatch {
		min-width: 45px;
		padding: 0 12px;
		font-size: 13px;
	}

	/* Reset link stacks below on mobile */
	.reset_variations {
		margin-left: 0;
		margin-top: 8px;
	}
}

@media screen and (max-width: 600px) {
	.tapp-gc-form {
		flex-direction: column;
	}

	.tapp-gc-form .form-row {
		width: 100%;
	}

	.tapp-gc-apply-btn {
		width: 100%;
	}

	/* Toggle label wraps nicely */
	.tapp-gc-toggle-label {
		flex-wrap: wrap;
	}

	.tapp-gc-toggle-text {
		flex: 1;
		min-width: 150px;
	}
}
