/**
 * Modern COD Form — front-end styles.
 * Colours and radii come from CSS custom properties set inline by PHP.
 */

.modern-cod-container {
	--mcf-primary: #2ecc71;
	--mcf-button: var(--mcf-primary);
	--mcf-button-text: #fff;
	--mcf-title: #333;
	--mcf-radius: 8px;
	--mcf-input-radius: 4px;
	--mcf-font-size: 14px;
	--mcf-bg: #fff;
	--mcf-addon: #f1f3f5;
	--mcf-border: #d8dee4;
	--mcf-text: #333;
	--mcf-muted: #6b7280;
	--mcf-error: #e74c3c;

	background: var(--mcf-bg);
	border-radius: var(--mcf-radius);
	padding: 20px 22px;
	margin: 28px 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: var(--mcf-font-size);
	color: var(--mcf-text);
	direction: ltr;
	text-align: left;
	box-sizing: border-box;
}

.modern-cod-container *,
.modern-cod-container *::before,
.modern-cod-container *::after {
	box-sizing: inherit;
}

.mcf-style-boxed { border: 2px solid var(--mcf-primary); }
.mcf-style-shadow { border: 1px solid #eceff3; box-shadow: 0 10px 30px rgba(15, 23, 42, .08); }
.mcf-style-flat { border: 0; padding: 0; box-shadow: none; }

/* RTL ------------------------------------------------------------------ */
.modern-cod-container.mcf-rtl {
	direction: rtl;
	text-align: right;
	font-family: "Cairo", "Tajawal", Tahoma, Arial, sans-serif;
}

/* Title ---------------------------------------------------------------- */
.modern-cod-container .mcf-title {
	text-align: center;
	color: var(--mcf-title);
	margin: 0 0 16px;
	font-size: 1.25em;
	font-weight: 700;
	line-height: 1.3;
}

/* Product recap -------------------------------------------------------- */
.mcf-product-summary {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px;
	margin-bottom: 14px;
	background: #fafbfc;
	border: 1px solid #eef1f4;
	border-radius: var(--mcf-input-radius);
}

.mcf-product-summary img {
	width: 52px;
	height: 52px;
	object-fit: cover;
	border-radius: var(--mcf-input-radius);
	margin: 0;
	flex-shrink: 0;
}

.mcf-product-meta {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.mcf-product-name {
	font-weight: 600;
	line-height: 1.3;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.mcf-product-price {
	color: var(--mcf-primary);
	font-weight: 700;
}

/* Fields --------------------------------------------------------------- */
.mcf-form-group { margin-bottom: 12px; }

.mcf-input-wrapper {
	display: flex;
	align-items: stretch;
	width: 100%;
	border: 1px solid var(--mcf-border);
	border-radius: var(--mcf-input-radius);
	overflow: hidden;
	background: var(--mcf-bg);
	transition: border-color .2s ease, box-shadow .2s ease;
}

.mcf-input-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--mcf-addon);
	width: 46px;
	flex-shrink: 0;
	color: #444;
	border-right: 1px solid var(--mcf-border);
	transition: color .2s ease;
}

.mcf-rtl .mcf-input-icon {
	border-right: 0;
	border-left: 1px solid var(--mcf-border);
}

.mcf-input-icon svg { width: 18px; height: 18px; }

.mcf-input-wrapper input[type="text"],
.mcf-input-wrapper input[type="tel"],
.mcf-input-wrapper input[type="email"],
.mcf-input-wrapper select,
.mcf-input-wrapper textarea {
	flex: 1;
	min-width: 0;
	width: 100%;
	border: 0 !important;
	padding: 12px 14px;
	font-size: 1em;
	font-family: inherit;
	color: var(--mcf-text);
	background: transparent;
	outline: none;
	box-shadow: none !important;
	margin: 0;
	border-radius: 0;
	line-height: 1.4;
}

.mcf-input-wrapper textarea { resize: vertical; min-height: 62px; }

.mcf-input-wrapper select {
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	background-size: 20px;
	padding-right: 34px;
}

.mcf-rtl .mcf-input-wrapper select {
	background-position: left 10px center;
	padding-right: 14px;
	padding-left: 34px;
}

.mcf-input-wrapper input::placeholder,
.mcf-input-wrapper textarea::placeholder { color: #9aa3ad; }

.mcf-input-wrapper:focus-within {
	border-color: var(--mcf-primary);
	box-shadow: 0 0 0 3px rgba(46, 204, 113, .2); /* fallback */
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--mcf-primary) 22%, transparent);
}

.mcf-input-wrapper:focus-within .mcf-input-icon { color: var(--mcf-primary); }

/* Errors --------------------------------------------------------------- */
.mcf-form-group.error .mcf-input-wrapper {
	border-color: var(--mcf-error);
	box-shadow: 0 0 0 3px rgba(231, 76, 60, .18);
}

.mcf-form-group.error .mcf-input-icon { color: var(--mcf-error); }

.mcf-field-error {
	display: block;
	color: var(--mcf-error);
	font-size: .85em;
	padding: 5px 4px 0;
}

/* Honeypot ------------------------------------------------------------- */
.mcf-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* Quantity ------------------------------------------------------------- */
.mcf-qty-wrapper {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-right: 8px;
}

.mcf-rtl .mcf-qty-wrapper { padding-right: 0; padding-left: 8px; }

.mcf-qty-label {
	flex: 1;
	min-width: 0;
	padding: 10px 14px;
	color: var(--mcf-muted);
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
}

.mcf-badge {
	background: var(--mcf-error);
	color: #fff;
	padding: 3px 7px;
	border-radius: 3px;
	font-weight: 700;
	font-size: .78em;
	line-height: 1.2;
	white-space: nowrap;
}

.mcf-badge[hidden] { display: none; }

.mcf-qty-controls {
	display: flex;
	align-items: center;
	gap: 4px;
	flex-shrink: 0;
}

.mcf-qty-btn {
	background: #f1f1f1;
	border: 1px solid var(--mcf-border);
	border-radius: 4px;
	width: 30px;
	height: 30px;
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--mcf-text);
	transition: background .15s;
	padding: 0;
}

.mcf-qty-btn:hover { background: #e4e6e8; }

.mcf-qty-controls input[type="number"] {
	width: 40px !important;
	text-align: center;
	border: 0 !important;
	background: transparent !important;
	font-weight: 700;
	font-size: 1.05em;
	padding: 0 !important;
	box-shadow: none !important;
	-moz-appearance: textfield;
	appearance: textfield;
	color: var(--mcf-text);
}

.mcf-qty-controls input[type="number"]::-webkit-outer-spin-button,
.mcf-qty-controls input[type="number"]::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* Summary -------------------------------------------------------------- */
.order-summary-box {
	background: #f8fafc;
	border: 1px dashed var(--mcf-border);
	padding: 12px 15px;
	border-radius: 6px;
	margin: 15px 0;
	display: flex;
	flex-direction: column;
	gap: 7px;
}

.summary-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	color: #555;
}

.summary-total {
	border-top: 1px solid #e6eaef;
	padding-top: 8px;
	margin-top: 1px;
}

.summary-total strong {
	color: var(--mcf-primary);
	font-size: 1.25em;
	font-weight: 800;
}

/* Submit --------------------------------------------------------------- */
.modern-submit-btn {
	width: 100%;
	background: var(--mcf-button);
	color: var(--mcf-button-text);
	border: 0;
	padding: 14px;
	font-size: 1.08em;
	font-family: inherit;
	font-weight: 700;
	border-radius: var(--mcf-input-radius);
	cursor: pointer;
	transition: filter .2s ease, transform .08s ease;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 10px;
	text-transform: uppercase;
	letter-spacing: .4px;
	line-height: 1.3;
}

.modern-submit-btn:hover { filter: brightness(1.06); }
.modern-submit-btn:active { transform: scale(.99); }
.modern-submit-btn:disabled { opacity: .7; cursor: not-allowed; }

.mcf-spinner {
	width: 17px;
	height: 17px;
	border: 2px solid rgba(255, 255, 255, .4);
	border-top-color: currentColor;
	border-radius: 50%;
	animation: mcf-spin .7s linear infinite;
}

.mcf-spinner[hidden] { display: none; }

@keyframes mcf-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
	.mcf-spinner { animation-duration: 2s; }
	.modern-submit-btn { transition: none; }
}

/* WhatsApp ------------------------------------------------------------- */
.mcf-whatsapp-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	margin-top: 10px;
	padding: 12px;
	background: #25d366;
	color: #fff !important;
	border-radius: var(--mcf-input-radius);
	font-weight: 700;
	text-decoration: none !important;
	transition: filter .2s ease;
}

.mcf-whatsapp-btn:hover { filter: brightness(1.06); }
.mcf-whatsapp-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* Messages ------------------------------------------------------------- */
.mcf-form-msg {
	margin-top: 14px;
	padding: 11px 14px;
	border-radius: var(--mcf-input-radius);
	font-weight: 600;
	text-align: center;
	line-height: 1.4;
}

.mcf-form-msg[hidden] { display: none; }
.mcf-msg-success { background: #e8f8ef; color: #17794a; border: 1px solid #b7e6cc; }
.mcf-msg-error { background: #fdecea; color: #a32319; border: 1px solid #f5c2bd; }

/* Sticky bar ----------------------------------------------------------- */
.mcf-sticky-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 9998;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 14px;
	background: #fff;
	border-top: 1px solid #e5e7eb;
	box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
}

.mcf-sticky-bar[hidden] { display: none; }

.mcf-sticky-price {
	font-weight: 800;
	font-size: 17px;
	color: #111;
}

.mcf-sticky-btn {
	flex: 1;
	max-width: 62%;
	background: var(--mcf-button, #2ecc71);
	color: #fff;
	border: 0;
	border-radius: 6px;
	padding: 12px;
	font-weight: 700;
	font-size: 15px;
	cursor: pointer;
	text-transform: uppercase;
}

@media (min-width: 782px) {
	.mcf-sticky-bar { display: none !important; }
}

@media (max-width: 480px) {
	.modern-cod-container { padding: 16px 14px; }
	.mcf-qty-label { padding: 8px 10px; }
	.mcf-input-icon { width: 42px; }
}
