/* Theme variables */
:root{
	--bg: #fbfbfd;
	--panel: #ffffff;
	--text: #1f2328;
	--muted: #6b7280;
	--border: #e5e7eb;
	--primary: #2563eb;
	--primary-600: #1d4ed8;
	--primary-100: #dbeafe;
	--secondary: #6b7280;
	--danger: #dc2626;
	--success-bg: #ecfdf5;
	--success-fg: #065f46;
	--error-bg: #fef2f2;
	--error-fg: #991b1b;
	--shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
	--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
	--radius: 10px;
	--header-height: 72px;
	--transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark){
	:root{
		--bg: #0b0f14;
		--panel: #0f1720;
		--text: #e5e7eb;
		--muted: #9ca3af;
		--border: #1f2937;
		--primary: #60a5fa;
		--primary-600: #3b82f6;
		--primary-100: #1e3a8a;
		--secondary: #94a3b8;
		--danger: #f87171;
		--success-bg: #022c22;
		--success-fg: #34d399;
		--error-bg: #3f1d1d;
		--error-fg: #fca5a5;
		--shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.35);
		--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
	}
}

/* Base */
* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html, body{
	height: 100%;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
	background: var(--bg);
	color: var(--text);
	font-size: 16px;
	line-height: 1.5;
}

.container {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 24px;
}

/* Header */
.header {
	background: var(--panel);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 0;
	z-index: 100;
	height: var(--header-height);
	display: flex;
	align-items: center;
	backdrop-filter: blur(8px);
}

.header-container {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	height: 100%;
}

.header-brand {
	display: flex;
	align-items: center;
}

.header-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 20px;
	font-weight: 700;
	color: var(--primary);
	margin: 0;
}

.logo-icon {
	display: block;
}

/* Navigation */
.nav {
	display: flex;
	gap: 8px;
	align-items: center;
}

.nav-link {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border-radius: 8px;
	text-decoration: none;
	color: var(--text);
	background: transparent;
	border: 1px solid transparent;
	transition: var(--transition);
	position: relative;
	font-size: 14px;
	font-weight: 500;
}

.nav-link:hover {
	background: var(--bg);
	border-color: var(--border);
	box-shadow: var(--shadow);
	transform: translateY(-1px);
}

.nav-link.active {
	background: var(--primary-100);
	color: var(--primary-600);
	border-color: var(--primary);
	font-weight: 600;
}

.nav-icon {
	display: block;
	flex-shrink: 0;
}

/* Menu toggle for mobile */
.menu-toggle {
	display: none;
	background: none;
	border: none;
	color: var(--text);
	cursor: pointer;
	padding: 8px;
	border-radius: 6px;
	transition: var(--transition);
}

.menu-toggle:hover {
	background: var(--bg);
}

.menu-toggle svg {
	display: block;
}

/* Flash messages */
.flash-container {
	margin-top: 16px;
	animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.flash {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.flash-item {
	padding: 12px 16px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--panel);
	display: flex;
	align-items: center;
	gap: 12px;
	position: relative;
	animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.flash-success {
	background: var(--success-bg);
	color: var(--success-fg);
	border-color: transparent;
}

.flash-error {
	background: var(--error-bg);
	color: var(--error-fg);
	border-color: transparent;
}

.flash-icon {
	flex-shrink: 0;
}

.flash-close {
	margin-left: auto;
	background: none;
	border: none;
	color: currentColor;
	cursor: pointer;
	opacity: 0.7;
	transition: opacity 0.2s;
	padding: 4px;
	border-radius: 4px;
}

.flash-close:hover {
	opacity: 1;
	background: rgba(0, 0, 0, 0.05);
}

.flash-close svg {
	display: block;
}

/* Main content */
.main-content {
	min-height: calc(100vh - var(--header-height) - 60px);
	padding: 24px 0 40px;
}

/* Footer */
.footer {
	background: var(--panel);
	border-top: 1px solid var(--border);
	padding: 20px 0;
	margin-top: auto;
}

.footer p {
	text-align: center;
	color: var(--muted);
	font-size: 14px;
	margin: 0;
}

/* Layout */
.grid {
	display: grid;
	grid-template-columns: 1fr 2fr;
	gap: 24px;
}

@media (max-width: 980px) {
	.grid {
		grid-template-columns: 1fr;
		gap: 20px;
	}
}

.card {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 24px;
	box-shadow: var(--shadow);
	margin-bottom: 24px;
	transition: var(--transition);
}

.card:hover {
	box-shadow: var(--shadow-lg);
	transform: translateY(-2px);
}

.card h2, .card h3 {
	font-size: 20px;
	font-weight: 600;
	margin-bottom: 20px;
	border-left: 4px solid var(--primary);
	padding-left: 12px;
	color: var(--primary-600);
	background: rgba(37, 99, 235, 0.04);
	border-radius: 0;
}

.card h3 {
	font-size: 18px;
	margin-bottom: 16px;
}

/* Table */
.table-container {
	overflow-x: auto;
	margin-bottom: 24px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
}

.table {
	width: 100%;
	border-collapse: collapse;
	font-size: 15px;
	background: var(--panel);
}

.table th, .table td {
	padding: 12px 16px;
	border-bottom: 1px solid var(--border);
	text-align: left;
	vertical-align: middle;
}

.table th {
	background: rgba(37, 99, 235, 0.06);
	color: var(--primary-600);
	font-weight: 600;
	white-space: nowrap;
	position: sticky;
	top: 0;
	z-index: 10;
}

.table tbody tr:last-child td {
	border-bottom: none;
}

.table tbody tr:nth-child(even) {
	background: rgba(0, 0, 0, 0.02);
}

.table tbody tr:hover {
	background: var(--primary-100);
	color: var(--primary-600);
}

/* Forms */
.form-group {
	margin-bottom: 20px;
}

.form-label {
	display: block;
	margin-bottom: 6px;
	font-weight: 500;
	color: var(--text);
}

.form-row {
	display: flex;
	gap: 16px;
	margin-bottom: 20px;
	align-items: flex-end;
	flex-wrap: wrap;
}

.form-control {
	flex: 1;
	min-width: 200px;
	padding: 10px 14px;
	border: 1px solid var(--border);
	background: var(--panel);
	color: var(--text);
	border-radius: 8px;
	outline: none;
	font-size: 15px;
	transition: var(--transition);
}

.form-control:focus {
	border-color: var(--primary);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-control:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	background: var(--bg);
}

textarea.form-control {
	resize: vertical;
	min-height: 120px;
}

select.form-control {
	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 0.5rem center;
	background-repeat: no-repeat;
	background-size: 1.5em 1.5em;
	padding-right: 2.5rem;
}

select[multiple].form-control {
	min-height: 180px;
}

/* Buttons */
.btn {
	padding: 10px 20px;
	border-radius: 8px;
	border: 1px solid transparent;
	background: var(--primary);
	color: #fff;
	cursor: pointer;
	transition: var(--transition);
	font-size: 15px;
	font-weight: 500;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-width: fit-content;
}

.btn:hover {
	background: var(--primary-600);
	box-shadow: var(--shadow);
	transform: translateY(-1px);
}

.btn:active {
	transform: translateY(0);
}

.btn-secondary {
	background: var(--bg);
	color: var(--primary-600);
	border-color: var(--border);
}

.btn-secondary:hover {
	background: var(--primary-100);
	border-color: var(--primary);
}

.btn-danger {
	background: var(--danger);
}

.btn-danger:hover {
	background: #b91c1c;
}

.btn-link {
	background: transparent;
	color: var(--primary);
	border-color: transparent;
	padding: 4px 8px;
}

.btn-link:hover {
	background: var(--primary-100);
	text-decoration: underline;
}

.btn[disabled], .btn:disabled, button[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

.btn-group {
	display: flex;
	gap: 10px;
}

/* Helpers */
.text-center {
	text-align: center;
}

.text-right {
	text-align: right;
}

.text-muted {
	color: var(--muted);
	font-size: 14px;
}

.text-primary {
	color: var(--primary);
}

.text-danger {
	color: var(--danger);
}

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

.tag {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	border: 1px solid var(--border);
	padding: 4px 10px;
	border-radius: 999px;
	margin: 2px;
	background: var(--primary-100);
	color: var(--primary-600);
	font-size: 13px;
	font-weight: 500;
}

/* details/summary panel */
details {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 12px 16px;
	margin-bottom: 16px;
	transition: var(--transition);
}

details[open] {
	box-shadow: var(--shadow);
}

details > summary {
	cursor: pointer;
	font-weight: 600;
	color: var(--primary-600);
	list-style: none;
	padding: 4px 0;
}

details > summary::-webkit-details-marker {
	display: none;
}

details > summary::before {
	content: '▶';
	display: inline-block;
	margin-right: 8px;
	transition: transform 0.2s ease;
	font-size: 12px;
}

details[open] > summary::before {
	transform: rotate(90deg);
}

/* Progress bar */
#genProgressPanel {
	margin-top: 20px;
}

#genProgressPanel > div:first-child {
	background: var(--bg);
	border-radius: 8px;
	height: 24px;
	border: 1px solid var(--border);
	overflow: hidden;
}

#genProgressBar {
	height: 100%;
	background: linear-gradient(90deg, var(--primary) 60%, var(--primary-100) 100%);
	border-radius: 8px;
	transition: width 0.3s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	color: white;
	font-size: 12px;
	font-weight: 600;
}

#genProgressText {
	margin-top: 10px;
	color: var(--primary);
	font-size: 15px;
	font-weight: 500;
}

/* Status badges */
.badge {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.badge-success {
	background: var(--success-bg);
	color: var(--success-fg);
}

.badge-error {
	background: var(--error-bg);
	color: var(--error-fg);
}

.badge-warning {
	background: #fef3c7;
	color: #92400e;
}

.badge-info {
	background: var(--primary-100);
	color: var(--primary-600);
}

/* Responsive styles */
@media (max-width: 768px) {
	.header {
		padding: 0 16px;
	}
	
	.container {
		padding: 0 16px;
	}
	
	.nav {
		position: fixed;
		top: var(--header-height);
		left: 0;
		right: 0;
		background: var(--panel);
		flex-direction: column;
		align-items: stretch;
		padding: 16px;
		gap: 8px;
		max-height: 0;
		overflow: hidden;
		transition: max-height 0.3s ease, opacity 0.3s ease;
		opacity: 0;
		z-index: 99;
		box-shadow: var(--shadow-lg);
		border-bottom: 1px solid var(--border);
	}
	
	.nav.nav-open {
		max-height: 500px;
		opacity: 1;
	}
	
	.nav-link {
		justify-content: flex-start;
		padding: 12px 16px;
		border-radius: 6px;
	}
	
	.menu-toggle {
		display: block;
	}
	
	.form-row {
		flex-direction: column;
		align-items: stretch;
	}
	
	.form-control {
		width: 100%;
		min-width: unset;
	}
	
	.btn-group {
		flex-direction: column;
	}
	
	.main-content {
		padding: 20px 0 32px;
	}
}

/* Animation */
@keyframes fadeIn {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: translateY(0); }
}

.fade-in {
	animation: fadeIn 0.5s ease-out;
}

/* Skeleton loading */
.skeleton {
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

/* Print styles */
@media print {
	.header, .footer, .btn, .nav {
		display: none !important;
	}
	
	body {
		background: white;
		color: black;
	}
	
	.card {
		box-shadow: none;
		border: 1px solid black;
		break-inside: avoid;
	}
}
