/* Satisfine Dashboard — Stylesheet */

:root {
	--font-body: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
	--color-bg: #f0f2f5;
	--color-surface: #fff;
	--color-sidebar: #0f172a;
	--color-sidebar-hover: #1e293b;
	--color-sidebar-text: #94a3b8;
	--color-sidebar-active: #e2e8f0;
	--color-text: #1a1a2e;
	--color-text-muted: #64748b;
	--color-border: #e2e5ea;
	--color-accent: #3b82f6;
	--color-accent-hover: #2563eb;
	--color-accent-soft: rgba(59, 130, 246, 0.08);
	--color-success: #059669;
	--color-success-bg: #ecfdf5;
	--color-danger: #dc2626;
	--color-danger-bg: #fef2f2;
	--color-warning-bg: #fffbeb;
	--color-warning: #92400e;
	--color-info-bg: #eff6ff;
	--color-info: #1e40af;
	--color-purple: #7c3aed;
	--color-purple-bg: #f5f3ff;
	--radius: 10px;
	--radius-sm: 6px;
	--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
	--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
	--sidebar-w: 240px;
	--transition: 0.2s ease;
}

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

body {
	font-family: var(--font-body);
	line-height: 1.6;
	color: var(--color-text);
	background: var(--color-bg);
	font-size: 15px;
	-webkit-font-smoothing: antialiased;
}

a {
	color: var(--color-accent);
	text-decoration: none;
	transition: color var(--transition);
}
a:hover { color: var(--color-accent-hover); }

/* ==================== Layout ==================== */

.admin-wrap {
	display: flex;
	min-height: 100vh;
}

.admin-sidebar {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	width: var(--sidebar-w);
	background: var(--color-sidebar);
	color: var(--color-sidebar-text);
	display: flex;
	flex-direction: column;
	z-index: 100;
	overflow-y: auto;
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 24px 20px 20px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-sidebar h2 {
	font-size: 1.15rem;
	font-weight: 700;
	color: #fff;
	letter-spacing: -0.02em;
}

.sidebar-close {
	display: none;
	background: none;
	border: none;
	color: var(--color-sidebar-text);
	font-size: 1.5rem;
	cursor: pointer;
	padding: 0;
	line-height: 1;
}

.admin-sidebar nav {
	padding: 12px 0;
	flex: 1;
}

.admin-sidebar nav a {
	display: flex;
	align-items: center;
	padding: 10px 20px;
	color: var(--color-sidebar-text);
	font-size: 0.9rem;
	font-weight: 500;
	border-left: 3px solid transparent;
	transition: all var(--transition);
}

.admin-sidebar nav a:hover {
	background: var(--color-sidebar-hover);
	color: var(--color-sidebar-active);
}

.admin-sidebar nav a.active {
	background: var(--color-sidebar-hover);
	color: #fff;
	border-left-color: var(--color-accent);
}

.nav-divider {
	display: block;
	height: 1px;
	background: rgba(255, 255, 255, 0.06);
	margin: 8px 20px;
}

.admin-content {
	flex: 1;
	margin-left: var(--sidebar-w);
	padding: 32px;
	min-width: 0;
	overflow-x: hidden;
}

/* Mobile menu button */
.mobile-menu-btn {
	display: none;
	position: fixed;
	top: 16px;
	left: 16px;
	z-index: 90;
	width: 40px;
	height: 40px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--color-border);
	background: var(--color-surface);
	box-shadow: var(--shadow-sm);
	cursor: pointer;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 5px;
	padding: 0;
	transition: box-shadow var(--transition);
}

.mobile-menu-btn:hover {
	box-shadow: var(--shadow-md);
}

.mobile-menu-btn span {
	display: block;
	width: 18px;
	height: 2px;
	background: var(--color-text);
	border-radius: 1px;
	transition: all var(--transition);
}

/* Sidebar overlay */
.sidebar-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.4);
	z-index: 99;
	backdrop-filter: blur(2px);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
	display: block;
	opacity: 1;
}

/* ==================== Header bar ==================== */

.admin-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 28px;
	flex-wrap: wrap;
	gap: 12px;
}

.admin-header h1 {
	font-size: 1.5rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--color-text);
}

/* ==================== Cards ==================== */

.card {
	background: var(--color-surface);
	border-radius: var(--radius);
	padding: 24px;
	box-shadow: var(--shadow-sm);
	margin-bottom: 20px;
	border: 1px solid var(--color-border);
}

.card h2 {
	font-size: 1.1rem;
	font-weight: 700;
	margin-bottom: 16px;
	letter-spacing: -0.01em;
}

/* ==================== Tables ==================== */

.table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

table {
	width: 100%;
	border-collapse: collapse;
}

th, td {
	padding: 12px 14px;
	text-align: left;
	border-bottom: 1px solid var(--color-border);
}

th {
	font-weight: 600;
	font-size: 0.8rem;
	color: var(--color-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

tbody tr {
	transition: background var(--transition);
}

tbody tr:hover {
	background: var(--color-accent-soft);
}

td .domain-link {
	font-weight: 600;
	color: var(--color-text);
}

td .domain-link:hover {
	color: var(--color-accent);
}

/* ==================== Forms ==================== */

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

.form-group label {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
	font-size: 0.85rem;
	color: var(--color-text);
	letter-spacing: 0.01em;
}

.form-group .hint {
	font-size: 0.8rem;
	color: var(--color-text-muted);
	margin-top: 4px;
}

.form-control {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
	font-size: 0.95rem;
	font-family: var(--font-body);
	color: var(--color-text);
	background: var(--color-surface);
	transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
	outline: none;
	border-color: var(--color-accent);
	box-shadow: 0 0 0 3px var(--color-accent-soft);
}

select.form-control {
	appearance: auto;
}

textarea.form-control {
	min-height: 100px;
	resize: vertical;
}

textarea.form-control-code {
	font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
	font-size: 0.85rem;
	line-height: 1.5;
	tab-size: 2;
	min-height: 160px;
}

.form-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
}

/* ==================== Buttons ==================== */

.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 20px;
	border-radius: var(--radius-sm);
	font-weight: 600;
	cursor: pointer;
	border: 1px solid transparent;
	font-size: 0.875rem;
	font-family: var(--font-body);
	text-decoration: none;
	transition: all var(--transition);
	white-space: nowrap;
}

.btn-primary {
	background: var(--color-accent);
	color: #fff;
}
.btn-primary:hover {
	background: var(--color-accent-hover);
	color: #fff;
	box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
	background: var(--color-bg);
	color: var(--color-text);
	border-color: var(--color-border);
}
.btn-secondary:hover {
	background: var(--color-border);
	color: var(--color-text);
}

.btn-danger {
	background: var(--color-danger);
	color: #fff;
}
.btn-danger:hover {
	background: #b91c1c;
	color: #fff;
	box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.btn-sm {
	padding: 5px 12px;
	font-size: 0.8rem;
}

.btn-group,
.header-actions {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}

/* ==================== Badges ==================== */

.badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 20px;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.02em;
}

/* Page / generic status */
.badge-published {
	background: var(--color-success-bg);
	color: var(--color-success);
}

.badge-draft {
	background: var(--color-warning-bg);
	color: var(--color-warning);
}

/* Site statuses */
.badge-active {
	background: var(--color-success-bg);
	color: var(--color-success);
}

.badge-generating {
	background: var(--color-info-bg);
	color: var(--color-info);
}

.badge-error {
	background: var(--color-danger-bg);
	color: var(--color-danger);
}

.badge-archived {
	background: #f1f5f9;
	color: #64748b;
}

/* Template types (legacy) */
.badge-analyzed {
	background: var(--color-purple-bg);
	color: var(--color-purple);
}

.badge-cloned {
	background: var(--color-info-bg);
	color: var(--color-info);
}

/* Template creation modes */
.badge-analyze {
	background: var(--color-purple-bg);
	color: var(--color-purple);
}

.badge-clone {
	background: var(--color-info-bg);
	color: var(--color-info);
}

.badge-prompt {
	background: var(--color-warning-bg);
	color: var(--color-warning);
}

/* Task statuses */
.badge-task-queued {
	background: var(--color-info-bg);
	color: var(--color-info);
}

.badge-task-running {
	background: var(--color-accent-soft);
	color: var(--color-accent);
	animation: pulse-badge 1.5s ease-in-out infinite;
}

.badge-task-done {
	background: var(--color-success-bg);
	color: var(--color-success);
}

.badge-task-error {
	background: var(--color-danger-bg);
	color: var(--color-danger);
}

@keyframes pulse-badge {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.6; }
}

/* User roles */
.badge-admin {
	background: var(--color-accent-soft);
	color: var(--color-accent);
}

.badge-editor {
	background: var(--color-warning-bg);
	color: var(--color-warning);
}

/* ==================== Alerts ==================== */

.alert {
	padding: 14px 18px;
	border-radius: var(--radius-sm);
	margin-bottom: 18px;
	font-size: 0.9rem;
	font-weight: 500;
	border-left: 3px solid transparent;
}

.alert-success {
	background: var(--color-success-bg);
	color: var(--color-success);
	border-left-color: var(--color-success);
}

.alert-error {
	background: var(--color-danger-bg);
	color: #991b1b;
	border-left-color: var(--color-danger);
}

.alert-info {
	background: var(--color-info-bg);
	color: var(--color-info);
	border-left-color: var(--color-accent);
}

/* ==================== Stats grid ==================== */

.stats-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 16px;
	margin-bottom: 24px;
}

.stat-card {
	background: var(--color-surface);
	border-radius: var(--radius);
	padding: 20px 24px;
	box-shadow: var(--shadow-sm);
	border: 1px solid var(--color-border);
	transition: box-shadow var(--transition);
}

.stat-card:hover {
	box-shadow: var(--shadow-md);
}

.stat-card .stat-value {
	font-size: 2rem;
	font-weight: 700;
	color: var(--color-text);
	letter-spacing: -0.03em;
	line-height: 1.2;
}

.stat-card .stat-label {
	font-size: 0.825rem;
	color: var(--color-text-muted);
	margin-top: 4px;
	font-weight: 500;
}

/* ==================== Detail grid ==================== */

.detail-grid {
	display: grid;
	grid-template-columns: 160px 1fr;
	gap: 0;
}

.detail-grid dt {
	padding: 10px 14px;
	font-weight: 600;
	font-size: 0.85rem;
	color: var(--color-text-muted);
	border-bottom: 1px solid var(--color-border);
}

.detail-grid dd {
	padding: 10px 14px;
	border-bottom: 1px solid var(--color-border);
	word-break: break-word;
}

/* ==================== Config display ==================== */

.config-display {
	background: #f8fafc;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
	padding: 16px;
	font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
	font-size: 0.82rem;
	line-height: 1.6;
	overflow-x: auto;
	white-space: pre-wrap;
	word-break: break-word;
}

/* ==================== Search bar ==================== */

.search-bar {
	margin-bottom: 18px;
}

.search-form {
	display: flex;
	gap: 8px;
	align-items: center;
}

.search-form .form-control {
	max-width: 360px;
}

/* ==================== Pagination ==================== */

.pagination {
	display: flex;
	align-items: center;
	gap: 4px;
	margin-top: 18px;
	flex-wrap: wrap;
}

.pagination-ellipsis {
	padding: 0 6px;
	color: var(--color-text-muted);
}

/* ==================== Task logs ==================== */

.task-logs {
	max-height: 500px;
	overflow-y: auto;
	font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
	font-size: 0.82rem;
	line-height: 1.7;
	background: #f8fafc;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
	padding: 12px 16px;
}

.log-entry {
	display: flex;
	gap: 12px;
	padding: 2px 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.log-entry:last-child {
	border-bottom: none;
}

.log-time {
	color: var(--color-text-muted);
	flex-shrink: 0;
}

.log-level {
	font-weight: 600;
	flex-shrink: 0;
	width: 42px;
}

.log-msg {
	word-break: break-word;
}

.log-info .log-level { color: var(--color-info); }
.log-warn .log-level { color: var(--color-warning); }
.log-error .log-level { color: var(--color-danger); }

.task-logs .empty-state {
	padding: 24px;
}

/* ==================== Empty state ==================== */

.empty-state {
	text-align: center;
	padding: 48px 24px;
	color: var(--color-text-muted);
}

.empty-state p {
	font-size: 0.95rem;
	margin-bottom: 16px;
}

/* ==================== Login page ==================== */

.login-page {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	background: var(--color-sidebar);
}

.login-box {
	background: var(--color-surface);
	padding: 44px 40px;
	border-radius: 14px;
	width: 100%;
	max-width: 400px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.login-box h1 {
	font-size: 1.4rem;
	font-weight: 700;
	margin-bottom: 28px;
	text-align: center;
	letter-spacing: -0.02em;
}

/* ==================== Utility ==================== */

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.gap-1 { gap: 8px; }

/* ==================== Responsive ==================== */

/* Tablet */
@media (max-width: 1024px) {
	.form-row {
		grid-template-columns: 1fr;
	}

	.detail-grid {
		grid-template-columns: 140px 1fr;
	}
}

/* Mobile */
@media (max-width: 768px) {
	.admin-sidebar {
		transform: translateX(-100%);
	}

	.admin-sidebar.open {
		transform: translateX(0);
	}

	.sidebar-close {
		display: block;
	}

	.mobile-menu-btn {
		display: flex;
	}

	.admin-content {
		margin-left: 0;
		padding: 20px 16px;
		padding-top: 68px;
	}

	.admin-header {
		margin-bottom: 20px;
		flex-direction: column;
		align-items: flex-start;
	}

	.admin-header h1 {
		font-size: 1.25rem;
	}

	.card {
		padding: 18px;
	}

	.btn {
		padding: 8px 14px;
		font-size: 0.82rem;
	}

	.login-box {
		margin: 16px;
		padding: 32px 24px;
	}

	.detail-grid {
		grid-template-columns: 1fr;
	}

	.detail-grid dt {
		border-bottom: none;
		padding-bottom: 2px;
	}

	.detail-grid dd {
		padding-top: 0;
	}

}

/* Small phones */
@media (max-width: 480px) {
	.admin-content {
		padding: 16px 12px;
		padding-top: 64px;
	}

	.stat-card {
		padding: 16px;
	}

	.stat-card .stat-value {
		font-size: 1.5rem;
	}

	.stat-card .stat-label {
		font-size: 0.75rem;
	}
}
