/**
 * Woo Direct COD Checkout — styles.
 * High-converting COD form. Brand accent #e85c00.
 * Bilingual FR/AR, RTL-aware, mobile-first.
 *
 * @package WooDirectCOD
 */

.dcod-wrapper {
	/* Brand accent (#e85c00) drives buttons, active shipping option, focus. */
	--dcod-green:        #e85c00;
	--dcod-green-dark:   #cf5200;
	--dcod-green-soft:   #ffe9d6;
	--dcod-orange:        #e85c00;
	--dcod-orange-dark:   #cf5200;
	--dcod-orange-darker: #b34700;
	--dcod-orange-soft:   #ffe9d6;
	--dcod-ink:          #1f2937;
	--dcod-muted:        #6b7280;
	--dcod-line:         #e5e7eb;
	--dcod-bg:           #ffffff;
	--dcod-field-bg:     #f9fafb;
	--dcod-error:        #dc2626;
	--dcod-error-soft:   #fef2f2;
	--dcod-radius:       12px;

	max-width: 560px;
	/* Left-aligned within its section on desktop (was centered via auto/auto). */
	margin: 24px auto 24px 0;
	color: var(--dcod-ink);
	font-family: inherit;
	/* No shadow on the outer container. */
	box-shadow: none !important;
}

.dcod-form {
	background: var(--dcod-bg);
	border: 1px solid var(--dcod-line);
	border-radius: var(--dcod-radius);
	padding: 22px 20px 24px;
	position: relative;
	/* No shadow on the form itself. */
	box-shadow: none !important;
}

/* ---- Title ---- */
.dcod-title {
	margin: 0 0 18px;
	text-align: center;
	font-size: 1.4rem;
	font-weight: 800;
	line-height: 1.25;
	color: var(--dcod-green-dark);
}
.dcod-title .dcod-title-ar {
	display: block;
	font-size: 1.05rem;
	color: var(--dcod-orange-dark);
	font-weight: 700;
	margin-top: 2px;
}

/* ---- Generic fields ---- */
.dcod-field { margin-bottom: 14px; }

.dcod-field > label,
.dcod-group-label {
	display: block;
	font-size: .9rem;
	font-weight: 700;
	margin-bottom: 6px;
	color: var(--dcod-ink);
}
.dcod-ar {
	color: var(--dcod-muted);
	font-weight: 600;
	font-size: .82em;
	direction: rtl;
	unicode-bidi: isolate;
}
.dcod-req { color: var(--dcod-error); font-weight: 700; }

.dcod-form input[type="text"],
.dcod-form input[type="tel"],
.dcod-form input[type="number"],
.dcod-form select {
	width: 100%;
	box-sizing: border-box;
	/* Original compact sizing (restored). */
	padding: 12px 14px;
	font-size: 1rem;
	line-height: 1.4;
	color: var(--dcod-ink);
	background: var(--dcod-field-bg);
	border: 1.5px solid var(--dcod-line);
	border-radius: 10px;
	transition: border-color .15s, box-shadow .15s, background .15s;
	-webkit-appearance: none;
	appearance: none;
}
.dcod-form select {
	/* A <select> needs an explicit height, otherwise some themes collapse the
	   box and the selected value (Wilaya / Commune text) disappears. Zero
	   vertical padding + this height lets the browser vertically centre the
	   value with no top-edge clipping, while staying compact. */
	height: 46px;
	line-height: normal;
	padding: 0 38px 0 14px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
}

.dcod-form input:focus,
.dcod-form select:focus {
	outline: none;
	border-color: var(--dcod-green);
	background: #fff;
	box-shadow: 0 0 0 3px var(--dcod-green-soft);
}
.dcod-form select:disabled {
	opacity: .6;
	cursor: not-allowed;
}

/* Two-column row (wilaya / commune) */
.dcod-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

/* ---- Error state ---- */
.dcod-field.dcod-has-error input,
.dcod-field.dcod-has-error select,
.dcod-form .dcod-error {
	border-color: var(--dcod-error) !important;
	background: var(--dcod-error-soft);
	box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}
.dcod-error-msg {
	display: block;
	color: var(--dcod-error);
	font-size: .78rem;
	font-weight: 600;
	margin-top: 4px;
	min-height: 0;
}
.dcod-field.dcod-has-error .dcod-error-msg { min-height: 1em; }

/* ---- Delivery radios ---- */
.dcod-delivery-options {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}
.dcod-radio {
	display: block;
	cursor: pointer;
	margin: 0;
	position: relative;
}
.dcod-radio input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}
.dcod-radio-box {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 12px 14px;
	border: 1.5px solid var(--dcod-line);
	border-radius: 10px;
	background: var(--dcod-field-bg);
	transition: all .15s;
	height: 100%;
	box-sizing: border-box;
}
.dcod-radio-title { font-weight: 700; font-size: .92rem; }
.dcod-radio-price { font-weight: 800; color: var(--dcod-green-dark); font-size: .95rem; }

.dcod-radio input:checked + .dcod-radio-box {
	border-color: var(--dcod-green);
	background: var(--dcod-green-soft);
	box-shadow: 0 0 0 3px rgba(232, 92, 0, .15);
}
.dcod-radio.dcod-radio-disabled { cursor: not-allowed; }
.dcod-radio.dcod-radio-disabled .dcod-radio-box {
	opacity: .5;
	background: #f3f4f6;
}
.dcod-radio.dcod-radio-disabled .dcod-radio-price { color: var(--dcod-muted); }

/* ---- Quantity stepper ---- */
.dcod-qty-control {
	display: inline-flex;
	align-items: stretch;          /* buttons stretch to the input's height */
	border: 1.5px solid var(--dcod-line);
	border-radius: 10px;
	overflow: hidden;              /* clips the button corners to the radius */
	background: #fff;
	transition: border-color .15s, box-shadow .15s;
}
/* Highlight the whole control while the number field is focused. */
.dcod-qty-control:focus-within {
	border-color: var(--dcod-orange);
	box-shadow: 0 0 0 3px var(--dcod-orange-soft);
}

.dcod-qty-control input[type="number"] {
	width: 70px;
	text-align: center;
	font-weight: 700;
	border: none;
	border-radius: 0;
	background: transparent;
	-moz-appearance: textfield;
	box-shadow: none !important;   /* the container carries the focus ring */
}
.dcod-qty-control input[type="number"]:focus {
	background: transparent;
	box-shadow: none !important;
}
.dcod-qty-control input[type="number"]::-webkit-outer-spin-button,
.dcod-qty-control input[type="number"]::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* +/- buttons.
   !important keeps theme <button> styles from overriding these states. */
.dcod-form .dcod-qty-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	padding: 0;
	border: none;
	border-radius: 0;
	font-size: 1.35rem;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	user-select: none;
	background: #fff !important;
	color: var(--dcod-orange-dark) !important;
	transition: background .15s, color .15s;
}
/* Thin separators so each button reads as its own tap zone. */
.dcod-qty-control .dcod-qty-btn:first-of-type { border-right: 1.5px solid var(--dcod-line); }
.dcod-qty-control .dcod-qty-btn:last-of-type  { border-left:  1.5px solid var(--dcod-line); }

/* Hover / keyboard focus → light orange fill, darker orange glyph. */
.dcod-form .dcod-qty-btn:hover,
.dcod-form .dcod-qty-btn:focus-visible {
	background: var(--dcod-orange-soft) !important;   /* #ffe9d6 */
	color: var(--dcod-orange-darker) !important;      /* #b34700 */
}
/* Pressed → solid brand orange with a white glyph. */
.dcod-form .dcod-qty-btn:active {
	background: var(--dcod-orange) !important;
	color: #fff !important;
}

/* ---- Coupon ---- */
.dcod-coupon-control {
	display: flex;
	gap: 8px;
}
.dcod-coupon-control input { flex: 1; }
.dcod-btn-coupon {
	flex: 0 0 auto;
	padding: 0 18px;
	border: none;
	border-radius: 10px;
	background: var(--dcod-ink);
	color: #fff;
	font-weight: 700;
	font-size: .9rem;
	cursor: pointer;
	transition: opacity .15s, transform .05s;
}
.dcod-btn-coupon:hover { opacity: .9; }
.dcod-btn-coupon:active { transform: scale(.98); }
.dcod-btn-coupon.is-loading { opacity: .6; cursor: wait; }
.dcod-coupon-msg {
	display: block;
	font-size: .8rem;
	font-weight: 600;
	margin-top: 6px;
}
.dcod-coupon-msg.is-valid { color: var(--dcod-green-dark); }
.dcod-coupon-msg.is-error { color: var(--dcod-error); }

/* ---- Summary box ---- */
.dcod-summary {
	margin: 18px 0;
	padding: 16px 18px;
	border: 1.5px dashed var(--dcod-green);
	border-radius: var(--dcod-radius);
	background: linear-gradient(180deg, #fff6f0 0%, #ffffff 100%);
}
.dcod-summary-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: .95rem;
	padding: 5px 0;
	color: var(--dcod-ink);
}
.dcod-summary-row.dcod-discount-row { color: var(--dcod-orange-dark); font-weight: 600; }
.dcod-summary-total {
	margin-top: 6px;
	padding-top: 12px;
	border-top: 1.5px solid var(--dcod-line);
	font-size: 1.2rem;
	font-weight: 800;
}
.dcod-summary-total .dcod-total { color: var(--dcod-green-dark); }

/* ---- Action buttons ---- */
.dcod-actions {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin-top: 6px;
}
.dcod-btn {
	position: relative;
	/* Perfectly centre the label both axes (spinner is absolutely positioned,
	   so it stays out of the flex flow and does not offset the text). */
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	width: 100%;
	/* Grow taller instead of clipping when the label wraps onto 2+ lines
	   (narrow screens). height:auto overrides theme-imposed fixed heights. */
	height: auto !important;
	min-height: 56px;
	padding: 16px 40px;   /* horizontal room so the label never sits under the spinner */
	border: none;
	border-radius: 12px;
	font-size: 1.05rem;
	font-weight: 800;
	line-height: 1.3;
	letter-spacing: .3px;
	cursor: pointer;
	transition: transform .06s, box-shadow .15s, opacity .15s;
	text-align: center;
	/* Render the labels exactly as written — many themes force uppercase. */
	text-transform: none !important;
	white-space: normal !important;
	overflow-wrap: break-word;
}
.dcod-btn .dcod-btn-label {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 4px 8px;
}
.dcod-btn .dcod-ar { color: inherit; opacity: .9; }
.dcod-btn:active { transform: translateY(1px); }

/* Secondary line inside a button ("Paiement à la livraison").
   flex-basis:100% forces it onto its own centred row. */
.dcod-btn .dcod-btn-sub {
	flex-basis: 100%;
	width: 100%;
	margin-top: 3px;
	font-size: .8rem;
	font-weight: 600;
	letter-spacing: .2px;
	opacity: .95;
}

/* PRIMARY CTA — "CONFIRMER MA COMMANDE": solid brand orange, white text.
   Stays filled in every state so the white spinner is always visible. */
.dcod-btn-confirm {
	color: #fff !important;
	background: linear-gradient(135deg, var(--dcod-orange) 0%, var(--dcod-orange-dark) 100%) !important;
	border: 2px solid transparent !important;
	box-shadow: 0 6px 16px rgba(232, 92, 0, .35) !important;
}
.dcod-btn-confirm:hover,
.dcod-btn-confirm:focus {
	color: #fff !important;
	background: linear-gradient(135deg, var(--dcod-orange-dark) 0%, var(--dcod-orange-darker) 100%) !important;
	box-shadow: 0 8px 22px rgba(232, 92, 0, .45) !important;
}
.dcod-btn-confirm:active {
	color: #fff !important;
	background: var(--dcod-orange-darker) !important;
}

/* FLIP buttons — outline by default, filled on hover/active/loading.
   One shared design method: "AJOUTER AU PANIER" in orange, "Paiement en
   ligne" in navy. !important guards against theme button styles. */
.dcod-btn-cart {
	color: var(--dcod-orange-dark) !important;
	background: #fff !important;
	border: 2px solid var(--dcod-orange) !important;
	box-shadow: none !important;
}
.dcod-btn-cart:hover,
.dcod-btn-cart:focus,
.dcod-btn-cart:active,
.dcod-btn-cart.is-loading {
	color: #fff !important;
	background: var(--dcod-orange) !important;
	border-color: var(--dcod-orange) !important;
}

.dcod-btn-online {
	color: var(--dcod-ink) !important;
	background: #fff !important;
	border: 2px solid var(--dcod-ink) !important;
	box-shadow: none !important;
}
.dcod-btn-online:hover,
.dcod-btn-online:focus,
.dcod-btn-online:active,
.dcod-btn-online.is-loading {   /* filled while loading → white spinner shows */
	color: #fff !important;
	background: var(--dcod-ink) !important;
	border-color: var(--dcod-ink) !important;
}

.dcod-btn.is-loading { opacity: .75; cursor: wait; pointer-events: none; }

/* Spinner inside confirm button */
.dcod-spinner {
	display: none;
	width: 18px;
	height: 18px;
	border: 2.5px solid rgba(255, 255, 255, .4);
	border-top-color: #fff;
	border-radius: 50%;
	position: absolute;
	top: 50%;
	right: 18px;
	margin-top: -9px;
	animation: dcod-spin .6s linear infinite;
}
.dcod-btn.is-loading .dcod-spinner { display: inline-block; }
@keyframes dcod-spin { to { transform: rotate(360deg); } }

/* ---- Form-level message ---- */
.dcod-form-message {
	margin-top: 14px;
	font-size: .9rem;
	font-weight: 700;
	text-align: center;
	min-height: 0;
}
.dcod-form-message.is-error   { color: var(--dcod-error); }
.dcod-form-message.is-success { color: var(--dcod-green-dark); }

/* ---- Variable product attribute table ---- */
.dcod-variations { margin-bottom: 16px; }
.dcod-variations table.variations {
	width: 100%;
	border-collapse: collapse;
	margin: 0;
}
.dcod-variations table.variations th.label {
	text-align: left;
	padding: 6px 10px 6px 0;
	font-weight: 700;
	font-size: .88rem;
	white-space: nowrap;
	vertical-align: middle;
}
.dcod-variations table.variations td.value {
	padding: 6px 0;
	width: 100%;
}
.dcod-variations.dcod-has-error {
	border: 1.5px solid var(--dcod-error);
	background: var(--dcod-error-soft);
	border-radius: 10px;
	padding: 10px;
}
.dcod-variations .single_variation {
	font-size: .9rem;
	font-weight: 600;
	margin-top: 4px;
}
.dcod-variations .single_variation .price {
	color: var(--dcod-green-dark);
	font-weight: 700;
}
/* Only turn the message red when the block is flagged invalid. */
.dcod-variations.dcod-has-error .single_variation {
	color: var(--dcod-error);
}
.dcod-reset {
	display: inline-block;
	font-size: .8rem;
	margin-top: 4px;
	color: var(--dcod-muted);
}

/* ---- Cart popup (checkout the whole cart) ---- */
.dcod-modal[hidden] { display: none; }
.dcod-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 24px 16px;
	overflow: hidden;
}
.dcod-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(17, 24, 39, .6);
	backdrop-filter: blur(2px);
	animation: dcod-fade .18s ease-out;
}
.dcod-modal__dialog {
	position: relative;
	width: 100%;
	max-width: 560px;
	max-height: calc(100vh - 48px);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 18px 50px rgba(0, 0, 0, .3);
	animation: dcod-pop .2s ease-out;
}
@keyframes dcod-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dcod-pop {
	from { opacity: 0; transform: translateY(14px); }
	to   { opacity: 1; transform: translateY(0); }
}
.dcod-modal__close {
	position: absolute;
	top: 10px;
	right: 12px;
	z-index: 2;
	width: 34px;
	height: 34px;
	padding: 0;
	line-height: 1;
	font-size: 26px;
	font-weight: 400;
	color: var(--dcod-muted, #6b7280);
	background: transparent;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	transition: background .15s, color .15s;
}
.dcod-modal__close:hover { background: #f3f4f6; color: #111827; }

/* The form inside the popup carries no extra frame/margins. */
.dcod-wrapper--modal { margin: 0 !important; max-width: none; }
.dcod-wrapper--modal .dcod-form { border: none; border-radius: 14px; }

/* Prevent the page behind the popup from scrolling. */
body.dcod-modal-open { overflow: hidden; }

/* ---- Cart line items inside the popup ---- */
.dcod-cart-items {
	margin: 0 0 16px;
	border: 1px solid var(--dcod-line);
	border-radius: 10px;
	overflow: hidden;
}
.dcod-cart-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-bottom: 1px solid var(--dcod-line);
	font-size: .88rem;
}
.dcod-cart-item:last-child { border-bottom: none; }
.dcod-cart-item__img {
	width: 42px;
	height: 42px;
	object-fit: cover;
	border-radius: 6px;
	flex: 0 0 auto;
}
.dcod-cart-item__info {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.dcod-cart-item__name {
	font-weight: 700;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.dcod-cart-item__qty { color: var(--dcod-muted); font-size: .8rem; }
.dcod-cart-item__total { font-weight: 800; color: var(--dcod-orange-dark); white-space: nowrap; }
.dcod-cart-loading,
.dcod-cart-empty {
	padding: 14px 12px;
	text-align: center;
	color: var(--dcod-muted);
	font-size: .88rem;
	font-weight: 600;
}

@media (max-width: 480px) {
	.dcod-modal { padding: 12px 8px; }
	.dcod-modal__dialog { max-height: calc(100vh - 24px); }
}

/* ---- Notices ---- */
.dcod-notice {
	padding: 14px 16px;
	border-radius: 10px;
	background: #fff7ed;
	border: 1px solid #fed7aa;
	color: #9a3412;
	font-weight: 600;
}

/* ---- RTL support (site set to RTL / Arabic) ---- */
.rtl .dcod-title,
[dir="rtl"] .dcod-title { direction: rtl; }
.rtl .dcod-variations table.variations th.label,
[dir="rtl"] .dcod-variations table.variations th.label {
	text-align: right;
	padding: 6px 0 6px 10px;
}
.rtl .dcod-form select,
[dir="rtl"] .dcod-form select {
	background-position: left 14px center;
	padding-right: 14px;
	padding-left: 38px;
}
.rtl .dcod-spinner,
[dir="rtl"] .dcod-spinner { right: auto; left: 18px; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
	.dcod-wrapper { margin: 16px 0; }
	.dcod-form { padding: 18px 14px 20px; border-radius: 10px; }
	.dcod-row { grid-template-columns: 1fr; }
	.dcod-delivery-options { grid-template-columns: 1fr; }
	.dcod-title { font-size: 1.2rem; }
	/* Narrower side padding on small screens so labels fit on one line for
	   longer; the button still grows in height if they do wrap. */
	.dcod-btn { padding: 14px 34px; font-size: 1rem; }
	.dcod-spinner { right: 12px; }
}
