/* Task - Theming System */

:root {
	/* ── Light Theme (Default) ── */
	--surface-0: #ffffff;
	--surface-1: #f8f9fa;
	--surface-2: #ffffff;
	--surface-3: #f1f3f5;
	--surface-4: #e9ecef;
	--surface-5: #dee2e6;

	--border-subtle: rgba(0, 0, 0, 0.08);
	--border-default: rgba(0, 0, 0, 0.12);
	--border-strong: rgba(0, 0, 0, 0.18);

	--text-primary: #212529;
	--text-secondary: #495057;
	--text-tertiary: #868e96;

	--accent: #635bff;
	--accent-hover: #564ad4;
	--accent-muted: rgba(99, 91, 255, 0.10);
	--accent-fg: #ffffff;

	/* Status colors */
	--status-todo: #adb5bd;
	--status-doing: #fcc419;
	--status-done: #635bff;

	/* Diff colors */
	--diff-add-bg: #ecfdf5;
	--diff-add-border: #10b981;
	--diff-remove-bg: #fef2f2;
	--diff-remove-border: #ef4444;

	color-scheme: light;
}

html.dark {
	/* ── Dark Theme ── */
	--surface-0: #0a0a0f;
	--surface-1: #12121a;
	--surface-2: #1a1a25;
	--surface-3: #222230;
	--surface-4: #2a2a3a;
	--surface-5: #333345;

	--border-subtle: rgba(255, 255, 255, 0.04);
	--border-default: rgba(255, 255, 255, 0.06);
	--border-strong: rgba(255, 255, 255, 0.10);

	--text-primary: #ececf1;
	--text-secondary: #8e8ea0;
	--text-tertiary: #5a5a6e;

	--accent: #635bff;
	--accent-hover: #7c75ff;
	--accent-muted: rgba(99, 91, 255, 0.15);
	--accent-fg: #ffffff;

	/* Status colors */
	--status-todo: #95959f;
	--status-doing: #f2c94c;
	--status-done: #635bff;

	/* Diff colors */
	--diff-add-bg: rgba(16, 185, 129, 0.1);
	--diff-add-border: #10b981;
	--diff-remove-bg: rgba(239, 68, 68, 0.1);
	--diff-remove-border: #ef4444;

	color-scheme: dark;
}

/* ── Base ──────────────────────────────── */
body {
	background-color: var(--surface-0);
	color: var(--text-primary);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	transition: background-color 0.3s ease, color 0.3s ease;
}
[x-cloak] { display: none !important; }
.hidden { display: none !important; }

/* ── Skip to content (accessibility) ───── */
.skip-link {
	position: absolute;
	top: -100%;
	left: 1rem;
	z-index: 9999;
	padding: 0.75rem 1.5rem;
	background: var(--accent);
	color: white;
	font-size: 0.875rem;
	font-weight: 600;
	border-radius: 0 0 0.5rem 0.5rem;
	text-decoration: none;
	transition: top 0.15s ease;
}
.skip-link:focus {
	top: 0;
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* ── Sidebar navigation links ─────────── */
.sidebar-link {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem 0.75rem;
	border-radius: 0.5rem;
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--text-secondary);
	transition: color 100ms ease, background-color 100ms ease;
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
}
.sidebar-link:hover {
	color: var(--text-primary);
	background-color: var(--surface-3);
}
.sidebar-link.active {
	color: var(--text-primary);
	background-color: var(--surface-3);
}
.sidebar-link svg {
	width: 1.125rem;
	height: 1.125rem;
	flex-shrink: 0;
	opacity: 0.7;
}
.sidebar-link.active svg,
.sidebar-link:hover svg {
	opacity: 1;
}

/* ── Task list rows ───────────────────── */
.task-row {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0.875rem 1.25rem;
	border-bottom: 1px solid var(--border-subtle);
	transition: background-color 75ms ease;
	cursor: pointer;
}
.task-row:hover {
	background-color: var(--surface-1);
}
.task-row:last-child {
	border-bottom: none;
}

/* ── Scrollbar ─────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-5); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ── Drag-and-drop card state ─────────── */
.task-card.dragging {
	opacity: 0.5;
	transform: rotate(1deg) scale(1.02);
	box-shadow: 0 0 20px rgba(99, 91, 255, 0.3);
	border-color: var(--accent) !important;
}

/* ── Task card entrance animation ──────── */
@keyframes card-enter {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}
.task-card {
	animation: card-enter 0.2s ease-out both;
}
.task-card:nth-child(1) { animation-delay: 0ms; }
.task-card:nth-child(2) { animation-delay: 30ms; }
.task-card:nth-child(3) { animation-delay: 60ms; }
.task-card:nth-child(4) { animation-delay: 90ms; }
.task-card:nth-child(5) { animation-delay: 120ms; }
.task-card:nth-child(n+6) { animation-delay: 150ms; }

/* ── Toast notifications ──────────────── */
@keyframes toast-in {
	from { transform: translateX(100%); opacity: 0; }
	to   { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
	from { transform: translateX(0); opacity: 1; }
	to   { transform: translateX(100%); opacity: 0; }
}
.toast-enter { animation: toast-in 0.25s ease-out forwards; }
.toast-exit  { animation: toast-out 0.2s ease-in forwards; }

/* ── Modal / command palette backdrop ─── */
.modal-backdrop {
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(4px);
}
.cmd-backdrop {
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(4px);
}

/* ── Line clamp fallback ──────────────── */
.line-clamp-2 {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ── Focus ring ───────────────────────── */
:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* ── Kanban column drag hover ─────────── */
.column-drop.drag-over {
	border-color: var(--accent) !important;
	background-color: var(--accent-muted) !important;
}

/* ── Smooth transitions globally ──────── */
.transition-fast {
	transition-property: color, background-color, border-color, opacity, transform;
	transition-duration: 100ms;
	transition-timing-function: ease-out;
}

/* ── Sidebar overlay for mobile ───────── */
.sidebar-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(4px);
	z-index: 35;
}

/* ── Status dot colors ────────────────── */
.status-dot-TODO  { background-color: var(--status-todo); }
.status-dot-DOING { background-color: var(--status-doing); }
.status-dot-DONE  { background-color: var(--status-done); }

/* ── Diff blocks ───────────────── */
.diff-add {
	background-color: var(--diff-add-bg);
	border-left: 2px solid var(--diff-add-border);
}
.diff-remove {
	background-color: var(--diff-remove-bg);
	border-left: 2px solid var(--diff-remove-border);
}

/* ── Utility overrides for theme ── */
.bg-surface-0 { background-color: var(--surface-0); }
.bg-surface-1 { background-color: var(--surface-1); }
.bg-surface-2 { background-color: var(--surface-2); }
.bg-surface-3 { background-color: var(--surface-3); }
.bg-surface-4 { background-color: var(--surface-4); }
.bg-surface-5 { background-color: var(--surface-5); }

.border-border { border-color: var(--border-default); }
.border-border-subtle { border-color: var(--border-subtle); }
.border-border-strong { border-color: var(--border-strong); }

.text-text-primary { color: var(--text-primary); }
.text-text-secondary { color: var(--text-secondary); }
.text-text-tertiary { color: var(--text-tertiary); }

.bg-accent { background-color: var(--accent); }
.bg-accent-hover:hover { background-color: var(--accent-hover); }
.bg-accent-muted { background-color: var(--accent-muted); }
.text-accent { color: var(--accent); }
.border-accent { border-color: var(--accent); }

/* ── Progress bar ───────────────── */
.progress-bar {
	height: 6px;
	border-radius: 3px;
	background: var(--surface-4);
	overflow: hidden;
}
.progress-bar-fill {
	height: 100%;
	border-radius: 3px;
	background: var(--accent);
	transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Password toggle ────────────── */
.password-wrapper {
	position: relative;
}
.password-wrapper input {
	padding-right: 2.75rem;
}
.password-toggle {
	position: absolute;
	right: 0.5rem;
	top: 50%;
	transform: translateY(-50%);
	padding: 0.375rem;
	border-radius: 0.375rem;
	color: var(--text-tertiary);
	background: none;
	border: none;
	cursor: pointer;
	transition: color 100ms ease;
	display: flex;
	align-items: center;
	justify-content: center;
}
.password-toggle:hover {
	color: var(--text-secondary);
}

/* ── Filter bar ─────────────────── */
.filter-bar {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: wrap;
}
.filter-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0.375rem 0.75rem;
	border-radius: 9999px;
	font-size: 0.75rem;
	font-weight: 500;
	border: 1px solid var(--border-default);
	background: var(--surface-2);
	color: var(--text-secondary);
	cursor: pointer;
	transition: all 100ms ease;
	white-space: nowrap;
}
.filter-chip:hover {
	background: var(--surface-3);
	color: var(--text-primary);
}
.filter-chip.active {
	background: var(--accent-muted);
	color: var(--accent);
	border-color: var(--accent);
}
.filter-chip .chip-count {
	font-size: 0.625rem;
	min-width: 1.25rem;
	height: 1.25rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 9999px;
	background: var(--surface-4);
	color: var(--text-tertiary);
	font-weight: 600;
}
.filter-chip.active .chip-count {
	background: var(--accent);
	color: white;
}

/* ── Audit view ────────────────── */
.audit-stat {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.5rem 0.625rem;
	border-radius: 0.5rem;
	background: var(--surface-3);
	border: 1px solid var(--border-subtle);
	color: var(--text-secondary);
}
.audit-stat strong {
	font-size: 0.875rem;
	color: var(--text-primary);
}
.audit-entry {
	transition: border-color 120ms ease, box-shadow 120ms ease;
}
.audit-entry:hover {
	border-color: var(--border-strong);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}
html.dark .audit-entry:hover {
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

/* ── Keyboard shortcut hints ────── */
.kbd-hint {
	display: inline-flex;
	align-items: center;
	padding: 0.125rem 0.375rem;
	border-radius: 0.25rem;
	font-size: 0.625rem;
	font-family: ui-monospace, monospace;
	font-weight: 500;
	background: var(--surface-4);
	color: var(--text-tertiary);
	border: 1px solid var(--border-strong);
	line-height: 1.4;
}

/* ── Keyboard shortcuts modal ───── */
.shortcuts-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.5rem 2rem;
}
.shortcut-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.375rem 0;
}
.shortcut-row span:first-child {
	font-size: 0.8125rem;
	color: var(--text-secondary);
}

/* ── Stat card hover ────────────── */
.stat-card {
	transition: transform 150ms ease, box-shadow 150ms ease;
}
.stat-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
html.dark .stat-card:hover {
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ── Mobile-specific toast positioning ── */
@media (max-width: 640px) {
	#toastContainer {
		left: 1rem;
		right: 1rem;
		width: auto !important;
	}
}

/* ── Reduced motion ─────────────── */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* ── Screen reader only ─────────── */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}
