/**
 * 前台用户体系样式：头部登录入口、登录/注册弹窗、左侧工具栏、用户中心
 *
 * 依赖 main.css 中的 CSS 变量（--bg-primary / --border-color / --accent 等）。
 */

/* ==========================================================================
   头部：登录按钮 / 用户菜单
   ========================================================================== */

.header-user {
	position: relative;
	display: flex;
	align-items: center;
	flex-shrink: 0;
	margin-left: 12px;
}

.header-user__login {
	height: 32px;
	padding: 0 16px;
	border: 1px solid var(--accent);
	border-radius: 16px;
	background-color: var(--accent);
	color: #fff;
	font-size: 13px;
	line-height: 1;
	cursor: pointer;
	transition: opacity .2s ease, background-color .2s ease;
}

.header-user__login:hover { opacity: .88; }

.header-user__btn {
	display: flex;
	align-items: center;
	gap: 6px;
	height: 32px;
	padding: 0 10px 0 4px;
	border: 1px solid var(--border-color);
	border-radius: 16px;
	background-color: var(--bg-secondary);
	color: var(--text-primary);
	font-size: 13px;
	cursor: pointer;
	transition: border-color .2s ease, background-color .2s ease;
}

.header-user__btn:hover { border-color: var(--accent); }

.header-user__avatar {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	display: block;
}

.header-user__name {
	max-width: 92px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.header-user__btn .fa { color: var(--text-secondary); font-size: 12px; }

.header-user__menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	z-index: 120;
	min-width: 176px;
	padding: 6px 0;
	border: 1px solid var(--border-color);
	border-radius: 5px;
	background-color: var(--bg-primary);
	box-shadow: var(--shadow);
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity .2s ease, transform .2s ease, visibility .2s;
}

.header-user.is-open .header-user__menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.header-user__menu a {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	color: var(--text-secondary);
	font-size: 13px;
	text-decoration: none;
	white-space: nowrap;
}

.header-user__menu a:hover {
	background-color: var(--accent-soft);
	color: var(--accent);
	text-decoration: none;
}

@media (max-width: 767px) {
	/* 移动端由 .search-toggle 的 auto 外边距负责整体靠右，
	   这里只保留与主题切换按钮之间的间距，避免多个 auto 平分空间。 */
	.header-user { margin-left: 8px; }
	.header-user__name { display: none; }
}

/* ==========================================================================
   登录 / 注册弹窗
   ========================================================================== */

.auth-modal {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	opacity: 0;
	visibility: hidden;
	transition: opacity .2s ease, visibility .2s;
}

.auth-modal.is-open {
	opacity: 1;
	visibility: visible;
}

.auth-modal__backdrop {
	position: absolute;
	inset: 0;
	background-color: rgba(0, 0, 0, .55);
}

.auth-modal__dialog {
	position: relative;
	width: 100%;
	max-width: 380px;
	max-height: calc(100vh - 40px);
	overflow-y: auto;
	padding: 24px 24px 18px;
	border: 1px solid var(--border-color);
	border-radius: 8px;
	background-color: var(--bg-primary);
	box-shadow: var(--shadow);
	transform: translateY(8px);
	transition: transform .2s ease;
}

.auth-modal.is-open .auth-modal__dialog { transform: translateY(0); }

.auth-modal__close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 30px;
	height: 30px;
	border: none;
	border-radius: 50%;
	background: none;
	color: var(--text-secondary);
	font-size: 15px;
	cursor: pointer;
}

.auth-modal__close:hover { background-color: var(--bg-secondary); color: var(--text-primary); }

.auth-modal__title {
	margin: 0 0 16px;
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--text-primary);
}

.auth-tabs {
	display: flex;
	margin-bottom: 18px;
	border-bottom: 1px solid var(--border-color);
}

.auth-tab {
	flex: 1 1 0;
	padding: 9px 0;
	border: none;
	border-bottom: 2px solid transparent;
	background: none;
	color: var(--text-secondary);
	font-size: 14px;
	cursor: pointer;
	transition: color .2s ease, border-color .2s ease;
}

.auth-tab:hover { color: var(--text-primary); }

.auth-tab.is-active {
	border-bottom-color: var(--accent);
	color: var(--accent);
	font-weight: 600;
}

.auth-form { display: none; }
.auth-form.is-active { display: block; }

.auth-field { display: block; margin-bottom: 14px; }

.auth-field > span {
	display: block;
	margin-bottom: 6px;
	color: var(--text-secondary);
	font-size: 12px;
}

.auth-field input {
	width: 100%;
	height: 38px;
	padding: 0 10px;
	border: 1px solid var(--border-color);
	border-radius: 5px;
	background-color: var(--bg-secondary);
	color: var(--text-primary);
	font-size: 14px;
	outline: none;
	transition: border-color .2s ease, box-shadow .2s ease;
}

.auth-field input:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-remember {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 12px;
	color: var(--text-secondary);
	font-size: 13px;
	cursor: pointer;
}

.auth-remember input { width: 14px; height: 14px; }

.auth-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.auth-msg {
	min-height: 18px;
	margin: 0 0 10px;
	font-size: 13px;
	line-height: 1.5;
}

.auth-msg.is-error { color: #d63638; }
.auth-msg.is-success { color: #1a7f37; }

.auth-submit {
	width: 100%;
	height: 40px;
	border: none;
	border-radius: 5px;
	background-color: var(--accent);
	color: #fff;
	font-size: 14px;
	cursor: pointer;
	transition: opacity .2s ease;
}

.auth-submit:hover { opacity: .9; }
.auth-submit[disabled] { opacity: .6; cursor: default; }

.auth-links {
	margin: 12px 0 0;
	text-align: right;
	font-size: 12px;
}

/* ==========================================================================
   左侧快捷工具栏（登录用户）
   ========================================================================== */

body.has-user-rail { padding-left: 48px; }
body.has-user-rail.rail-collapsed { padding-left: 0; }

.user-rail {
	position: fixed;
	top: 0;
	bottom: 0;
	left: 0;
	z-index: 130;
	width: 48px;
	display: flex;
	flex-direction: column;
	background-color: #1d2327;
	color: #c3c4c7;
	transition: width .2s ease;
}

.user-rail__avatar {
	display: flex;
	justify-content: center;
	padding: 12px 0 10px;
	border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.user-rail__avatar-img {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	border: 1px solid rgba(255, 255, 255, .25);
	display: block;
}

.user-rail__nav {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	padding-top: 6px;
	overflow: hidden;
}

.user-rail__item {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 42px;
	color: #c3c4c7;
	font-size: 15px;
	text-decoration: none;
	transition: background-color .2s ease, color .2s ease;
}

.user-rail__item:hover {
	background-color: #2c3338;
	color: #fff;
	text-decoration: none;
}

.user-rail__item--logout { margin-top: auto; margin-bottom: 12px; }
.user-rail__item--logout:hover { background-color: #8a2424; }

/* 单篇文章 / 页面：编辑入口，用主题色区分日常导航 */
.user-rail__item--edit { color: #72aee6; }
.user-rail__item--edit:hover { background-color: #2271b1; color: #fff; }

.user-rail__label {
	position: absolute;
	left: 56px;
	top: 50%;
	transform: translate(-4px, -50%);
	padding: 4px 10px;
	border-radius: 4px;
	background-color: #2c3338;
	color: #fff;
	font-size: 12px;
	white-space: nowrap;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity .15s ease, transform .15s ease, visibility .15s;
	z-index: 140;
}

.user-rail__item:hover .user-rail__label,
.user-rail__item:focus-visible .user-rail__label {
	opacity: 1;
	visibility: visible;
	transform: translate(0, -50%);
}

.user-rail__toggle {
	position: absolute;
	top: 50%;
	right: 0;
	width: 16px;
	height: 44px;
	margin-top: -22px;
	padding: 0;
	border: none;
	border-radius: 0 4px 4px 0;
	background-color: #2c3338;
	color: #c3c4c7;
	font-size: 11px;
	cursor: pointer;
	transition: background-color .2s ease, color .2s ease;
}

.user-rail__toggle:hover { background-color: #3c434a; color: #fff; }
.user-rail__toggle .fa { transition: transform .2s ease; }

body.rail-collapsed .user-rail { width: 0; background-color: transparent; }

body.rail-collapsed .user-rail__avatar,
body.rail-collapsed .user-rail__nav {
	opacity: 0;
	visibility: hidden;
}

body.rail-collapsed .user-rail__toggle {
	left: 0;
	right: auto;
	border-radius: 0 4px 4px 0;
}

body.rail-collapsed .user-rail__toggle .fa { transform: rotate(180deg); }

@media (max-width: 767px) {
	body.has-user-rail,
	body.has-user-rail.rail-collapsed { padding-left: 0; }

	.user-rail { display: none; }
}

/* ==========================================================================
   用户中心
   ========================================================================== */

body.is-user-center .site-column { display: none; }

body.is-user-center .site-grid {
	grid-template-areas: "content";
	grid-template-columns: minmax(0, 1fr);
}

body.is-user-center .content-col {
	max-width: 1100px;
	padding: 0 1.5rem;
}

body.is-user-center .uc-col { margin: 2rem auto 3rem; }

.uc {
	display: grid;
	grid-template-columns: 240px minmax(0, 1fr);
	gap: 24px;
	align-items: start;
}

@media (max-width: 900px) {
	.uc { grid-template-columns: minmax(0, 1fr); }
}

.uc-profile {
	padding: 20px;
	border: 1px solid var(--border-color);
	border-radius: 5px;
	background-color: var(--bg-primary);
	text-align: center;
}

.uc-profile__avatar {
	width: 72px;
	height: 72px;
	border-radius: 50%;
	display: block;
	margin: 0 auto 10px;
	border: 1px solid var(--border-color);
}

.uc-profile__name {
	margin: 0 0 4px;
	color: var(--text-primary);
	font-size: 1rem;
	font-weight: 600;
	word-break: break-all;
}

.uc-profile__email {
	margin: 0;
	color: var(--text-secondary);
	font-size: 12px;
	word-break: break-all;
}

.uc-nav {
	margin-top: 16px;
	border: 1px solid var(--border-color);
	border-radius: 5px;
	background-color: var(--bg-primary);
	overflow: hidden;
}

.uc-nav__item {
	display: block;
	padding: 10px 14px;
	border-bottom: 1px solid var(--border-color);
	color: var(--text-secondary);
	font-size: 14px;
	text-decoration: none;
	transition: background-color .2s ease, color .2s ease;
}

.uc-nav__item:last-child { border-bottom: none; }

.uc-nav__item:hover {
	background-color: var(--bg-secondary);
	color: var(--text-primary);
	text-decoration: none;
}

.uc-nav__item.is-active {
	background-color: var(--accent-soft);
	color: var(--accent);
	font-weight: 600;
	box-shadow: inset 2px 0 0 var(--accent);
}

.uc-nav__item--danger:hover { color: #d63638; }

.uc-stats {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 12px;
	margin-bottom: 16px;
}

@media (max-width: 600px) {
	.uc-stats { grid-template-columns: minmax(0, 1fr); }
}

.uc-stat {
	padding: 14px;
	border: 1px solid var(--border-color);
	border-radius: 5px;
	background-color: var(--bg-primary);
	text-align: center;
}

.uc-stat__num {
	display: block;
	margin-bottom: 4px;
	color: var(--text-primary);
	font-size: 1.35rem;
	font-weight: 700;
	line-height: 1.2;
}

.uc-stat__num--date { font-size: .95rem; font-weight: 600; }
.uc-stat__label { color: var(--text-secondary); font-size: 12px; }

.uc-card {
	padding: 22px;
	border: 1px solid var(--border-color);
	border-radius: 5px;
	background-color: var(--bg-primary);
}

.uc-card__title {
	margin: 0 0 18px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--border-color);
	color: var(--text-primary);
	font-size: 1.1rem;
}

.uc-form {
	display: flex;
	flex-direction: column;
	gap: 14px;
	max-width: 520px;
}

.uc-field > span {
	display: block;
	margin-bottom: 6px;
	color: var(--text-secondary);
	font-size: 13px;
}

.uc-field input,
.uc-field textarea {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid var(--border-color);
	border-radius: 5px;
	background-color: var(--bg-secondary);
	color: var(--text-primary);
	font-family: inherit;
	font-size: 14px;
	line-height: 1.5;
	outline: none;
	transition: border-color .2s ease, box-shadow .2s ease;
}

.uc-field textarea { resize: vertical; }

.uc-field input:focus,
.uc-field textarea:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}

.uc-hint {
	margin: 0;
	color: var(--text-secondary);
	font-size: 12px;
}

.uc-submit {
	align-self: flex-start;
	height: 36px;
	padding: 0 20px;
	border: none;
	border-radius: 5px;
	background-color: var(--accent);
	color: #fff;
	font-size: 14px;
	cursor: pointer;
	transition: opacity .2s ease;
}

.uc-submit:hover { opacity: .9; }

.uc-notice {
	margin-bottom: 16px;
	padding: 10px 14px;
	border-left: 3px solid transparent;
	border-radius: 4px;
	font-size: 14px;
}

.uc-notice--success {
	border-left-color: #1a7f37;
	background-color: rgba(26, 127, 55, .1);
	color: #1a7f37;
}

.uc-notice--error {
	border-left-color: #d63638;
	background-color: rgba(214, 54, 56, .1);
	color: #d63638;
}

.uc-comments,
.uc-posts {
	margin: 0;
	padding: 0;
	list-style: none;
}

.uc-comments__item,
.uc-posts__item {
	padding: 12px 0;
	border-bottom: 1px dashed var(--border-color);
}

.uc-comments__item:first-child,
.uc-posts__item:first-child { padding-top: 0; }

.uc-comments__item:last-child,
.uc-posts__item:last-child { padding-bottom: 0; border-bottom: none; }

.uc-comments__meta {
	display: flex;
	align-items: baseline;
	gap: 10px;
	margin: 0 0 4px;
	font-size: 13px;
}

.uc-comments__meta a {
	color: var(--text-primary);
	font-weight: 600;
	text-decoration: none;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.uc-comments__meta a:hover { color: var(--link-color); }

.uc-comments__meta time {
	flex: 0 0 auto;
	margin-left: auto;
	color: var(--text-secondary);
	font-size: 12px;
}

.uc-comments__text {
	margin: 0;
	color: var(--text-secondary);
	font-size: 13px;
	line-height: 1.6;
}

.uc-posts__item a {
	color: var(--text-primary);
	font-size: 14px;
	text-decoration: none;
}

.uc-posts__item a:hover { color: var(--link-color); }

.uc-posts__meta {
	margin-left: 8px;
	color: var(--text-secondary);
	font-size: 12px;
}

.uc-empty { margin: 0; color: var(--text-secondary); font-size: 14px; }

@media (max-width: 767px) {
	body.is-user-center .content-col { padding: 0 1rem; }
	.uc-card { padding: 16px; }
	.uc-profile { padding: 16px; }
}
