*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 基础和通用样式 */
:root {
	--primary-color: #007aff;
	--danger-color: #dc3545;
	--success-color: #28a745;
	--warning-color: #ffc107;
	--gray-100: #f8f9fa;
	--gray-200: #e9ecef;
	--gray-500: #6c757d;
	--gray-700: #495057;
	--gray-900: #212529;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	background-color: var(--gray-100);
	color: var(--gray-700);
	margin: 0;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* 加载动画 */
#initialLoader {
	position: fixed;
	inset: 0;
	background-color: white;
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.3s ease-out;
}
#initialLoader.fade-out {
	opacity: 0;
}
.loading-spinner .spinner-icon {
	animation: rotate 1.5s linear infinite;
}
.loading-spinner .spinner-circle {
	stroke: var(--primary-color);
	stroke-linecap: round;
	animation: dash 1.5s ease-in-out infinite;
}
@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
	0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
	50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
	100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* 登录页面 */
#loginPage {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}
.login-card {
	background: white;
	padding: 2.5rem;
	border-radius: 1rem;
	box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
	width: 100%;
	max-width: 420px;
	text-align: center;
}
.login-title {
	font-size: 1.875rem;
	font-weight: 700;
	color: var(--gray-900);
}
.form-input {
	width: 100%;
	padding: 0.75rem 1rem;
	border: 1px solid var(--gray-200);
	border-radius: 0.5rem;
	font-size: 1rem;
	transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

/* 按钮样式 */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.625rem 1.25rem;
	border-radius: 0.5rem;
	font-weight: 600;
	font-size: 0.9375rem;
	border: 1px solid transparent;
	cursor: pointer;
	transition: all 0.2s;
	text-decoration: none;
}
.btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}
.btn-primary {
	background-color: var(--primary-color);
	color: white;
}
.btn-primary:hover:not(:disabled) {
	background-color: #0062cc;
}
.btn-outline {
	background-color: white;
	color: var(--gray-700);
	border-color: var(--gray-200);
}
.btn-outline:hover:not(:disabled) {
	background-color: var(--gray-100);
	border-color: #ced4da;
}
.btn-danger {
	background-color: var(--danger-color);
	color: white;
}
.btn-danger:hover:not(:disabled) {
	background-color: #c82333;
}
.btn-icon {
	background: none;
	border: none;
	padding: 0.5rem;
	color: var(--gray-500);
}
.btn-icon:hover:not(:disabled) {
	color: var(--gray-900);
	background-color: var(--gray-100);
}
.btn-sm {
	padding: 0.375rem 0.75rem;
	font-size: 0.875rem;
}

/* 主应用界面 */
.hidden { display: none !important; }
.navbar {
	background-color: white;
	padding: 1rem 2rem;
	box-shadow: 0 1px 3px rgba(0,0,0,0.05);
	position: sticky;
	top: 0;
	z-index: 50;
}
.navbar-container {
	display: flex;
	justify-content: space-between;
	align-items: center;
	max-width: 1280px;
	margin: 0 auto;
}
.navbar-brand {
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--gray-900);
}
.navbar-actions {
	display: flex;
	align-items: center;
	gap: 1rem;
}

/* 用户信息样式 */
.user-info {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 1rem;
	background-color: var(--gray-100);
	border-radius: 0.5rem;
	font-weight: 500;
	color: var(--gray-700);
	font-size: 0.9rem;
}
.user-info svg {
	width: 16px;
	height: 16px;
	color: var(--gray-500);
}

.main-container {
	max-width: 1280px;
	margin: 2rem auto;
	padding: 0 2rem;
}

/* 集成代码容器 */
.integration-wrapper {
	position: relative;
}

/* 集成代码弹出层样式 */
.integration-popover {
	position: absolute;
	top: calc(100% + 0.5rem);
	right: 0;
	z-index: 1000;
	width: 600px;
	max-width: calc(100vw - 2rem);
	background: white;
	border-radius: 0.75rem;
	box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
	border: 1px solid var(--gray-200);
}

.integration-popover-content {
	padding: 1.5rem;
}
.code-block {
	background-color: #1e293b;
	border-radius: 0.5rem;
	overflow: hidden;
	margin-bottom: 1.5rem;
}
.code-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.75rem 1rem;
	background-color: #0f172a;
	border-bottom: 1px solid #334155;
}
.code-title {
	color: #94a3b8;
	font-size: 0.875rem;
	font-weight: 500;
}
.btn-copy {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.375rem 0.75rem;
	background-color: #334155;
	color: #e2e8f0;
	border: none;
	border-radius: 0.375rem;
	font-size: 0.8125rem;
	cursor: pointer;
	transition: all 0.2s;
}
.btn-copy:hover {
	background-color: #475569;
}
.btn-copy.copied {
	background-color: var(--success-color);
	color: white;
}
.code-content {
	padding: 1rem;
	margin: 0;
	overflow-x: auto;
	color: #e2e8f0;
	font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
	font-size: 0.875rem;
	line-height: 1.5;
	white-space: pre;
}
.integration-tips {
	background-color: #f0f9ff;
	border: 1px solid #e0f2fe;
	border-radius: 0.5rem;
	padding: 1rem;
}
.integration-tips h4 {
	margin: 0 0 0.5rem 0;
	color: #0369a1;
	font-size: 0.9375rem;
}
.integration-tips ul {
	margin: 0;
	padding-left: 1.5rem;
	color: #0c4a6e;
}
.integration-tips li {
	margin-bottom: 0.375rem;
}
.integration-tips code {
	background-color: #dbeafe;
	padding: 0.125rem 0.375rem;
	border-radius: 0.25rem;
	font-size: 0.8125rem;
	font-family: monospace;
}

/* 模态框 - 响应式缩放版本 */
.modal {
	position: fixed;
	inset: 0;
	background-color: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	padding: 1rem;
}

.modal-content {
	background: white;
	border-radius: 1rem;
	box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
	width: 90vw; /* 使用视口宽度 */
	max-width: 600px;
	max-height: 85vh; /* 使用视口高度 */
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.modal-header {
	padding: 1.5rem;
	font-size: 1.25rem;
	font-weight: 600;
	border-bottom: 1px solid var(--gray-200);
	flex-shrink: 0;
}

.modal-body {
	padding: 1.5rem;
	overflow-y: auto;
	flex: 1;
	-webkit-overflow-scrolling: touch;
}

.modal-footer {
	padding: 1rem 1.5rem;
	border-top: 1px solid var(--gray-200);
	display: flex;
	justify-content: flex-end;
	gap: 0.75rem;
	flex-shrink: 0;
	background-color: white;
}

/* 移动端等比例缩放 */
@media (max-width: 768px) {
	.modal {
		padding: 0.5rem;
	}

	.modal-content {
		width: calc(100vw - 1rem); /* 留出边距 */
		max-height: calc(100vh - 1rem);
		/* 使用缩放来适配内容 */
		font-size: 14px; /* 基准字体缩小 */
	}

	.modal-header {
		padding: 1rem;
		font-size: 1.1rem; /* 等比例缩小 */
	}

	.modal-body {
		padding: 1rem;
	}

	/* 表单元素等比例缩小 */
	.form-group {
		margin-bottom: 0.875rem;
	}

	.form-label {
		font-size: 0.875rem;
	}

	.form-input {
		padding: 0.5rem 0.75rem;
		font-size: 16px; /* iOS防止缩放 */
	}

	textarea.form-input {
		min-height: 60px;
	}

	.modal-footer {
		padding: 0.875rem 1rem;
		gap: 0.5rem;
	}

	.modal-footer .btn {
		padding: 0.5rem 1rem;
		font-size: 0.875rem;
	}

	/* 表单网格保持单列 */
	.form-grid, .form-grid-inline {
		grid-template-columns: 1fr;
		gap: 0.875rem;
	}
}

/* 横屏模式优化 */
@media (max-height: 500px) and (orientation: landscape) {
	.modal-content {
		max-height: 95vh;
	}

	.modal-header {
		padding: 0.75rem 1rem;
		font-size: 1rem;
	}

	.modal-body {
		padding: 0.75rem 1rem;
	}

	.modal-footer {
		padding: 0.75rem 1rem;
	}
}

/* 恢复原有的响应式样式（不影响卡片） */
@media (max-width: 768px) {
	/* 导航栏和主要布局 */
	.navbar {
		padding: 1rem;
		position: relative;
	}
	.navbar-brand {
		font-size: 1.25rem;
	}
	.navbar-actions {
		flex-wrap: wrap;
		gap: 0.5rem;
	}

	.integration-wrapper {
		display: none;
	}
	.user-info {
		padding: 0.375rem 0.75rem;
		font-size: 0.8125rem;
	}
	.main-container {
		padding: 0 1rem;
		margin: 1rem auto;
	}
	#adListContainer {
		grid-template-columns: 1fr;
		gap: 1rem;
	}
	/* 移动端集成代码弹出层调整 */
	.integration-popover {
		position: fixed;
		top: 50%;
		left: 50%;
		right: auto;
		transform: translate(-50%, -50%);
		width: calc(100vw - 2rem);
		max-height: calc(100vh - 4rem);
		overflow-y: auto;
	}
	.integration-popover-content {
		padding: 1rem;
	}
	.code-content {
		font-size: 0.75rem;
	}
}

/* Toggle Switch */
.toggle-switch {
	position: relative;
	display: inline-block;
	width: 50px;
	height: 28px;
}
.toggle-switch input {
	opacity: 0;
	width: 0;
	height: 0;
}
.toggle-slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: #ccc;
	transition: .4s;
	border-radius: 28px;
}
.toggle-slider:before {
	position: absolute;
	content: "";
	height: 20px;
	width: 20px;
	left: 4px;
	bottom: 4px;
	background-color: white;
	transition: .4s;
	border-radius: 50%;
}
input:checked + .toggle-slider {
	background-color: var(--primary-color);
}
input:checked + .toggle-slider:before {
	transform: translateX(22px);
}

/* 通知 */
#notificationContainer {
	position: fixed;
	top: 1rem;
	right: 1rem;
	z-index: 2000;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}
.notification {
	background-color: white;
	padding: 1rem 1.5rem;
	border-radius: 0.5rem;
	box-shadow: 0 4px 12px rgba(0,0,0,0.15);
	display: flex;
	align-items: center;
	gap: 0.75rem;
	transform: translateX(120%);
	transition: transform 0.3s ease-in-out;
	min-width: 280px;
}
.notification.show {
	transform: translateX(0);
}
.notification-icon {
	width: 1.25rem;
	height: 1.25rem;
}
.notification-success { border-left: 4px solid var(--success-color); }
.notification-success .notification-icon { color: var(--success-color); }
.notification-error { border-left: 4px solid var(--danger-color); }
.notification-error .notification-icon { color: var(--danger-color); }

/* 空状态和加载状态 */
.loading-state, .empty-state {
	text-align: center;
	padding: 4rem 1rem;
	color: var(--gray-500);
	grid-column: 1 / -1;
}
.loading-state .loading-spinner {
	margin: 0 auto 1rem;
	width: 3rem;
	height: 3rem;
}
.empty-state svg {
	width: 4rem;
	height: 4rem;
	margin: 0 auto 1rem;
	color: var(--gray-200);
}

/* 卡片列表 */
#adListContainer {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 1.5rem;
}

/* 卡片容器 (管理后台专用) */
.admin-card-container {
	background-color: white;
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0,0,0,.1);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* 管理信息和操作区域 */
.admin-card-footer {
	padding: 0.75rem 1rem;
	border-top: 1px solid #e5e7eb;
	background-color: #f9fafb;
	margin-top: auto;
}
.admin-card-info {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 0.8rem;
	color: var(--gray-500);
	margin-bottom: 0.75rem;
}
.admin-card-actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.75rem;
}
.status-badge {
	padding: 0.2rem 0.5rem;
	border-radius: 999px;
	font-weight: 600;
	font-size: 0.7rem;
	text-transform: uppercase;
}
.status-active {
	background-color: rgba(40, 167, 69, 0.1);
	color: #1d7b34;
}
.status-inactive {
	background-color: rgba(108, 117, 125, 0.1);
	color: var(--gray-500);
}

/* 卡片链接容器 */
.xai-card-wrapper-link {
	text-decoration: none;
	color: inherit;
	display: block;
	transition: transform 0.2s;
}
.xai-card-wrapper-link:hover {
	transform: translateY(-2px);
}

/* 整合并覆盖的卡片样式 */
.xai-card-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: none;
  background: #fff;
  border: none;
  border-radius: 3px;
  box-shadow: none;
  z-index: 1;
  font-size: 13px;
  line-height: 1.6;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.xai-card-wrapper .card-image-container {
  width: 100%;
  height: 180px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.xai-card-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.xai-card-wrapper .card-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.xai-card-wrapper .card-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
  color: #111827;
}
.xai-card-wrapper .card-content {
  color: #4b5563;
  margin-bottom: 12px;
  max-height: 100px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.xai-card-wrapper .card-footer{
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.xai-card-wrapper .card-brand {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-primary { color: var(--primary-color); text-decoration: none; }

/* 表单相关样式 */
.form-group {
	margin-bottom: 1rem;
}
.form-label {
	display: block;
	margin-bottom: 0.5rem;
	font-weight: 500;
	color: var(--gray-700);
}
.form-grid, .form-grid-inline {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 1rem;
	align-items: end;
}
.col-span-2 {
	grid-column: span 2 / span 2;
}
textarea.form-input {
	min-height: 80px;
	resize: vertical;
}
/* 注册相关样式 */
.auth-switch {
	margin-top: 1.5rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--gray-200);
	text-align: center;
	color: var(--gray-500);
}

.auth-link {
	color: var(--primary-color);
	text-decoration: none;
	font-weight: 500;
	transition: color 0.2s;
}

.auth-link:hover {
	color: #0062cc;
}

.hover\:underline:hover {
	text-decoration: underline;
}

.form-hint {
	display: block;
	margin-top: 0.5rem;
	font-size: 0.75rem;
	color: var(--gray-500);
}

.success-message {
	text-align: center;
	padding: 2rem;
}

.success-icon {
	width: 4rem;
	height: 4rem;
	margin: 0 auto 1rem;
	color: var(--success-color);
}

.success-message h3 {
	font-size: 1.25rem;
	font-weight: 600;
	color: var(--gray-900);
	margin-bottom: 0.5rem;
}

.success-message p {
	color: var(--gray-600);
	margin-bottom: 0;
}

/* 按钮加载状态 */
.btn.loading {
	position: relative;
	color: transparent;
}

.btn.loading::after {
	content: '';
	position: absolute;
	width: 1rem;
	height: 1rem;
	top: 50%;
	left: 50%;
	margin-left: -0.5rem;
	margin-top: -0.5rem;
	border: 2px solid #ffffff;
	border-radius: 50%;
	border-top-color: transparent;
	animation: button-loading-spinner 0.8s linear infinite;
}

@keyframes button-loading-spinner {
	from { transform: rotate(0turn); }
	to { transform: rotate(1turn); }
}

/* 表单动画 */
.hidden {
	display: none !important;
}

form {
	transition: opacity 0.3s ease-in-out;
}

/* 响应式优化 */
@media (max-width: 768px) {
	.auth-switch {
		margin-top: 1rem;
		padding-top: 1rem;
	}

	.success-message {
		padding: 1.5rem;
	}

	.success-icon {
		width: 3rem;
		height: 3rem;
	}

	.success-message h3 {
		font-size: 1.125rem;
	}

	.success-message p {
		font-size: 0.875rem;
	}
}

