/**
 * 消息系统 - 图片消息样式
 *
 * @package    Hui
 * @subpackage Messaging
 * @since      1.1.0
 */

/* ============================================================================
   图片消息
   ========================================================================== */

.hui-messaging-image {
	max-width: 300px;
	max-height: 300px;
	border-radius: var(--xun-radius, 8px);
	cursor: pointer;
	transition: all 0.2s var(--ease-smooth);
	display: block;
}

.hui-messaging-image:hover {
	transform: scale(1.02);
	box-shadow: var(--shadow-md);
}

/* 图片消息气泡 */
.hui-messaging-message-bubble:has(.hui-messaging-image) {
	padding: 4px;
	background: transparent;
}

/* ============================================================================
   上传进度
   ========================================================================== */

.hui-messaging-upload-progress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: var(--color-bg-mask);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 9999;
}

.hui-messaging-upload-progress-inner {
	background: var(--color-bg-container);
	padding: 2rem;
	border-radius: var(--xun-radius-lg, 12px);
	box-shadow: var(--shadow-modal);
	text-align: center;
	min-width: 200px;
}

.hui-messaging-upload-spinner {
	width: 40px;
	height: 40px;
	margin: 0 auto 1rem;
	border: 3px solid var(--color-border);
	border-top-color: var(--xun-secondary, var(--color-secondary));
	border-radius: 50%;
	animation: hui-messaging-spin 0.8s linear infinite;
}

@keyframes hui-messaging-spin {
	to {
		transform: rotate(360deg);
	}
}

.hui-messaging-upload-text {
	color: var(--color-text-secondary);
	font-size: 14px;
}

/* ============================================================================
   图片预览
   ========================================================================== */

.hui-messaging-image-preview-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.9);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10000;
	cursor: pointer;
}

.hui-messaging-image-preview-container {
	position: relative;
	max-width: 90vw;
	max-height: 90vh;
	cursor: default;
}

.hui-messaging-image-preview-container img {
	max-width: 100%;
	max-height: 90vh;
	display: block;
	border-radius: var(--xun-radius, 8px);
}

.hui-messaging-image-preview-close {
	position: absolute;
	top: -40px;
	right: 0;
	width: 40px;
	height: 40px;
	background: rgba(255, 255, 255, 0.1);
	border: none;
	border-radius: 50%;
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	transition: all 0.2s var(--ease-smooth);
}

.hui-messaging-image-preview-close:hover {
	background: rgba(255, 255, 255, 0.2);
	transform: scale(1.1);
}

/* ============================================================================
   响应式
   ========================================================================== */

@media (max-width: 768px) {
	.hui-messaging-image {
		max-width: 200px;
		max-height: 200px;
	}

	.hui-messaging-image-preview-container {
		max-width: 95vw;
		max-height: 95vh;
	}

	.hui-messaging-image-preview-close {
		top: 10px;
		right: 10px;
	}
}


/* ============================================================================
   图片预览容器（输入框上方）
   ========================================================================== */

.hui-messaging-image-preview-container {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	padding: 0.75rem;
	background: var(--color-fill-quaternary);
	border-radius: var(--xun-radius-sm, 6px);
	margin-bottom: 0.75rem;
}

.hui-messaging-image-preview-item {
	position: relative;
	width: 80px;
	height: 80px;
	border-radius: var(--xun-radius-sm, 6px);
	overflow: hidden;
	background: var(--color-bg-container);
	border: 2px solid var(--color-border);
	transition: all 0.2s var(--ease-smooth);
}

.hui-messaging-image-preview-item:hover {
	border-color: var(--xun-secondary, var(--color-secondary));
	box-shadow: var(--shadow-sm);
}

.hui-messaging-image-preview-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.hui-messaging-image-preview-remove {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 20px;
	height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	font-size: 12px;
	transition: all 0.2s var(--ease-smooth);
	opacity: 0;
}

.hui-messaging-image-preview-item:hover .hui-messaging-image-preview-remove {
	opacity: 1;
}

.hui-messaging-image-preview-remove:hover {
	background: var(--color-error);
	transform: scale(1.1);
}

/* 添加更多按钮 */
.hui-messaging-image-preview-add {
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--color-fill-tertiary);
	border: 2px dashed var(--color-border);
	cursor: pointer;
}

.hui-messaging-image-preview-add:hover {
	background: var(--color-fill-secondary);
	border-color: var(--xun-secondary, var(--color-secondary));
}

.hui-messaging-image-preview-add button {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.25rem;
	background: transparent;
	border: none;
	color: var(--color-text-secondary);
	cursor: pointer;
	padding: 0.5rem;
	width: 100%;
	height: 100%;
}

.hui-messaging-image-preview-add button:hover {
	color: var(--xun-secondary, var(--color-secondary));
}

.hui-messaging-image-preview-add i {
	font-size: 1.25rem;
}

.hui-messaging-image-preview-add span {
	font-size: 0.6875rem;
}

/* ============================================================================
   图片预览模态框（查看大图）
   ========================================================================== */

.hui-messaging-image-preview-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.85);
	backdrop-filter: blur(4px);
	animation: fadeIn 0.2s var(--ease-smooth);
}

.hui-messaging-image-preview-modal {
	position: relative;
	max-width: 90vw;
	max-height: 90vh;
	animation: zoomIn 0.3s var(--ease-smooth);
}

.hui-messaging-image-preview-modal img {
	max-width: 100%;
	max-height: 90vh;
	object-fit: contain;
	border-radius: var(--xun-radius, 8px);
	box-shadow: var(--shadow-modal);
}

.hui-messaging-image-preview-close {
	position: absolute;
	top: -40px;
	right: 0;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	font-size: 24px;
	transition: all 0.2s var(--ease-smooth);
}

.hui-messaging-image-preview-close:hover {
	background: rgba(255, 255, 255, 0.3);
	transform: scale(1.1);
}

@keyframes zoomIn {
	from {
		opacity: 0;
		transform: scale(0.9);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

/* ============================================================================
   响应式设计
   ========================================================================== */

@media (max-width: 768px) {
	.hui-messaging-image-preview-item {
		width: 70px;
		height: 70px;
	}

	.hui-messaging-image-preview-modal {
		max-width: 95vw;
		max-height: 95vh;
	}

	.hui-messaging-image-preview-close {
		top: 10px;
		right: 10px;
	}
}
