/**
 * Messages Module - Theme Integrated
 * Uses global CSS variables
 */

.msg-module { 
	font-size: 14px; 
}

/* Card - using existing card styles, just overrides */
.msg-module .card {
	background: var(--card-bg);
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-lg);
}

.msg-module .card-header {
	padding: 12px 16px;
	background: var(--card-header-bg);
	border-bottom: 1px solid var(--border-subtle);
	display: flex !important;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	font-family: 'Orbitron', sans-serif;
	font-weight: 600;
	color: var(--text-primary);
}

.msg-module .card-header a {
	color: var(--primary-accent);
}

.msg-header-info {
	display: flex;
	align-items: center;
	gap: 0;
	flex: 1;
	min-width: 0;
	overflow: hidden;
}

.msg-module .card-header .msg-actions {
	display: flex !important;
	visibility: visible !important;
	opacity: 1 !important;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

.msg-module .card-header .msg-actions .msg-btn {
	padding: 8px 14px;
	font-size: 12px;
	white-space: nowrap;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
}

.msg-module .card-header .msg-actions .msg-btn-danger {
	padding: 8px 12px;
}

.msg-module .card-body {
	padding: 20px;
}

/* Standalone card for send message */
.msg-card {
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-lg);
	margin-bottom: 15px;
	background: var(--card-bg);
}

.msg-card-header {
	padding: 16px 20px;
	border-bottom: 1px solid var(--border-subtle);
	background: var(--card-header-bg);
	font-family: 'Orbitron', sans-serif;
	font-weight: 600;
	color: var(--text-primary);
}

.msg-card-header a {
	color: var(--primary-accent);
}

.msg-card-body { 
	padding: 20px; 
}

/* Header elements */
.msg-header-users a { 
	font-weight: 600;
	color: var(--primary-accent);
}

.msg-header-topic {
	color: var(--text-muted);
	font-size: 12px;
	font-family: 'Exo 2', sans-serif;
	font-weight: 400;
	margin-left: 10px;
	padding-left: 10px;
	border-left: 1px solid var(--border-medium);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 200px;
}

.msg-arrow {
	color: var(--text-muted);
	margin: 0 6px;
	font-size: 12px;
}

/* Tabs */
.msg-tabs { 
	display: flex; 
	gap: 8px; 
}

.msg-tab {
	padding: 6px 16px;
	border: 1px solid var(--border-medium);
	border-radius: var(--radius-md);
	background: transparent;
	cursor: pointer;
	transition: all 0.2s ease;
	color: var(--text-secondary);
	font-size: 13px;
	font-family: inherit;
}

.msg-tab:hover { 
	background: var(--hover-bg);
	color: var(--text-primary);
	border-color: var(--primary-accent-alpha);
}

.msg-tab-active {
	background: var(--primary-accent-alpha);
	border-color: var(--primary-accent);
	color: var(--primary-accent);
	font-weight: 600;
}

/* Buttons */
.msg-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px 16px;
	border: 1px solid var(--border-medium);
	border-radius: var(--radius-md);
	background: var(--bg-input);
	cursor: pointer;
	text-decoration: none;
	color: var(--text-secondary);
	transition: all 0.2s ease;
	font-size: 13px;
	font-family: inherit;
}

.msg-btn:hover {
	background: var(--hover-bg);
	border-color: var(--primary-accent-alpha);
	color: var(--text-primary);
	text-decoration: none;
}

.msg-btn-danger { 
	border-color: var(--danger-alpha);
	color: var(--danger);
	background: var(--alert-danger-bg);
}

.msg-btn-danger:hover { 
	background: var(--danger);
	border-color: var(--danger);
	color: #fff;
}

.msg-btn-unread {
	background: var(--primary-accent-alpha);
	border-color: var(--primary-accent);
	color: var(--text-primary);
	font-weight: 600;
}

.msg-btn-primary {
	background: var(--btn-primary-bg);
	border-color: var(--primary-accent);
	color: var(--btn-primary-text);
}

.msg-btn-primary:hover {
	box-shadow: var(--accent-glow);
	transform: translateY(-1px);
}

/* Forms */
.msg-form-row {
	margin-bottom: 20px;
}

.msg-form-row label {
	display: block;
	margin-bottom: 8px;
	font-weight: 500;
	color: var(--text-secondary);
}

.msg-input {
	width: 100%;
	padding: 12px 16px;
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
	background: var(--bg-input);
	color: var(--text-primary);
	font: inherit;
	font-size: 14px;
	box-sizing: border-box;
	transition: all 0.2s ease;
}

.msg-input:focus {
	outline: none;
	border-color: var(--primary-accent);
	box-shadow: var(--input-focus-shadow);
	background: var(--bg-elevated);
}

.msg-input::placeholder {
	color: var(--text-muted);
}

.msg-input:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.msg-form-actions {
	display: flex;
	gap: 12px;
	margin-top: 24px;
}

/* Actions bar - list items */
.msg-list-body .msg-btn {
	padding: 6px 12px;
	font-size: 12px;
	white-space: nowrap;
}

/* Load more */
.msg-load-more {
	text-align: center;
	padding: 12px;
	border-bottom: 1px solid var(--border-subtle);
	margin-bottom: 15px;
}

.msg-load-more a {
	color: var(--primary-accent);
	font-size: 13px;
	text-decoration: none;
	transition: color 0.2s ease;
}

.msg-load-more a:hover {
	color: var(--primary-accent-light);
}

/* Conversation container */
.msg-conversation {
	max-height: calc(100vh - 350px);
	min-height: 200px;
	overflow-y: scroll;
	padding: 16px;
	background: var(--bg-input);
	border-radius: var(--radius-md);
	border: 1px solid var(--border-subtle);
}

/* Message bubbles */
.msg-bubble {
	max-width: 75%;
	margin-bottom: 12px;
	padding: 12px 16px;
	border-radius: var(--radius-lg);
	border: 1px solid var(--border-subtle);
	background: var(--bg-card);
	position: relative;
}

.msg-own {
	margin-left: auto;
	background: var(--primary-accent-alpha);
	border-color: rgba(0, 212, 170, 0.2);
	border-bottom-right-radius: var(--radius-sm);
}

.msg-other {
	margin-right: auto;
	border-bottom-left-radius: var(--radius-sm);
}

.msg-bubble-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 8px;
	font-size: 12px;
}

.msg-sender { 
	font-weight: 600;
	color: var(--text-primary);
}

.msg-sender a { 
	color: var(--primary-accent);
	text-decoration: none;
}

.msg-sender a:hover {
	text-decoration: underline;
}

.msg-time { 
	color: var(--text-muted);
	font-size: 11px;
}

.msg-bubble-body {
	line-height: 1.6;
	word-wrap: break-word;
	color: var(--text-primary);
}

.msg-bubble-body img { 
	max-width: 100%; 
	border-radius: var(--radius-sm); 
}

.msg-bubble-body a {
	color: var(--primary-accent);
}

.msg-bubble-foot {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 10px;
	font-size: 11px;
}

.msg-del {
	margin-left: auto;
	opacity: 0;
	font-size: 16px;
	text-decoration: none;
	color: var(--text-muted);
	transition: all 0.2s ease;
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: transparent;
}

.msg-bubble:hover .msg-del { 
	opacity: 1;
	color: var(--danger);
	background: var(--danger-alpha);
}

.msg-del:hover {
	color: #fff !important;
	background: var(--danger) !important;
	transform: scale(1.1);
}

/* Badges */
.msg-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 10px;
	border-radius: 12px;
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.msg-badge:not([class*="msg-new"]):not([class*="msg-unread"]):not([class*="msg-seen"]):not([class*="msg-deleted"]) {
	background: var(--icon-bg);
	color: var(--text-secondary);
}

.msg-new {
	background: var(--danger);
	color: #fff;
	animation: msg-pulse 2s infinite;
}

.msg-unread { 
	background: var(--primary-accent-alpha);
	color: var(--primary-accent);
}

.msg-seen { 
	background: var(--alert-success-bg);
	color: var(--alert-success-text);
}

.msg-deleted { 
	background: var(--alert-danger-bg);
	color: var(--alert-danger-text);
}

@keyframes msg-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.6; }
}

/* Typing indicator */
.msg-typing {
	padding: 8px 0;
	font-size: 13px;
	color: var(--text-muted);
	font-style: italic;
}

/* Reply box */
.msg-reply { 
	margin-top: 16px; 
}

.msg-reply-row {
	position: relative;
	display: flex;
	align-items: center;
}

.msg-reply-row .msg-input {
	width: 100%;
	resize: none;
	min-height: 52px;
	max-height: 150px;
	padding: 14px 110px 14px 16px;
	line-height: 1.5;
	overflow-y: auto;
}

.msg-reply-row .msg-btn { 
	position: absolute;
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
	padding: 10px 18px;
	height: auto;
}

/* Notice */
.msg-notice {
	padding: 16px;
	text-align: center;
	background: var(--alert-danger-bg);
	border: 1px solid var(--alert-danger-border);
	border-radius: var(--radius-md);
	margin-top: 16px;
	color: var(--alert-danger-text);
}

/* Empty state */
.msg-empty {
	text-align: center;
	padding: 60px 20px;
	color: var(--text-muted);
}

.msg-empty::before {
	content: '\f0e0';
	font-family: 'Font Awesome 5 Free';
	font-weight: 400;
	display: block;
	font-size: 48px;
	margin-bottom: 16px;
	opacity: 0.3;
}

/* Message list */
.msg-list-item {
	padding: 16px;
	border-bottom: 1px solid var(--border-subtle);
	transition: background 0.2s ease;
}

.msg-list-item:last-child { 
	border-bottom: none; 
}

.msg-list-item:hover {
	background: var(--hover-bg);
}

.msg-list-item.msg-unread { 
	background: var(--primary-accent-alpha);
	border-left: 3px solid var(--primary-accent);
}

.msg-list-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10px;
	font-size: 13px;
}

.msg-list-users {
	color: var(--text-secondary);
}

.msg-list-users a { 
	font-weight: 500;
	color: var(--primary-accent);
	text-decoration: none;
}

.msg-list-users a:hover {
	text-decoration: underline;
}

.msg-list-date { 
	color: var(--text-muted);
	font-size: 12px;
}

.msg-list-body {
	display: flex;
	gap: 10px;
	align-items: center;
}

.msg-list-body .msg-btn { 
	flex: 1; 
	text-align: left;
	justify-content: flex-start;
}

.msg-list-body .msg-btn-danger {
	flex: 0 0 auto;
	padding: 8px 12px;
}

/* Scrollbar - always visible */
.msg-conversation::-webkit-scrollbar,
#messages_box::-webkit-scrollbar { 
	width: 8px; 
}

.msg-conversation::-webkit-scrollbar-track,
#messages_box::-webkit-scrollbar-track { 
	background: var(--bg-elevated);
	border-radius: 4px;
}

.msg-conversation::-webkit-scrollbar-thumb,
#messages_box::-webkit-scrollbar-thumb {
	background: var(--primary-accent-alpha);
	border-radius: 4px;
	border: 2px solid var(--bg-elevated);
}

.msg-conversation::-webkit-scrollbar-thumb:hover,
#messages_box::-webkit-scrollbar-thumb:hover { 
	background: var(--primary-accent);
}

/* Firefox scrollbar */
.msg-conversation,
#messages_box {
	scrollbar-width: thin;
	scrollbar-color: var(--primary-accent-alpha) var(--bg-elevated);
}

/* Responsive */
@media (max-width: 768px) {
	.msg-bubble { 
		max-width: 90%; 
	}
	
	.msg-module .card-header { 
		flex-direction: column; 
		align-items: flex-start;
		gap: 12px;
	}
	
	.msg-tabs {
		width: 100%;
	}
	
	.msg-tab {
		flex: 1;
		text-align: center;
	}
	
	.msg-reply-row { 
		flex-direction: column;
		align-items: stretch;
	}
	
	.msg-reply-row .msg-btn { 
		width: 100%;
		height: auto;
		padding: 12px;
	}
	
	.msg-list-body {
		flex-direction: column;
		align-items: stretch;
	}
	
	.msg-list-body .msg-btn-danger {
		width: 100%;
	}
}

@media (max-width: 480px) {
	.msg-module .card-body,
	.msg-card-body {
		padding: 12px;
	}
	
	.msg-conversation {
		padding: 10px;
	}
	
	.msg-bubble {
		padding: 10px 12px;
	}
}