/* ============================================================
   hhh66.icu 共享设计系统  base.css v2.0
   - 设计令牌（深/浅双主题）
   - 共享组件：玻璃头部 / 按钮 / 卡片 / 表单 / Toast / 骨架屏
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
    /* 品牌色（两主题通用） */
    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --accent-glow: #818cf8;
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --info: #38bdf8;

    /* 尺寸刻度 */
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --header-h: 60px;

    /* 字体 */
    --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Segoe UI", "Helvetica Neue", Roboto, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono",
        Consolas, "Courier New", monospace;

    /* 动效 */
    --ease: cubic-bezier(.22, .68, .35, 1);
    --dur: .25s;

    color-scheme: dark;
}

/* ---------- 深色主题（默认） ---------- */
:root, [data-theme="dark"] {
    --bg: #070b16;
    --bg-2: #0b1122;
    --card: rgba(148, 163, 184, .055);
    --card-solid: #10172e;
    --card-hover: rgba(148, 163, 184, .11);
    --card-alt: rgba(148, 163, 184, .09);
    --text: #e9edf7;
    --muted: #8f9ab3;
    --border: rgba(148, 163, 184, .16);
    --border-strong: rgba(148, 163, 184, .28);
    --header-bg: rgba(7, 11, 22, .72);
    --input-bg: rgba(148, 163, 184, .08);
    --tooltip-bg: #141b33;
    --shadow-sm: 0 2px 10px rgba(2, 6, 18, .35);
    --shadow: 0 12px 36px rgba(2, 6, 18, .5);
    --shadow-lg: 0 24px 64px rgba(2, 6, 18, .6);
    --glass-blur: saturate(1.4) blur(14px);
    --star-alpha: 1;
    --aurora-1: rgba(99, 102, 241, .16);
    --aurora-2: rgba(139, 92, 246, .10);
    --aurora-3: rgba(56, 189, 248, .07);
    --code-inline: #fbbf24;
    --scrollbar: rgba(148, 163, 184, .25);
}

/* ---------- 浅色主题 ---------- */
[data-theme="light"] {
    color-scheme: light;
    --bg: #f2f4fa;
    --bg-2: #e9edf6;
    --card: #ffffff;
    --card-solid: #ffffff;
    --card-hover: #f7f9fe;
    --card-alt: #f1f4fb;
    --text: #1a2340;
    --muted: #5d6b8c;
    --border: #e2e7f3;
    --border-strong: #c9d2e8;
    --header-bg: rgba(255, 255, 255, .78);
    --input-bg: #f4f6fc;
    --tooltip-bg: #ffffff;
    --shadow-sm: 0 1px 4px rgba(26, 35, 64, .06);
    --shadow: 0 10px 30px rgba(26, 35, 64, .09);
    --shadow-lg: 0 24px 60px rgba(26, 35, 64, .14);
    --glass-blur: saturate(1.6) blur(14px);
    --star-alpha: .38;
    --aurora-1: rgba(99, 102, 241, .10);
    --aurora-2: rgba(139, 92, 246, .07);
    --aurora-3: rgba(56, 189, 248, .06);
    --code-inline: #b45309;
    --scrollbar: rgba(93, 107, 140, .3);
}

/* ---------- 基础重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background .35s ease, color .35s ease;
}

::selection { background: rgba(99, 102, 241, .32); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; }

a { color: var(--accent-glow); }
button { font-family: inherit; }
img { max-width: 100%; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- 极光背景氛围层 ---------- */
.aurora {
    position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.aurora::before, .aurora::after {
    content: ''; position: absolute; border-radius: 50%;
    filter: blur(90px); will-change: transform;
}
.aurora::before {
    width: 55vw; height: 55vw; top: -18vw; right: -12vw;
    background: radial-gradient(circle, var(--aurora-1), transparent 65%);
    animation: auroraFloat 26s ease-in-out infinite alternate;
}
.aurora::after {
    width: 48vw; height: 48vw; bottom: -16vw; left: -10vw;
    background: radial-gradient(circle, var(--aurora-2), transparent 65%),
                radial-gradient(circle at 70% 30%, var(--aurora-3), transparent 60%);
    animation: auroraFloat 32s ease-in-out infinite alternate-reverse;
}
@keyframes auroraFloat {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(-4vw, 3vw, 0) scale(1.12); }
}

/* ---------- 玻璃拟态头部 ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    min-height: var(--header-h);
    padding: 0 16px;
    background: var(--header-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
}
.site-header h1 {
    font-size: 1.12rem; font-weight: 650; letter-spacing: .3px;
    display: flex; align-items: center; gap: 8px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-header .spacer { flex: 1; }

.nav-back {
    position: absolute; left: 14px;
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--muted); text-decoration: none;
    font-size: .84rem; font-weight: 500;
    padding: 6px 13px; border-radius: 999px;
    background: var(--card-alt); border: 1px solid var(--border);
    transition: all var(--dur) var(--ease);
}
.nav-back:hover { color: var(--accent-glow); border-color: var(--accent); transform: translateX(-2px); }

.header-actions {
    position: absolute; right: 14px;
    display: flex; align-items: center; gap: 8px;
}

/* 头部通用小按钮（管理 / 主题） */
.hd-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    min-width: 34px; height: 34px; padding: 0 10px;
    border-radius: 999px; border: 1px solid var(--border);
    background: var(--card-alt); color: var(--muted);
    font-size: .84rem; cursor: pointer; user-select: none;
    transition: all var(--dur) var(--ease);
}
.hd-btn:hover { color: var(--accent-glow); border-color: var(--accent); transform: translateY(-1px); }

/* ---------- 主题切换按钮（日月图标旋转） ---------- */
.theme-toggle svg { width: 17px; height: 17px; display: block; }
.theme-toggle .icon-sun, .theme-toggle .icon-moon {
    transition: opacity .3s var(--ease), transform .45s var(--ease);
}
[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(.4); position: absolute; }
[data-theme="dark"] .theme-toggle .icon-sun { opacity: 1; transform: none; }
[data-theme="light"] .theme-toggle .icon-sun { opacity: 0; transform: rotate(-90deg) scale(.4); position: absolute; }
[data-theme="light"] .theme-toggle .icon-moon { opacity: 1; transform: none; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border: none; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 14px; font-weight: 550; text-decoration: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), filter var(--dur);
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(99, 102, 241, .38); filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 6px 14px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { background: linear-gradient(135deg, #f87171, #ef4444); }
.btn-danger:hover:not(:disabled) { box-shadow: 0 8px 22px rgba(239, 68, 68, .35); }
.btn-success { background: linear-gradient(135deg, #34d399, #10b981); }
.btn-success:hover:not(:disabled) { box-shadow: 0 8px 22px rgba(16, 185, 129, .35); }
.btn-muted {
    background: var(--card-alt); color: var(--text);
    border: 1px solid var(--border);
}
.btn-muted:hover:not(:disabled) { box-shadow: var(--shadow-sm); border-color: var(--border-strong); filter: none; }

/* ---------- 卡片 ---------- */
.card-surface {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: background .35s ease, border-color .35s ease, box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

/* ---------- 表单 ---------- */
.input, input.input, textarea.input, select.input {
    width: 100%; padding: 11px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit; color: var(--text);
    background: var(--input-bg); outline: none;
    transition: border-color var(--dur), box-shadow var(--dur), background .35s ease;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .16); }
.input::placeholder { color: var(--muted); opacity: .75; }

/* 原生 select 下拉弹层适配双主题（弹层由浏览器原生渲染，需显式覆盖） */
select option { background: var(--card-solid); color: var(--text); }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 36px; right: 26px; z-index: 1000;
    max-width: min(420px, calc(100vw - 40px));
    padding: 13px 20px; border-radius: 12px;
    background: var(--tooltip-bg); color: var(--text);
    box-shadow: var(--shadow); font-size: .9rem;
    transform: translateX(calc(100% + 30px));
    transition: transform .35s var(--ease);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
}
.toast.show { transform: translateX(0); }
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--success); }
.toast.warn { border-left-color: var(--warning); }

/* ---------- 骨架屏 ---------- */
.skeleton {
    position: relative; overflow: hidden;
    background: var(--card-alt); border-radius: var(--radius);
    border: 1px solid var(--border);
}
.skeleton::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, .14), transparent);
    animation: shimmer 1.4s infinite;
    transform: translateX(-100%);
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skl-line { height: 12px; border-radius: 6px; background: var(--card-alt); margin-bottom: 10px; }

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center; color: var(--muted);
    padding: 72px 20px; font-size: .95rem;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-state .empty-icon { font-size: 2.4rem; opacity: .6; }

/* ---------- 淡入动画 ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .45s var(--ease) both; }

/* ---------- 徽章 ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 11px; border-radius: 999px;
    font-size: .76rem; font-weight: 550;
    background: rgba(99, 102, 241, .14); color: var(--accent-glow);
}
[data-theme="light"] .badge { color: var(--accent); }

/* ---------- 工具类 ---------- */
.hidden { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- 减少动态偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
    html { scroll-behavior: auto; }
}
