/* Site Valet — admin panel theme.
   Based on the Octopus Law "Tech Dark" design system (see DESIGN.md):
   near-black blue-grey surface, single violet accent. (Grid + cursor
   spotlight intentionally removed — plain background only.) */
:root {
	/* Surfaces */
	--bg: #101116;
	--card-bg: #191b22;
	--card-border: #272a35;
	--field-bg: #14161d;
	--avatar-tile: #23252f;

	/* Text */
	--text: #e8e9ee;
	--text-muted: #8f93a3;

	/* Accent (violet) */
	--accent: #a78bfa;
	--accent-soft: #8b7bff;
	--logo-grad-a: #a78bfa;
	--logo-grad-b: #6d5cff;

	/* Background glow */
	--glow: rgba(139, 123, 255, 0.13);

	/* Status */
	--ok: #4ade80;
	--warn: #fbbf24;
	--err: #f87171;
	--danger: #ff6b6b;

	/* Shadows */
	--card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
	--card-shadow-hover: 0 2px 6px rgba(139, 123, 255, 0.12), 0 14px 40px rgba(139, 123, 255, 0.22);

	--sidebar-w: 244px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
	margin: 0;
	font: 15px/1.55 "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
	color: var(--text);
	background-color: var(--bg);
	background-image: radial-gradient(ellipse 70% 50% at 50% -10%, var(--glow), transparent);
	background-attachment: fixed;
}
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace; }

/* --- app layout: sidebar + content --- */
.layout { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
	width: var(--sidebar-w);
	flex: none;
	display: flex;
	flex-direction: column;
	gap: 26px;
	padding: 22px 16px;
	border-right: 1px solid var(--card-border);
	background: rgba(20, 22, 29, 0.6);
	position: sticky;
	top: 0;
	height: 100vh;
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); padding: 4px; }
.brand-tile {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 12px;
	background: linear-gradient(135deg, var(--logo-grad-a), var(--logo-grad-b));
	box-shadow: 0 6px 20px rgba(109, 92, 255, 0.35);
}
.brand-tile img { width: 72%; height: 72%; object-fit: contain; display: block; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 10px 12px;
	border-radius: 10px;
	color: var(--text-muted);
	text-decoration: none;
	font-weight: 500;
	transition: background 0.16s ease, color 0.16s ease;
}
.nav-link svg { width: 18px; height: 18px; flex: none; }
.nav-link:hover { background: rgba(139, 123, 255, 0.08); color: var(--text); }
.nav-link.active { background: rgba(139, 123, 255, 0.14); color: var(--accent); }

.side-logout { margin-top: auto; padding: 4px 12px; }

.content-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

main {
	flex: 1;
	width: 100%;
	max-width: 920px;
	margin: 0 auto;
	padding: 34px 28px;
	display: flex;
	flex-direction: column;
	gap: 22px;
}
.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; padding: 24px; }
.auth-main .flash { width: 100%; max-width: 400px; }

/* --- page header --- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.back { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.back:hover { color: var(--accent); }

/* --- cards --- */
.card {
	position: relative;
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: 14px;
	padding: 24px 26px;
	box-shadow: var(--card-shadow);
	transition: box-shadow 0.22s ease, border-color 0.22s ease;
}
.card::before {
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	width: 3px;
	border-radius: 14px 0 0 14px;
	background: linear-gradient(180deg, var(--accent-soft), var(--accent));
	opacity: 0;
	transition: opacity 0.22s ease;
}
.card:hover { border-color: rgba(167, 139, 250, 0.5); box-shadow: var(--card-shadow-hover); }
.card:hover::before { opacity: 1; }
.card.narrow { max-width: 400px; width: 100%; margin: 0; }
.card.danger-zone { border-color: rgba(255, 107, 107, 0.3); }
.card.danger-zone::before { background: linear-gradient(180deg, #ff8a8a, var(--danger)); }

.eyebrow { margin: 0 0 6px; font-size: 0.8rem; letter-spacing: 0.06em; color: var(--text-muted); }
.eyebrow::before { content: "// "; color: var(--accent); }

h1 { font-size: 1.35rem; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 4px; }
h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -0.005em; margin: 0 0 12px; }
h1 .accent, .accent {
	background: linear-gradient(120deg, var(--accent-soft), var(--accent));
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}
.hint { color: var(--text-muted); margin: 0 0 18px; line-height: 1.5; }
.hint a { color: var(--accent); }
.opt { color: var(--text-muted); font-weight: 400; font-size: 0.85em; }
code {
	font-family: ui-monospace, Consolas, "Courier New", monospace;
	background: rgba(139, 123, 255, 0.12);
	color: #c9bcff;
	padding: 1px 6px;
	border-radius: 5px;
	font-size: 0.86em;
}

/* --- forms --- */
.stack { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 7px; font-weight: 600; font-size: 0.85rem; color: var(--text); }
input[type=text], input[type=password], input[type=file], textarea {
	font: inherit;
	color: var(--text);
	padding: 11px 13px;
	border: 1px solid var(--card-border);
	border-radius: 9px;
	background: var(--field-bg);
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
	width: 100%;
}
textarea { resize: vertical; min-height: 44px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #5c6070; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 123, 255, 0.18); }
input[type=file] { padding: 9px 12px; }
input[type=file]::file-selector-button {
	font: inherit;
	margin-right: 12px;
	padding: 7px 12px;
	border: 1px solid var(--card-border);
	border-radius: 7px;
	background: var(--avatar-tile);
	color: var(--text);
	cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }

/* --- buttons --- */
button {
	font: inherit;
	cursor: pointer;
	border: none;
	border-radius: 9px;
	padding: 10px 18px;
	transition: filter 0.18s ease, transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
button.primary {
	background: linear-gradient(135deg, var(--logo-grad-a), var(--logo-grad-b));
	color: #fff;
	font-weight: 600;
	box-shadow: 0 6px 18px rgba(109, 92, 255, 0.3);
}
button.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
button.danger {
	background: transparent;
	color: var(--danger);
	border: 1px solid rgba(255, 107, 107, 0.5);
	padding: 8px 14px;
	font-size: 0.85rem;
}
button.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
button.mini { padding: 5px 11px; font-size: 0.8rem; background: var(--avatar-tile); color: var(--text); border: 1px solid var(--card-border); }
button.mini:hover { border-color: var(--accent); color: var(--accent); }
button.mini.danger { background: transparent; color: var(--danger); border-color: rgba(255, 107, 107, 0.5); }
button.mini.danger:hover { background: var(--danger); color: #fff; }
button.linklike { background: none; color: var(--text-muted); padding: 0; font-size: 0.85rem; }
button.linklike:hover { color: var(--accent); }
.inline { display: inline; margin: 0; }

.btn-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	text-decoration: none;
	font-weight: 600;
	font-size: 0.9rem;
	padding: 9px 15px;
	border-radius: 9px;
	border: 1px solid var(--card-border);
	color: var(--text);
	background: var(--card-bg);
	transition: border-color 0.18s ease, color 0.18s ease;
}
.btn-link:hover { border-color: var(--accent); color: var(--accent); }
.primary-link {
	background: linear-gradient(135deg, var(--logo-grad-a), var(--logo-grad-b));
	color: #fff;
	border: none;
	box-shadow: 0 6px 18px rgba(109, 92, 255, 0.3);
}
.primary-link:hover { color: #fff; filter: brightness(1.08); }

/* --- site detail meta --- */
.site-meta { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 18px; font-size: 0.9rem; }

/* --- tables --- */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--card-border); vertical-align: middle; }
thead th { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: rgba(139, 123, 255, 0.05); }
td a, .site-link { color: var(--accent); text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }
td.reason { color: var(--err); max-width: 280px; word-break: break-word; }
.nowrap { white-space: nowrap; }
.desc-cell { max-width: 240px; }
.actions-col { white-space: nowrap; }
.actions-col form { margin-right: 6px; }

.inline-note { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-note input[type=text] { padding: 6px 9px; font-size: 0.85rem; min-width: 140px; }

/* --- site detail: toggles, stats, health --- */
.toggle-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--card-border); }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text-muted); cursor: pointer; }
.check input { width: auto; }
.desc-form { margin-top: 18px; }

.mini-link { display: inline-block; padding: 5px 11px; font-size: 0.8rem; border-radius: 7px; border: 1px solid var(--card-border); color: var(--text); text-decoration: none; background: var(--avatar-tile); margin-right: 6px; }
.mini-link:hover { border-color: var(--accent); color: var(--accent); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--field-bg); border: 1px solid var(--card-border); border-radius: 11px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.stat-lbl { font-size: 0.78rem; color: var(--text-muted); }
.stat-note { margin: 14px 0 0; }

.health { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cert-issuer { font-size: 0.85rem; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: rgba(74, 222, 128, 0.1); }
.badge.warn { color: var(--warn); background: rgba(251, 191, 36, 0.1); }
.badge.err { color: var(--err); background: rgba(248, 113, 113, 0.1); }
.badge.muted-badge { color: var(--text-muted); background: rgba(143, 147, 163, 0.12); }
.muted { color: var(--text-muted); }

/* --- flash --- */
.flash { padding: 13px 16px; border-radius: 10px; margin: 0; font-weight: 500; border: 1px solid transparent; }
.flash-ok { background: rgba(74, 222, 128, 0.1); color: #bbf7d0; border-color: rgba(74, 222, 128, 0.3); }
.flash-err { background: rgba(248, 113, 113, 0.1); color: #fecaca; border-color: rgba(248, 113, 113, 0.3); }

/* --- footer --- */
.footer { text-align: center; color: var(--text-muted); padding: 24px 16px 30px; font-size: 0.78rem; letter-spacing: 0.05em; }

/* --- entrance cascade --- */
@keyframes rise {
	from { opacity: 0; transform: translateY(14px); }
	to   { opacity: 1; transform: translateY(0); }
}
main > * { animation: rise 0.5s ease both; }
main > *:nth-child(1) { animation-delay: 0.04s; }
main > *:nth-child(2) { animation-delay: 0.10s; }
main > *:nth-child(3) { animation-delay: 0.16s; }
main > *:nth-child(4) { animation-delay: 0.22s; }
main > *:nth-child(5) { animation-delay: 0.28s; }

/* --- responsive: sidebar collapses to a top bar --- */
@media (max-width: 760px) {
	.layout { flex-direction: column; }
	.sidebar {
		width: 100%;
		height: auto;
		position: static;
		flex-direction: row;
		align-items: center;
		gap: 12px;
		padding: 12px 14px;
		border-right: none;
		border-bottom: 1px solid var(--card-border);
		overflow-x: auto;
	}
	.side-nav { flex-direction: row; gap: 4px; }
	.nav-link span { display: none; }
	.side-logout { margin-top: 0; margin-left: auto; padding: 0; }
	.brand-name { display: none; }
	main { padding: 22px 16px; }
}

@media (prefers-reduced-motion: reduce) {
	* { animation: none !important; transition: none !important; }
}
