/* ==========================================================================
   base.css - 全局变量 / 重置 / 基础布局
   深色科技风 · 个人专属加密解密系统
   ========================================================================== */

/* ---------- 色彩与设计令牌 ---------- */
:root {
    /* 主色 */
    --c-primary: #4f7cff;
    --c-primary-dark: #3a5fd9;
    --c-primary-light: #e8efff;

    /* 背景 / 表面 */
    --c-bg: #0f1420;
    --c-surface: #1a2030;
    --c-surface-2: #232b3d;
    --c-border: #2e3850;

    /* 文本 */
    --c-text: #e6ebf5;
    --c-text-muted: #8a93a6;

    /* 状态色 */
    --c-success: #2dd4a4;
    --c-warning: #f6b73c;
    --c-danger: #ff5c7a;

    /* 字体 */
    --font-stack: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Menlo", "Consolas", monospace;

    /* 尺寸 */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --max-width: 1200px;
    --sidebar-w: 240px;
    --topbar-h: 60px;

    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);

    /* 间距 */
    --gap: 16px;
    --gap-lg: 24px;

    /* 过渡 */
    --t-fast: 0.15s ease;
    --t: 0.25s ease;
}

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

html {
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-stack);
    color: var(--c-text);
    background-color: var(--c-bg);
    min-height: 100vh;
    /* 深色科技风渐变背景 */
    background-image:
        radial-gradient(circle at 20% 0%, rgba(79, 124, 255, 0.08), transparent 40%),
        radial-gradient(circle at 80% 100%, rgba(45, 212, 164, 0.05), transparent 40%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--c-primary);
    text-decoration: none;
    transition: color var(--t-fast);
}

a:hover {
    color: var(--c-primary-dark);
}

a:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

button {
    font-family: inherit;
    cursor: pointer;
}

img,
svg {
    display: block;
    max-width: 100%;
}

input,
textarea,
select {
    font-family: inherit;
    font-size: 1rem;
    color: inherit;
}

ul,
ol {
    list-style: none;
}

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

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

/* ---------- 基础工具类 ---------- */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gap);
}

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

.text-muted {
    color: var(--c-text-muted);
}

.text-success { color: var(--c-success); }
.text-danger  { color: var(--c-danger); }
.text-warning { color: var(--c-warning); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }

.mono {
    font-family: var(--font-mono);
}

/* ---------- 应用主布局（登录态：顶栏 + 侧边栏 + 主区域） ---------- */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 顶栏 */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    height: var(--topbar-h);
    padding: 0 var(--gap-lg);
    background: rgba(26, 32, 48, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--c-border);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--c-text);
    white-space: nowrap;
}

.topbar__brand svg {
    width: 26px;
    height: 26px;
    color: var(--c-primary);
}

.topbar__spacer {
    flex: 1;
}

.topbar__user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar__username {
    color: var(--c-text-muted);
    font-size: 0.9rem;
}

.topbar__username strong {
    color: var(--c-text);
    font-weight: 600;
}

/* 角色徽章 */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 999px;
    background: rgba(79, 124, 255, 0.15);
    color: var(--c-primary);
    border: 1px solid rgba(79, 124, 255, 0.3);
}

.role-badge.role-admin {
    background: rgba(246, 183, 60, 0.15);
    color: var(--c-warning);
    border-color: rgba(246, 183, 60, 0.35);
}

/* 应用主体：侧边栏 + 主内容 */
.app-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    padding: var(--gap) 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--c-text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: background var(--t-fast), color var(--t-fast);
}

.sidebar__link:hover {
    background: var(--c-surface-2);
    color: var(--c-text);
}

.sidebar__link.is-active {
    background: rgba(79, 124, 255, 0.15);
    color: var(--c-primary);
    font-weight: 600;
}

.sidebar__link.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    width: 3px;
    height: 24px;
    background: var(--c-primary);
    border-radius: 0 3px 3px 0;
}

.sidebar__link {
    position: relative;
}

.sidebar__link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar__footer {
    margin-top: auto;
    padding-top: var(--gap);
    border-top: 1px solid var(--c-border);
    font-size: 0.78rem;
    color: var(--c-text-muted);
}

/* 主内容区 */
.main {
    flex: 1;
    min-width: 0;
    padding: var(--gap-lg);
    overflow-x: auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap);
    margin-bottom: var(--gap-lg);
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--c-text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ---------- 居中卡片布局（登录/注册页） ---------- */
.center-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--gap);
}

.brand-hero {
    text-align: center;
    margin-bottom: var(--gap-lg);
}

.brand-hero svg {
    width: 56px;
    height: 56px;
    color: var(--c-primary);
    margin: 0 auto var(--gap);
}

.brand-hero h1 {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.brand-hero p {
    color: var(--c-text-muted);
    font-size: 0.9rem;
}

/* ---------- 表单通用 ---------- */
.form-row {
    margin-bottom: var(--gap);
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.88rem;
    color: var(--c-text-muted);
    font-weight: 500;
}

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

.form-error {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--c-danger);
}

/* ---------- 可访问性：聚焦态 ---------- */
:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--c-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--c-surface-2);
    border-radius: 5px;
    border: 2px solid var(--c-bg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--c-border);
}

/* 选中态颜色 */
::selection {
    background: rgba(79, 124, 255, 0.35);
    color: var(--c-text);
}
