/* Layout Global de la Messagerie */
#app {
	display: flex;
	width: 100%;
	height: calc(90vh - 60px); /* Ajusté pour laisser la place au nav fixed */
	/*margin-top: 10px;*/
	position: relative;
	overflow: hidden;
	text-align: left; /* Annule le text-align: center du body */
}

/* Liste des conversations (Sidebar) */
.sidebar {
	width: 320px;
	border-right: 0.5px solid rgba(0, 0, 0, 0.1);
	display: flex;
	flex-direction: column;
	background: #fff;
	transition: transform 0.3s ease;
}
.new_msg_wrap {
	text-align: center;
	margin: 0 5px 5px 5px;
}

.conv-list {
	flex: 1;
	overflow-y: auto;
}

.wide {
	width: 100%;
}

.conv-item {
	border-bottom: 1px solid var(--grey);
	transition: background 0.2s;
	display: flex;
	align-items: center;
	padding: 0.6rem 0.75rem;
	gap: 0.75rem;
	cursor: pointer;

}

.conv-item:hover {
	background-color: var(--primary-hover);
}

.conv-item.active, .media-tab.active {
	background-color: var(--primary-hover) !important;
	border-right: 10px solid var(--primary);
	box-shadow: 0 0px 20px rgba(0, 0, 0, 0.08);
}

.conv-item .last-msg {
	font-size: 0.85rem;
	color: var(--text-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 250px;
}

.conv-item.active .last-msg {
	color: var(--secondary);
}

/* Zone de Discussion Main */
.chat-view {
	flex: 1;
	display: flex;
	flex-direction: column;
	background-color: var(--bg-light);
}

.chat-header {
	padding: 8px 20px;
	font-family: var(--font-titles);
	font-weight: 700;
	border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
	background: #fff;
	display: flex;
	align-items: center;
	gap: 12px;
}

#chatTitle {
  display: flex;
  flex-direction: column;
}

.back-btn {
	display: none;
	background: none;
	border: none;
	font-size: 1.2rem;
	cursor: pointer;
	color: var(--secondary);
	padding: 0 8px;
}

.messages-container {
	flex: 1;
	padding: 20px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* Bulles de message */
.message {
	/*max-width: 65%;*/
	max-width: 300px;
	padding: 10px 14px;
	border-radius: 8px;
	font-size: 0.95rem;
	line-height: 1.4;
	overflow-wrap: anywhere;
}

.message img {
	max-width: 100%;
	max-height: 250px;
	object-fit: cover; /* Recadre proprement sans déformer */
	border-radius: 5px;
}

.message.sent {
	align-self: flex-end;
	background-color: var(--primary);
	color: var(--secondary);
	border-bottom-right-radius: 2px;
}

.message.sent .user-id {
	color: var(--secondary);
}

.message.received {
	align-self: flex-start;
	background-color: #fff;
	color: var(--secondary);
	border: 0.5px solid rgba(0, 0, 0, 0.1);
	border-bottom-left-radius: 2px;
}

.message .time {
	font-size: 11px;
	margin-top: 4px;
	text-align: right;
	color: var(--text-muted);
}

.empty-state {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	color: var(--text-muted);
}

/* Formulaire d'envoi réutilisant vos règles existantes */
#form_new_msg_chat {
	margin: 0;
	width: auto;
	max-width: 100%;
	padding: 12px 20px;
	background: #fff;
	border-top: 0.5px solid rgba(0, 0, 0, 0.08);
	display: flex;
	gap: 10px;
	align-items: center;
}

#form_new_msg_chat textarea {
	flex: 1;
	min-height: 40px;
	height: 40px;
}

#form_new_msg_chat textarea:focus {
	border-color: var(--secondary);
}

#form_new_msg_chat button {
	height: 40px;
	padding: 0 10px;
}

/* Adaptation Responsive Mobile */
@media (max-width: 768px) {
	.sidebar {
		width: 100%;
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		z-index: 2;
	}

	.chat-view {
		width: 100%;
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		z-index: 1;
	}

	.back-btn {
		display: block;
	}

	#app.mobile-chat .sidebar {
		transform: translateX(-100%);
	}

	#app.mobile-chat .chat-view {
		z-index: 3;
	}
	

	#form_new_user div, #form_new_msg div {
		grid-template-columns: 1fr !important;
		text-align: left;
	}
	#form_new_user label, #form_new_msg label {
		text-align: center !important;
	}
}