/*
 * Conversația temelor, ca în WhatsApp: antetul sus, mesajele pe fundalul crem, câmpul de scris lipit jos.
 * Aceeași în aplicația profesorului și în a studentului (SBA_Homework::chat_head / chat_thread, assets/js/chat.js).
 */

.wa {
	--wa-bg: #efeae2;
	--wa-in: #ffffff;
	--wa-out: #d9fdd3;
	--wa-text: #111b21;
	--wa-meta: #667781;
	--wa-blue: #53bdeb;
	--wa-green: #00a884;
	--wa-ink: #16213a;
	--wa-gold: #b08a3e;

	/* Ecranul conversației: fix peste partea vizibilă a ecranului; chat.js îi potrivește înălțimea deasupra tastaturii. */
	position: fixed; top: 0; left: 0; right: 0; z-index: 50; height: 100vh; height: 100dvh;
	display: flex; flex-direction: column; overflow: hidden;
	background: var(--wa-bg); color: var(--wa-text); text-align: left;
	font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
.wa *, .wa *::before, .wa *::after { box-sizing: border-box; }

/*
 * Ecranul temelor: lista (studenții la profesor, materiile la student) și conversația deschisă.
 * Pe telefon, pe rând: lista, apoi conversația pe tot ecranul. Pe calculator, una lângă alta (mai jos).
 */
@media (max-width: 759px) {
	.wa-split.has-convo .wa-side { display: none; }
	.wa-split:not(.has-convo) .wa-pane { display: none; }
	/* Pagina din spate nu se mai derulează: se derulează doar mesajele. */
	html.wa-page, html.wa-page body { height: 100%; overflow: hidden; overscroll-behavior: none; }
}

/* Antetul: înapoi, inițialele, numele — mereu sus */
.wa-head {
	flex: none; display: flex; align-items: center; gap: 8px;
	padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px 4px;
	background: var(--wa-ink); color: #fff; border-bottom: 2px solid var(--wa-gold);
}
.wa-back { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: #fff; text-decoration: none; }
.wa-back:hover, .wa-back:active { background: rgba(255, 255, 255, .1); color: #fff; }
.wa-back svg { width: 24px; height: 24px; }
.wa-avatar { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #f5eddc; color: #7a5a22; font-size: 15px; font-weight: 700; }
.wa-title { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.wa-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; font-weight: 600; }
.wa-title small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: rgba(255, 255, 255, .72); }

/* Mesajele */
.wa-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 6px 12px 14px; }
.wa-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.wa-day { align-self: center; margin: 12px 0 4px; }
.wa-day span { display: inline-block; padding: 5px 12px; border-radius: 8px; background: #fff; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); color: #54656f; font-size: 12.5px; font-weight: 600; }
.wa-msg { display: flex; margin-top: 2px; }
.wa-msg.is-first { margin-top: 10px; }
.wa-msg.is-out { justify-content: flex-end; }
.wa-bubble {
	position: relative; min-width: 0; max-width: 82%; padding: 6px 8px 8px 9px;
	border-radius: 8px; background: var(--wa-in); box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
	font-size: 15.5px; line-height: 1.38;
}
.is-out .wa-bubble { background: var(--wa-out); }
/* Codița bulei, doar la primul mesaj dintr-un șir */
.is-first.is-in .wa-bubble { border-top-left-radius: 0; }
.is-first.is-out .wa-bubble { border-top-right-radius: 0; }
.is-first .wa-bubble::before { content: ""; position: absolute; top: 0; width: 8px; height: 13px; }
.is-first.is-in .wa-bubble::before { left: -8px; background: var(--wa-in); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.is-first.is-out .wa-bubble::before { right: -8px; background: var(--wa-out); clip-path: polygon(0 0, 100% 0, 0 100%); }

.wa-author { display: block; margin-bottom: 1px; font-size: 13px; font-weight: 600; color: var(--wa-gold); }
.wa-label { display: block; margin: 1px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--wa-meta); }
.wa-label.is-new { color: var(--wa-gold); }
.wa-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-text.is-empty { display: block; line-height: 1; }
/* Loc pentru ora din colț la capătul ultimului rând (mai lat la mesajele tale, care au și bife) */
.wa-spacer { display: inline-block; width: 42px; height: 1px; }
.is-out .wa-spacer { width: 62px; }
.wa-meta { position: absolute; right: 8px; bottom: 4px; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; line-height: 1; color: var(--wa-meta); white-space: nowrap; }
.wa-ticks { width: 17px; height: 11px; color: #8696a0; }
.wa-ticks.is-read { color: var(--wa-blue); }

/* Tema: fișierele ca documentele din WhatsApp; numele lung se scurtează, nu iese din bulă */
.wa-bubble.is-doc { width: 82%; padding: 4px 4px 8px; }
.wa-bubble.is-doc .wa-label, .wa-bubble.is-doc .wa-author, .wa-bubble.is-doc .wa-text, .wa-bubble.is-doc .wa-withdraw-form { margin-left: 6px; margin-right: 6px; }
.wa-bubble.is-doc .wa-label, .wa-bubble.is-doc .wa-author { margin-top: 5px; margin-bottom: 6px; }
/* Mesaj doar cu fișiere: rămâne loc pentru ora din colț sub ultimul document. */
.wa-bubble.is-doc .wa-text.is-empty { height: 12px; }
.wa-doc {
	display: flex; align-items: center; gap: 10px; min-width: 0; margin: 0 0 4px; padding: 8px 10px;
	border-radius: 6px; background: rgba(11, 20, 26, .05); color: var(--wa-text); text-decoration: none;
}
.is-out .wa-doc { background: rgba(11, 20, 26, .06); }
.wa-doc:hover, .wa-doc:active { background: rgba(11, 20, 26, .09); color: var(--wa-text); }
.wa-doc-icon {
	flex: none; display: grid; place-items: center; width: 36px; height: 44px; border-radius: 4px;
	background: #fff; box-shadow: 0 0 0 1px rgba(11, 20, 26, .08); color: #b3261e; font-size: 9.5px; font-weight: 800; letter-spacing: .02em;
}
.wa-doc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wa-doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; font-weight: 500; }
.wa-doc-size { font-size: 12px; color: var(--wa-meta); }
.wa-bubble.is-doc .wa-text { display: block; margin-top: 4px; }
.wa-withdraw-form { margin: 2px 0 0; }
.wa-withdraw { padding: 2px 0; border: 0; background: none; color: #b3261e; font: 600 13px inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

.wa-empty { align-self: center; max-width: 320px; margin: 24px auto 0; padding: 10px 14px; border-radius: 8px; background: #fff3c4; color: #54656f; font-size: 13.5px; line-height: 1.45; text-align: center; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); }

/* Jos: câmpul de scris, lipit de marginea ecranului */
.wa-foot { flex: none; max-height: 70%; overflow-y: auto; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); background: #f0f2f5; }
/* Cu tastatura deschisă, câmpul stă lipit de ea: fără locul pentru bara de jos a telefonului. */
.wa.is-typing .wa-foot { padding-bottom: 6px; }
.wa-compose { display: flex; align-items: flex-end; gap: 6px; }
/* 16 px: altfel iPhone-ul mărește pagina când apeși în câmp. */
.wa-compose textarea {
	flex: 1; min-width: 0; min-height: 44px; max-height: 140px; padding: 11px 15px; resize: none;
	border: 0; border-radius: 22px; background: #fff; outline: none;
	font: 16px/1.35 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--wa-text);
}
.wa-send { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--wa-green); color: #fff; cursor: pointer; }
.wa-send svg { width: 22px; height: 22px; }
.wa-send:disabled { opacity: .55; cursor: progress; }
/* „Temă”: deschide camera sau fișierele telefonului (la student) */
.wa-attach {
	flex: none; display: inline-flex; align-items: center; gap: 5px; height: 44px; padding: 0 12px 0 10px; border-radius: 22px;
	background: #fff; color: #54656f; font-size: 14px; font-weight: 600; cursor: pointer;
}
.wa-attach svg { width: 20px; height: 20px; }
.wa-attach.is-working { opacity: .6; pointer-events: none; }
.wa-primary {
	display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px; border-radius: 24px;
	background: var(--wa-green); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
}
.wa-primary svg { width: 20px; height: 20px; }
.wa-error { margin: 0 6px 6px; font-size: 13.5px; color: #b3261e; }

/* Fișierele alese de profesor, înainte de trimitere: câte o etichetă cu × pentru scos */
.wa-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.wa-files { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.wa-file-chip {
	display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 4px 4px 10px;
	border-radius: 16px; background: #fff; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); font-size: 13.5px; color: var(--wa-text);
}
.wa-file-chip b { flex: none; font-size: 10px; font-weight: 800; color: #b3261e; }
.wa-file-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.wa-file-chip small { flex: none; color: var(--wa-meta); font-size: 12px; }
.wa-file-chip button { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--wa-meta); font-size: 18px; line-height: 1; cursor: pointer; }
.wa-file-chip button:hover { background: #fcebea; color: #b3261e; }

/*
 * Pe calculator, ca o aplicație de mesaje pe tot ecranul (sub bara de sus): lista în stânga, conversația în dreapta,
 * fiecare cu derularea ei. Nu imităm telefonul: culorile site-ului — bule fără codiță, mesajele tale pe albastru
 * deschis, butonul de trimitere bleumarin. Pagina (public.css, front.css) îi lasă ecranul întreg.
 */
@media (min-width: 760px) {
	.wa-split {
		flex: 1; min-height: 0; display: grid; grid-template-columns: clamp(280px, 30%, 380px) minmax(0, 1fr);
		background: #fff; border-top: 1px solid #e6e1d6;
	}
	.wa-side { min-height: 0; overflow-y: auto; padding: 20px 18px 28px; background: #fbfaf7; border-right: 1px solid #e6e1d6; }
	.wa-pane { min-width: 0; min-height: 0; display: flex; }
	.wa {
		position: relative; top: auto !important; left: auto; right: auto; z-index: auto;
		flex: 1; height: auto !important; min-height: 0; background: #fff;
	}
	/* Nimic de ales încă: un îndemn liniștit, pe fundalul conversației. */
	.wa-placeholder {
		flex: 1; display: grid; place-items: center; padding: 40px; background: #f7f5f0;
		color: #6b7180; font-size: 16px; text-align: center;
	}
	.wa-placeholder p { max-width: 340px; margin: 0; }
	/* Lista e mereu la vedere în stânga: săgeata „înapoi” din antet nu mai e nevoie. */
	.wa-split .wa-back { display: none; }
	.wa-head { padding: 12px 24px; background: #fff; color: var(--wa-ink); border-bottom: 1px solid #e6e1d6; }
	.wa-back { color: var(--wa-ink); }
	.wa-back:hover, .wa-back:active { background: #f6f4ef; color: var(--wa-ink); }
	.wa-title strong { font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif; font-size: 19px; }
	.wa-title small { color: #6b7180; }
	.wa-body { padding: 10px 32px 20px; background: #f7f5f0; }
	.wa-day span { background: #fff; box-shadow: none; border: 1px solid #e6e1d6; color: #6b7180; }
	/* Pe un ecran lat, bulele nu se întind cât rândul: textul rămâne ușor de citit. */
	.wa-bubble { max-width: min(68%, 640px); border: 1px solid #e6e1d6; border-radius: 12px; box-shadow: none; }
	.is-out .wa-bubble { background: #e9eef8; border-color: #d6deee; }
	.is-first.is-in .wa-bubble, .is-first.is-out .wa-bubble { border-radius: 12px; }
	.is-first .wa-bubble::before { display: none; }
	.wa-bubble.is-doc { width: min(70%, 440px); }
	.wa-doc { background: rgba(22, 33, 58, .04); }
	.wa-author { color: #8a6424; }
	.wa-foot { padding: 12px 24px; background: #fff; border-top: 1px solid #e6e1d6; }
	.wa-compose textarea { border: 1px solid #e6e1d6; background: #fcfbf8; }
	.wa-compose textarea:focus { border-color: var(--wa-ink); background: #fff; box-shadow: 0 0 0 3px rgba(22, 33, 58, .08); }
	.wa-send, .wa-primary { background: var(--wa-ink); }
	.wa-attach { border: 1px solid #e6e1d6; }
	.wa-empty { background: #fff; border: 1px solid #e6e1d6; box-shadow: none; }
}
