/* PM Base Structure - Clean Layout */

/* PM Button - desktop: fixed bottom right */
#pm_btn {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 899999;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 50px;
	border-radius: 50%;
	border: none;
	background: rgba(59, 130, 246, 0.9);
	box-shadow: 0 4px 15px rgba(0,0,0,0.2);
	transition: transform 0.2s, box-shadow 0.2s;
}

#pm_btn:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 20px rgba(0,0,0,0.25);
	background: rgba(59, 130, 246, 1);
}

#pm_btn img {
	max-height: 22px;
	width: auto;
	filter: brightness(0) invert(1);
}

#mpm_icon_num {
	position: fixed;
	bottom: 55px;
	right: 10px;
	z-index: 900000;
	font-size: 11px;
	font-weight: bold;
	padding: 2px 6px;
	border-radius: 10px;
	min-width: 18px;
	text-align: center;
	background: #dc3c3c;
	color: #fff;
	pointer-events: none;
}

/* PM Navbar Button - mobile only */
#pm_navbar_btn {
	display: none;
}

/* Navbar buttons container - desktop hidden */
.navbar-buttons-right {
	display: none;
}

/* Main PM Window */
#mpm_div {
	display: none;
	position: fixed;
	bottom: 0;
	right: 0;
	width: 600px;
	height: 380px;
	border-radius: 12px 12px 0 0;
	z-index: 90000000;
	overflow: hidden;
}

#mpm_div[style*="display: block"],
#mpm_div[style*="display:block"] {
	display: flex !important;
	flex-direction: column !important;
}

/* Header */
.pm_header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	flex-shrink: 0;
}

.pm_header_title {
	font-size: 14px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 8px;
}

.pm_header_badge {
	display: none;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 10px;
	min-width: 16px;
	text-align: center;
}

.pm_current_user {
	font-weight: 400;
	opacity: 0.6;
	font-size: 12px;
	margin-left: 6px;
}

.pm_header_actions {
	display: flex;
	align-items: center;
	gap: 6px;
}

.pm_header_btn {
	font-size: 16px;
	cursor: pointer;
	padding: 5px 10px;
	border-radius: 6px;
	border: none;
	opacity: 0.7;
	transition: opacity 0.2s;
}

.pm_header_btn:hover {
	opacity: 1;
}

/* Container - flex row */
.pm_container {
	display: flex;
	flex-direction: row;
	flex: 1;
	min-height: 0;
	overflow: hidden;
}

/* Users List - LEFT side */
#pm_users {
	width: 170px;
	min-width: 170px;
	max-width: 170px;
	flex-shrink: 0;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 6px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	order: 1;
}

#pm_users a {
	display: block;
	padding: 8px 10px;
	text-decoration: none;
	border-radius: 6px;
	font-size: 13px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: background 0.15s;
	flex-shrink: 0;
}

.pm_remove_btn {
	float: left;
	margin-right: 6px;
	font-size: 11px;
	opacity: 0.4;
	cursor: pointer;
}

.pm_remove_btn:hover {
	opacity: 1;
}

/* Messages Area - RIGHT side */
#pm_messages {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	order: 2;
}

#pm_messages_kezdo {
	display: none;
}

.pm_messages {
	display: none;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

.pm_messages.pm_active {
	display: flex;
}

.pm_messages_dd {
	flex: 1;
	overflow-y: auto;
	padding: 10px;
	display: flex;
	flex-direction: column;
}

.pm_messages_d {
	display: flex;
	flex-direction: column;
	gap: 3px;
	margin-top: auto;
}

.pm_regebbi {
	text-align: center;
	padding: 6px;
	font-size: 11px;
	cursor: pointer;
	opacity: 0.5;
	border-radius: 6px;
	margin-bottom: 8px;
}

.pm_regebbi:hover {
	opacity: 0.8;
}

/* Messages */
.pm_message {
	max-width: 75%;
	padding: 8px 12px;
	border-radius: 14px;
	font-size: 13px;
	line-height: 1.4;
	word-wrap: break-word;
}

.pm_message_a {
	align-self: flex-start;
	border-bottom-left-radius: 4px;
}

.pm_message_b {
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}

.pm_message_time {
	font-size: 9px;
	opacity: 0.5;
	margin-bottom: 2px;
}

.pm_message_time span,
.pm_message_time div {
	display: none;
}

/* Images in messages */
.pm_message img {
	max-width: 180px !important;
	max-height: 140px !important;
	border-radius: 8px !important;
	cursor: pointer;
	display: block;
	object-fit: cover;
}

/* Audio player */
.pm_audio_message {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 160px;
}

.pm_audio_message audio {
	display: none;
}

.pm_audio_player {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
}

.pm_audio_play_btn {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	font-size: 12px;
	flex-shrink: 0;
}

.pm_audio_wave {
	flex: 1;
	height: 24px;
	display: flex;
	align-items: center;
	gap: 2px;
	cursor: pointer;
}

.pm_audio_wave_bar {
	width: 2px;
	border-radius: 1px;
}

.pm_audio_time {
	font-size: 11px;
	opacity: 0.7;
	min-width: 30px;
	text-align: right;
	font-family: monospace;
}

/* Status messages */
.pm_latta,
.pm_ir {
	font-size: 10px;
	padding: 4px 10px;
	text-align: right;
	font-style: italic;
	opacity: 0.6;
}

/* Message Form */
.pm_message_form {
	padding: 8px;
	flex-shrink: 0;
}

.pm_message_form form {
	display: flex;
	gap: 6px;
	align-items: flex-end;
}

.pm_message_form textarea {
	flex: 1;
	padding: 8px 12px;
	border-radius: 18px;
	font-size: 13px;
	border: none;
	outline: none;
	min-width: 0;
	resize: none;
	min-height: 20px;
	max-height: 100px;
	line-height: 1.4;
	font-family: inherit;
	overflow-y: auto;
}

.pm_send_btn {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	font-size: 16px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s, opacity 0.15s;
}

.pm_send_btn:hover {
	transform: scale(1.1);
}

.pm_send_btn:active {
	transform: scale(0.95);
}

.pm_message_name {
	display: none;
}

/* Attachment bar */
.pm_attach_bar {
	display: flex;
	gap: 3px;
}

.pm_attach_btn {
	padding: 5px 8px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	border: none;
}

/* Voice recording */
.pm_voice_recording {
	display: none;
	align-items: center;
	gap: 10px;
	padding: 10px;
	border-radius: 10px;
	margin: 6px;
}

.pm_voice_recording.active {
	display: flex;
}

.pm_voice_indicator {
	font-size: 10px;
	animation: pm_blink 1s infinite;
}

@keyframes pm_blink {
	0%, 50% { opacity: 1; }
	51%, 100% { opacity: 0.3; }
}

.pm_voice_timer {
	font-family: monospace;
	font-size: 14px;
	font-weight: bold;
}

.pm_voice_max {
	font-size: 11px;
	opacity: 0.5;
}

.pm_voice_waveform {
	display: flex;
	align-items: center;
	gap: 2px;
	flex: 1;
	height: 24px;
	justify-content: center;
}

.pm_voice_bar {
	width: 2px;
	border-radius: 1px;
	animation: pm_wave 0.5s ease-in-out infinite alternate;
}

@keyframes pm_wave {
	from { height: 6px; }
	to { height: 18px; }
}

.pm_voice_cancel,
.pm_voice_send {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	font-size: 14px;
}

/* Upload progress */
.pm_upload_progress {
	display: none;
	padding: 6px 10px;
	margin: 4px 6px;
	border-radius: 6px;
}

.pm_upload_progress.active {
	display: block;
}

.pm_upload_bar {
	height: 3px;
	border-radius: 2px;
	overflow: hidden;
	margin-bottom: 3px;
}

.pm_upload_fill {
	height: 100%;
	width: 0%;
	transition: width 0.2s;
}

.pm_upload_text {
	font-size: 10px;
	opacity: 0.6;
}

/* Image preview */
.pm_image_preview {
	display: none;
	position: absolute;
	bottom: 50px;
	left: 8px;
	right: 8px;
	border-radius: 10px;
	padding: 10px;
	z-index: 100;
	flex-direction: column;
	align-items: center;
	gap: 10px;
}

.pm_image_preview.active {
	display: flex;
}

.pm_image_preview img {
	max-width: 100%;
	max-height: 180px;
	border-radius: 8px;
	object-fit: contain;
}

.pm_image_preview_actions {
	display: flex;
	gap: 10px;
}

.pm_image_preview_actions button {
	padding: 6px 16px;
	border-radius: 16px;
	cursor: pointer;
	font-size: 13px;
	border: none;
}

/* Emoji picker */
.pm_emoji_picker {
	display: none;
	position: absolute;
	bottom: 50px;
	left: 8px;
	max-width: 280px;
	max-height: 220px;
	border-radius: 10px;
	z-index: 101;
	overflow: hidden;
}

.pm_emoji_picker.active {
	display: block;
}

.pm_emoji_header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 6px 10px;
	font-size: 12px;
	font-weight: 600;
}

.pm_emoji_close {
	background: none;
	border: none;
	font-size: 16px;
	cursor: pointer;
	opacity: 0.5;
}

.pm_emoji_close:hover {
	opacity: 1;
}

.pm_emoji_grid {
	display: grid;
	grid-template-columns: repeat(8, 1fr);
	gap: 2px;
	padding: 6px;
	max-height: 170px;
	overflow-y: auto;
}

.pm_emoji_grid img {
	width: 26px;
	height: 26px;
	cursor: pointer;
	padding: 3px;
	border-radius: 4px;
}

.pm_emoji_preview {
	position: fixed;
	width: 70px;
	height: 70px;
	border-radius: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 9999;
	opacity: 0;
	transform: scale(0.5);
	transition: opacity 0.15s, transform 0.15s;
	pointer-events: none;
}

.pm_emoji_preview.active {
	opacity: 1;
	transform: scale(1);
}

.pm_emoji_preview img {
	width: 48px;
	height: 48px;
}

/* Settings panel */
#pm_settings_panel {
	display: none;
	position: absolute;
	top: 44px;
	right: 8px;
	width: 240px;
	border-radius: 10px;
	z-index: 1000;
	overflow: hidden;
}

.pm_settings_header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 12px;
	font-weight: 600;
	font-size: 13px;
}

.pm_settings_close {
	cursor: pointer;
	font-size: 18px;
	opacity: 0.5;
}

.pm_settings_close:hover {
	opacity: 1;
}

.pm_settings_body {
	padding: 6px 12px 12px;
}

.pm_setting_row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 8px 0;
}

.pm_setting_row label {
	font-size: 12px;
}

.pm_setting_row input[type="checkbox"] {
	width: 16px;
	height: 16px;
}

.pm_setting_row input[type="range"] {
	width: 80px;
}

#pm_volume_value {
	font-size: 11px;
	min-width: 30px;
	text-align: right;
}

.pm_setting_test button {
	padding: 6px 12px;
	border-radius: 6px;
	font-size: 12px;
	border: none;
	cursor: pointer;
}

/* Fullscreen */
#mpm_div.pm_fullscreen {
	width: 100% !important;
	height: 100vh !important;
	height: 100dvh !important;
	border-radius: 0 !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
}

/* Fullscreen overlay */
.pm_overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.7);
	z-index: 899999;
}

.pm_overlay.active {
	display: block;
}

/* Body scroll lock */
body.pm_fullscreen_active {
	overflow: hidden !important;
	position: fixed !important;
	width: 100% !important;
	height: 100% !important;
}

/* ===================== */
/* MOBILE STYLES         */
/* ===================== */
@media (max-width: 991px) {
	/* Hide desktop PM button on mobile/tablet */
	#pm_btn,
	#mpm_icon_num {
		display: none !important;
	}
	
	/* Navbar buttons container - right side */
	.navbar-buttons-right {
		display: flex !important;
		align-items: center;
		gap: 6px;
		position: absolute;
		right: 15px;
		top: 8px;
		z-index: 1050;
	}
	
	/* PM Navbar Button */
	#pm_navbar_btn {
		display: flex !important;
		align-items: center;
		justify-content: center;
		width: 52px;
		height: 40px;
		border: 1px solid rgba(0,0,0,0.1);
		border-radius: 4px;
		background: transparent;
		cursor: pointer;
		position: relative;
	}
	
	#pm_navbar_btn i {
		font-size: 18px;
		color: rgba(0,0,0,0.5);
	}
	
	#pm_navbar_btn .pm_badge {
		position: absolute;
		top: -4px;
		right: -4px;
		background: #dc3c3c;
		color: #fff;
		font-size: 10px;
		font-weight: bold;
		padding: 1px 5px;
		border-radius: 8px;
		min-width: 16px;
		text-align: center;
	}
	
	/* Navbar toggler adjustment */
	.navbar-buttons-right .navbar-toggler {
		position: static;
		margin: 0;
	}

	#pm_fullscreen_btn {
		display: none !important;
	}
}

/* Mobile specific - smaller screens */
@media (max-width: 600px) {

	#mpm_div {
		position: fixed !important;
		top: 0 !important;
		left: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		width: 100% !important;
		height: 100% !important;
		height: 100dvh !important;
		max-height: -webkit-fill-available !important;
		border-radius: 0 !important;
		z-index: 90000000 !important;
		padding-bottom: env(safe-area-inset-bottom, 0) !important;
		box-sizing: border-box !important;
	}

	#mpm_div[style*="display: block"],
	#mpm_div[style*="display:block"] {
		display: flex !important;
		flex-direction: column !important;
	}

	.pm_header {
		padding: 12px 14px;
	}

	.pm_container {
		flex-direction: column;
	}

	/* Users - full screen when no conversation */
	#pm_users {
		width: 100% !important;
		flex: 1;
		padding: 8px;
	}

	#pm_users a {
		padding: 12px 14px;
		font-size: 14px;
		margin: 2px 0;
	}

	/* Hide users when conversation active */
	#pm_users.pm_users_hidden {
		display: none !important;
	}

	/* Messages - full screen */
	#pm_messages {
		position: absolute;
		top: 48px;
		left: 0;
		right: 0;
		bottom: 0;
		display: none;
	}

	#pm_messages.pm_mobile_active {
		display: flex !important;
	}

	.pm_messages_dd {
		padding: 10px;
	}

	.pm_message {
		max-width: 85%;
		padding: 10px 14px;
		font-size: 14px;
	}

	.pm_message_form {
		padding: 10px;
		padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
	}

	.pm_message_form textarea {
		padding: 10px 14px;
		font-size: 15px;
	}

	.pm_message img {
		max-width: 140px !important;
		max-height: 110px !important;
	}

	.pm_emoji_picker {
		left: 5px;
		right: 5px;
		max-width: none;
	}

	.pm_emoji_grid {
		grid-template-columns: repeat(7, 1fr);
	}

	.pm_emoji_grid img {
		width: 30px;
		height: 30px;
	}

	#pm_settings_panel {
		left: 8px;
		right: 8px;
		width: auto;
	}
}