/* ========================================
   wiki - 聆风音乐 全局响应式样式
   ======================================== */

/* ----- 基础变量（后备） ----- */
:root {
    --primary: #8195FC;
    --primary-hover: #6b7de0;
    --bg: #f5f5f5;
    --surface: #ffffff;
    --text: #333333;
    --text-secondary: #888888;
    --border: #e0e0e0;
    --radius: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.05);
    --btn-radius: 4px;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --header-bg: #ffffff;
    --sidebar-bg: #2c3e50;
    --sidebar-text: #bdc3c7;
    --sidebar-hover: #34495e;
    --input-bg: #ffffff;
    --login-bg: #ffffff;
}

/* ----- 重置 ----- */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: var(--font-family);
    background: var(--bg);
    color: var(--text);
    margin: 0;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ----- 容器 ----- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

/* ==================== 头部导航 ==================== */
.main-header {
    background: var(--header-bg);
    box-shadow: var(--shadow);
    padding: 10px 0;
    position: relative;
}
.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}
.logo {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary) !important;
    text-decoration: none !important;
    white-space: nowrap;
}

/* 汉堡按钮 */
.hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.4em;
    padding: 5px 10px;
    cursor: pointer;
    color: var(--text);
    order: 1;
}
.hamburger:hover { background: var(--bg); }

/* 导航菜单 */
.nav-collapse {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}
.nav-select, .btn-outline, .btn { font-size: 0.95em; }

/* 用户栏 */
.user-info { font-weight: 500; white-space: nowrap; }

/* ==================== 按钮基础 ==================== */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border: none;
    border-radius: var(--btn-radius);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    transition: opacity 0.2s;
    font-family: var(--font-family);
    white-space: nowrap;
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn.danger { background: #e74c3c; }
.btn.danger:hover { background: #c0392b; }

/* ==================== 表单 ==================== */
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--text);
    width: 100%;
    margin: 5px 0 15px;
    -webkit-appearance: none;
}
textarea { min-height: 120px; resize: vertical; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px; }

/* ==================== 卡片 ==================== */
.article-item, .login-container, .comment, .content, .profile-card, .alert {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 15px;
}
.login-container {
    max-width: 400px;
    margin: 40px auto;
    background: var(--login-bg);
}

/* 文章列表网格 */
.article-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.article-item h3 { margin-top: 0; font-size: 1.2em; }
.article-item small { color: var(--text-secondary); }

/* ==================== 文章详情页 ==================== */
.article-page {
    display: flex;
    gap: 25px;
    align-items: flex-start;
}
.article-sidebar {
    width: 230px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    background: var(--surface);
    padding: 15px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.article-main { flex: 1; min-width: 0; }

/* 目录样式 */
.toc-nav ul { list-style: none; padding-left: 0; margin: 0; }
.toc-nav li { line-height: 1.5; margin: 4px 0; }
.toc-toggle { display: inline-block; width: 16px; color: var(--text-secondary); cursor: pointer; }
.toc-toggle:hover { color: var(--primary); }
.toc-active { font-weight: bold; color: #000 !important; background: rgba(129,149,252,0.08); border-radius: 3px; padding: 0 4px; }

/* 留言区 */
.comment { border-left: 3px solid var(--primary); }
.comment .reply { background: var(--bg); padding: 10px; margin-top: 10px; border-radius: 4px; }
.comment .status { font-size: 0.9em; color: var(--text-secondary); }

/* ==================== 后台专用 ==================== */
.admin-body { background: var(--bg); margin: 0; }
.admin-container { display: flex; min-height: 100vh; position: relative; }

/* 侧边栏 */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px 15px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}
.sidebar h2 { font-size: 1.1em; margin-top: 0; }
.sidebar ul { list-style: none; padding: 0; }
.sidebar ul li { margin: 8px 0; }
.sidebar a {
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 8px 12px;
    display: block;
    border-radius: 3px;
    transition: background 0.2s;
}
.sidebar a:hover { background: var(--sidebar-hover); color: #fff; }

/* 后台内容区 */
.content { flex: 1; padding: 20px; min-width: 0; }

/* 后台汉堡按钮（默认隐藏） */
.admin-hamburger {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 1.5em;
    padding: 5px 12px;
    cursor: pointer;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* 后台表格响应式 */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* 保证小屏不挤 */
}
.admin-table th, .admin-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.admin-table th { background: var(--bg); font-weight: 600; }

/* 表单分组 */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; }

/* 通用 */
footer { text-align: center; padding: 25px 15px; color: var(--text-secondary); font-size: 0.9em; }
.alert { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.error { color: #e74c3c; }
.success { color: #2ecc71; }

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    /* 前端头部 */
    .main-header .container {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .hamburger {
        display: block;
        order: 1;
    }
    .nav-collapse {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 10px;
        padding: 15px 0;
        background: var(--surface);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        margin-top: 10px;
    }
    .nav-collapse.show { display: flex; }
    .nav-select, .btn-outline, .btn {
        width: 100%;
        text-align: center;
    }

    /* 文章列表 */
    .article-list {
        grid-template-columns: 1fr;
    }

    /* 文章详情：目录移到上方 */
    .article-page {
        flex-direction: column;
    }
    .article-sidebar {
        width: 100%;
        position: static;
        max-height: none;
        margin-bottom: 20px;
    }

    /* 登录框 */
    .login-container { margin: 20px; padding: 20px; }

    /* 后台布局 */
    .admin-container { flex-direction: column; }
    .admin-hamburger { display: block; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 999;
        transform: translateX(-100%);
        width: 250px;
    }
    .sidebar.show { transform: translateX(0); }
    .content { margin-top: 50px; padding: 15px; }

    /* 表格滚动 */
    .table-wrapper { margin-left: -15px; margin-right: -15px; }
    .admin-table th, .admin-table td { padding: 8px 10px; font-size: 0.9em; }

    /* 按钮调整 */
    .btn.small { padding: 6px 10px; }

    /* 表单全宽 */
    input[type="text"], input[type="password"], input[type="email"], textarea, select {
        font-size: 16px; /* 防止 iOS 缩放 */
    }
}

@media (max-width: 480px) {
    .logo { font-size: 1.3em; }
    .container { padding: 10px; }
    .article-item, .comment, .content { padding: 15px; }
    h1 { font-size: 1.5em; }
    h2 { font-size: 1.3em; }
}

/* ========== 优化后的导航样式 ========== */
.nav-collapse {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.nav-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-select {
    width: auto;
    min-width: 90px;
    padding: 6px 8px;
    margin: 0;
    font-size: 0.9em;
    background-color: var(--surface);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 0.9em;
}

/* 汉堡按钮微调 */
.hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.4em;
    padding: 4px 10px;
    cursor: pointer;
    color: var(--text);
    order: 1;
}
.hamburger:hover { background: var(--bg); }
.hamburger.active { background: var(--bg); }

/* 响应式：移动端改为纵向排列 */
@media (max-width: 768px) {
    .hamburger { display: block; }
    .nav-collapse {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        background: var(--surface);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        margin-top: 10px;
    }
    .nav-collapse.show { display: flex; }
    .nav-group {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }
    .nav-group .btn, .nav-group .btn-outline, .nav-group .nav-select {
        width: 100%;
        text-align: center;
    }
}

/* 合集卡片网格 */
.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.collection-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    transition: transform 0.2s, box-shadow 0.2s;
}
.collection-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    text-decoration: none;
}
.collection-card h3 {
    margin-top: 0;
    color: var(--primary);
}
.collection-card p.count {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* 合集侧边栏中的文章列表样式 */
.collection-nav a {
    display: block;
    padding: 6px 10px;
    border-radius: var(--radius);
    color: var(--text);
    transition: background 0.2s;
}
.collection-nav a:hover {
    background: var(--bg);
    color: var(--primary);
}
.collection-nav a.active {
    background: var(--primary);
    color: #fff;
    font-weight: bold;
}

/* 毛玻璃与背景图 */
body.glass-bg {
    background-image: var(--bg-image);
    background-size: cover;
    background-attachment: fixed;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
}
.glass-container {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(5px);
    border-radius: var(--radius);
}
/* 将主要容器添加毛玻璃背景 */
.main-header, .container, .content, .sidebar, .login-container, .article-item, .comment {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    background-color: rgba(var(--surface-rgb, 255,255,255), 0.7);
}

body.custom-bg {
    background-image: var(--bg-image);
    background-size: cover;
    background-attachment: fixed;
}
body.glass-on .main-header,
body.glass-on .container,
body.glass-on .content,
body.glass-on .sidebar,
body.glass-on .login-container,
body.glass-on .article-item,
body.glass-on .comment,
body.glass-on .dashboard-card,
body.glass-on .collection-form-area,
body.glass-on .editor-area {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    background-color: rgba(255,255,255,0.7);
}

.table-wrapper { overflow-x: auto; }
.admin-table { min-width: 700px; }  /* 确保最小宽度，小屏滚动 */

/* 毛玻璃全局美化 */
body.glass-on .main-header,
body.glass-on .container,
body.glass-on .content,
body.glass-on .sidebar,
body.glass-on .login-container,
body.glass-on .article-item,
body.glass-on .comment,
body.glass-on .dashboard-card,
body.glass-on .collection-form-area,
body.glass-on .editor-area,
body.glass-on .media-item {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background-color: rgba(255,255,255,0.65);
    border-right: 1px solid rgba(255,255,255,0.8);   /* 右侧高光 */
    border-bottom: 1px solid rgba(255,255,255,0.8);  /* 底部高光 */
    box-shadow: 4px 4px 12px rgba(0,0,0,0.08), inset 0 0 0 1px rgba(255,255,255,0.6);
    transition: all 0.3s ease;
}

body.glass-on .article-item:hover,
body.glass-on .comment:hover,
body.glass-on .dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 6px 8px 18px rgba(0,0,0,0.12), inset 0 0 0 1px rgba(255,255,255,0.8);
}

/* 强制侧边栏文字清晰 */
.sidebar, .sidebar a, .sidebar h2 {
    color: #000000 !important;
    font-weight: 500;
}
.sidebar a:hover {
    background: rgba(255,255,255,0.15);
    color: #ffffff !important;
}
.content img { max-width: 100%; height: auto; }

progress {
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    height: 8px;
}
progress::-webkit-progress-bar { background-color: var(--bg); border-radius: 4px; }
progress::-webkit-progress-value { background-color: var(--primary); border-radius: 4px; }