/* Copyright (C) 2026 Siliteo / eighteen-ai
 *
 * Styles du chat.
 *
 * ATTENTION : ce fichier est declare dans module_parts['css'], donc charge sur TOUTES
 * les pages de Dolibarr. Tout ce qui n'est pas la pastille de menu doit rester
 * prefixe .dolichat- et ne jamais toucher aux selecteurs du theme, sinon on casse
 * des ecrans qui n'ont rien a voir avec le module.
 */

/* ------------------------------------------------ pastille du menu haut (globale) */
.dolichat-badge {
	position: absolute;
	top: 0;
	right: 2px;
	z-index: 5;
	min-width: 16px;
	padding: 0 4px;
	font-size: 10px;
	font-weight: bold;
	line-height: 16px;
	text-align: center;
	color: #fff;
	background: #2c7be5;
	border-radius: 8px;
	pointer-events: none;   /* ne vole pas le clic destine a l'entree de menu */
}

/* ------------------------------------------------ disposition generale */
.dolichat-app {
	display: flex;
	gap: 12px;
	min-height: 420px;
	height: calc(100vh - 220px);
	margin-top: 8px;
}

/* Rail gauche : pastilles a initiales (contacts), grappes (groupes), visiteurs. */
.dolichat-side {
	flex: 0 0 64px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 8px 4px;
	border: 1px solid rgba(128, 128, 128, .25);
	border-radius: 12px;
	overflow: hidden;
}
.dolichat-rail {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	width: 100%;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 2px 0;
}
.dolichat-rail-add {
	flex: none;
	width: 34px;
	height: 34px;
	border: 1px dashed rgba(128, 128, 128, .6);
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}
.dolichat-rail-add:hover { border-style: solid; background: rgba(128, 128, 128, .12); }
.dolichat-rail-sep {
	flex: none;
	width: 60%;
	border-top: 1px solid rgba(128, 128, 128, .3);
	margin: 2px 0;
}

.dolichat-av {
	position: relative;
	flex: none;
	cursor: pointer;
}
.dolichat-av.closed { opacity: .4; }
.dolichat-av-circle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: #d35400;	/* les visiteurs du site ; les contacts recoivent leur couleur en ligne */
	color: #fff;
	font-weight: 600;
	font-size: 15px;
	letter-spacing: .5px;
	user-select: none;
}
.dolichat-av:hover .dolichat-av-circle { filter: brightness(1.08); }
.dolichat-av.active .dolichat-av-circle { box-shadow: 0 0 0 3px #2c7be5; }

/* Un groupe : grappe de trois petites bulles portant les initiales du groupe. */
.dolichat-cluster {
	position: relative;
	display: block;
	width: 42px;
	height: 42px;
}
.dolichat-av-mini {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	border: 2px solid var(--colorbackbody, #fff);
	user-select: none;
}
.dolichat-av-mini:nth-child(1) { top: 0; left: 9px; z-index: 3; }
.dolichat-av-mini:nth-child(2) { bottom: 0; left: 0; z-index: 2; }
.dolichat-av-mini:nth-child(3) { bottom: 0; right: 0; z-index: 1; }
.dolichat-av.active .dolichat-cluster { border-radius: 50%; box-shadow: 0 0 0 3px #2c7be5; }

.dolichat-av-badge {
	position: absolute;
	top: -4px;
	right: -6px;
	z-index: 4;
	min-width: 17px;
	padding: 0 4px;
	font-size: 10px;
	font-weight: bold;
	line-height: 17px;
	text-align: center;
	color: #fff;
	background: #e63757;
	border-radius: 9px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.dolichat-av-watch {
	position: absolute;
	bottom: -2px;
	right: -4px;
	z-index: 4;
	width: 15px;
	height: 15px;
	font-size: 10px;
	font-weight: bold;
	line-height: 15px;
	text-align: center;
	color: #fff;
	background: #d35400;
	border-radius: 50%;
}

.dolichat-main {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
	border: 1px solid rgba(128, 128, 128, .25);
	border-radius: 4px;
	overflow: hidden;
}

/* Sur telephone, le rail reste a gauche (il est etroit) : il retrecit juste un peu. */
@media (max-width: 767px) {
	.dolichat-side { flex-basis: 56px; }
	.dolichat-av-circle, .dolichat-cluster { width: 38px; height: 38px; }
	.dolichat-messages { min-height: 240px; }
}

.dolichat-tag {
	display: inline-block;
	padding: 0 5px;
	font-size: 10px;
	line-height: 15px;
	border: 1px solid rgba(128, 128, 128, .45);
	border-radius: 3px;
	opacity: .8;
	vertical-align: middle;
}
.dolichat-tag-ext { border-color: #2c7be5; color: #2c7be5; }
.dolichat-tag-watch { border-color: #d35400; color: #d35400; }

/* ------------------------------------------------ salon ouvert */
.dolichat-roomheader {
	padding: 8px 10px;
	border-bottom: 1px solid rgba(128, 128, 128, .2);
}
.dolichat-head-title { font-weight: 600; }
.dolichat-head-actions { float: right; }

.dolichat-roompanel {
	padding: 8px 10px;
	border-bottom: 1px solid rgba(128, 128, 128, .2);
	background: rgba(128, 128, 128, .06);
	font-size: .92em;
}
.dolichat-roompanel.hidden { display: none; }
.dolichat-panel-row { margin-top: 6px; }
.dolichat-remove { opacity: .7; }

/* ------------------------------------------------ fil de messages, facon iMessage */
.dolichat-messages {
	position: relative;	/* offsetTop local : le defilement vers "Nouveaux messages" s'y fie */
	flex: 1;
	overflow-y: auto;
	padding: 12px 10px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.dolichat-msg { margin-bottom: 2px; max-width: 78%; }
.dolichat-msg + .dolichat-msg { margin-top: 8px; }
.dolichat-msg.mine { margin-left: auto; }
.dolichat-msg.theirs { margin-right: auto; }

.dolichat-msg-name {
	font-size: .72em;
	opacity: .6;
	margin: 0 0 1px 14px;
}
.dolichat-msg.mine .dolichat-msg-name { text-align: right; margin: 0 14px 1px 0; }

.dolichat-msg-row {
	display: flex;
	align-items: center;
	gap: 6px;
}
.dolichat-msg.mine .dolichat-msg-row { flex-direction: row-reverse; }

.dolichat-msg-body {
	position: relative;	/* porte les pastilles de reactions sur son coin */
	display: inline-block;
	padding: 7px 12px;
	border-radius: 18px;
	background: #e9e9eb;
	color: #111;
	font-size: 14px;
	line-height: 1.35;
	text-align: left;
	word-break: break-word;
	white-space: normal;
}
.dolichat-msg.mine .dolichat-msg-body { background: #0a84ff; color: #fff; }
.dolichat-msg.mine .dolichat-msg-body a { color: #fff; text-decoration: underline; }
.dolichat-msg.guest .dolichat-msg-body { background: #ffe8d6; color: #5b2c00; }

/* Heure (toute petite) + lien "Creer un ticket" juste apres, revele au survol. */
.dolichat-msg-meta {
	font-size: .68em;
	opacity: .55;
	margin: 2px 14px 0;
}
.dolichat-msg.mine .dolichat-msg-meta { text-align: right; }
.dolichat-ticketlink {
	margin-left: 6px;
	visibility: hidden;
	text-decoration: none;
	color: #2c7be5;
}
.dolichat-msg:hover .dolichat-ticketlink { visibility: visible; }

/* Bouton "reagir", discret a cote de la bulle, revele au survol du message. */
.dolichat-react-btn {
	flex: none;
	width: 22px;
	height: 22px;
	padding: 0;
	border: 1px solid rgba(128, 128, 128, .4);
	border-radius: 50%;
	background: transparent;
	color: inherit;
	opacity: 0;
	font-size: 13px;
	line-height: 1;
	cursor: pointer;
}
.dolichat-msg:hover .dolichat-react-btn { opacity: .6; }
.dolichat-react-btn:hover { opacity: 1 !important; background: rgba(128, 128, 128, .12); }

/* Pastilles de reactions : a cheval sur le coin haut de la bulle, comme iMessage. */
.dolichat-reacts {
	position: absolute;
	top: -12px;
	right: -6px;
	display: flex;
	gap: 2px;
}
.dolichat-msg.mine .dolichat-reacts { right: auto; left: -6px; }
.dolichat-react-chip {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	padding: 1px 6px;
	font-size: 12px;
	line-height: 17px;
	background: var(--colorbackbody, #fff);
	border: 1px solid rgba(128, 128, 128, .35);
	border-radius: 10px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
	cursor: pointer;
	user-select: none;
}
.dolichat-react-chip.me { border-color: #0a84ff; background: #e5f1ff; }
.dolichat-react-n { font-size: 10px; opacity: .7; color: #111; }

/* Le nuancier des six reactions (tapbacks), pose pres de la bulle visee. */
.dolichat-picker {
	position: fixed;
	z-index: 10010;
	display: flex;
	gap: 2px;
	padding: 4px 6px;
	background: var(--colorbackbody, #fff);
	border: 1px solid rgba(128, 128, 128, .35);
	border-radius: 18px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.dolichat-picker button {
	border: none;
	background: transparent;
	font-size: 17px;
	padding: 2px 4px;
	cursor: pointer;
	border-radius: 50%;
}
.dolichat-picker button:hover { background: rgba(128, 128, 128, .15); transform: scale(1.15); }

/* Trait "Nouveaux messages" : la lecture reprend ici. */
.dolichat-unread-sep {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 10px 0;
	color: #e63757;
	font-size: .72em;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .5px;
}
.dolichat-unread-sep::before, .dolichat-unread-sep::after {
	content: '';
	flex: 1;
	border-top: 1px solid #e63757;
	opacity: .5;
}

/* ------------------------------------------------ envoi */
.dolichat-sendform {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: flex-start;
	padding: 8px 10px;
	border-top: 1px solid rgba(128, 128, 128, .2);
}
.dolichat-sendform textarea {
	flex: 1;
	min-width: 180px;
	resize: vertical;
}
.dolichat-hint { flex-basis: 100%; }
.dolichat-sendform.hidden { display: none; }

/* ------------------------------------------------ boites de creation */
.dolichat-modal {
	position: fixed;
	inset: 0;
	z-index: 1500;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, .35);
}
.dolichat-modal.hidden { display: none; }
.dolichat-modal-box {
	background: var(--colorbackbody, #fff);
	border-radius: 6px;
	padding: 16px;
	min-width: 280px;
	max-width: 92vw;
	box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.dolichat-modal-title { font-weight: 600; margin-bottom: 10px; }
.dolichat-modal-actions { margin-top: 12px; }
.dolichat-block { display: block; width: 100%; box-sizing: border-box; }

/* ------------------------------------------------ widget flottant (toutes les pages)
 * La bulle est posee par js/widget.js en position:fixed, left/top pilotes par le
 * script (deplacable, position retenue). z-index au-dessus du theme mais sous rien
 * d'essentiel : les modales Dolibarr (jnotify ~30000) restent devant. */
.dolichat-fab {
	position: fixed;
	z-index: 9990;
	width: 52px;
	height: 52px;
}
.dolichat-fab-btn {
	position: relative;
	width: 52px;
	height: 52px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: #2c7be5;
	color: #fff;
	cursor: pointer;
	box-shadow: 0 3px 12px rgba(0, 0, 0, .3);
	touch-action: none;	/* le glisser au doigt ne doit pas faire defiler la page */
}
.dolichat-fab-btn:hover { background: #2368c4; }
.dolichat-fab-btn svg { width: 26px; height: 26px; vertical-align: middle; }
.dolichat-fab-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 18px;
	padding: 0 5px;
	font-size: 11px;
	font-weight: bold;
	line-height: 18px;
	text-align: center;
	color: #fff;
	background: #e63757;
	border-radius: 9px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}

/* Infobulle "nouveau message", juste sous la bulle (ou au-dessus pres du bord bas). */
.dolichat-tip {
	position: absolute;
	width: 280px;
	max-width: calc(100vw - 24px);
	padding: 8px 26px 8px 10px;
	font-size: 12px;
	line-height: 1.4;
	color: #fff;
	background: #343a40;
	border-radius: 6px;
	box-shadow: 0 3px 12px rgba(0, 0, 0, .35);
	cursor: pointer;
}
.dolichat-tip.below { top: calc(100% + 8px); }
.dolichat-tip.above { bottom: calc(100% + 8px); }
.dolichat-tip.alignleft { left: 0; }
.dolichat-tip.alignright { right: 0; }
.dolichat-tip-close {
	position: absolute;
	top: 2px;
	right: 8px;
	font-size: 14px;
	opacity: .7;
	cursor: pointer;
}
.dolichat-tip-close:hover { opacity: 1; }
.dolichat-tip-track { overflow: hidden; white-space: nowrap; }
.dolichat-tip-text {
	display: inline-block;
	max-width: 100%;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;	/* texte fixe une fois le marquee termine */
	vertical-align: bottom;
}
/* Pendant les 10 premieres secondes (classe retiree ensuite par widget.js) : le texte
 * entre par la droite et defile en continu, a la marquee. */
.dolichat-tip-text.dolichat-marquee {
	max-width: none;
	overflow: visible;
	padding-left: 100%;
	animation: dolichat-marquee 9s linear infinite;
}
@keyframes dolichat-marquee {
	from { transform: translateX(0); }
	to   { transform: translateX(-100%); }
}

/* Panneau de chat ancre a la bulle : une iframe de index.php?widget=1. */
.dolichat-panel {
	position: fixed;
	z-index: 9991;
	display: flex;
	flex-direction: column;
	background: var(--colorbackbody, #fff);
	border: 1px solid rgba(128, 128, 128, .35);
	border-radius: 8px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, .35);
	overflow: hidden;
}
.dolichat-panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 6px 10px;
	background: #2c7be5;
	color: #fff;
	font-weight: 600;
}
.dolichat-panel-tools { display: flex; gap: 10px; align-items: center; }
.dolichat-panel-full, .dolichat-panel-close {
	color: #fff;
	font-size: 15px;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	opacity: .85;
}
.dolichat-panel-full:hover, .dolichat-panel-close:hover { opacity: 1; color: #fff; }
.dolichat-panel-frame {
	flex: 1;
	width: 100%;
	border: none;
	background: var(--colorbackbody, #fff);
}
