/*
 * CFPDR Chat AI: aspectul chatului. Culorile vin din variabilele --cfc-* puse în pagină pentru fiecare site
 * (verde CFPDR pe cfpdr.eu, aproape negru cu lime pe calificare.net). Totul stă sub #cfc-chat și resetează ce ar
 * putea moșteni de la temă (butoane, câmpuri, titluri), ca să arate la fel pe ambele site-uri.
 */

#cfc-chat,
#cfc-chat *,
#cfc-chat *::before,
#cfc-chat *::after { box-sizing: border-box; }

#cfc-chat {
	--cfc-raza: 18px;
	--cfc-text: #17201a;
	--cfc-gri: #5b665e;
	--cfc-linie: #e3e6dc;
	--cfc-alb: #fff;
	line-height: 1.45;
	font-size: 15px;
	color: var(--cfc-text);
	-webkit-font-smoothing: antialiased;
}

#cfc-chat button,
#cfc-chat input,
#cfc-chat select,
#cfc-chat textarea {
	font: inherit;
	color: inherit;
	letter-spacing: normal;
	text-transform: none;
	margin: 0;
	box-shadow: none;
	min-height: 0;
}
#cfc-chat button { cursor: pointer; background: none; border: 0; padding: 0; line-height: inherit; }
#cfc-chat p { margin: 0; }
#cfc-chat a { color: var(--cfc-link); text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
#cfc-chat :focus-visible { outline: 3px solid var(--cfc-accent2); outline-offset: 2px; }

/* ---------- bula ---------- */
#cfc-chat .cfc-bula { position: relative; transition: transform .18s ease, box-shadow .18s ease; }
#cfc-chat .cfc-bula:hover { transform: translateY(-2px) scale(1.03); }
#cfc-chat .cfc-bula:active { transform: scale(.97); }
#cfc-chat[data-stare="inchis"] .cfc-bula::after {
	content: "";
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	border: 2px solid var(--cfc-accent);
	opacity: 0;
	animation: cfc-puls 3.2s ease-out 2s 3;
	pointer-events: none;
}
@keyframes cfc-puls {
	0% { transform: scale(.9); opacity: .7; }
	70%, 100% { transform: scale(1.35); opacity: 0; }
}

/* ---------- întâmpinarea ---------- */
#cfc-chat .cfc-teaser {
	position: absolute;
	right: 0;
	bottom: 74px;
	width: max-content;
	max-width: min(280px, calc(100vw - 32px));
	background: var(--cfc-alb);
	color: var(--cfc-text);
	border-radius: 16px 16px 4px 16px;
	padding: 13px 34px 13px 15px;
	box-shadow: 0 14px 38px -10px rgba(10, 30, 18, .35), 0 2px 6px rgba(0, 0, 0, .08);
	border: 1px solid var(--cfc-linie);
	cursor: pointer;
	font-size: 14.5px;
	font-weight: 500;
	animation: cfc-intra .3s ease-out;
}
#cfc-chat .cfc-teaser-x {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	font-size: 18px;
	line-height: 26px;
	color: var(--cfc-gri);
	text-align: center;
}
#cfc-chat .cfc-teaser-x:hover { background: var(--cfc-fond); color: var(--cfc-text); }

@keyframes cfc-intra {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: none; }
}

/* ---------- fereastra ---------- */
#cfc-chat .cfc-panou {
	position: absolute;
	right: 0;
	bottom: 76px;
	width: 390px;
	height: min(620px, calc(100vh - 120px - var(--cfc-jos, 0px)));
	height: min(620px, calc(100dvh - 120px - var(--cfc-jos, 0px)));
	display: flex;
	flex-direction: column;
	background: var(--cfc-fond);
	border-radius: var(--cfc-raza);
	overflow: hidden;
	box-shadow: 0 24px 60px -16px rgba(8, 26, 15, .45), 0 4px 14px rgba(0, 0, 0, .1);
	border: 1px solid rgba(0, 0, 0, .06);
	animation: cfc-intra .22s ease-out;
}

#cfc-chat .cfc-cap {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 12px 14px 16px;
	background: var(--cfc-inchis);
	color: #fff;
	flex: none;
}
#cfc-chat .cfc-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: #fff;
	padding: 5px;
	object-fit: contain;
	flex: none;
	margin: 0;
	max-width: none;
}
#cfc-chat .cfc-cap-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
#cfc-chat .cfc-cap-text strong { font-family: var(--font-d, inherit); font-size: 16px; font-weight: 700; color: #fff; line-height: 1.25; }
#cfc-chat .cfc-cap-text > span { font-size: 12.5px; color: rgba(255, 255, 255, .78); display: flex; align-items: center; gap: 6px; }
#cfc-chat .cfc-sub { min-width: 0; }
#cfc-chat .cfc-punct { width: 8px; height: 8px; border-radius: 50%; background: var(--cfc-accent); box-shadow: 0 0 0 3px rgba(195, 236, 122, .25); flex: none; }
#cfc-chat .cfc-inchide { width: 38px; height: 38px; border-radius: 10px; color: #fff; display: grid; place-items: center; flex: none; }
#cfc-chat .cfc-inchide:hover { background: rgba(255, 255, 255, .12); }
#cfc-chat .cfc-inchide svg { width: 22px; height: 22px; }

/* ---------- mesajele ---------- */
#cfc-chat .cfc-mesaje {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px 14px 8px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}
#cfc-chat .cfc-m { display: flex; max-width: 100%; }
#cfc-chat .cfc-m-eu { justify-content: flex-end; }
#cfc-chat .cfc-b {
	max-width: 86%;
	padding: 10px 13px;
	border-radius: 16px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	font-size: 14.5px;
}
#cfc-chat .cfc-m-ei .cfc-b { background: var(--cfc-alb); border: 1px solid var(--cfc-linie); border-bottom-left-radius: 5px; }
#cfc-chat .cfc-m-eu .cfc-b { background: var(--cfc-inchis); color: #fff; border-bottom-right-radius: 5px; }
#cfc-chat .cfc-m-eu .cfc-b a { color: #fff; }
#cfc-chat .cfc-b a.cfc-tel { font-weight: 600; white-space: nowrap; }

/* „scrie…” */
#cfc-chat .cfc-scrie-acum .cfc-b { display: flex; gap: 5px; padding: 14px 15px; }
#cfc-chat .cfc-scrie-acum i { width: 7px; height: 7px; border-radius: 50%; background: var(--cfc-accent2); animation: cfc-sar 1.2s infinite ease-in-out; }
#cfc-chat .cfc-scrie-acum i:nth-child(2) { animation-delay: .15s; }
#cfc-chat .cfc-scrie-acum i:nth-child(3) { animation-delay: .3s; }
@keyframes cfc-sar {
	0%, 60%, 100% { transform: translateY(0); opacity: .45; }
	30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------- butoanele rapide ---------- */
#cfc-chat .cfc-rapide {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 4px 14px 10px;
	flex: none;
	max-height: 40%;
	overflow-y: auto;
}
#cfc-chat .cfc-rapide:empty { display: none; }
#cfc-chat .cfc-btn-r {
	border: 1.5px solid var(--cfc-mediu);
	color: var(--cfc-mediu);
	background: var(--cfc-alb);
	border-radius: 999px;
	padding: 7px 13px;
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.25;
	text-align: left;
	transition: background .15s, color .15s;
}
#cfc-chat .cfc-btn-r:hover { background: var(--cfc-mediu); color: #fff; }
.cfc-site-calificare#cfc-chat .cfc-btn-r { border-color: var(--cfc-inchis); color: var(--cfc-inchis); }
.cfc-site-calificare#cfc-chat .cfc-btn-r:hover { background: var(--cfc-inchis); color: var(--cfc-accent); }
#cfc-chat .cfc-rapide.cfc-lista .cfc-btn-r { font-weight: 500; font-size: 13px; padding: 6px 11px; }

/* ---------- cardurile (certificatul, formularul) ---------- */
#cfc-chat .cfc-card {
	background: var(--cfc-alb);
	border: 1px solid var(--cfc-linie);
	border-radius: 14px;
	padding: 14px;
	margin: 0;
	flex: none;
}
#cfc-chat .cfc-cert { padding: 8px; }
#cfc-chat .cfc-cert img { display: block; width: 100%; height: auto; border-radius: 8px; margin: 0; }
#cfc-chat .cfc-cert figcaption { font-size: 13px; padding: 8px 4px 2px; color: var(--cfc-gri); }

#cfc-chat .cfc-formular h4 { margin: 0 0 4px; font-family: var(--font-d, inherit); font-size: 16px; font-weight: 700; color: var(--cfc-text); line-height: 1.3; text-transform: none; letter-spacing: normal; }
#cfc-chat .cfc-mic { font-size: 13px; color: var(--cfc-gri); margin: 0 0 10px; }
#cfc-chat .cfc-formular form { display: flex; flex-direction: column; gap: 9px; margin: 0; }
#cfc-chat .cfc-formular form.cfpdr-insc { margin-bottom: 4px; }
#cfc-chat .cfc-doua { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
#cfc-chat .cfc-camp { display: flex; flex-direction: column; gap: 3px; margin: 0; font-size: 12.5px; font-weight: 600; color: var(--cfc-gri); min-width: 0; }
#cfc-chat .cfc-camp input,
#cfc-chat .cfc-camp select {
	width: 100%;
	height: 42px;
	padding: 0 11px;
	border: 1.5px solid #cfd5c7;
	border-radius: 10px;
	background: #fff;
	font-size: 16px; /* sub 16px, iPhone mărește pagina la scris */
	font-weight: 400;
	color: var(--cfc-text);
	-webkit-appearance: none;
	appearance: none;
}
#cfc-chat .cfc-camp select {
	padding-right: 32px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b665e' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	background-size: 16px;
}
#cfc-chat .cfc-camp input:focus,
#cfc-chat .cfc-camp select:focus { border-color: var(--cfc-mediu); outline: none; box-shadow: 0 0 0 3px rgba(124, 179, 66, .25); }
#cfc-chat .cfc-acord { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--cfc-gri); line-height: 1.4; margin: 2px 0 0; cursor: pointer; }
#cfc-chat .cfc-acord input { width: 18px; height: 18px; flex: none; margin: 1px 0 0; accent-color: var(--cfc-mediu); }
#cfc-chat .cfc-capcana { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

#cfc-chat .cfc-btn-p {
	display: block;
	width: 100%;
	height: 46px;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--cfc-accent), var(--cfc-accent2));
	color: var(--cfc-pe_accent);
	font-weight: 700;
	font-size: 15.5px;
	margin-top: 4px;
	transition: filter .15s, transform .15s;
}
#cfc-chat .cfc-btn-p:hover { filter: brightness(1.04); transform: translateY(-1px); }
#cfc-chat .cfc-btn-p:disabled { opacity: .5; cursor: not-allowed; transform: none; }
#cfc-chat .cfc-btn-sec {
	display: block;
	width: 100%;
	margin-top: 10px;
	padding: 10px;
	border-radius: 999px;
	border: 1.5px solid var(--cfc-linie);
	color: var(--cfc-mediu);
	font-weight: 600;
	font-size: 14px;
	background: #fff;
}
#cfc-chat .cfc-btn-sec:hover { border-color: var(--cfc-mediu); }
#cfc-chat .cfc-suna { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--cfc-linie); }
#cfc-chat .cfc-eroare { color: #b42318; font-size: 13px; font-weight: 600; }
#cfc-chat .cfc-gata { border-color: var(--cfc-accent2); background: #f3fae8; }
#cfc-chat .cfc-gata p { font-size: 14.5px; font-weight: 500; }

/* ---------- scrisul ---------- */
#cfc-chat .cfc-scrie {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin: 0 12px;
	padding: 6px 6px 6px 14px;
	background: #fff;
	border: 1.5px solid var(--cfc-linie);
	border-radius: 24px;
	flex: none;
	transition: border-color .15s;
}
#cfc-chat .cfc-scrie:focus-within { border-color: var(--cfc-mediu); }
#cfc-chat .cfc-scrie textarea {
	flex: 1;
	min-width: 0;
	border: 0;
	outline: none;
	resize: none;
	background: transparent;
	padding: 8px 0;
	max-height: 120px;
	font-size: 16px;
	line-height: 1.35;
	height: auto;
	width: auto;
	border-radius: 0;
}
#cfc-chat .cfc-scrie textarea:focus-visible { outline: none; }
#cfc-chat .cfc-scrie button {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	flex: none;
	display: grid;
	place-items: center;
	background: var(--cfc-inchis);
	color: var(--cfc-accent);
}
#cfc-chat .cfc-scrie button svg { width: 19px; height: 19px; }
#cfc-chat .cfc-nota { font-size: 11px; color: var(--cfc-gri); text-align: center; padding: 7px 14px 10px; line-height: 1.35; flex: none; }
#cfc-chat .cfc-nota a { color: var(--cfc-gri); }

#cfc-chat .cfc-vizual-ascuns {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* ---------- telefonul (și ținut orizontal): fereastra pe tot ecranul ----------
   Înălțimea și poziția vin din JS (--cfc-vh, --cfc-vt, după ecranul vizibil), ca tastatura să nu acopere căsuța de scris. */
@media (max-width: 600px), (max-height: 500px) {
	#cfc-chat .cfc-panou {
		position: fixed;
		left: 0;
		right: 0;
		top: var(--cfc-vt, 0px);
		bottom: auto;
		width: 100%;
		height: var(--cfc-vh, 100%);
		border-radius: 0;
		border: 0;
		z-index: 2;
		animation: cfc-sus .22s ease-out;
	}
	#cfc-chat .cfc-cap { padding-top: max(14px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
	#cfc-chat .cfc-mesaje { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
	#cfc-chat .cfc-scrie { margin-left: max(12px, env(safe-area-inset-left)); margin-right: max(12px, env(safe-area-inset-right)); }
	#cfc-chat .cfc-nota { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
	#cfc-chat[data-stare="deschis"] .cfc-bula { display: none; }
	#cfc-chat .cfc-b { max-width: 90%; }
	#cfc-chat .cfc-teaser { bottom: 68px; }
	html.cfc-blocat,
	html.cfc-blocat body { overflow: hidden !important; }
}
@keyframes cfc-sus {
	from { transform: translateY(24px); opacity: 0; }
	to { transform: none; opacity: 1; }
}

/* ---------- fereastra joasă: telefon ținut orizontal sau cu tastatura deschisă, calculator cu fereastra mică ----------
   Clasele le pune chat.js după înălțimea ferestrei (cfc-scund sub 520px), ca mesajele să aibă loc. */
#cfc-chat.cfc-scund .cfc-cap { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px; }
#cfc-chat.cfc-scund .cfc-avatar { width: 32px; height: 32px; padding: 4px; }
#cfc-chat.cfc-scund .cfc-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cfc-chat.cfc-scund .cfc-mesaje { padding-top: 10px; }
#cfc-chat.cfc-scund .cfc-rapide { max-height: 30%; }
#cfc-chat.cfc-scund .cfc-nota {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
	padding-top: 5px;
	padding-bottom: max(6px, env(safe-area-inset-bottom));
}
#cfc-chat.cfc-scund .cfc-nota br { display: none; }
@media (max-width: 600px), (max-height: 500px) {
	/* pe telefon, butoanele de continuare stau pe un rând care se derulează în lateral (lista cursurilor rămâne pe rânduri) */
	#cfc-chat.cfc-scund .cfc-rapide:not(.cfc-lista) { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; scrollbar-width: none; }
	#cfc-chat.cfc-scund .cfc-rapide:not(.cfc-lista)::-webkit-scrollbar { display: none; }
	#cfc-chat.cfc-scund .cfc-rapide:not(.cfc-lista) .cfc-btn-r { flex: none; white-space: nowrap; }
}
/* tastatura deschisă: textul de jos (văzut deja) face loc mesajelor, căsuța de scris stă lipită de tastatură */
#cfc-chat.cfc-tastatura .cfc-nota { display: none; }
#cfc-chat.cfc-tastatura .cfc-scrie { margin-bottom: 8px; }

/* ---------- calculator cu fereastra joasă: chatul nu depășește ecranul ---------- */
@media (min-width: 601px) and (min-height: 501px) and (max-height: 640px) {
	#cfc-chat .cfc-panou { height: calc(100vh - 100px - var(--cfc-jos, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
	#cfc-chat *,
	#cfc-chat *::before,
	#cfc-chat *::after { animation: none !important; transition: none !important; }
	#cfc-chat .cfc-mesaje { scroll-behavior: auto; }
}

@media print {
	#cfc-chat { display: none !important; }
}
