/* WordPress theme token integration */
[class*="rv-"] {
	--mhm-primary: var(--wp--preset--color--primary, #2271b1);
	--mhm-font-base: var(--wp--preset--font-size--normal, 1rem);
	--mhm-radius: var(--wp--preset--border-radius, 4px);
	--mhm-text: var(--wp--preset--color--foreground, #1d2327);
}

.rv-shortcode-wrapper,
[class*="rv-"] {
	white-space: normal;
}

/**
 * Customer Messages CSS
 * Müşteri mesaj paneli stilleri
 */

/* Utility: hide toggled views (list / thread / new-message form are mutually exclusive). */
.mhm-messages-section .hidden,
.mhm-messages-section .thread-reply.hidden,
.mhm-messages-section .new-message-form.hidden,
.mhm-messages-section .message-thread.hidden {
	display: none !important;
}

/* Portal Section */
.messages-section {
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 8px;
	padding: 20px;
	margin-bottom: 20px;
}

.messages-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
	padding-bottom: 15px;
	border-bottom: 1px solid #eee;
}

.messages-header h3 {
	margin: 0;
	color: #333;
	font-size: 1.5em;
}

/* Messages List */
.messages-list {
	min-height: 200px;
}

.message-item {
	position: relative;
	background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
	border: 1px solid #e4e7ef;
	border-radius: 12px;
	padding: 16px 18px;
	margin-bottom: 12px;
	cursor: pointer;
	transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.message-item::before {
	content: "";
	position: absolute;
	left: 0;
	top: 14px;
	bottom: 14px;
	width: 3px;
	border-radius: 0 3px 3px 0;
	background: transparent;
	transition: background 0.18s ease;
}

.message-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10px;
	flex-wrap: wrap;
	gap: 8px;
}

.message-id {
	font-weight: 700;
	color: #4f46e5;
	font-size: 0.8125rem;
	background: #eef2ff;
	border: 1px solid #e0e7ff;
	padding: 3px 10px;
	border-radius: 999px;
	letter-spacing: 0.02em;
}

.status-badge-new {
	background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
	color: #fff;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 10.5px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	white-space: nowrap;
	box-shadow: 0 2px 6px rgba(245, 158, 11, 0.25);
}

.message-item:hover {
	border-color: #c7d2fe;
	transform: translateY(-2px);
	box-shadow: 0 8px 20px rgba(79, 70, 229, 0.08);
}

.message-item:hover::before {
	background: linear-gradient(180deg, #6366f1, #4f46e5);
}

.message-item.unread {
	background: linear-gradient(180deg, #fffdf5 0%, #fff8e1 100%);
	border-color: #fde68a;
}

.message-item.unread::before {
	background: linear-gradient(180deg, #f59e0b, #d97706);
}

.message-subject {
	font-weight: 700;
	color: #111827;
	margin-bottom: 6px;
	font-size: 0.9375rem;
	line-height: 1.35;
}

@media (max-width: 600px) {
	.message-item {
		padding: 14px 16px;
		border-radius: 10px;
	}

	.message-header {
		margin-bottom: 8px;
	}

	.message-id {
		font-size: 0.75rem;
	}
}

.message-info {
	margin-bottom: 8px;
}

.message-meta {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	align-items: center;
	font-size: 0.9em;
	color: #666;
	margin-top: 8px;
}

.message-meta span {
	padding: 4px 10px;
	border-radius: 4px;
	font-size: 0.85em;
}

.message-category {
	background: #e7f3ff;
	color: #2271b1;
	font-weight: 500;
	border: 1px solid #b3d9ff;
}

.message-category.category-booking {
	background: #fff3cd;
	color: #856404;
	border-color: #ffeaa7;
}

.message-category.category-support {
	background: #d1ecf1;
	color: #0c5460;
	border-color: #bee5eb;
}

.message-category.category-general {
	background: #e9ecef;
	color: #495057;
	border-color: #ced4da;
}

.message-date {
	display: flex;
	gap: 8px;
	align-items: center;
}

.message-date .date-relative {
	background: #e7f3ff;
	color: #2271b1;
	border: 1px solid #b3d9ff;
	padding: 4px 10px;
	border-radius: 4px;
	font-weight: 500;
	font-size: 0.85em;
	white-space: nowrap;
}

.message-date .date-full {
	background: #f8f9fa;
	color: #6c757d;
	border: 1px solid #dee2e6;
	padding: 4px 10px;
	border-radius: 4px;
	font-size: 0.85em;
	white-space: nowrap;
}

.message-meta .status {
	background: #d1ecf1;
	color: #0c5460;
}

.message-meta .date {
	background: #f8d7da;
	color: #721c24;
}

.message-preview {
	color: #666;
	font-size: 0.9em;
	line-height: 1.4;
	margin-top: 8px;
}

/* Message Thread */
.message-thread {
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 20px;
}

.thread-header {
	display: flex;
	align-items: center;
	gap: 15px;
	margin-bottom: 20px;
	padding-bottom: 15px;
	border-bottom: 1px solid #eee;
}

.thread-header h4 {
	margin: 0;
	color: #333;
}

.back-to-list {
	background: #6c757d;
	color: white;
	border: none;
	padding: 8px 15px;
	border-radius: 4px;
	cursor: pointer;
	text-decoration: none;
	display: inline-block;
	font-size: 0.9em;
}

.back-to-list:hover {
	background: #5a6268;
	color: white;
}

.thread-messages {
	margin-bottom: 20px;
}

/* Chat bubble layout — customer (self) right, admin (other) left. */
.thread-messages-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 8px 0;
}

.thread-message-item {
	max-width: 70%;
	padding: 10px 14px;
	border-radius: 14px;
	line-height: 1.5;
	word-wrap: break-word;
}

.thread-message-item.customer-message {
	align-self: flex-end;
	background: #2563eb;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.thread-message-item.admin-message {
	align-self: flex-start;
	background: #f3f4f6;
	color: #1f2937;
	border-bottom-left-radius: 4px;
}

.thread-message-item .message-header {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 4px;
	font-size: 12px;
	opacity: 0.85;
}

.thread-message-item.customer-message .message-header strong { color: rgba(255, 255, 255, 0.95); }
.thread-message-item.admin-message    .message-header strong { color: #374151; }

.thread-message-item .message-date { opacity: 0.7; font-size: 11px; }
.thread-message-item .message-content { margin: 0; }
.thread-message-item .message-content p:last-child { margin-bottom: 0; }

@media (max-width: 600px) {
	.thread-message-item { max-width: 88%; }
}

/* Thread Reply */
.thread-reply {
	background: #f8f9fa;
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 20px;
}

.form-group {
	margin-bottom: 15px;
}

.form-group label {
	display: block;
	margin-bottom: 5px;
	font-weight: 600;
	color: #333;
}

.form-group textarea {
	width: 100%;
	min-height: 100px;
	padding: 10px;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-family: inherit;
	font-size: 14px;
	resize: vertical;
}

.form-actions {
	display: flex;
	gap: 10px;
	margin-top: 15px;
}

.form-actions .button {
	padding: 12px 24px;
	border: none;
	border-radius: 6px;
	cursor: pointer;
	text-decoration: none;
	display: inline-block;
	font-size: 14px;
	font-weight: 600;
	transition: background-color 0.2s ease;
}

.button-primary {
	background: #2271b1;
	color: white;
}

.button-primary:hover {
	background: #135e96;
	color: white;
}

.button:not(.button-primary) {
	background: #6c757d;
	color: white;
}

.button:not(.button-primary):hover {
	background: #5a6268;
	color: white;
}

/* New Message Form */
.new-message-form {
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 20px;
	margin-top: 20px;
}

.form-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
	padding-bottom: 15px;
	border-bottom: 1px solid #eee;
}

.form-header h4 {
	margin: 0;
	color: #333;
}

.close-form {
	background: #dc3545;
	color: white;
	border: none;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	cursor: pointer;
	font-size: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.close-form:hover {
	background: #c82333;
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
	width: 100%;
	padding: 10px;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 14px;
	font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group select:focus,
.form-group textarea:focus {
	outline: none;
	border-color: #2271b1;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

/* No Messages */
.no-messages {
	text-align: center;
	padding: 40px;
	color: #666;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 6px;
}

/* Unread Count Badge */
.unread-count {
	background: #dc3545;
	color: white;
	border-radius: 50%;
	padding: 2px 6px;
	font-size: 0.8em;
	font-weight: bold;
	margin-left: 5px;
	display: none;
}

.unread-count:not(:empty) {
	display: inline-block;
}

/* Loading States */
.loading {
	text-align: center;
	padding: 40px;
	color: #666;
}

.loading::after {
	content: '';
	display: inline-block;
	width: 20px;
	height: 20px;
	border: 2px solid #f3f3f3;
	border-top: 2px solid #2271b1;
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin-left: 10px;
}

@keyframes spin {
	0% {
		transform: rotate(0deg);
	}

	100% {
		transform: rotate(360deg);
	}
}

/* Responsive Design */
@media (max-width: 782px) {
	.messages-header {
		flex-direction: column;
		gap: 15px;
		align-items: stretch;
	}

	.thread-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}

	.message-meta {
		flex-direction: column;
		gap: 5px;
	}

	.form-actions {
		flex-direction: column;
	}

	.form-actions .button {
		width: 100%;
		text-align: center;
	}
}

/* Tab Integration */
.tab-button {
	position: relative;
}

.tab-button .unread-count {
	position: absolute;
	top: -5px;
	right: -5px;
	min-width: 18px;
	height: 18px;
	line-height: 18px;
	text-align: center;
	font-size: 0.7em;
}

/* Success/Error Messages */
.message-success {
	background: #d4edda;
	color: #155724;
	border: 1px solid #c3e6cb;
	border-radius: 4px;
	padding: 10px 15px;
	margin-bottom: 15px;
}

.message-error {
	background: #f8d7da;
	color: #721c24;
	border: 1px solid #f5c6cb;
	border-radius: 4px;
	padding: 10px 15px;
	margin-bottom: 15px;
}
