/* ---------------- DESIGN TOKENS ---------------- */
:root {
	--bg-main: #0f1115;
	--bg-card: #171a21;
	--bg-input: #111318;
	--bg-item: #1d212b;
	--bg-item-hover: #2a2f3d;
	--accent: #4f8cff;
	--accent-hover: #3f7be0;
	--success: #38d39f;
	--border-color: #333333;
	--text-main: #f5f7fa;
	--text-muted: #b5bcc8;
	--text-sidebar: #d7dce5;
	--text-status: #7f8794;
	--radius-lg: 16px;
	--radius-md: 12px;
	--radius-sm: 10px;
	--transition: background 0.2s ease, border-color 0.2s ease;
}
/* ---------------- GLOBAL RESET ---------------- */
* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	font-family: Arial, sans-serif;
}
body {
	background: var(--bg-main);
	color: var(--text-main);
	display: flex;
	justify-content: center;
	align-items: center;
	min-height: 100vh;
	padding: 20px;
}
#app {
	width: 100%;
	max-width: 900px;
}
/* ---------------- REUSABLE COMPONENTS ---------------- */
.card {
	background: var(--bg-card);
	padding: 24px;
	border-radius: var(--radius-lg);
	box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}
h1 {
	font-size: 42px;
	margin-bottom: 10px;
}
p {
	color: var(--text-muted);
	margin-bottom: 20px;
}
button {
	background: var(--accent);
	border: none;
	padding: 12px 18px;
	border-radius: var(--radius-sm);
	color: white;
	cursor: pointer;
	font-weight: bold;
	transition: var(--transition);
}
button:hover {
	background: var(--accent-hover);
}
button:disabled, input:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}
input {
	width: 100%;
	background: var(--bg-input);
	border: 1px solid var(--border-color);
	color: white;
	padding: 12px;
	border-radius: var(--radius-sm);
	margin-top: 10px;
	outline: none;
	transition: var(--transition);
}
input:focus {
	border-color: var(--accent);
}
.row {
	display: flex;
	gap: 10px;
}
/* ---------------- FLOATING BUTTONS ---------------- */
#diagBtn {
	position: absolute;
	top: 20px;
	left: 20px;
	cursor: pointer;
	background: var(--bg-item);
	padding: 10px;
	border-radius: 50%;
	border: 1px solid var(--border-color);
	transition: var(--transition);
}
#diagBtn:hover {
	background: var(--bg-item-hover);
}
#settingsBtn {
	position: absolute;
	top: 20px;
	right: 20px;
	font-size: 20px;
	cursor: pointer;
	display: none; /* Crucial: Managed programmatically by JS */
	background: var(--bg-item);
	padding: 10px 12px;
	border-radius: 50%;
	box-shadow: 0 4px 10px rgba(0,0,0,0.3);
	border: 1px solid var(--border-color);
	transition: var(--transition);
}
#settingsBtn:hover {
	background: var(--bg-item-hover);
}
/* ---------------- LANDING PANEL ---------------- */
#landing input {
	margin-bottom: 10px;
}
/* ---------------- CHAT INTERFACE ---------------- */
#chat {
	display: none;
}
#chatLayout {
	display: flex;
	gap: 16px;
}
#sidebar {
	width: 220px;
	background: var(--bg-input);
	border-radius: var(--radius-md);
	padding: 14px;
	flex-shrink: 0;
	height: 500px;
	overflow-y: auto;
}
#sidebar h3 {
	margin-bottom: 12px;
	color: var(--text-sidebar);
	font-size: 16px;
}
#chatMain {
	flex: 1;
}
#status {
	margin-bottom: 15px;
	color: var(--success);
	font-weight: bold;
}
#messages {
	height: 400px;
	overflow-y: auto;
	background: var(--bg-input);
	padding: 15px;
	border-radius: var(--radius-md);
	margin-bottom: 12px;
}
.system {
	color: var(--success);
}
/* Users List Layout */
.user-entry {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px;
	border-radius: var(--radius-sm);
	margin-bottom: 8px;
	background: #1a1e27;
}
.user-entry.offline {
	opacity: 0.45;
}
.user-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	background: #2b3240;
}
.user-meta {
	display: flex;
	flex-direction: column;
}
.user-name {
	font-size: 14px;
}
.user-status {
	font-size: 11px;
	color: var(--text-status);
}
/* ---------------- MODALS ---------------- */
.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,0.7);
	display: none; /* Crucial: Managed programmatically by JS */
	justify-content: center;
	align-items: center;
	z-index: 1000;
}
.modal-content {
	width: 100%;
	max-width: 320px;
	text-align: center;
}
#myAvatarPreview {
	display: none;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	margin: 0 auto 10px auto;
	border: 2px solid var(--accent);
	object-fit: cover;
}
.avatar-cropper-overlay {
	z-index: 2000;
}
.message {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	background: var(--bg-item);
	padding: 10px;
	border-radius: var(--radius-sm);
	margin-bottom: 10px;
}
.message-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}
.message-body {
	display: flex;
	flex-direction: column;
}
.message-text {
	word-break: break-word;
}
.message-time {
	font-size: 10px;
	opacity: 0.6;
	margin-top: 2px;
}
.modal-title {
	margin-bottom: 5px;
}
.modal-subtitle {
	margin-bottom: 15px;
	font-size: 14px;
}
.file-input {
	padding: 8px;
	border: 1px dashed var(--border-color);
	cursor: pointer;
}
.full-width-button {
	width: 100%;
	margin-top: 15px;
}
.spaced-button {
	margin-top: 10px;
}
.ui-root {
	width: 100%;
	display: flex;
	justify-content: center;
}
#chatLayout {
	position: relative;
	overflow: hidden; /* Needed for the absolute mobile menu */
}

#sidebar {
	transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
	z-index: 100;
}

#sidebar.desktop-collapsed {
	width: 0;
	padding-left: 0;
	padding-right: 0;
	opacity: 0;
	margin: 0;
	pointer-events: none;
}

.chat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 15px;
}

#toggleUsersBtn {
	background: var(--bg-item);
	border: 1px solid var(--border-color);
	color: var(--text-main);
	padding: 6px 10px;
	border-radius: var(--radius-sm);
	cursor: pointer;
}

#mobileOverlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
	z-index: 90;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
	border-radius: var(--radius-md);
}

#mobileOverlay.active {
	opacity: 1;
	pointer-events: auto;
}

@media (max-width: 768px) {
	#sidebar {
		position: absolute;
		top: 0;
		left: 0;
		height: 100%;
		transform: translateX(-110%);
		box-shadow: 4px 0 15px rgba(0,0,0,0.5);
	}
	#sidebar.mobile-open {
		transform: translateX(0);
	}
}