/**
 * WooCommerce compatibility overrides for DriveBro theme.
 *
 * Loaded conditionally on WC pages via drivebro_needs_wc_compat_css().
 * Uses token variables from drivebro/base/tokens.css.
 */

/* ══════════════════════════════════════════════════
   1. Reset conflicting WC defaults
   ══════════════════════════════════════════════════ */

.woocommerce,
.woocommerce-page {
	line-height: inherit;
}

.woocommerce .woocommerce-result-count,
.woocommerce .woocommerce-ordering {
	display: none;
}

.woocommerce .woocommerce-breadcrumb {
	display: none;
}

.woocommerce-page .entry-header,
.woocommerce-page .page-title:not(.drivebro-page-title) {
	display: none;
}

.woocommerce::before,
.woocommerce::after {
	display: none;
}

/* ══════════════════════════════════════════════════
   2. WC Notices — match theme alert tokens
   ══════════════════════════════════════════════════ */

.woocommerce-error,
.woocommerce-message,
.woocommerce-info {
	list-style: none;
	margin: 0 0 1rem;
	padding: 1rem;
	border-radius: var(--radius-lg, 1rem);
	font-size: 0.875rem;
	line-height: 1.5;
}

.woocommerce-error::before,
.woocommerce-message::before,
.woocommerce-info::before {
	display: none;
}

.woocommerce-error li,
.woocommerce-message li,
.woocommerce-info li {
	list-style: none;
}

.woocommerce-error {
	background: var(--destructive-light, rgba(239, 68, 68, 0.1));
	color: var(--destructive, #EF4444);
	border: 1px solid rgba(239, 68, 68, 0.3);
}

.woocommerce-message {
	background: var(--green-light, rgba(34, 197, 94, 0.1));
	color: var(--green, #22C55E);
	border: 1px solid rgba(34, 197, 94, 0.3);
}

.woocommerce-info {
	background: var(--primary-light, rgba(44, 95, 111, 0.1));
	color: var(--primary, #2C5F6F);
	border: 1px solid var(--primary-mid, rgba(44, 95, 111, 0.2));
}

.woocommerce-message .button.wc-forward {
	display: none !important;
}

/* ══════════════════════════════════════════════════
   3. WC Forms — match theme form components
   ══════════════════════════════════════════════════ */

.woocommerce form .form-row {
	margin-bottom: 1rem;
	padding: 0;
}

.woocommerce form .form-row label {
	display: block;
	margin-bottom: 0.5rem;
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--muted-foreground, #6B7280);
}

.woocommerce form .form-row label .required {
	color: var(--destructive, #EF4444);
}

.woocommerce form .form-row input.input-text,
.woocommerce form .form-row textarea,
.woocommerce form .form-row select,
.woocommerce form .form-row .select2-container .select2-selection--single {
	width: 100%;
	padding: 0.75rem 1rem;
	background: var(--input-bg, #ffffff);
	border: 1px solid var(--border, #E5E7EB);
	border-radius: var(--radius-lg, 1rem);
	font-size: 1rem;
	font-family: inherit;
	color: var(--foreground, #1A1A1A);
	outline: none;
	transition: box-shadow var(--transition, 0.2s ease), border-color var(--transition, 0.2s ease);
}

.woocommerce form .form-row input.input-text:focus,
.woocommerce form .form-row textarea:focus,
.woocommerce form .form-row select:focus {
	box-shadow: 0 0 0 3px var(--primary-light, rgba(44, 95, 111, 0.1));
	border-color: var(--primary, #2C5F6F);
}

.woocommerce form .form-row textarea {
	min-height: 120px;
	resize: vertical;
}

.woocommerce form .form-row .select2-container .select2-selection--single {
	height: auto;
	min-height: 2.75rem;
}

.woocommerce form .form-row-wide {
	width: 100%;
}

.woocommerce form .form-row-first,
.woocommerce form .form-row-last {
	width: 100%;
}

@media (min-width: 640px) {
	.woocommerce form .form-row-first,
	.woocommerce form .form-row-last {
		width: calc(50% - 0.5rem);
		display: inline-block;
		vertical-align: top;
	}
	.woocommerce form .form-row-first {
		margin-left: 1rem;
	}
	[dir="ltr"] .woocommerce form .form-row-first {
		margin-left: 0;
		margin-right: 1rem;
	}
}

/* ══════════════════════════════════════════════════
   4. WC Buttons — match theme .btn / .btn-primary
   ══════════════════════════════════════════════════ */

.woocommerce .button,
.woocommerce button.button,
.woocommerce a.button,
.woocommerce input.button,
.woocommerce #respond input#submit,
.woocommerce .woocommerce-Button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.75rem 1.5rem;
	font-size: 1rem;
	font-weight: 600;
	font-family: inherit;
	line-height: 1.5;
	border-radius: var(--radius-lg, 1rem);
	border: none;
	cursor: pointer;
	text-align: center;
	text-decoration: none;
	background: var(--primary, #2C5F6F);
	color: var(--primary-foreground, #ffffff);
	box-shadow: var(--shadow-lg);
	transition: all var(--transition, 0.2s ease);
}

.woocommerce .button:hover,
.woocommerce button.button:hover,
.woocommerce a.button:hover,
.woocommerce input.button:hover {
	background: var(--primary-hover, #245161);
	box-shadow: var(--shadow-xl);
}

.woocommerce .button.alt,
.woocommerce button.button.alt,
.woocommerce a.button.alt,
.woocommerce input.button.alt {
	background: var(--primary, #2C5F6F);
	color: var(--primary-foreground, #ffffff);
}

.woocommerce .button.alt:hover,
.woocommerce button.button.alt:hover {
	background: var(--primary-hover, #245161);
}

.woocommerce .button:disabled,
.woocommerce button.button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	pointer-events: none;
}

#place_order {
	width: 100%;
	padding: 0.875rem 1rem !important;
	border-radius: var(--radius-lg, 1rem) !important;
	background: var(--primary, #2C5F6F) !important;
	color: var(--primary-foreground, #ffffff) !important;
	border: none !important;
	font-weight: 600;
	font-size: 1rem;
	cursor: pointer;
	transition: all var(--transition, 0.2s ease);
}

#place_order:hover {
	background: var(--primary-hover, #245161) !important;
	box-shadow: var(--shadow-xl);
}

/* ══════════════════════════════════════════════════
   5. WC Tables — clean modern look
   ══════════════════════════════════════════════════ */

.woocommerce table.shop_table {
	border-collapse: collapse;
	width: 100%;
	border: 1px solid var(--border, #E5E7EB);
	border-radius: var(--radius-lg, 1rem);
	overflow: hidden;
	font-size: 0.9375rem;
}

.woocommerce table.shop_table th,
.woocommerce table.shop_table td {
	padding: 0.875rem 1rem;
	text-align: start;
	border-bottom: 1px solid var(--border, #E5E7EB);
}

.woocommerce table.shop_table thead th {
	background: var(--muted, #F5F5F5);
	font-weight: 600;
	color: var(--foreground, #1A1A1A);
	font-size: 0.875rem;
	text-transform: none;
}

.woocommerce table.shop_table tbody tr:last-child td {
	border-bottom: none;
}

.woocommerce table.shop_table .order-total th,
.woocommerce table.shop_table .order-total td {
	font-weight: 700;
	color: var(--primary, #2C5F6F);
	font-size: 1.1rem;
}

/* Cart table */
.woocommerce table.shop_table.cart .product-thumbnail img {
	width: 64px;
	height: 64px;
	object-fit: cover;
	border-radius: var(--radius, 0.75rem);
}

.woocommerce table.shop_table.cart .product-name a {
	color: var(--foreground, #1A1A1A);
	text-decoration: none;
	font-weight: 600;
}

.woocommerce table.shop_table.cart .product-name a:hover {
	color: var(--primary, #2C5F6F);
}

.woocommerce table.shop_table.cart .product-remove a {
	color: var(--destructive, #EF4444) !important;
	font-size: 1.25rem;
	text-decoration: none;
}

/* Order detail tables (account orders) */
.woocommerce-orders-table {
	border-radius: var(--radius-lg, 1rem);
	overflow: hidden;
}

.woocommerce-orders-table .woocommerce-orders-table__cell-order-actions a {
	display: inline-flex;
	align-items: center;
	padding: 0.5rem 1rem;
	font-size: 0.875rem;
	font-weight: 600;
	border-radius: var(--radius, 0.75rem);
	background: var(--primary-light, rgba(44, 95, 111, 0.1));
	color: var(--primary, #2C5F6F);
	text-decoration: none;
	transition: all var(--transition, 0.2s ease);
}

.woocommerce-orders-table .woocommerce-orders-table__cell-order-actions a:hover {
	background: var(--primary, #2C5F6F);
	color: var(--primary-foreground, #ffffff);
}

@media (max-width: 768px) {
	.woocommerce table.shop_table,
	.woocommerce table.shop_table thead,
	.woocommerce table.shop_table tbody,
	.woocommerce table.shop_table tr,
	.woocommerce table.shop_table th,
	.woocommerce table.shop_table td {
		display: block;
		width: 100%;
	}

	.woocommerce table.shop_table thead {
		display: none;
	}

	.woocommerce table.shop_table tr {
		margin-bottom: 1rem;
		border: 1px solid var(--border, #E5E7EB);
		border-radius: var(--radius-lg, 1rem);
		overflow: hidden;
	}

	.woocommerce table.shop_table td {
		text-align: start;
		padding: 0.75rem 1rem;
		border-bottom: 1px solid var(--border, #E5E7EB);
	}

	.woocommerce table.shop_table td::before {
		content: attr(data-title) ": ";
		font-weight: 600;
		color: var(--muted-foreground, #6B7280);
	}
}

/* ══════════════════════════════════════════════════
   6. WC Account Navigation
   ══════════════════════════════════════════════════ */

.woocommerce-MyAccount-navigation {
	display: none;
}

.woocommerce-MyAccount-content {
	width: 100%;
	background: transparent;
	border: none;
	padding: 0;
	box-shadow: none;
}

.woocommerce-MyAccount-content .woocommerce-EditAccountForm .form-row {
	margin-bottom: 1rem;
}

.woocommerce-MyAccount-content .woocommerce-EditAccountForm label {
	display: block;
	margin-bottom: 0.5rem;
	font-weight: 500;
	color: var(--muted-foreground, #6B7280);
	font-size: 0.875rem;
}

.woocommerce-MyAccount-content .woocommerce-EditAccountForm input.input-text {
	width: 100%;
	padding: 0.75rem 1rem;
	border-radius: var(--radius-lg, 1rem);
	border: 1px solid var(--border, #E5E7EB);
	background: var(--input-bg, #ffffff);
	font-size: 1rem;
	font-family: inherit;
	outline: none;
	transition: box-shadow var(--transition, 0.2s ease), border-color var(--transition, 0.2s ease);
}

.woocommerce-MyAccount-content .woocommerce-EditAccountForm input.input-text:focus {
	box-shadow: 0 0 0 3px var(--primary-light, rgba(44, 95, 111, 0.1));
	border-color: var(--primary, #2C5F6F);
}

.woocommerce-MyAccount-content button[type="submit"],
.woocommerce-MyAccount-content .woocommerce-Button {
	background: var(--primary, #2C5F6F) !important;
	color: var(--primary-foreground, #ffffff) !important;
	border: none !important;
	border-radius: var(--radius-lg, 1rem) !important;
	padding: 0.75rem 1.5rem !important;
	font-weight: 600;
	cursor: pointer;
}

.woocommerce-MyAccount-content button[type="submit"]:hover,
.woocommerce-MyAccount-content .woocommerce-Button:hover {
	background: var(--primary-hover, #245161) !important;
}

/* ══════════════════════════════════════════════════
   7. WC Breadcrumb (theme provides its own)
   ══════════════════════════════════════════════════ */

.woocommerce .woocommerce-breadcrumb {
	display: none;
}

/* Theme breadcrumb */
.drivebro-breadcrumb {
	font-size: 0.875rem;
	color: var(--muted-foreground, #6B7280);
	margin-bottom: 0.5rem;
}

.drivebro-breadcrumb a {
	color: var(--muted-foreground, #6B7280);
	text-decoration: none;
	transition: color var(--transition, 0.2s ease);
}

.drivebro-breadcrumb a:hover {
	color: var(--primary, #2C5F6F);
}

.drivebro-breadcrumb__sep {
	margin: 0 0.375rem;
	opacity: 0.5;
}

/* ══════════════════════════════════════════════════
   8. Hide WC elements replaced by theme templates
   ══════════════════════════════════════════════════ */

.woocommerce-page .woocommerce > .woocommerce-notices-wrapper:empty {
	display: none;
}

.woocommerce .woocommerce-result-count,
.woocommerce .woocommerce-ordering,
.woocommerce-page .woocommerce-sidebar,
.woocommerce-checkout #order_review_heading,
.single-product .related.products > h2 {
	display: none;
}

.woocommerce .woocommerce-product-gallery__trigger,
.woocommerce .woocommerce-product-gallery .flex-control-thumbs {
	display: none;
}

/* ══════════════════════════════════════════════════
   9. Product grid — reset WC float layout
   ══════════════════════════════════════════════════ */

.woocommerce ul.products {
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
	display: grid !important;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 1.5rem;
	align-items: stretch;
}

@media (max-width: 992px) {
	.woocommerce ul.products {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 560px) {
	.woocommerce ul.products {
		grid-template-columns: 1fr;
	}
}

.woocommerce ul.products li.product {
	float: none !important;
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
}

.woocommerce ul.products::before,
.woocommerce ul.products::after {
	display: none !important;
}

.woocommerce ul.products li.product img {
	width: 100%;
	height: 224px;
	object-fit: cover;
	border-radius: var(--radius-lg, 1rem) var(--radius-lg, 1rem) 0 0;
}

/* ══════════════════════════════════════════════════
   10. WC Pagination
   ══════════════════════════════════════════════════ */

.woocommerce-pagination {
	text-align: center;
	margin-top: 2rem;
}

.woocommerce-pagination ul.page-numbers {
	display: inline-flex;
	gap: 0.5rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.woocommerce-pagination .page-numbers li a,
.woocommerce-pagination .page-numbers li span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.25rem;
	height: 2.25rem;
	padding: 0 0.5rem;
	border-radius: var(--radius, 0.75rem);
	border: 1px solid var(--border, #E5E7EB);
	text-decoration: none;
	color: var(--foreground, #1A1A1A);
	font-size: 0.875rem;
	transition: all var(--transition, 0.2s ease);
}

.woocommerce-pagination .page-numbers li span.current {
	background: var(--primary, #2C5F6F);
	color: var(--primary-foreground, #ffffff);
	border-color: var(--primary, #2C5F6F);
}

.woocommerce-pagination .page-numbers li a:hover {
	background: var(--secondary, #F5F5F5);
}

/* ══════════════════════════════════════════════════
   11. Cart & Checkout shell
   ══════════════════════════════════════════════════ */

.drivebro-cart-shell,
.drivebro-checkout-shell {
	max-width: 72rem;
	margin: 0 auto;
	padding: 2rem 1rem;
}

@media (min-width: 768px) {
	.drivebro-cart-shell,
	.drivebro-checkout-shell {
		padding: 3rem 2rem;
	}
}

/* الجوال: تقليل الهوامش المزدوجة مع .container داخل صفحة الحجز لتوسيع البطاقات */
@media (max-width: 640px) {
	.drivebro-checkout-shell {
		max-width: 100%;
		padding: 1rem max(0.75rem, env(safe-area-inset-left, 0px)) 2rem max(0.75rem, env(safe-area-inset-right, 0px));
	}
}

.drivebro-page-title {
	font-size: clamp(1.5rem, 3vw, 2rem);
	font-weight: 700;
	color: var(--foreground, #1A1A1A);
	margin-bottom: 1.5rem;
}

/* ══════════════════════════════════════════════════
   12. Payment method styling
   ══════════════════════════════════════════════════ */

.woocommerce-checkout #payment {
	background: transparent;
	border-radius: var(--radius-lg, 1rem);
}

.woocommerce-checkout #payment ul.payment_methods {
	list-style: none;
	margin: 0;
	padding: 0;
	border: none;
}

.woocommerce-checkout #payment ul.payment_methods li {
	padding: 1rem;
	border-radius: var(--radius, 0.75rem);
	border: 2px solid var(--border, #E5E7EB);
	margin-bottom: 0.75rem;
	cursor: pointer;
	transition: all var(--transition, 0.2s ease);
}

.woocommerce-checkout #payment ul.payment_methods li:hover {
	border-color: var(--primary-mid, rgba(44, 95, 111, 0.2));
}

.woocommerce-checkout #payment ul.payment_methods li.wc_payment_method input[type="radio"]:checked ~ label {
	color: var(--primary, #2C5F6F);
	font-weight: 600;
}

.woocommerce-checkout #payment .payment_box {
	background: var(--muted, #F5F5F5);
	padding: 1rem;
	border-radius: var(--radius, 0.75rem);
	margin-top: 0.75rem;
	font-size: 0.875rem;
	color: var(--muted-foreground, #6B7280);
}

.woocommerce-checkout #payment .payment_box::before {
	display: none;
}

/* ══════════════════════════════════════════════════
   13. Thank-you / Order-received page
   ══════════════════════════════════════════════════ */

.woocommerce-order-received .woocommerce-order {
	max-width: 42rem;
	margin: 0 auto;
}

.woocommerce-order-received .woocommerce-order-overview {
	list-style: none;
	padding: 0;
	margin: 1rem 0 0;
}

.woocommerce-order-received .woocommerce-order-overview li {
	padding: 0.5rem 0;
	border-bottom: 1px solid var(--border, #E5E7EB);
}

/* ══════════════════════════════════════════════════
   14. RTL compatibility
   ══════════════════════════════════════════════════ */

html[dir="rtl"] .woocommerce table.shop_table th,
html[dir="rtl"] .woocommerce table.shop_table td {
	text-align: right;
}

html[dir="rtl"] .woocommerce form .form-row-first {
	float: right;
	margin-left: 1rem;
	margin-right: 0;
}

html[dir="rtl"] .woocommerce form .form-row-last {
	float: left;
	margin-left: 0;
}

html[dir="rtl"] .woocommerce-pagination {
	direction: rtl;
}

html[dir="rtl"] .drivebro-breadcrumb__sep {
	margin: 0 0.375rem;
}

html[dir="rtl"] .woocommerce .button,
html[dir="rtl"] .woocommerce a.button {
	direction: rtl;
}

/* ══════════════════════════════════════════════════
   15. Select2 overrides (WC country/state dropdowns)
   ══════════════════════════════════════════════════ */

.select2-container--default .select2-selection--single {
	height: auto !important;
	padding: 0.75rem 1rem !important;
	border: 1px solid var(--border, #E5E7EB) !important;
	border-radius: var(--radius-lg, 1rem) !important;
	background: var(--input-bg, #ffffff) !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
	line-height: normal !important;
	color: var(--foreground, #1A1A1A) !important;
	padding: 0 !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
	height: 100% !important;
	top: 0 !important;
}

.select2-container--open .select2-dropdown {
	border: 1px solid var(--border, #E5E7EB);
	border-radius: var(--radius, 0.75rem);
	box-shadow: var(--shadow-lg);
	overflow: hidden;
}

.select2-results__option--highlighted[aria-selected] {
	background: var(--primary, #2C5F6F) !important;
	color: var(--primary-foreground, #ffffff) !important;
}

/* ══════════════════════════════════════════════════
   16. Misc WC resets
   ══════════════════════════════════════════════════ */

.woocommerce .quantity .qty {
	width: 4rem;
	padding: 0.5rem;
	text-align: center;
	border: 1px solid var(--border, #E5E7EB);
	border-radius: var(--radius, 0.75rem);
	font-size: 1rem;
}

.woocommerce .star-rating {
	color: var(--accent, #D4AF37);
}

.woocommerce span.onsale {
	background: var(--accent, #D4AF37);
	color: var(--accent-foreground, #1A1A1A);
	border-radius: var(--radius, 0.75rem);
	padding: 0.25rem 0.75rem;
	font-size: 0.75rem;
	font-weight: 600;
	min-height: auto;
	min-width: auto;
	line-height: 1.5;
}

.woocommerce .price del {
	opacity: 0.5;
}

.woocommerce .price ins {
	text-decoration: none;
	font-weight: 700;
}

a.filter-pill {
	text-decoration: none;
	color: inherit;
}

a.filter-pill:hover {
	color: var(--primary, #2C5F6F);
}

a.filter-pill.active {
	color: var(--primary-foreground, #ffffff);
}
