/* =====================================================
   🎨 猫叔AIA — 双主题系统 (CyberTech)
   暗夜机械 (Dark) / 白昼极光 (Light)
   ===================================================== */

/* ========== 主题变量 ========== */
:root,
[data-theme="dark"] {
    --bg: #0b0f1a;
    --bg-card: #111827;
    --bg-nav: rgba(11, 15, 26, 0.88);
    --bg-sidebar: #0d1117;
    --border: #1e293b;
    --border-light: #334155;
    --text: #e2e8f0;
    --text-muted: #64748b;
    --primary: #818cf8;
    --primary-glow: rgba(129, 140, 248, 0.12);
    --accent: #22d3ee;
    --accent-glow: rgba(34, 211, 238, 0.08);
    --success: #34d399;
    --warning: #fbbf24;
    --error: #f87171;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 220px;
    --grid-color: rgba(129, 140, 248, 0.04);
    --glow-primary: 0 0 24px rgba(129, 140, 248, 0.15);
    --glow-accent: 0 0 24px rgba(34, 211, 238, 0.1);
    --btn-theme-bg: rgba(129, 140, 248, 0.1);
    --btn-theme-border: rgba(129, 140, 248, 0.25);
    --code-bg: #0d1117;
    --scrollbar-thumb: #1e293b;
    --scrollbar-track: #0b0f1a;
}

[data-theme="light"] {
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --bg-nav: rgba(255, 255, 255, 0.9);
    --bg-sidebar: #ffffff;
    --border: #d1d9e6;
    --border-light: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.07);
    --accent: #0891b2;
    --accent-glow: rgba(8, 145, 178, 0.05);
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 220px;
    --grid-color: rgba(99, 102, 241, 0.03);
    --glow-primary: 0 0 20px rgba(99, 102, 241, 0.1);
    --glow-accent: 0 0 20px rgba(8, 145, 178, 0.06);
    --btn-theme-bg: rgba(99, 102, 241, 0.06);
    --btn-theme-border: rgba(99, 102, 241, 0.15);
    --code-bg: #f8fafc;
    --scrollbar-thumb: #cbd5e1;
    --scrollbar-track: #f1f5f9;
}

/* ========== 主题三：汇川工业蓝 (Inovance Blue) ========== */
[data-theme="inovance"] {
    --bg: #16181a;
    --bg-card: #222426;
    --bg-nav: rgba(22, 24, 26, 0.92);
    --bg-sidebar: #1a1c1e;
    --border: #2e3034;
    --border-light: #454e66;
    --text: #e8eaed;
    --text-muted: #8a9bb5;
    --primary: #0099f2;
    --primary-glow: rgba(0, 153, 242, 0.15);
    --accent: #00bcd4;
    --accent-glow: rgba(0, 188, 212, 0.1);
    --success: #43a047;
    --warning: #ff9800;
    --error: #e53935;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 220px;
    --grid-color: rgba(0, 153, 242, 0.04);
    --glow-primary: 0 0 28px rgba(0, 153, 242, 0.18);
    --glow-accent: 0 0 24px rgba(0, 188, 212, 0.12);
    --btn-theme-bg: rgba(0, 153, 242, 0.1);
    --btn-theme-border: rgba(0, 153, 242, 0.3);
    --code-bg: #1e2022;
    --scrollbar-thumb: #454e66;
    --scrollbar-track: #16181a;
}

/* ========== 科技感背景网格 ========== */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 48px 48px;
}

.main-content,
.admin-main,
.auth-page,
.about-page,
.post-detail,
.posts-section,
.hero {
    position: relative;
    z-index: 1;
}

/* ========== 自定义滚动条 ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== 主题切换按钮 ========== */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--btn-theme-border);
    background: var(--btn-theme-bg);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
    line-height: 1;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-glow);
    transform: rotate(15deg);
}

.theme-toggle:active {
    transform: scale(0.9);
}

.theme-toggle .theme-icon {
    transition: transform 0.4s ease;
    display: inline-block;
}

.theme-toggle:hover .theme-icon {
    animation: themeSpin 0.6s ease;
}

@keyframes themeSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== 科技感卡片装饰 ========== */
.post-card,
.stat-card,
.auth-card,
.post-form,
.table-container {
    position: relative;
    overflow: hidden;
}

/* 左上角科技感小装饰 */
.post-card::before,
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.post-card:hover::before,
.stat-card:hover::before {
    opacity: 1;
}

/* ========== 按钮科技感增强 ========== */
.btn-primary {
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.08) 50%, transparent 60%);
    background-size: 200% 200%;
    transition: background-position 0.5s ease;
}

.btn-primary:hover::after {
    background-position: 100% 100%;
}

/* ========== 导航栏玻璃效果增强 ========== */
.navbar {
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-bottom: 1px solid var(--border);
}

/* ========== 代码块科技感 ========== */
.markdown-body pre {
    background: var(--code-bg) !important;
    border: 1px solid var(--border);
    position: relative;
}

/* 代码块顶部文件栏装饰 */
.markdown-body pre::before {
    content: '';
    display: block;
    height: 12px;
    padding: 0;
    margin-bottom: 16px;
    background: repeating-linear-gradient(
        90deg,
        var(--error) 0px, var(--error) 6px,
        transparent 6px, transparent 10px,
        var(--warning) 10px, var(--warning) 16px,
        transparent 16px, transparent 20px,
        var(--success) 20px, var(--success) 26px,
        transparent 26px, transparent 30px
    );
    border-radius: 4px;
}

/* ========== Hero 区域科技感增强 ========== */
.hero {
    position: relative;
}

.hero::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.hero-title {
    letter-spacing: -0.5px;
    position: relative;
}

.hero-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    margin: 16px auto 0;
}

/* ========== 文章内容科技感 ========== */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    letter-spacing: -0.3px;
}

.markdown-body h2 {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.markdown-body blockquote {
    border-left: 3px solid var(--primary);
    background: linear-gradient(135deg, var(--primary-glow), transparent);
}

/* ========== 侧栏增强 ========== */
.admin-sidebar {
    border-right: 1px solid var(--border);
    background: var(--bg-sidebar);
}

.sidebar-link.active {
    border: 1px solid var(--border-light);
    background: var(--primary-glow);
}

/* ========== 输入框聚焦效果增强 ========== */
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow), var(--glow-primary);
}

/* ========== 分页 ========== */
.page-link {
    position: relative;
}

.page-link:hover {
    border-color: var(--primary);
    box-shadow: var(--glow-primary);
}

/* ========== 导航链接 ========== */
.nav-link {
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 60%;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
    transition: transform 0.3s ease;
}

.nav-link:hover::after {
    transform: translateX(-50%) scaleX(1);
}

/* ========== 移动端适配 ========== */
@media (max-width: 640px) {
    body::before {
        background-size: 32px 32px;
    }
}

/* ========== 淡入加载动画 ========== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.post-card {
    animation: fadeInUp 0.4s ease both;
}

.post-card:nth-child(1) { animation-delay: 0.05s; }
.post-card:nth-child(2) { animation-delay: 0.1s; }
.post-card:nth-child(3) { animation-delay: 0.15s; }
.post-card:nth-child(4) { animation-delay: 0.2s; }
.post-card:nth-child(5) { animation-delay: 0.25s; }

/* ========== 标签徽章科技风 ========== */
.post-tag {
    border: 1px solid rgba(129, 140, 248, 0.2);
    backdrop-filter: blur(4px);
}

.post-tag:hover {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(129, 140, 248, 0.2);
}

/* ========== 分割线科技感 ========== */
hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-light), transparent);
    margin: 24px 0;
}

/* ========== 加载进度条（微博风格头部渐变） ========== */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
    background-size: 200% 100%;
    animation: loadingBar 2s ease infinite;
    z-index: 9999;
    opacity: 0.6;
    pointer-events: none;
}

@keyframes loadingBar {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
