/* ──── 基础变量 ──── */
:root {
	--form-gap: 20px;          /* 表单项间距 */
	--section-gap: 28px;       /* 分组间距 */
	--input-h: 40px;           /* 输入框高度 */
	--input-px: 12px;          /* 输入框水平内边距 */
	--input-radius: 8px;       /* 输入框圆角 */
	--label-mb: 6px;           /* Label 下方间距 */
	--hint-mt: 4px;            /* 提示文字上方间距 */
}

/* ──── 导航 ──── */
.nav-item.active {
	background-color: #eff6ff;
	color: #2563eb;
	font-weight: 600;
}
.nav-item.active svg {
	color: #2563eb;
}

/* ──── 卡片 ──── */
.stat-card {
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ──── 表格 ──── */
.data-table th {
	padding: 12px 16px;
	text-align: left;
	font-size: 12px;
	font-weight: 500;
	color: #6b7280;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	background: #f9fafb;
}
.data-table td {
	padding: 12px 16px;
	font-size: 14px;
	color: #374151;
}
.data-table tbody tr:hover td {
	background: #f9fafb;
}

/* ──── 按钮 ──── */
.btn-primary {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: var(--input-h);
	padding: 0 20px;
	border-radius: var(--input-radius);
	background: #2563eb;
	color: #fff;
	font-size: 14px;
	font-weight: 500;
	transition: background 0.15s;
	border: none;
	cursor: pointer;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: var(--input-h);
	padding: 0 20px;
	border-radius: var(--input-radius);
	background: #f3f4f6;
	color: #374151;
	font-size: 14px;
	font-weight: 500;
	transition: background 0.15s;
	border: 1px solid #e5e7eb;
	cursor: pointer;
}
.btn-secondary:hover { background: #e5e7eb; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: var(--input-h);
	padding: 0 20px;
	border-radius: var(--input-radius);
	background: #dc2626;
	color: #fff;
	font-size: 14px;
	font-weight: 500;
	transition: background 0.15s;
	border: none;
	cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; }

/* ──── 表单 ──── */

/* 统一 Label */
.form-label {
	display: block;
	font-size: 13px;
	font-weight: 500;
	color: #374151;
	margin-bottom: var(--label-mb);
	line-height: 1.4;
}

/* Label 中的可选标记 */
.form-label .optional {
	font-weight: 400;
	color: #9ca3af;
	font-size: 12px;
	margin-left: 4px;
}

/* Label 中的必填标记 */
.form-label .required {
	color: #ef4444;
	margin-left: 2px;
}

/* 统一输入框 */
.form-input {
	display: block;
	width: 100%;
	height: var(--input-h);
	padding: 0 var(--input-px);
	border: 1px solid #d1d5db;
	border-radius: var(--input-radius);
	font-size: 14px;
	color: #111827;
	background: #fff;
	transition: border-color 0.15s, box-shadow 0.15s;
	outline: none;
}
.form-input:focus {
	border-color: #3b82f6;
	box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-input:disabled {
	background: #f9fafb;
	color: #9ca3af;
	cursor: not-allowed;
}
.form-input::placeholder {
	color: #9ca3af;
}

/* Textarea 特殊处理 */
textarea.form-input {
	height: auto;
	padding: 10px var(--input-px);
	resize: vertical;
	line-height: 1.5;
}

/* Select 特殊处理 */
select.form-input {
	appearance: none;
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
	background-position: right 10px center;
	background-repeat: no-repeat;
	background-size: 16px;
	padding-right: 36px;
}

/* 提示文本 */
.form-hint {
	display: block;
	margin-top: var(--hint-mt);
	font-size: 12px;
	color: #9ca3af;
	line-height: 1.4;
}
.form-hint code {
	background: #f3f4f6;
	padding: 1px 5px;
	border-radius: 4px;
	font-size: 11px;
	color: #6b7280;
}

/* 单个表单项 */
.form-field {
	display: flex;
	flex-direction: column;
}

/* 表单行（并排字段） */
.form-row {
	display: grid;
	gap: 16px;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* 表单分组 */
.form-section {
	position: relative;
}
.form-section + .form-section {
	margin-top: var(--section-gap);
	padding-top: var(--section-gap);
	border-top: 1px solid #f3f4f6;
}
.form-section-title {
	font-size: 13px;
	font-weight: 600;
	color: #6b7280;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin-bottom: 16px;
}
.form-section-body {
	display: flex;
	flex-direction: column;
	gap: var(--form-gap);
}

/* ──── Modal ──── */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.4);
	z-index: 40;
	display: none;
	align-items: center;
	justify-content: center;
	backdrop-filter: blur(2px);
}
.modal-overlay.active {
	display: flex;
}
.modal-panel {
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 20px 60px rgba(0,0,0,0.15);
	max-width: 540px;
	width: 100%;
	margin: 16px;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid #f3f4f6;
	flex-shrink: 0;
}
.modal-header h3 {
	font-size: 17px;
	font-weight: 600;
	color: #111827;
}
.modal-close {
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	color: #9ca3af;
	transition: background 0.15s, color 0.15s;
	border: none;
	background: transparent;
	cursor: pointer;
}
.modal-close:hover {
	background: #f3f4f6;
	color: #374151;
}
.modal-body {
	padding: 24px;
	overflow-y: auto;
	flex: 1;
}
.modal-footer {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 10px;
	padding: 16px 24px;
	border-top: 1px solid #f3f4f6;
	background: #fafafa;
	flex-shrink: 0;
}

/* ──── Toggle Switch ──── */
.toggle-switch {
	position: relative;
	display: inline-block;
	width: 44px;
	height: 24px;
	flex-shrink: 0;
}
.toggle-switch input { display: none; }
.toggle-track {
	position: absolute;
	inset: 0;
	background: #d1d5db;
	border-radius: 12px;
	transition: background 0.2s;
	cursor: pointer;
}
.toggle-switch input:checked + .toggle-track {
	background: #2563eb;
}
.toggle-track::after {
	content: '';
	position: absolute;
	width: 20px;
	height: 20px;
	background: #fff;
	border-radius: 50%;
	top: 2px;
	left: 2px;
	transition: transform 0.2s;
	box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.toggle-switch input:checked + .toggle-track::after {
	transform: translateX(20px);
}

/* ──── Checkbox ──── */
.form-checkbox {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	padding: 6px 0;
}
.form-checkbox input[type="checkbox"] {
	width: 16px;
	height: 16px;
	border-radius: 4px;
	accent-color: #2563eb;
	cursor: pointer;
}
.form-checkbox span {
	font-size: 14px;
	color: #374151;
}

/* ──── 加载动画 ──── */
.spinner {
	border: 3px solid #f3f3f3;
	border-top: 3px solid #3b82f6;
	border-radius: 50%;
	width: 24px;
	height: 24px;
	animation: spin 0.8s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin {
	from { transform: rotate(0deg); }
	to { transform: rotate(360deg); }
}

/* ──── Toast 动画 ──── */
.toast-enter { animation: slideIn 0.3s ease forwards; }
.toast-exit { animation: slideOut 0.3s ease forwards; }
@keyframes slideIn {
	from { transform: translateX(100%); opacity: 0; }
	to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
	from { transform: translateX(0); opacity: 1; }
	to { transform: translateX(100%); opacity: 0; }
}

/* ──── 预设标签 ──── */
.preset-tag {
	display: inline-flex;
	align-items: center;
	height: 28px;
	padding: 0 10px;
	font-size: 12px;
	color: #4b5563;
	background: #f3f4f6;
	border: 1px solid #e5e7eb;
	border-radius: 6px;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}
.preset-tag:hover {
	background: #e5e7eb;
	border-color: #d1d5db;
}
.preset-tag.active {
	background: #eff6ff;
	border-color: #bfdbfe;
	color: #2563eb;
}

/* ──── 认证方式切换 ──── */
.auth-tabs {
	display: flex;
	gap: 0;
	border: 1px solid #e5e7eb;
	border-radius: var(--input-radius);
	overflow: hidden;
	margin-bottom: 16px;
}
.auth-tab {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: 36px;
	font-size: 13px;
	font-weight: 500;
	color: #6b7280;
	background: #f9fafb;
	border: none;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}
.auth-tab + .auth-tab {
	border-left: 1px solid #e5e7eb;
}
.auth-tab.active {
	background: #eff6ff;
	color: #2563eb;
}
.auth-tab:hover:not(.active) {
	background: #f3f4f6;
}
.auth-group { display: none; }
.auth-group.active { display: flex; flex-direction: column; gap: var(--form-gap); }

/* 认证方式徽章 */
.auth-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	padding: 2px 8px;
	border-radius: 4px;
}
.auth-badge-cookie { background: #fef3c7; color: #92400e; }
.auth-badge-credential { background: #dbeafe; color: #1e40af; }

/* ──── 批量操作工具栏 ──── */
.batch-toolbar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	background: #eff6ff;
	border-bottom: 1px solid #bfdbfe;
	font-size: 13px;
	color: #1e40af;
}
.batch-toolbar .batch-actions {
	display: flex;
	gap: 6px;
	margin-left: auto;
}

/* ──── 登录 / 注册页 ──── */
.auth-page {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 50%, #f5f3ff 100%);
	padding: 24px;
}
.auth-card {
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 4px 24px rgba(0,0,0,0.08);
	width: 100%;
	max-width: 400px;
	overflow: hidden;
}
.auth-card-header {
	padding: 32px 32px 0;
	text-align: center;
}
.auth-card-header h1 {
	font-size: 22px;
	font-weight: 700;
	color: #111827;
}
.auth-card-header p {
	font-size: 14px;
	color: #6b7280;
	margin-top: 6px;
}
.auth-card-body {
	padding: 28px 32px 32px;
	display: flex;
	flex-direction: column;
	gap: 20px;
}
.auth-btn {
	width: 100%;
	height: 44px;
	font-size: 15px;
	margin-top: 4px;
}

/* ──── 响应式：移动端适配 ──── */

/* 侧边栏 overlay */
.sidebar-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.4);
	z-index: 25;
	transition: opacity 0.3s;
}
.sidebar-overlay.active {
	display: block;
}

/* 移动端顶栏 */
.mobile-header {
	display: none;
}

/* ── 平板/手机断点 (<=768px) ── */
@media (max-width: 768px) {
	/* 侧边栏：默认隐藏，滑入动画 */
	#sidebar {
		transform: translateX(-100%);
		transition: transform 0.3s ease;
	}
	#sidebar.mobile-open {
		transform: translateX(0);
	}

	/* 主内容区：全宽 */
	main {
		margin-left: 0 !important;
	}

	/* 显示顶栏 */
	.mobile-header {
		display: flex;
	}

	/* 页面内容内边距缩小 */
	#page-content {
		padding: 16px;
	}
}

/* ── 小屏断点 (<=640px) ── */
@media (max-width: 640px) {
	/* 表单双列回退为单列 */
	.form-row-2,
	.form-row-3 {
		grid-template-columns: 1fr;
	}

	/* 批量操作栏换行 */
	.batch-toolbar {
		flex-wrap: wrap;
	}

	/* 页面标题区换行 */
	.page-header {
		flex-direction: column;
		align-items: flex-start !important;
		gap: 12px;
	}

	/* Modal 缩小内边距 */
	.modal-body {
		padding: 16px;
	}
	.modal-header {
		padding: 16px;
	}
	.modal-footer {
		padding: 12px 16px;
	}
}
