/*
 * User Communication — front-end styles.
 *
 * Self-contained where it matters: fields use .uc-field (NOT the theme's
 * .form-group — bi1-compat.css gives .form-group labels a 2.5rem line-height
 * meant for the 1.x floating-label pattern, which breaks plain label+input
 * markup and causes the overlaps). Inputs keep .form-control for the site's
 * input look. Sections and chats both use the WordPress core accordion
 * block, styled by the core per-block stylesheets plus the child theme;
 * the chat level is differentiated here (smaller, darker tint).
 *
 * Colors hook into the theme palette variables (italiawp3-child/style.css).
 */

/* Base typography: Lora serif, like the rest of the site (inc/fonts.css). */
.uc-gate,
.uc-comunicazioni {
	font-family: 'Lora', Georgia, serif;
}

/* ------------------------------------------------------------------ Gate */

.uc-gate {
	max-width: 480px;
}

.uc-gate p {
	margin: 0 0 1rem;
}

.uc-form {
	margin: 1.75rem 0 0;
}

/* The code form shows up right under the phone form once the code is sent. */
#uc-code-form {
	margin-top: 1rem;
}

.uc-field {
	margin: 0 0 1.25rem;
}

.uc-field label {
	display: block;
	margin: 0 0 0.5rem;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--iwp-testo-scuro, #0a343c);
}

.uc-error {
	margin: 0.5rem 0 0;
	color: #d10000;
	font-size: 0.875rem;
}

/* -------------------------------------------------------------- Toolbar */

/* "Chiudi" sits above the sections, aligned right (see uc_render_tree). */
.uc-head {
	display: flex;
	justify-content: flex-end;
	margin-bottom: 0.75rem;
}

/* Breathing room between a section heading and its chat list. */
.uc-comunicazioni .uc-sections > .wp-block-accordion-item > .wp-block-accordion-panel {
	padding-top: 0.5rem;
}

/* ----------------------------------------------------------- Chat list */

/*
 * Chats reuse the same core accordion markup as the sections, one level
 * down: same rotating chevron, same row rhythm, no separators. The chat
 * level is told apart by a slightly darker tint (var(--iwp-primario)
 * instead of --iwp-primario-testo) and a smaller type size, matching the
 * old chat headers (18px). Specificity (0,3,0) beats the child theme's
 * .wp-block-accordion color rule (0,1,0), which would repaint these rows
 * in the section tint.
 */
.uc-comunicazioni .uc-chats .wp-block-accordion-heading__toggle {
	font-size: 1.125rem;
	color: var(--iwp-primario, #0f4b57);
}

/* Ogni riga chat è rientrata solo a sinistra rispetto alla sezione genitore. */
.uc-comunicazioni .uc-chats > .wp-block-accordion-item {
	padding-left: 1rem;
}

/* Contorno netto per la chat attualmente aperta. */
.uc-comunicazioni .uc-chats > .wp-block-accordion-item.is-open {
	/* border: 1px solid #07748d59; */
}

/* Nelle chat l'icona di espansione è nascosta del tutto: resta solo nelle sezioni. */
.uc-comunicazioni .uc-chats .wp-block-accordion-heading__toggle-icon {
	display: none;
}

/*
 * Fixed columns inside the toggle: the title flexes and gets an
 * ellipsis when too long. Without flex:1 + min-width:0 a long title
 * would overflow the row.
 */
.uc-chat-title {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 600;
	text-align: left;
}

/*
 * La data a destra del titolo non viene più renderizzata: la data è
 * ormai inclusa direttamente nel titolo composto dal backend. Regola
 * commentata insieme al markup .uc-chat-date in uc_render_chat().
 *
.uc-chat-date {
	flex: 0 0 auto;
	margin-left: 0.75rem;
	font-size: 0.875rem;
	font-weight: 400;
	opacity: 0.75;
	white-space: nowrap;
}
*/

/*
 * Open chat: tinted background (site primary-text color at 22% alpha),
 * same box the bootstrap-italia body used to draw, square corners.
 */
.uc-chat-body {
	padding: 0.75rem 1.5rem 2.625rem;
	background-color: #07748d38;
}

.uc-empty {
	padding: 1rem 0.5rem;
	color: var(--iwp-testo-grigio, #444);
}

/* -------------------------------------------------------------- Thread */

/* Long conversations scroll inside their own box instead of stretching the page. */
.uc-thread {
	max-height: 24rem;
	overflow-y: auto;
	padding: 0.5rem 0.75rem;
}

/* Day separator: centered label flanked by thin lines in the chat tint. */
.uc-day-separator {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin: 0.25rem 0 0.75rem;
	font-size: 0.75rem;
	color: var(--iwp-testo-scuro, #0a343c);
}

.uc-day-separator::before,
.uc-day-separator::after {
	content: '';
	flex: 1 1 auto;
	border-top: 1px solid #07748d59;
}

/* Bubbles: patient (in) solid white, centralino (out) translucent white. */
.uc-msg {
	display: flex;
	margin-bottom: 0.5rem;
}

.uc-msg.uc-mine {
	justify-content: flex-end;
}

.uc-msg.uc-theirs {
	justify-content: flex-start;
}

.uc-bubble {
	max-width: 80%;
	padding: 0.5rem 0.75rem;
	border-radius: 1rem;
	font-size: 0.9375rem;
	line-height: 1.5;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
	/* Messaggi con HTML del backend: URL e parole lunghe non sforano la bolla. */
	overflow-wrap: break-word;
}

/*
 * Contenuto HTML consentito nei messaggi (br, p, liste): dentro la bolla
 * questi blocchi devono respirare senza azzerare i margini del chat body.
 */
.uc-bubble p {
	margin: 0.25rem 0;
}

.uc-bubble ul,
.uc-bubble ol {
	margin: 0.25rem 0;
	padding-left: 1.25rem;
}

.uc-mine .uc-bubble {
	background-color: #fff;
	border-bottom-right-radius: 0.25rem;
}

.uc-theirs .uc-bubble {
	background-color: rgba(255, 255, 255, 0.78);
	border-bottom-left-radius: 0.25rem;
}

.uc-msg-time {
	display: block;
	margin-top: 0.25rem;
	text-align: right;
	font-size: 0.6875rem;
	color: var(--iwp-testo-grigio, #444);
}
