/**
 * Afoomart Shopping Cart Stylesheet
 *
 * Implements:
 * - 2-Column Responsive Layout (65% Cart Items / 35% Order Summary)
 * - Stacked Responsive Cart Items with Quantity Steppers
 * - Order Summary Card, Subtotal, Discount & Shipping Calculator
 * - Real-Time Coupon Input & Validation Notice
 * - Global Offcanvas Cart Drawer (Desktop + Mobile)
 * - Empty Cart State with Category Shortcuts & Recommendations
 * - Mobile Sticky Bottom Checkout Bar (< 768px)
 *
 * @package Afoomart
 */

/* ==========================================================================
   1. FULL CART PAGE LAYOUT
   ========================================================================== */

.af-cart-page-wrapper {
	padding-top: var(--space-4);
	padding-bottom: var(--space-12);
	background-color: var(--color-bg-body, #f8fafc);
}

.af-cart-page-title {
	display: flex;
	align-items: baseline;
	gap: var(--space-2);
	font-size: 1.75rem;
	font-weight: 700;
	color: var(--color-text-main, #0f172a);
	margin: 0;
}

.af-cart-header-count {
	font-size: 1.125rem;
	font-weight: 500;
	color: var(--color-text-muted, #64748b);
}

.af-cart-layout-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 380px;
	gap: var(--space-8);
	align-items: start;
}

.af-cart-items-column {
	display: flex;
	flex-direction: column;
}

.af-cart-items-card {
	background: #ffffff;
	border: 1px solid var(--color-border, #e2e8f0);
	border-radius: var(--radius-lg, 12px);
	overflow: hidden;
	box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.05));
}

/* ==========================================================================
   2. CART ITEMS TABLE / LIST
   ========================================================================== */

.af-cart-table-head {
	display: grid;
	grid-template-columns: minmax(0, 3fr) 1fr 1.2fr 1fr 40px;
	gap: var(--space-4);
	padding: var(--space-3) var(--space-5);
	background: #f8fafc;
	border-bottom: 1px solid var(--color-border, #e2e8f0);
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--color-text-muted, #64748b);
}

.af-cart-table-body {
	display: flex;
	flex-direction: column;
}

.af-cart-item-row {
	display: grid;
	grid-template-columns: minmax(0, 3fr) 1fr 1.2fr 1fr 40px;
	gap: var(--space-4);
	align-items: center;
	padding: var(--space-5);
	border-bottom: 1px solid var(--color-border, #e2e8f0);
	transition: background-color 0.2s ease, opacity 0.2s ease;
}

.af-cart-item-row:last-child {
	border-bottom: none;
}

.af-cart-item-row.is-loading {
	opacity: 0.45;
	pointer-events: none;
}

/* Item Thumbnail */
.af-item-thumb {
	width: 80px;
	height: 80px;
	border-radius: var(--radius-md, 8px);
	border: 1px solid var(--color-border, #e2e8f0);
	background: #ffffff;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.af-item-thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* Title & Metadata */
.af-cart-item-row .af-item-thumb,
.af-cart-item-row .af-item-details {
	display: flex;
}

.af-item-details {
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.af-cart-item-row > .af-item-thumb {
	grid-column: 1 / 2;
	float: left;
	margin-right: var(--space-4);
}

.af-cart-item-row:after {
	content: "";
	display: table;
	clear: both;
}

.af-item-title {
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.4;
	margin: 0;
}

.af-item-title a {
	color: var(--color-text-main, #0f172a);
	text-decoration: none;
	transition: color 0.2s ease;
}

.af-item-title a:hover {
	color: var(--color-primary-navy, #113F6D);
}

.af-item-seller-line {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 0.75rem;
	color: var(--color-text-muted, #64748b);
}

.af-seller-micro-name {
	color: #0369a1;
	font-weight: 600;
}

.variation,
.variation dd,
.variation dt {
	display: inline-block;
	font-size: 0.75rem;
	color: #475569;
	margin: 0;
}

.variation dt {
	font-weight: 600;
	margin-right: 4px;
}

.variation dd {
	margin-right: 8px;
}

.af-item-mobile-price {
	display: none;
	font-size: 0.8125rem;
	color: var(--color-text-muted);
}

/* Unit Price */
.af-item-unit-price {
	font-size: 0.9375rem;
	font-weight: 600;
	color: #334155;
}

/* Quantity Stepper */
.af-qty-stepper-box {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--color-border, #e2e8f0);
	border-radius: var(--radius-md, 8px);
	background: #ffffff;
	overflow: hidden;
}

.af-qty-btn {
	width: 32px;
	height: 32px;
	background: #f8fafc;
	border: none;
	font-size: 1rem;
	font-weight: 700;
	color: var(--color-text-main);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
}

.af-qty-btn:hover {
	background: #e2e8f0;
}

.af-qty-input {
	width: 44px;
	height: 32px;
	border: none;
	text-align: center;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--color-text-main);
	-moz-appearance: textfield;
}

.af-qty-input::-webkit-outer-spin-button,
.af-qty-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* Line Total */
.af-item-line-total {
	font-size: 1.0625rem;
	font-weight: 700;
	color: var(--color-primary-navy, #113F6D);
}

/* Remove Action */
.af-cart-item-remove {
	background: transparent;
	border: none;
	color: #94a3b8;
	cursor: pointer;
	padding: 6px;
	border-radius: var(--radius-sm, 4px);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
}

.af-cart-item-remove:hover {
	color: var(--color-accent-red, #DE2C27);
	background: #fff1f2;
}

.af-remove-text {
	display: none;
}

/* Bottom Strip Actions */
.af-cart-card-actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--space-4) var(--space-5);
	background: #f8fafc;
	border-top: 1px solid var(--color-border, #e2e8f0);
}

.af-continue-shopping-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

/* ==========================================================================
   3. ORDER SUMMARY CARD (RIGHT COLUMN)
   ========================================================================== */

.af-cart-summary-column {
	position: sticky;
	top: calc(var(--header-height, 80px) + var(--space-4));
}

.af-order-summary-card {
	background: #ffffff;
	border: 1px solid var(--color-border, #e2e8f0);
	border-radius: var(--radius-lg, 12px);
	padding: var(--space-6);
	box-shadow: var(--shadow-sm);
}

.af-summary-heading {
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--color-text-main);
	margin: 0 0 var(--space-4) 0;
	padding-bottom: var(--space-3);
	border-bottom: 1px solid #e2e8f0;
}

/* Totals Table */
.af-totals-table {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
}

.af-totals-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 0.9375rem;
	color: #475569;
}

.af-totals-label {
	font-weight: 500;
}

.af-totals-value {
	font-weight: 600;
	color: var(--color-text-main);
}

/* Applied Coupons */
.af-coupon-row {
	color: #15803d;
}

.af-coupon-label-wrap {
	display: flex;
	align-items: center;
	gap: 6px;
}

.af-coupon-remove-link {
	font-size: 0.75rem;
	color: var(--color-accent-red, #DE2C27);
	text-decoration: none;
	cursor: pointer;
}

.af-coupon-remove-link:hover {
	text-decoration: underline;
}

.af-discount-val {
	color: #15803d;
	font-weight: 700;
}

/* Grand Total Row */
.af-grand-total-row {
	margin-top: var(--space-2);
	padding-top: var(--space-3);
	border-top: 2px dashed #e2e8f0;
	font-size: 1.125rem;
}

.af-total-label {
	font-weight: 700;
	color: var(--color-text-main);
}

.af-total-val,
.af-total-val .woocommerce-Price-amount {
	font-size: 1.5rem;
	font-weight: 800;
	color: var(--color-primary-navy, #113F6D);
}

/* Checkout Button */
.af-proceed-checkout-wrap .checkout-button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 48px;
	background: var(--color-primary-navy, #113F6D);
	border: 1px solid var(--color-primary-navy, #113F6D);
	color: #ffffff;
	border-radius: var(--radius-md, 8px);
	font-size: 1rem;
	font-weight: 700;
	text-decoration: none;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(17, 63, 109, 0.2);
	transition: all 0.2s ease;
}

.af-proceed-checkout-wrap .checkout-button:hover {
	background: #0d2f53;
	border-color: #0d2f53;
	transform: translateY(-1px);
	box-shadow: 0 6px 16px rgba(17, 63, 109, 0.25);
}

/* Coupon Card */
.af-coupon-card {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: var(--radius-md, 8px);
	padding: var(--space-4);
}

.af-coupon-header {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--color-text-muted);
	margin-bottom: var(--space-2);
}

.af-coupon-input-wrap {
	display: flex;
	gap: var(--space-2);
}

.af-coupon-input {
	flex: 1;
	height: 38px;
	padding: 0 12px;
	font-size: 0.8125rem;
	background: #ffffff;
}

.af-apply-coupon-btn {
	height: 38px;
	padding: 0 16px;
	font-size: 0.8125rem;
	flex-shrink: 0;
}

.af-coupon-msg {
	margin-top: var(--space-2);
	font-size: 0.75rem;
	padding: 6px 10px;
	border-radius: var(--radius-sm, 4px);
}

.af-coupon-msg.is-success {
	background: #dcfce7;
	color: #15803d;
	border: 1px solid #bbf7d0;
}

.af-coupon-msg.is-error {
	background: #fee2e2;
	color: #b91c1c;
	border: 1px solid #fecaca;
}

/* Trust Badges Card */
.af-cart-trust-card {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	padding: var(--space-3) 0 0 0;
	border-top: 1px solid #f1f5f9;
}

.af-cart-trust-row {
	display: flex;
	align-items: flex-start;
	gap: var(--space-2);
}

.af-trust-icon-box {
	color: #16a34a;
	margin-top: 2px;
	flex-shrink: 0;
}

.af-trust-text-box {
	display: flex;
	flex-direction: column;
}

.af-trust-row-title {
	font-size: 0.75rem;
	font-weight: 700;
	color: var(--color-text-main);
}

.af-trust-row-desc {
	font-size: 0.6875rem;
	color: var(--color-text-muted);
	line-height: 1.35;
}

/* ==========================================================================
   4. CART RECOMMENDATIONS / CROSS-SELLS
   ========================================================================== */

.af-cart-recommendations-section {
	background: #ffffff;
	border: 1px solid var(--color-border, #e2e8f0);
	border-radius: var(--radius-lg, 12px);
	padding: var(--space-6);
	box-shadow: var(--shadow-sm);
}

.af-cart-recs-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: var(--space-4);
}

/* ==========================================================================
   5. EMPTY CART PAGE
   ========================================================================== */

.af-cart-empty-page {
	padding: var(--space-6) 0 var(--space-12) 0;
}

.af-empty-cart-card {
	background: #ffffff;
	border: 1px solid var(--color-border, #e2e8f0);
	border-radius: var(--radius-lg, 12px);
	padding: var(--space-10) var(--space-6);
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	box-shadow: var(--shadow-sm);
}

.af-empty-cart-illustration {
	color: #94a3b8;
	margin-bottom: var(--space-4);
}

.af-empty-cart-title {
	font-size: 1.5rem;
	font-weight: 800;
	color: var(--color-text-main);
	margin: 0 0 var(--space-2) 0;
}

.af-empty-cart-subtitle {
	font-size: 0.9375rem;
	color: var(--color-text-muted);
	max-width: 520px;
	margin: 0 0 var(--space-6) 0;
	line-height: 1.6;
}

.af-empty-cats-label {
	display: block;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--color-text-muted);
	margin-bottom: var(--space-3);
}

.af-empty-cats-pills {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2);
	justify-content: center;
}

.af-cat-shortcut-pill {
	display: inline-block;
	padding: 6px 14px;
	border-radius: 20px;
	background: #f1f5f9;
	color: var(--color-primary-navy, #113F6D);
	font-size: 0.8125rem;
	font-weight: 600;
	text-decoration: none;
	transition: all 0.2s ease;
}

.af-cat-shortcut-pill:hover {
	background: var(--color-primary-navy, #113F6D);
	color: #ffffff;
}

.af-empty-cart-recs-grid {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: var(--space-4);
}

/* ==========================================================================
   6. GLOBAL CART DRAWER (OFFCANVAS)
   ========================================================================== */

.af-cart-drawer {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	justify-content: flex-end;
}

.af-cart-drawer[hidden] {
	display: none;
}

.af-cart-drawer-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.65);
	backdrop-filter: blur(4px);
}

.af-cart-drawer-panel {
	position: relative;
	z-index: 1;
	width: 420px;
	max-width: 100vw;
	height: 100%;
	background: #ffffff;
	display: flex;
	flex-direction: column;
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
	transform: translateX(100%);
	transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.af-cart-drawer.is-open .af-cart-drawer-panel {
	transform: translateX(0);
}

/* Drawer Header */
.af-drawer-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--space-4) var(--space-5);
	border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.af-drawer-title {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	font-size: 1.0625rem;
	font-weight: 700;
	margin: 0;
	color: var(--color-text-main);
}

.af-drawer-count-badge {
	color: var(--color-primary-navy, #113F6D);
}

.af-drawer-close-btn {
	background: transparent;
	border: none;
	color: #64748b;
	cursor: pointer;
	padding: 4px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.2s ease;
}

.af-drawer-close-btn:hover {
	color: var(--color-text-main);
}

/* Drawer Body */
.af-drawer-body {
	flex: 1;
	overflow-y: auto;
	padding: var(--space-4) var(--space-5);
}

.af-drawer-items-list {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
}

.af-drawer-item {
	display: flex;
	gap: var(--space-3);
	padding-bottom: var(--space-4);
	border-bottom: 1px solid #f1f5f9;
}

.af-drawer-item-thumb {
	width: 64px;
	height: 64px;
	border-radius: var(--radius-md, 8px);
	border: 1px solid var(--color-border, #e2e8f0);
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.af-drawer-item-thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.af-drawer-item-details {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.af-drawer-item-title-row {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--space-2);
}

.af-drawer-item-title {
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--color-text-main);
	text-decoration: none;
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.af-drawer-remove-btn {
	background: transparent;
	border: none;
	color: #94a3b8;
	cursor: pointer;
	padding: 2px;
	flex-shrink: 0;
	transition: color 0.2s ease;
}

.af-drawer-remove-btn:hover {
	color: var(--color-accent-red, #DE2C27);
}

.af-drawer-var-pill {
	display: inline-block;
	font-size: 0.6875rem;
	color: #64748b;
	background: #f1f5f9;
	padding: 1px 6px;
	border-radius: 4px;
	margin-right: 4px;
}

.af-drawer-item-bottom {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 4px;
}

.af-drawer-qty-stepper {
	display: inline-flex;
	align-items: center;
	border: 1px solid #e2e8f0;
	border-radius: 4px;
}

.af-qty-step-btn {
	width: 24px;
	height: 24px;
	border: none;
	background: #f8fafc;
	font-size: 0.875rem;
	cursor: pointer;
	color: #334155;
}

.af-drawer-qty-input {
	width: 32px;
	height: 24px;
	border: none;
	text-align: center;
	font-size: 0.75rem;
	font-weight: 600;
}

.af-drawer-item-price {
	font-size: 0.875rem;
	font-weight: 700;
	color: var(--color-primary-navy, #113F6D);
}

/* Drawer Empty State */
.af-drawer-empty-state {
	padding: var(--space-10) var(--space-4);
	text-align: center;
	color: var(--color-text-muted);
}

.af-drawer-empty-icon {
	color: #94a3b8;
	margin-bottom: var(--space-3);
}

.af-drawer-empty-title {
	font-size: 1.125rem;
	font-weight: 700;
	color: var(--color-text-main);
	margin: 0 0 var(--space-2) 0;
}

.af-drawer-empty-text {
	font-size: 0.8125rem;
	margin-bottom: var(--space-4);
}

/* Drawer Footer */
.af-drawer-footer {
	padding: var(--space-4) var(--space-5);
	border-top: 1px solid var(--color-border, #e2e8f0);
	background: #f8fafc;
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
}

.af-drawer-subtotal-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 1rem;
	font-weight: 700;
}

.af-drawer-subtotal-val,
.af-drawer-subtotal-val .woocommerce-Price-amount {
	font-size: 1.25rem;
	color: var(--color-primary-navy, #113F6D);
}

.af-drawer-trust-banner {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.6875rem;
	font-weight: 600;
	color: #15803d;
	background: #dcfce7;
	padding: 4px 8px;
	border-radius: 4px;
}

.af-drawer-actions-grid {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

/* ==========================================================================
   7. MOBILE STICKY CHECKOUT BAR (< 768px)
   ========================================================================== */

.af-mobile-cart-sticky-bar {
	display: none;
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 1000;
	background: rgba(255, 255, 255, 0.95);
	backdrop-filter: blur(10px);
	border-top: 1px solid var(--color-border, #e2e8f0);
	padding: var(--space-2) var(--space-4);
	box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}

.af-mobile-sticky-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	max-width: 600px;
	margin: 0 auto;
	gap: var(--space-3);
}

.af-mobile-sticky-total {
	display: flex;
	flex-direction: column;
}

.af-mob-sub-label {
	font-size: 0.6875rem;
	color: var(--color-text-muted);
}

.af-mob-total-val,
.af-mob-total-val .woocommerce-Price-amount {
	font-size: 1.125rem;
	font-weight: 800;
	color: var(--color-primary-navy, #113F6D);
}

/* ==========================================================================
   8. RESPONSIVE BREAKPOINTS
   ========================================================================== */

@media (max-width: 1024px) {
	.af-cart-layout-grid {
		grid-template-columns: 1fr;
	}

	.af-cart-summary-column {
		position: static;
	}

	.af-cart-recs-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.af-empty-cart-recs-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 768px) {
	.af-cart-table-head {
		display: none;
	}

	.af-cart-item-row {
		display: flex;
		flex-wrap: wrap;
		gap: var(--space-3);
		position: relative;
		padding: var(--space-4);
	}

	.af-item-thumb {
		width: 72px;
		height: 72px;
	}

	.af-item-details {
		flex: 1;
		min-width: 0;
	}

	.af-item-unit-price {
		display: none;
	}

	.af-item-mobile-price {
		display: block;
	}

	.af-item-quantity {
		order: 4;
	}

	.af-item-line-total {
		order: 5;
		margin-left: auto;
	}

	.af-item-remove-col {
		position: absolute;
		top: var(--space-3);
		right: var(--space-3);
	}

	.af-cart-recs-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: var(--space-2);
	}

	.af-empty-cart-recs-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: var(--space-2);
	}

	.af-mobile-cart-sticky-bar {
		display: block;
	}

	.af-cart-page-wrapper {
		padding-bottom: 72px;
	}

	.af-cart-drawer-panel {
		width: 100vw;
	}
}

/* AJAX Add to Cart Button States & Feedback */
.af-btn-spinner {
	display: inline-block;
	width: 15px;
	height: 15px;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: afBtnSpin 0.65s linear infinite;
	vertical-align: middle;
	margin-right: 6px;
}

@keyframes afBtnSpin {
	to { transform: rotate(360deg); }
}

.af-add-to-cart-btn {
	transition: all 0.25s ease;
	position: relative;
}

.af-add-to-cart-btn.is-loading {
	opacity: 0.85;
	pointer-events: none;
	cursor: wait;
}

.af-add-to-cart-btn.is-success {
	background-color: var(--color-success, #10B981) !important;
	border-color: var(--color-success, #10B981) !important;
	color: #ffffff !important;
	pointer-events: none;
}
