/**
 * SmartUtil — Alege-ți cadoul
 * Stiluri frontend: bloc de progres, buton de deschidere, modal, grilă de carduri,
 * marcaje în coș / mini-coș / checkout.
 *
 * Fără dependențe externe. Fontul este moștenit din temă (Woodmart).
 *
 * Contract de markup (identic în PHP și JS):
 *   div.sc-progress.sc-progress--CONTEXT[data-context]
 *     div.sc-progress__msg > span.sc-progress__line(.sc-progress__line--next|--unlocked)
 *     div.sc-bar > span.sc-bar__fill
 *     div.sc-progress__actions
 *       button.sc-btn.sc-open-gifts
 *       a.sc-remove-gift[data-sc-remove-gift]
 *   div#sc-cadou-modal.sc-modal(.is-open)
 *     div.sc-modal__box > div.sc-modal__head > .sc-modal__title + button.sc-modal__close
 *     div.sc-grid > div.sc-card[data-product-id][data-variation-id]
 *       span.sc-card__badge, div.sc-card__img > img, div.sc-card__name,
 *       div.sc-card__price, button.sc-card__choose
 *   span.sc-badge — badge INLINE în coș / mini-coș (niciodată poziționat absolut)
 */

/* ==========================================================================
   1. Variabile de brand
   ========================================================================== */
:root {
	--sc-green: #83b735;
	--sc-green-dark: #5f8f22;
	--sc-green-mid: #7ba52f;
	--sc-bg-soft: #f6faf0;
	--sc-border: #e4eed4;
	--sc-text: #2f3a1f;
	--sc-muted: #6b7761;
	--sc-danger: #b03535;
	--sc-radius: 12px;
}

.sc-progress *,
.sc-progress *::before,
.sc-progress *::after,
.sc-modal *,
.sc-modal *::before,
.sc-modal *::after {
	box-sizing: border-box;
}

/* ==========================================================================
   2. Blocul de progres
   ========================================================================== */
.sc-progress {
	box-sizing: border-box;
	display: block;
	width: 100%;
	margin: 0 0 18px;
	padding: 14px 16px;
	background: var(--sc-bg-soft, #f6faf0);
	border: 1px solid var(--sc-border, #e4eed4);
	border-radius: var(--sc-radius, 12px);
	color: var(--sc-text, #2f3a1f);
	font-size: 14px;
	line-height: 1.45;
	text-align: left;
}

/* Container gol (fragment WooCommerce fără conținut) — nu lăsa o cutie goală. */
.sc-progress:empty {
	display: none;
	margin: 0;
	padding: 0;
	border: 0;
}

.sc-progress__msg {
	display: block;
	margin: 0 0 10px;
	font-size: 14px;
	font-weight: 600;
	color: var(--sc-text, #2f3a1f);
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.sc-progress__msg:last-child {
	margin-bottom: 0;
}

.sc-progress__msg strong,
.sc-progress__msg b {
	color: var(--sc-green-dark, #5f8f22);
	font-weight: 700;
}

.sc-progress__msg small {
	display: block;
	margin-top: 4px;
	font-size: 12px;
	font-weight: 400;
	color: var(--sc-muted, #6b7761);
}

/* Linii de mesaj: fiecare mesaj pe rândul lui, chiar dacă PHP emite <span>. */
.sc-progress__line {
	display: block;
	margin: 0 0 4px;
}

.sc-progress__line:last-child {
	margin-bottom: 0;
}

.sc-progress__line--unlocked {
	color: var(--sc-green-dark, #5f8f22);
	font-weight: 700;
}

.sc-progress__line--next {
	color: var(--sc-muted, #6b7761);
	font-weight: 400;
}

/* Bara de progres */
.sc-bar {
	position: relative;
	display: block;
	width: 100%;
	height: 10px;
	margin: 0 0 12px;
	overflow: hidden;
	background: #e6e9e1;
	border-radius: 999px;
}

.sc-bar:last-child {
	margin-bottom: 0;
}

.sc-bar__fill {
	display: block;
	width: 0;
	height: 100%;
	min-width: 0;
	max-width: 100%;
	background: var(--sc-green-mid, #7ba52f);
	background: linear-gradient(90deg, #7ba52f 0%, #5f8f22 100%);
	border-radius: 999px;
	transition: width .45s cubic-bezier(.22, .61, .36, 1);
}

/* Zona de acțiuni (buton + link de renunțare) */
.sc-progress__actions {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	margin: 0;
}

.sc-progress__actions:not(:first-child) {
	margin-top: 2px;
}

/* ==========================================================================
   3. Butonul principal / butonul de deschidere a popup-ului
   ========================================================================== */
button.sc-btn,
a.sc-btn,
.sc-btn {
	display: inline-block;
	max-width: 100%;
	margin: 0;
	padding: 10px 20px;
	background: var(--sc-green, #83b735);
	border: 1px solid var(--sc-green, #83b735);
	border-radius: 9px;
	box-shadow: none;
	color: #fff;
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: .01em;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .12s ease;
}

button.sc-btn:hover,
button.sc-btn:focus,
a.sc-btn:hover,
a.sc-btn:focus,
.sc-btn:hover,
.sc-btn:focus {
	background: var(--sc-green-dark, #5f8f22);
	border-color: var(--sc-green-dark, #5f8f22);
	color: #fff;
	text-decoration: none;
}

.sc-btn:focus-visible {
	outline: 2px solid var(--sc-green-dark, #5f8f22);
	outline-offset: 2px;
}

.sc-btn:active {
	transform: translateY(1px);
}

.sc-btn[disabled],
.sc-btn.is-disabled {
	opacity: .6;
	cursor: not-allowed;
	transform: none;
}

.sc-btn.is-loading {
	position: relative;
	color: rgba(255, 255, 255, .55);
	pointer-events: none;
}

.sc-btn.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 16px;
	height: 16px;
	margin: -8px 0 0 -8px;
	border: 2px solid rgba(255, 255, 255, .45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: sc-spin .7s linear infinite;
}

/* Butonul care deschide modalul (singurul selector pe care ascultă JS-ul). */
.sc-open-gifts {
	flex: 0 0 auto;
}

/* ==========================================================================
   4. Linkul de renunțare la cadou
   ========================================================================== */
a.sc-remove-gift,
.sc-remove-gift {
	display: inline-block;
	flex: 0 0 auto;
	margin: 0;
	padding: 0;
	background: none;
	border: 0;
	color: var(--sc-muted, #6b7761);
	font-family: inherit;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.3;
	text-decoration: underline;
	cursor: pointer;
}

a.sc-remove-gift:hover,
a.sc-remove-gift:focus,
.sc-remove-gift:hover,
.sc-remove-gift:focus {
	color: var(--sc-danger, #b03535);
	text-decoration: underline;
}

.sc-remove-gift:focus-visible {
	outline: 2px solid var(--sc-danger, #b03535);
	outline-offset: 2px;
}

.sc-remove-gift.is-loading {
	opacity: .55;
	pointer-events: none;
}

/* ==========================================================================
   5. Variante contextuale ale blocului de progres
   ========================================================================== */
.sc-progress--minicart {
	margin-bottom: 12px;
	padding: 12px;
	font-size: 13px;
}

.sc-progress--minicart .sc-progress__msg,
.sc-progress--minicart .sc-progress__line {
	font-size: 13px;
}

.sc-progress--minicart .sc-progress__actions {
	display: block;
}

.sc-progress--minicart .sc-btn {
	display: block;
	width: 100%;
	padding: 9px 14px;
	font-size: 13px;
}

.sc-progress--minicart .sc-remove-gift {
	display: block;
	margin-top: 8px;
	text-align: center;
}

.sc-progress--shop {
	margin: 0 0 20px;
	text-align: center;
}

.sc-progress--shop .sc-progress__msg,
.sc-progress--shop .sc-progress__line {
	text-align: center;
}

.sc-progress--shop .sc-progress__actions {
	justify-content: center;
}

.sc-progress--checkout {
	margin-bottom: 20px;
}

/* ==========================================================================
   6. Modal
   ========================================================================== */
.sc-modal {
	display: none;
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 999999;
	padding: 20px;
	background: rgba(23, 30, 16, .62);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

/* !important garantează deschiderea chiar dacă tema (sau un stil inline
   rămas) încearcă să impună display:none pe container. */
.sc-modal.is-open {
	display: flex !important;
	align-items: center;
	justify-content: center;
}

body.sc-modal-open {
	overflow: hidden;
}

.sc-modal__box {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 900px;
	max-height: 85vh;
	margin: auto;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 18px 60px rgba(0, 0, 0, .28);
	color: var(--sc-text, #2f3a1f);
	overflow: hidden;
	animation: sc-pop .22s ease-out;
}

.sc-modal__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex: 0 0 auto;
	padding: 16px 20px;
	background: var(--sc-bg-soft, #f6faf0);
	border-bottom: 1px solid var(--sc-border, #e4eed4);
	font-size: 17px;
	font-weight: 700;
	line-height: 1.3;
}

.sc-modal__head h2,
.sc-modal__head h3,
.sc-modal__head .sc-modal__title,
.sc-modal__title {
	margin: 0;
	padding: 0;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--sc-text, #2f3a1f);
}

.sc-modal__head small {
	display: block;
	margin-top: 3px;
	font-size: 12px;
	font-weight: 400;
	color: var(--sc-muted, #6b7761);
}

.sc-modal__close {
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	padding: 0;
	background: #fff;
	border: 1px solid var(--sc-border, #e4eed4);
	border-radius: 50%;
	color: var(--sc-green-dark, #5f8f22);
	font-family: inherit;
	font-size: 20px;
	line-height: 1;
	text-align: center;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.sc-modal__close:hover,
.sc-modal__close:focus {
	background: var(--sc-green, #83b735);
	border-color: var(--sc-green, #83b735);
	color: #fff;
}

.sc-modal__close:focus-visible {
	outline: 2px solid var(--sc-green-dark, #5f8f22);
	outline-offset: 2px;
}

/* ==========================================================================
   7. Grila de produse + stări
   ========================================================================== */
.sc-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 14px;
	flex: 1 1 auto;
	margin: 0;
	padding: 18px 20px;
	list-style: none;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

/* Dacă grila rămâne goală, afișează textul din atributul data-empty. */
.sc-grid:empty::before {
	content: attr(data-empty);
	grid-column: 1 / -1;
	display: block;
	padding: 26px 10px;
	color: var(--sc-muted, #6b7761);
	font-size: 14px;
	text-align: center;
}

.sc-state,
.sc-grid .sc-state {
	grid-column: 1 / -1;
	display: block;
	padding: 26px 10px;
	color: var(--sc-muted, #6b7761);
	font-size: 14px;
	text-align: center;
}

.sc-state--empty {
	color: var(--sc-muted, #6b7761);
}

.sc-state--error,
.sc-grid .sc-state--error {
	color: var(--sc-danger, #b03535);
	font-weight: 600;
}

.sc-state--loading::before,
.sc-grid .sc-state--loading::before {
	content: "";
	display: block;
	width: 24px;
	height: 24px;
	margin: 0 auto 10px;
	border: 3px solid var(--sc-border, #e4eed4);
	border-top-color: var(--sc-green, #83b735);
	border-radius: 50%;
	animation: sc-spin .7s linear infinite;
}

/* ==========================================================================
   8. Cardul de cadou
   ========================================================================== */
.sc-card {
	position: relative;
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 10px;
	background: #fff;
	border: 1px solid var(--sc-border, #e4eed4);
	border-radius: var(--sc-radius, 12px);
	color: var(--sc-text, #2f3a1f);
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.sc-card:hover,
.sc-card:focus {
	border-color: var(--sc-green, #83b735);
	box-shadow: 0 10px 22px rgba(95, 143, 34, .18);
	color: var(--sc-text, #2f3a1f);
	text-decoration: none;
	transform: translateY(-3px);
}

.sc-card:focus-visible {
	outline: 2px solid var(--sc-green-dark, #5f8f22);
	outline-offset: 2px;
}

/* Zona de imagine: container <div class="sc-card__img"> cu <img> înăuntru. */
.sc-card__img {
	position: relative;
	display: block;
	width: 100%;
	height: 150px;
	margin: 0 0 10px;
	background: var(--sc-bg-soft, #f6faf0);
	border-radius: 8px;
	overflow: hidden;
}

.sc-card__img img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	border-radius: 8px;
	object-fit: contain;
	object-position: center;
}

/* Variantă de siguranță: dacă marcajul folosește direct <img class="sc-card__img">. */
img.sc-card__img {
	object-fit: contain;
	object-position: center;
}

.sc-card__name {
	display: block;
	margin: 0 0 6px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--sc-text, #2f3a1f);
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.sc-card__price {
	display: block;
	margin: auto 0 0;
	font-size: 13px;
	font-weight: 700;
	color: var(--sc-green-dark, #5f8f22);
	line-height: 1.35;
}

/* Prețul normal, tăiat (marcaj canonic: <s>, dar acceptăm și <del>/.sc-old). */
.sc-card__price s,
.sc-card__price del,
.sc-card__price .sc-old {
	margin-right: 5px;
	color: #97a08d;
	font-weight: 400;
	text-decoration: line-through;
}

.sc-card__price s .amount,
.sc-card__price del .amount {
	color: inherit;
	font-weight: inherit;
}

/* „→ 0 lei” — și ca element separat, și pe același element cu .sc-card__price. */
.sc-free,
.sc-card__price .sc-free {
	color: var(--sc-green, #83b735);
	font-weight: 700;
	white-space: nowrap;
}

/* Butonul „Alege” din card — clasă proprie, NU .sc-btn. */
.sc-card__choose {
	display: block;
	width: 100%;
	margin: 10px 0 0;
	padding: 8px 12px;
	background: var(--sc-green, #83b735);
	border: 1px solid var(--sc-green, #83b735);
	border-radius: 8px;
	box-shadow: none;
	color: #fff;
	font-family: inherit;
	font-size: 13px;
	font-weight: 700;
	line-height: 1.3;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color .2s ease, border-color .2s ease;
}

.sc-card__choose:hover,
.sc-card__choose:focus,
.sc-card:hover .sc-card__choose {
	background: var(--sc-green-dark, #5f8f22);
	border-color: var(--sc-green-dark, #5f8f22);
	color: #fff;
	text-decoration: none;
}

.sc-card__choose:focus-visible {
	outline: 2px solid var(--sc-green-dark, #5f8f22);
	outline-offset: 2px;
}

.sc-card__choose[disabled],
.sc-card__choose.is-disabled {
	opacity: .6;
	cursor: not-allowed;
}

/* Stări ale cardului */
.sc-card.sc-chosen {
	background: var(--sc-bg-soft, #f6faf0);
	border-color: var(--sc-green-dark, #5f8f22);
	box-shadow: 0 0 0 2px rgba(131, 183, 53, .35);
	color: var(--sc-text, #2f3a1f);
}

.sc-card.sc-chosen::after {
	content: "\2713";
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	background: var(--sc-green-dark, #5f8f22);
	border-radius: 50%;
	color: #fff;
	font-size: 13px;
	line-height: 1;
}

.sc-card.is-loading {
	opacity: .6;
	pointer-events: none;
}

.sc-card.is-disabled {
	opacity: .5;
	cursor: not-allowed;
	pointer-events: none;
}

/* ==========================================================================
   9. Badge-uri — două clase DISTINCTE, nu le confunda
   --------------------------------------------------------------------------
   .sc-card__badge  = badge în colțul cardului din popup (poziționat absolut)
   .sc-badge        = badge INLINE în coș / mini-coș / checkout (în flux)
   ========================================================================== */
.sc-card__badge {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 2;
	display: inline-block;
	max-width: calc(100% - 16px);
	padding: 3px 9px;
	background: var(--sc-green, #83b735);
	border-radius: 999px;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.5;
	letter-spacing: .02em;
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.sc-badge {
	position: static;
	display: inline-block;
	vertical-align: baseline;
	margin: 0 0 0 4px;
	padding: 2px 8px;
	background: var(--sc-green, #83b735);
	border-radius: 999px;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.5;
	letter-spacing: .02em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
}

/* ==========================================================================
   10. Marcaje în coș / mini-coș / comandă
   ========================================================================== */
.sc-chosen {
	color: var(--sc-green-dark, #5f8f22);
	font-weight: 700;
}

/* Prețul „0 lei” din linia de coș / mini-coș rămâne în flux. */
span.sc-chosen {
	display: inline;
}

span.sc-chosen .amount,
span.sc-chosen bdi {
	color: inherit;
	font-weight: inherit;
}

.sc-cart-gift-note {
	display: block;
	margin-top: 4px;
	color: var(--sc-green-dark, #5f8f22);
	font-size: 12px;
	line-height: 1.4;
}

.sc-cart-gift-note .sc-badge {
	margin: 0 6px 0 0;
}

/* ==========================================================================
   11. Animații
   ========================================================================== */
@keyframes sc-spin {
	to { transform: rotate(360deg); }
}

@keyframes sc-pop {
	from { opacity: 0; transform: translateY(14px) scale(.98); }
	to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.sc-bar__fill,
	.sc-card,
	.sc-card__choose,
	.sc-btn,
	.sc-modal__box {
		transition: none;
		animation: none;
	}

	.sc-card:hover {
		transform: none;
	}
}

/* ==========================================================================
   12. Responsive
   ========================================================================== */
@media (max-width: 1024px) {
	.sc-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.sc-card__img {
		height: 140px;
	}
}

@media (max-width: 640px) {
	.sc-modal {
		padding: 10px;
	}

	.sc-modal__box {
		max-height: 92vh;
		border-radius: 14px;
	}

	.sc-modal__head {
		padding: 13px 15px;
		font-size: 15px;
	}

	.sc-modal__head h2,
	.sc-modal__head h3,
	.sc-modal__head .sc-modal__title {
		font-size: 15px;
	}

	.sc-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 10px;
		padding: 13px 15px;
	}

	.sc-card {
		padding: 8px;
	}

	.sc-card__img {
		height: 120px;
	}

	.sc-card__name {
		font-size: 12px;
	}

	.sc-card__price {
		font-size: 12px;
	}

	.sc-card__choose {
		margin-top: 8px;
		padding: 7px 10px;
		font-size: 12px;
	}

	.sc-progress {
		padding: 12px 13px;
	}

	.sc-progress__actions {
		display: block;
	}

	.sc-progress .sc-btn {
		display: block;
		width: 100%;
	}

	.sc-progress .sc-remove-gift {
		display: block;
		margin: 8px 0 0;
		text-align: center;
	}
}

@media (max-width: 380px) {
	.sc-card__img {
		height: 100px;
	}
}
