/* ==========================================================
   Affiliate Manager Pro – frontend (v5.9)
   Toate valorile vizuale sunt variabile CSS. Culorile vin din
   admin (inline pe :root); tema le poate suprascrie pe `body`.
   ========================================================== */
:root {
	--afm-accent: #c08a2e;
	--afm-grad-start: #00c6ff;
	--afm-grad-end: #ff0000;
	--afm-sticky-start: #00c6ff;
	--afm-sticky-end: #ff0000;
	--afm-banner-bg: #e8f9ef;
	--afm-banner-btn: #f2662f;
	--afm-disc-border: #d97706;
	--afm-disc-bg: #fff8eb;
	--afm-disc-text: #5b3410;
	--afm-atc-start: #00c6ff;
	--afm-atc-end: #ff0000;
	--afm-atc-text: #fff;
	--afm-atc-size: 16px;
	--afm-atc-radius: 50px;
	--afm-atc-pad: 14px 28px;
}

body {
	--afm-font: inherit;
	--afm-heading-font: inherit;
	--afm-text: #1f2937;
	--afm-muted: #6b7280;
	--afm-border: #e5e7eb;
	--afm-surface: #fff;
	--afm-field-bg: #fff;
	--afm-soft: #f3f4f6;
	--afm-success: #166534;
	--afm-error-bg: #fef2f2;
	--afm-error-border: #fca5a5;
	--afm-error-text: #b91c1c;
	--afm-radius: 18px;
	--afm-field-radius: 10px;
	--afm-btn-radius: 999px;
	--afm-shadow: 0 20px 60px rgba(0, 0, 0, .25);
	--afm-sticky-top: 16px;
	--afm-z: 99999;
}

/* ---------- utilitare ---------- */
.afm-sr {
	position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.afm-hp { position: absolute !important; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.afm-inline [hidden], .afm-modal [hidden] { display: none !important; }

/* ---------- campuri ---------- */
.afm-form { display: flex; flex-direction: column; gap: 14px; margin: 0; font-family: var(--afm-font); }
.afm-field { display: flex; flex-direction: column; gap: 6px; }
.afm-field label { font-size: 15px; font-weight: 600; color: var(--afm-text); margin: 0; }
.afm-form input[type="text"],
.afm-form input[type="tel"] {
	width: 100%; min-height: 48px; box-sizing: border-box; margin: 0;
	padding: 12px 14px; font: inherit; font-size: 16px; /* 16px = fara zoom pe iOS */
	color: var(--afm-text); background: var(--afm-field-bg);
	border: 1.5px solid var(--afm-border); border-radius: var(--afm-field-radius);
	box-shadow: none; outline: none; transition: border-color .15s, box-shadow .15s;
}
.afm-form input::placeholder { color: #9ca3af; opacity: 1; }
.afm-form input:focus {
	border-color: var(--afm-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--afm-accent) 22%, transparent);
}
.afm-form input[aria-invalid="true"] { border-color: var(--afm-error-text); }

.afm-phone { display: flex; align-items: stretch; }
.afm-phone__prefix {
	flex: 0 0 auto; display: flex; align-items: center; padding: 0 14px;
	font-size: 16px; font-weight: 600; color: var(--afm-muted); background: var(--afm-soft);
	border: 1.5px solid var(--afm-border); border-right: 0;
	border-radius: var(--afm-field-radius) 0 0 var(--afm-field-radius);
}
.afm-phone__prefix + input { border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; }

.afm-error {
	padding: 10px 14px; font-size: 14px; line-height: 1.45;
	color: var(--afm-error-text); background: var(--afm-error-bg);
	border: 1px solid var(--afm-error-border); border-radius: 8px;
}

/* ---------- butoane ---------- */
.afm-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	width: 100%; min-height: 50px; padding: 14px 22px; margin: 0;
	font: inherit; font-size: 16px; font-weight: 700; line-height: 1.2; letter-spacing: .01em;
	color: #fff; border: 0; border-radius: var(--afm-btn-radius); cursor: pointer;
	text-decoration: none; transition: transform .15s, box-shadow .15s, filter .15s, background .15s;
	-webkit-tap-highlight-color: transparent;
}
.afm-btn:hover { filter: brightness(1.05); box-shadow: 0 6px 18px rgba(0, 0, 0, .14); }
.afm-btn:active { transform: scale(.985); }
.afm-btn:focus-visible { outline: 3px solid var(--afm-text); outline-offset: 2px; }
.afm-btn[disabled] { opacity: .7; cursor: wait; transform: none; }
.afm-btn--accent { background: var(--afm-accent); }
.afm-btn--gradient { background: linear-gradient(90deg, var(--afm-grad-start), var(--afm-grad-end)); }
.afm-btn--banner { background: var(--afm-banner-btn); width: auto; }
.afm-btn--ghost { background: var(--afm-soft); color: var(--afm-text); width: auto; min-height: 42px; font-weight: 600; }
.afm-spinner {
	width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent;
	border-radius: 50%; animation: afm-spin .8s linear infinite;
}
@keyframes afm-spin { to { transform: rotate(360deg); } }

/* ---------- formular inline ("Comandă rapidă") ---------- */
.afm-inline {
	box-sizing: border-box; width: 100%; padding: 22px 20px 20px;
	color: var(--afm-text); background: var(--afm-surface);
	border: 2px solid var(--afm-accent); border-radius: var(--afm-radius);
	font-family: var(--afm-font);
}
.afm-inline__title {
	margin: 0 0 6px; font-family: var(--afm-heading-font); font-size: 24px; line-height: 1.2; font-weight: 700; color: var(--afm-text);
}
.afm-inline__sub { margin: 0 0 18px; font-size: 15.5px; line-height: 1.55; color: var(--afm-muted); }
.afm-trust { margin: 2px 0 0; text-align: center; font-size: 13px; color: var(--afm-muted); }
.afm-legal { margin: 2px 0 0; font-size: 13px; line-height: 1.6; color: var(--afm-muted); }
.afm-legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.afm-badges {
	display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none;
}
.afm-badges li {
	margin: 0; padding: 9px 12px; font-size: 13px; color: var(--afm-muted);
	background: var(--afm-soft); border-radius: 10px;
}
.afm-note {
	display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; padding-top: 16px;
	border-top: 1px dashed var(--afm-border); color: var(--afm-muted);
}
.afm-note svg { flex: 0 0 auto; margin-top: 2px; color: var(--afm-text); }
.afm-note p { margin: 0; font-size: 14px; line-height: 1.55; }
.afm-note strong { color: var(--afm-text); }

/* ---------- succes ---------- */
.afm-success { text-align: center; padding: 12px 0 4px; }
.afm-success__icon {
	display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px;
	margin-bottom: 12px; border-radius: 50%; color: #fff; background: var(--afm-success);
}
.afm-success__title { margin: 0 0 8px; font-family: var(--afm-heading-font); font-size: 20px; color: var(--afm-success); }
.afm-success__msg { margin: 0 0 16px; font-size: 15px; line-height: 1.6; color: var(--afm-text); }

/* ---------- banner consultanta ---------- */
.afm-banner {
	margin: 28px 0; padding: 22px 24px; background: var(--afm-banner-bg); border-radius: var(--afm-radius);
}
.afm-banner__text { margin: 0 0 16px !important; font-size: 16px; line-height: 1.6; color: var(--afm-text); }

/* ---------- modale ---------- */
html.afm-lock, html.afm-lock body { overflow: hidden; }
.afm-modal {
	/* ocupă exact zona vizibilă (fără tastatură) – setată din JS prin visualViewport */
	position: fixed; left: 0; right: 0; top: var(--afm-vv-top, 0px); height: var(--afm-vv-h, 100%); z-index: var(--afm-z);
	display: flex; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box;
	font-family: var(--afm-font);
}
.afm-modal[hidden] { display: none; }
.afm-modal__backdrop {
	position: absolute; inset: 0; background: rgba(15, 23, 20, .55);
	-webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
	opacity: 0; transition: opacity .25s;
}
.afm-modal__box {
	position: relative; width: 100%; max-width: 440px; max-height: calc(var(--afm-vv-h, 100dvh) - 32px); overflow-y: auto; outline: none;
	overscroll-behavior: contain; background: var(--afm-surface); color: var(--afm-text);
	border-radius: 20px; box-shadow: var(--afm-shadow);
	transform: translateY(12px) scale(.97); opacity: 0;
	transition: transform .3s cubic-bezier(.2, .9, .3, 1.2), opacity .2s;
}
.afm-modal.is-open .afm-modal__backdrop { opacity: 1; }
.afm-modal.is-open .afm-modal__box { transform: none; opacity: 1; }

.afm-modal__head {
	display: flex; align-items: center; gap: 14px; padding: 18px 56px 18px 20px;
	background: linear-gradient(135deg, var(--afm-grad-start), var(--afm-grad-end)); color: #fff;
}
.afm-modal__head img {
	width: 54px; height: 54px; flex: 0 0 auto; object-fit: cover; border-radius: 12px;
	border: 2px solid rgba(255, 255, 255, .45); background: #fff;
}
.afm-modal__head-text { min-width: 0; }
.afm-modal__kicker { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.afm-modal__product { margin: 3px 0 0; font-size: 17px; font-weight: 700; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.afm-modal__close {
	position: absolute; top: 14px; right: 14px; display: flex; align-items: center; justify-content: center;
	width: 36px; height: 36px; padding: 0; color: #fff; background: rgba(255, 255, 255, .22);
	border: 0; border-radius: 50%; cursor: pointer; transition: background .15s;
}
.afm-modal__close:hover { background: rgba(255, 255, 255, .36); }
.afm-modal__close--light { color: var(--afm-muted); background: var(--afm-soft); z-index: 1; }
.afm-modal__close--light:hover { background: var(--afm-border); }
.afm-modal__close:focus-visible { outline: 3px solid var(--afm-text); outline-offset: 2px; }
.afm-modal__body { padding: 22px 20px 20px; }
.afm-modal__title { margin: 0 44px 2px 0; font-family: var(--afm-heading-font); font-size: 22px; line-height: 1.25; color: var(--afm-text); }
.afm-modal__intro { margin: 0 0 4px; text-align: center; font-size: 15px; line-height: 1.5; color: var(--afm-muted); }
.afm-modal__intro--left { text-align: left; }
.afm-fineprint { margin: 0; text-align: center; font-size: 12.5px; color: var(--afm-muted); }

@media (max-width: 600px) {
	/* Pe telefon popup-ul stă SUS: tastatura apare jos și nu-l mai poate acoperi. */
	.afm-modal { align-items: flex-start; padding: 8px 8px 0; }
	.afm-modal__box {
		max-width: none; max-height: calc(var(--afm-vv-h, 100dvh) - 16px); border-radius: 18px;
		transform: translateY(-24px);
	}
	.afm-modal.is-open .afm-modal__box { transform: none; }
	.afm-modal__head { padding: 12px 52px 12px 14px; gap: 12px; }
	.afm-modal__head img { width: 42px; height: 42px; border-radius: 10px; }
	.afm-modal__body { padding: 16px 14px 14px; }
	.afm-modal__intro { font-size: 14px; }
	.afm-form { gap: 10px; }
}


/* ---------- sticky ---------- */
.afm-sticky {
	position: fixed; z-index: calc(var(--afm-z) - 10); top: var(--afm-sticky-top); right: 16px;
	display: flex; align-items: center; gap: 12px; box-sizing: border-box; max-width: 340px; padding: 10px 12px 10px 10px;
	background: var(--afm-surface); border: 1px solid var(--afm-border); border-radius: 14px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, .12); font-family: var(--afm-font);
	opacity: 0; visibility: hidden; transform: translateY(-8px);
	transition: opacity .2s, transform .2s, visibility 0s linear .2s;
}
.afm-sticky.is-visible { opacity: 1; visibility: visible; transform: none; transition: opacity .2s, transform .2s; }
.afm-sticky img { width: 48px; height: 48px; flex: 0 0 auto; object-fit: cover; border-radius: 10px; }
.afm-sticky__text { flex: 1 1 auto; min-width: 0; }
.afm-sticky__title, .afm-sticky__price { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.afm-sticky__title { font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--afm-text); }
.afm-sticky__price { margin-top: 2px; font-size: 14px; font-weight: 700; color: var(--afm-text); }
.afm-sticky__price del { font-weight: 400; color: var(--afm-muted); }
.afm-sticky__price ins { text-decoration: none; }
.afm-sticky__btn {
	flex: 0 0 auto; min-height: 44px; padding: 10px 18px; font: inherit; font-size: 15px; font-weight: 700; color: #fff;
	background: linear-gradient(90deg, var(--afm-sticky-start), var(--afm-sticky-end));
	border: 0; border-radius: var(--afm-btn-radius); cursor: pointer; white-space: nowrap;
}
.afm-sticky__btn:focus-visible { outline: 3px solid var(--afm-text); outline-offset: 2px; }
html.afm-ordered .afm-sticky { display: none !important; }

@media (max-width: 768px) {
	.afm-sticky {
		top: auto; bottom: 0; left: 0; right: 0; max-width: none; gap: 10px;
		padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
		border-width: 1px 0 0; border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, .12);
		transform: translateY(100%);
	}
	.afm-sticky img { width: 42px; height: 42px; }
	.afm-sticky__btn { min-height: 46px; padding: 10px 20px; }
	/* loc pentru bara, ca sa nu acopere footerul */
	body.afm-has-sticky { padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- disclaimer ---------- */
.afm-disclaimer {
	display: flex; gap: 14px; align-items: flex-start; margin: 32px 0 0; padding: 18px 20px;
	color: var(--afm-disc-text); background: var(--afm-disc-bg);
	border-left: 4px solid var(--afm-disc-border); border-radius: 12px; font-family: var(--afm-font);
}
.afm-disclaimer__icon {
	flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px;
	font-weight: 700; color: #fff; background: var(--afm-disc-border); border-radius: 50%;
}
.afm-disclaimer__title { margin: 0 0 4px; font-weight: 700; color: var(--afm-disc-border); }
.afm-disclaimer__body { margin: 0; font-size: 14px; line-height: 1.6; }

/* ---------- butonul de comanda WooCommerce ---------- */
body.afm-styled-atc.single-product .single_add_to_cart_button,
body.afm-styled-atc .afm-order-btn {
	display: inline-flex !important; align-items: center; justify-content: center;
	padding: var(--afm-atc-pad) !important; font-size: var(--afm-atc-size) !important; font-weight: 700 !important;
	color: var(--afm-atc-text) !important; border: 0 !important; border-radius: var(--afm-atc-radius) !important;
	background: linear-gradient(90deg, var(--afm-atc-start), var(--afm-atc-end)) !important;
	transition: transform .15s, box-shadow .15s !important; text-decoration: none !important; cursor: pointer;
}
body.afm-styled-atc.single-product .single_add_to_cart_button:hover,
body.afm-styled-atc .afm-order-btn:hover { transform: scale(1.02); box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }

@media (prefers-reduced-motion: reduce) {
	.afm-modal__box, .afm-modal__backdrop, .afm-sticky, .afm-btn { transition: none !important; }
}

/* Unele teme (ex. Astra) colorează toate butoanele la :hover/:focus – le blocăm. */
.afm-btn, .afm-sticky__btn, .afm-modal__close { text-transform: none; }
.afm-btn--accent:hover, .afm-btn--accent:focus, .afm-btn--accent:active { background-color: var(--afm-accent); background-image: none; color: #fff; }
.afm-btn--banner:hover, .afm-btn--banner:focus, .afm-btn--banner:active { background-color: var(--afm-banner-btn); background-image: none; color: #fff; }
.afm-btn--gradient:hover, .afm-btn--gradient:focus, .afm-btn--gradient:active { background-color: var(--afm-grad-start); background-image: linear-gradient(90deg, var(--afm-grad-start), var(--afm-grad-end)); color: #fff; }
.afm-btn--ghost:hover, .afm-btn--ghost:focus { background-color: var(--afm-soft); background-image: none; color: var(--afm-text); }
.afm-sticky__btn:hover, .afm-sticky__btn:focus, .afm-sticky__btn:active { background-color: var(--afm-sticky-start); background-image: linear-gradient(90deg, var(--afm-sticky-start), var(--afm-sticky-end)); color: #fff; }
.afm-modal__close:focus { background-color: rgba(255, 255, 255, .22); color: #fff; }
.afm-modal__close--light:hover, .afm-modal__close--light:focus { background-color: var(--afm-border); color: var(--afm-muted); }

/* Cu tastatura deschisă: popup compact, ca nume + telefon + buton să încapă deasupra ei */
html.afm-kb-open .afm-modal__head { padding-top: 12px; padding-bottom: 12px; }
html.afm-kb-open .afm-modal__head img { width: 40px; height: 40px; }
html.afm-kb-open .afm-modal__body { padding-top: 14px; padding-bottom: 14px; }
html.afm-kb-open .afm-modal__intro, html.afm-kb-open .afm-fineprint { display: none; }
html.afm-kb-open .afm-form { gap: 10px; }
