/**
 * Quick Order card — the same-page Algeria COD form on the single product
 * page. Reuses the shared .form-row field system and notice tokens from
 * components.css; only the card-specific layout lives here.
 */

.quick-order-card {
	margin-block-start: var(--space-6);
	max-width: 560px;
	background: var(--color-card);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm);
	padding: var(--space-5);
	display: flex;
	flex-direction: column;
	gap: var(--space-5);
}

/* ---- Mini summary row (thumbnail, name, price, own quantity) ----
   Reference layout pairs image+name on one side and price+quantity as a
   stacked column on the other, rather than a single flex row — replicated
   here with a 3-column grid (image / name / price+qty) and `display:contents`
   on the info wrapper so the price can share a grid column with the
   quantity stepper despite being nested one level deeper in the markup. */
.quick-order-card__summary {
	display: grid;
	grid-template-columns: 64px 1fr auto;
	align-items: center;
	column-gap: var(--space-4);
	row-gap: var(--space-1);
}
.quick-order-card__summary img {
	grid-column: 1;
	grid-row: 1 / span 2;
	width: 64px;
	height: 64px;
	object-fit: contain;
	background: var(--color-surface);
	border-radius: var(--radius-md);
	flex-shrink: 0;
}
.quick-order-card__summary-info { display: contents; }
.quick-order-card__name {
	grid-column: 2;
	grid-row: 1;
	align-self: end;
	min-width: 0;
	font-weight: var(--font-weight-bold);
	font-size: var(--text-sm);
	overflow: hidden;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow-wrap: anywhere;
}
.quick-order-card__price {
	grid-column: 3;
	grid-row: 1;
	justify-self: start;
	color: var(--color-accent-strong);
	font-weight: var(--font-weight-bold);
	font-size: var(--text-sm);
}
.quick-order-card__summary .quantity {
	grid-column: 3;
	grid-row: 2;
	justify-self: start;
	flex-shrink: 0;
}

/* ---- Bundle section (Phase 14): whatever's already in the cart, shown as
   part of this same order. Read-only in v1 — no in-card quantity/remove
   controls, just a clear, collapsible summary of what's being combined. ---- */
.quick-order-card__bundle {
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	overflow: hidden;
}
/* The row is a mode selector (opens the "كيف تريد المتابعة؟" modal) plus a
   separate, secondary expand/collapse control for the bundle list — two
   distinct buttons, not one overloaded click target, so "change mode" and
   "show me the cart items" stay clearly separate actions regardless of
   which mode is currently active. */
.quick-order-card__bundle-row {
	display: flex;
	align-items: stretch;
	background: var(--color-surface);
}
.quick-order-card__bundle-toggle {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: var(--space-3);
	padding: var(--space-3) var(--space-4);
	background: transparent;
	border: none;
	cursor: pointer;
	text-align: start;
	font-family: inherit;
	color: inherit;
}
.quick-order-card__bundle-expand {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	border: none;
	border-inline-start: 1px solid var(--color-border);
	background: transparent;
	cursor: pointer;
	color: inherit;
}
.quick-order-card__bundle-expand[hidden] {
	display: none;
}
.quick-order-card__bundle-icon {
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	color: var(--color-accent-strong);
}
.quick-order-card__bundle-icon svg { width: 100%; height: 100%; }
.quick-order-card__bundle-text {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.quick-order-card__bundle-text strong { font-size: var(--text-sm); }
.quick-order-card__bundle-hint {
	font-size: var(--text-xs);
	color: var(--color-text-muted);
	line-height: var(--line-height-relaxed);
}
.quick-order-card__bundle-badge {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding-inline: 6px;
	border-radius: 999px;
	background: var(--color-accent);
	color: var(--color-text-on-accent);
	font-size: var(--text-xs);
	font-weight: var(--font-weight-bold);
}
.quick-order-card__bundle-badge[hidden] {
	display: none;
}
.quick-order-card__bundle-chevron {
	flex-shrink: 0;
	width: 10px;
	height: 10px;
	border-inline-end: 2px solid var(--color-text-muted);
	border-block-end: 2px solid var(--color-text-muted);
	transform: rotate(45deg);
	transition: transform var(--transition-fast);
}
.quick-order-card__bundle-expand[aria-expanded="true"] .quick-order-card__bundle-chevron {
	transform: rotate(-135deg);
}
/* Open/close animation: JS measures the content's real height
   (`scrollHeight`) and transitions `max-height` to that exact pixel value —
   chosen over the CSS-only grid-template-rows `0fr -> 1fr` trick after that
   approach was observed getting stuck mid-transition (settling at a wrong,
   too-small height instead of the content's real size) once the bundle rows
   got taller with the quantity stepper added; transitioning between two
   concrete pixel values has none of that ambiguity and is the long-standing,
   reliable version of this technique. This deliberately does NOT use the
   `hidden` attribute — `hidden` maps to `display:none` in the UA
   stylesheet, which cannot be transitioned, so relying on it here would
   make the "smooth" animation impossible. Instead `aria-hidden` (toggled in
   JS, no display/layout effect) keeps the collapsed content out of the
   accessibility tree, and max-height:0 + overflow:hidden already makes it
   unfocusable/unreachable by mouse regardless. Collapsed is the default (no
   class needed, max-height:0 in the base rule), matching the
   collapsed-by-default requirement without JS having to run first. */
.quick-order-card__bundle-list {
	max-height: 0;
	overflow: hidden;
	transition: max-height var(--transition-base);
}
.quick-order-card__bundle-list-inner {
	display: flex;
	flex-direction: column;
	padding: 0 var(--space-4);
	opacity: 0;
	transition: opacity var(--transition-base);
}
.quick-order-card__bundle-list.is-open .quick-order-card__bundle-list-inner {
	padding: var(--space-2) var(--space-4) var(--space-4);
	opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
	.quick-order-card__bundle-list,
	.quick-order-card__bundle-list-inner {
		transition-duration: 0.01ms;
	}
}
.quick-order-card__bundle-items {
	display: flex;
	flex-direction: column;
}
.quick-order-card__bundle-item {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	padding-block: var(--space-2);
	border-block-start: 1px solid var(--color-border);
	font-size: var(--text-sm);
}
.quick-order-card__bundle-item:first-child { border-block-start: none; }
/* Same product/variation as the Quick Order form's own anchor product —
   folded into the anchor's own line by quick-order.js's applyAnchorMerge()
   instead of being shown as a second, separate product. Compound selectors
   (not a bare class) so this always outranks .quick-order-card__bundle-item
   { display:flex } / .quick-order-card__summary-row { display:flex }
   regardless of which one appears later in this file — the same
   source-order-dependent specificity trap already hit three times elsewhere
   in this project. */
.quick-order-card__bundle-item.quick-order-card__bundle-item--merged,
.quick-order-card__summary-row.quick-order-card__summary-row--merged {
	display: none;
}
.quick-order-card__bundle-item img {
	width: 36px;
	height: 36px;
	object-fit: contain;
	background: var(--color-surface);
	border-radius: var(--radius-sm);
	flex-shrink: 0;
}
/* Name is the only flexible column — everything else (image, stepper, price,
   delete) keeps its natural size via flex-shrink:0, so a long name truncates
   with an ellipsis instead of growing the row or pushing the other controls
   out of alignment, on any viewport width. */
.quick-order-card__bundle-item-name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.quick-order-card__bundle-item-qty {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 2px;
	flex-shrink: 0;
	border: 1px solid var(--color-border-strong);
	border-radius: var(--radius-pill);
	overflow: hidden;
}
.quick-order-card__bundle-item-qty .qty-stepper__btn {
	width: 24px;
	height: 24px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: none;
	background: transparent;
	color: var(--color-primary);
	font-size: var(--text-sm);
	line-height: 1;
	cursor: pointer;
	flex-shrink: 0;
}
.quick-order-card__bundle-item-qty .qty-stepper__btn:hover:not(:disabled) { background: var(--color-surface); }
.quick-order-card__bundle-item-qty .qty-stepper__btn:disabled { opacity: 0.35; cursor: not-allowed; }
.quick-order-card__bundle-item-qty-value {
	min-width: 20px;
	text-align: center;
	font-weight: var(--font-weight-bold);
}
/* While a quantity update is in flight for this specific item: the digit
   is hidden (not removed — keeps the pill's width stable) and a spinner
   appears in its place, reusing the same rotating-ring look and
   @keyframes quick-order-spin already defined for the searchable-select
   spinner. The +/- buttons are disabled via the existing setBundleBusy()
   mechanism (unchanged) — this class only adds the visual spinner. */
.quick-order-card__bundle-item-qty--loading .quick-order-card__bundle-item-qty-value {
	visibility: hidden;
}
.quick-order-card__bundle-item-qty-spinner {
	display: none;
	position: absolute;
	top: 50%;
	left: 50%;
	width: 14px;
	height: 14px;
	margin: -7px 0 0 -7px;
	border: 2px solid var(--color-border-strong);
	border-inline-start-color: var(--color-accent);
	border-radius: 50%;
	pointer-events: none;
	animation: quick-order-spin 0.7s linear infinite;
}
.quick-order-card__bundle-item-qty--loading .quick-order-card__bundle-item-qty-spinner {
	display: block;
}
.quick-order-card__bundle-item-price {
	flex-shrink: 0;
	font-weight: var(--font-weight-bold);
	margin-inline-start: auto;
}
.quick-order-card__bundle-item-remove {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: none;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--color-text-muted);
	cursor: pointer;
	transition: background-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}
.quick-order-card__bundle-item-remove svg { width: 16px; height: 16px; }
.quick-order-card__bundle-item-remove:hover {
	background: var(--color-error-tint);
	color: var(--color-error);
}
.quick-order-card__bundle-item-remove:disabled {
	opacity: 0.4;
	cursor: wait;
}
.quick-order-card__bundle-cancel {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-1);
	width: 100%;
	margin-block-start: var(--space-2);
	padding: var(--space-2);
	border: none;
	background: transparent;
	color: var(--color-text-muted);
	font-size: var(--text-xs);
	font-family: inherit;
	cursor: pointer;
	transition: color var(--transition-fast);
}
.quick-order-card__bundle-cancel svg { width: 12px; height: 12px; }
.quick-order-card__bundle-cancel:hover:not(:disabled) { color: var(--color-error); }
.quick-order-card__bundle-cancel:disabled { opacity: 0.5; cursor: wait; }
/* Keeps the summary box's flex `gap` from reserving space for this wrapper
   when it renders empty (no bundle) — its children participate directly in
   the parent flex layout, and whitespace-only content is ignored by the
   flex algorithm the same way it already is between any two flex items. */
.quick-order-card__summary-bundle-rows {
	display: contents;
}
/* Same author-stylesheet-beats-UA-stylesheet issue already fixed for
   .quick-order-card__bundle-list and .ss-select__panel: `display: contents`
   above wins over the UA `[hidden]{display:none}` rule unless overridden
   explicitly here. */
.quick-order-card__summary-bundle-rows[hidden] {
	display: none;
}

/* ---- Mode-selection modal: "هذا المنتج فقط" vs "اختر الكل" ----
   Mirrors the site's existing .mobile-nav-backdrop overlay convention
   (same backdrop tint, shadow and transition tokens) so no new visual
   language is introduced for this one dialog. */
.quick-order-card__mode-modal {
	position: fixed;
	inset: 0;
	z-index: 300;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--space-4);
}
.quick-order-card__mode-modal[hidden] {
	display: none;
}
.quick-order-card__mode-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(22, 35, 63, 0.45);
	border: none;
	padding: 0;
	cursor: pointer;
}
.quick-order-card__mode-modal-dialog {
	position: relative;
	width: 100%;
	max-width: 440px;
	max-height: 90vh;
	overflow-y: auto;
	background: var(--color-card);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-md);
	padding: var(--space-5);
	text-align: center;
	animation: quick-order-mode-modal-in var(--transition-base);
}
@keyframes quick-order-mode-modal-in {
	from { opacity: 0; transform: translateY(8px) scale(0.98); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}
.quick-order-card__mode-modal-close {
	position: absolute;
	top: var(--space-3);
	inset-inline-end: var(--space-3);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: none;
	border-radius: var(--radius-pill);
	background: var(--color-surface);
	color: var(--color-text-muted);
	cursor: pointer;
	transition: background-color var(--transition-fast), color var(--transition-fast);
}
.quick-order-card__mode-modal-close svg {
	width: 16px;
	height: 16px;
}
.quick-order-card__mode-modal-close:hover {
	background: var(--color-error-tint);
	color: var(--color-error);
}
.quick-order-card__mode-modal-title {
	margin: 0 0 var(--space-1);
	font-size: var(--text-lg);
	font-weight: var(--font-weight-black);
	color: var(--color-text);
}
.quick-order-card__mode-modal-subtitle {
	margin: 0 0 var(--space-5);
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}
.quick-order-card__mode-options {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
}
.quick-order-card__mode-option {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	width: 100%;
	padding: var(--space-3);
	border: 2px solid var(--color-border);
	border-radius: var(--radius-md);
	background: var(--color-surface);
	font-family: inherit;
	text-align: start;
	cursor: pointer;
	transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}
.quick-order-card__mode-option:hover,
.quick-order-card__mode-option:focus-visible {
	border-color: var(--color-accent);
	background: var(--color-card);
}
.quick-order-card__mode-option:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px var(--color-accent-tint);
}
.quick-order-card__mode-option-thumb {
	position: relative;
	flex-shrink: 0;
	width: 56px;
	height: 56px;
	border-radius: var(--radius-md);
	overflow: hidden;
	background: var(--color-card);
	box-shadow: 0 0 0 1px var(--color-border);
}
.quick-order-card__mode-option-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.quick-order-card__mode-option-count {
	position: absolute;
	bottom: -6px;
	inset-inline-end: -6px;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	padding: 0 4px;
	border-radius: var(--radius-pill);
	background: var(--color-accent);
	color: var(--color-text-on-accent);
	font-size: 10px;
	font-weight: var(--font-weight-bold);
	box-shadow: var(--shadow-sm);
}
.quick-order-card__mode-option-body {
	display: flex;
	flex: 1;
	min-width: 0;
	flex-direction: column;
	gap: 2px;
}
.quick-order-card__mode-option-title {
	font-size: var(--text-md);
	font-weight: var(--font-weight-bold);
	color: var(--color-text);
}
.quick-order-card__mode-option-desc {
	font-size: var(--text-xs);
	line-height: 1.4;
	color: var(--color-text-muted);
}
.quick-order-card__mode-option-meta {
	margin-block-start: 2px;
	font-size: var(--text-sm);
	font-weight: var(--font-weight-medium);
	color: var(--color-accent-strong);
}
@media (max-width: 480px) {
	.quick-order-card__mode-modal-dialog {
		padding: var(--space-4);
	}
	.quick-order-card__mode-option-thumb {
		width: 48px;
		height: 48px;
	}
}

.quick-order-card__variation-hint {
	font-size: var(--text-xs);
	color: var(--color-warning);
	background: var(--color-warning-tint);
	padding: var(--space-2) var(--space-3);
	border-radius: var(--radius-sm);
	margin: 0;
}

/* ---- Notice ---- */
.quick-order-card__notice {
	font-size: var(--text-sm);
	padding: var(--space-3) var(--space-4);
	border-radius: var(--radius-md);
	background: var(--color-success-tint);
	color: var(--color-success);
}
.quick-order-card__notice--error {
	background: var(--color-error-tint);
	color: var(--color-error);
}

/* ---- Fields ----
   Same paired form-row-first/form-row-last flex pattern checkout.css
   establishes via its own field-wrapper — .quick-order-card__fields has no
   equivalent separate wrapper in the markup, so the heading and the
   delivery-methods block are pinned to a full-width "row" of their own via
   flex-basis: 100%, letting only the actual form-row pairs sit side by
   side. Fixes fields silently stacking full-width despite having room. */
.quick-order-card__fields {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-4);
}
.quick-order-card__fields h3 {
	flex-basis: 100%;
	font-size: var(--text-md);
	margin-block-end: calc(-1 * var(--space-2));
}
.quick-order-card__fields .form-row { margin-block-end: 0; }
.quick-order-card__delivery-methods { flex-basis: 100%; }
.quick-order-card__field-error {
	display: block;
	color: var(--color-error);
	font-size: var(--text-xs);
	margin-block-start: var(--space-1);
}

/* Searchable dropdown (.ss-select*) component now lives in
   assets/css/searchable-select.css — shared with the standard checkout,
   enqueued as a dependency of this stylesheet. @keyframes quick-order-spin
   (used below by .quick-order-card__bundle-item-qty-spinner too) is defined
   there. */

.quick-order-card__delivery-methods-label {
	display: block;
	font-size: var(--text-sm);
	font-weight: var(--font-weight-medium);
	margin-block-end: var(--space-2);
}
.quick-order-card__delivery-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	padding: var(--space-3) var(--space-4);
	border: 1px solid var(--color-border-strong);
	border-radius: var(--radius-md);
	margin-block-end: var(--space-2);
	cursor: pointer;
	font-size: var(--text-sm);
}
.quick-order-card__delivery-option:has(input:checked) {
	border-color: var(--color-accent);
	background: color-mix(in srgb, var(--color-accent) 6%, transparent);
}
.quick-order-card__delivery-option input { margin-inline-end: var(--space-2); }
.quick-order-card__delivery-option-price {
	margin-inline-start: auto;
	font-weight: var(--font-weight-bold);
	color: var(--color-text-muted);
}

/* ---- Order summary box ---- */
.quick-order-card__summary-box {
	background: var(--color-surface);
	border-radius: var(--radius-md);
	padding: var(--space-4);
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}
.quick-order-card__summary-box-title {
	font-size: var(--text-sm);
	font-weight: var(--font-weight-bold);
	margin-block-end: var(--space-1);
}
.quick-order-card__summary-row {
	display: flex;
	justify-content: space-between;
	gap: var(--space-3);
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}
.quick-order-card__summary-row > span:first-child {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.quick-order-card__summary-row > span:last-child { flex-shrink: 0; }
.quick-order-card__summary-row--total {
	font-size: var(--text-md);
	font-weight: var(--font-weight-bold);
	color: var(--color-text);
	padding-block-start: var(--space-2);
	border-block-start: 1px solid var(--color-border);
}

/* ---- Actions ----
   Reference gives the primary "confirm" action more visual weight than the
   secondary "add to cart" — replicated as an uneven flex split rather than
   the even 50/50 the card used before. */
.quick-order-card__actions {
	display: flex;
	gap: var(--space-3);
}
.quick-order-card__actions .button {
	padding: var(--space-4) var(--space-5);
	border-radius: var(--radius-md);
	font-weight: var(--font-weight-bold);
	font-size: var(--text-sm);
	border: none;
	cursor: pointer;
	transition: background-color var(--transition-fast), opacity var(--transition-fast);
}
.quick-order-card__add-to-cart {
	order: 2;
	flex: 0 1 38%;
	background: var(--color-surface);
	color: var(--color-text);
	border: 1px solid var(--color-border-strong) !important;
}
.quick-order-card__add-to-cart:hover { border-color: var(--color-accent) !important; color: var(--color-accent-strong); }
.quick-order-card__confirm {
	order: 1;
	flex: 1 1 62%;
	background: var(--color-accent);
	color: var(--color-text-on-accent);
}
.quick-order-card__confirm:hover { background: var(--color-accent-strong); }
.quick-order-card__confirm:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

@media (max-width: 576px) {
	.quick-order-card { padding: var(--space-4); }
	/* Keep the delivery fields (name/phone, wilaya/commune) 2-per-row down
	   to ~375px instead of the shared .form-row-first/.form-row-last mobile
	   rule (components.css) collapsing them to one field per row — scoped
	   to just the Quick Order card so checkout/my-account keep their
	   existing single-column mobile behavior unchanged. The custom
	   searchable-select trigger (.ss-select) already fills its parent
	   <p class="form-row-first/last">'s width at 100%, so it automatically
	   follows this without any dropdown-specific CSS. */
	.quick-order-card__fields .form-row-first,
	.quick-order-card__fields .form-row-last {
		flex: 1 1 calc(50% - var(--space-4) / 2);
	}
	.quick-order-card__actions { flex-direction: column; }
	.quick-order-card__bundle-toggle { flex-wrap: wrap; }
	.quick-order-card__bundle-hint { display: none; }
	/* Bundle-item rows deliberately stay single-line here (no flex-wrap) —
	   the name column is the only flexible one and truncates via ellipsis
	   instead, so image/stepper/price/delete stay aligned in a fixed row
	   regardless of name length. Tighten gaps/price size to fit the denser
	   stepper control in the available width. */
	.quick-order-card__bundle-item { gap: var(--space-2); }
	.quick-order-card__bundle-item-price { font-size: var(--text-xs); }
}
