/* Shared styles across pages (index.html, content.html) */

/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui,-apple-system,Segoe UI,Rototo,Helvetica,Arial,sans-serif;
    color: #181C1F;
    line-height: 1.6;
    padding-top: 60px; /* 为固定顶部栏留出空间 */
}

/* 顶部固定栏 */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header-container {
    max-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-link {
    display: flex;
    align-items: center;
}

.logo {
    height: 40px;
    width: auto;
}

.header-center {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 15px;
    color: #999;
    font-size: 14px;
}

.search-input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    background-color: #f5f5f5;
    transition: background-color 0.2s, border-color 0.2s;
}

.search-input:focus {
    outline: none;
    background-color: #ffffff;
    border-color: #ff6600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 图标按钮（消息、通知） */
.header-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    padding: 0;
}

.header-icon-btn:hover {
    background-color: #f0f0f0;
    color: #181C1F;
}

/* 创建按钮 */
.header-create-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: none;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: #181C1F;
    cursor: pointer;
    transition: all 0.2s;
}

.header-create-btn:hover {
    background-color: #f5f5f5;
}

.header-create-btn i {
    font-size: 16px;
}

/* 用户头像 */
.user-avatar-wrapper {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 18px;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}

.user-avatar:hover {
    transform: scale(1.05);
}

.user-avatar i {
    position: relative;
    z-index: 1;
}

/* 在线状态指示器 */
.user-status-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 12px;
    height: 12px;
    background-color: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

/* 主容器 */
.main-container {
    display: flex;
    min-height: calc(100vh - 60px);
}

/* 左侧菜单 */
.sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    width: 180px;
    background-color: #ffffff;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 100;
    border-right: 1px solid #e0e0e0;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

/* 菜单切换按钮 */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    cursor: pointer;
    color: #666;
    font-size: 16px;
    transition: background-color 0.2s, color 0.2s;
}

.sidebar-toggle:hover {
    background-color: #f5f5f5;
    color: #ff6600;
}

/* 固定在左侧菜单右边界那条线上（不随内容区居中移动） */
.sidebar-toggle-edge {
    position: fixed;
    top: 96px; /* 60px header + 36px 视觉间距 */
    left: 180px; /* 与 .sidebar 宽度一致 */
    transform: translateX(-50%); /* 按钮中心压在分割线上 */
    z-index: 1003;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.sidebar-toggle-edge:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* 当侧边栏隐藏时，按钮贴到屏幕左边缘 */
.sidebar.hidden ~ .sidebar-toggle-edge {
    left: 0;
    transform: translateX(50%);
    border-left: none;
}

.sidebar-nav {
    padding: 20px 0 20px 16px;
}

.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    font-size: 14px;
    font-weight: 400;
    color: #21272A;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 5px 0px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.nav-section-title:hover {
    color: #4a5b6e;
}

.nav-section-text {
    flex: 1;
}

.nav-section-toggle {
    font-size: 12px;
    color: #5a6b7e;
    transition: transform 0.3s ease, color 0.2s;
}

.nav-section-title:hover .nav-section-toggle {
    color: #4a5b6e;
}

.nav-section.collapsed .nav-section-toggle {
    transform: rotate(180deg);
}

.nav-section.collapsed .nav-list {
    display: none;
}

.nav-list {
    list-style: none;
}

.nav-list li {
    margin: 0;
    height: 40px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    height: 40px;
    color: #21272A;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
    line-height: 1.5;
}

.nav-link:hover {
    background-color: #f5f5f5;
}

.nav-link i {
    width: 20px;
    text-align: center;
    color: #666;
}

.nav-divider {
    height: 1px;
    background-color: #e0e0e0;
    margin: 15px 10px;
}

/* 右侧内容区 */
.content-area {
    flex: 1;
    margin-left: 180px;
    display: flex;
    gap: 0;
    transition: margin-left 0.3s ease;
    max-width: calc(100% - 180px);
    min-height: calc(100vh - 60px);
}

.sidebar.hidden ~ .content-area {
    margin-left: 0;
    max-width: 100%;
}

/* 主内容区 */
.main-content {
    flex: 1;
    padding: 12px 16px;
    min-width: 0;
}

/* 右侧边栏 */
.right-sidebar {
    width: 320px;
    min-width: 320px;
    display: flex;
    padding: 20px 20px 20px 0;
    background-color: transparent;
}

/* 右侧列表部分 */
.right-list-section {
    width: 300px;
    margin-top: 20px;
    background-color: #f3f5f7;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-size: 12px;
}

/* 右侧列表区块 */
.right-list-block {
    padding: 16px;
}

/* 右侧区块之间的分割线 */
.right-list-block-divider {
    height: 1px;
    background-color: #e0e0e0;
    margin: 0 16px;
}

.right-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.right-list-header h3 {
    font-size: 12px;
    font-weight: 600;
    color: #181C1F;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.right-list-header h3 i {
    color: #ff6600;
    font-size: 12px;
}

/* 社区书签部分 */
.bookmark-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bookmark-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: #ffffff;
    border-radius: 6px;
    text-decoration: none;
    color: #181C1F;
    font-size: 12px;
    transition: background-color 0.2s;
}

.bookmark-item:hover {
    background-color: #f0f0f0;
}

.bookmark-item i {
    font-size: 10px;
    color: #999;
}

/* 规则部分 */
.rules-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
    color: #181C1F;
}

.rule-number {
    font-weight: 600;
    min-width: 16px;
}

.rule-text {
    flex: 1;
}

.rule-item i {
    font-size: 10px;
    color: #999;
    margin-left: auto;
}

/* 推荐的子版块部分 */
.subreddit-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.subreddit-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #181C1F;
}

.subreddit-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #000000;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.subreddit-icon-orange {
    background-color: #ff6600;
}

.subreddit-info {
    flex: 1;
    min-width: 0;
}

.subreddit-name {
    font-size: 12px;
    font-weight: 600;
    color: #181C1F;
    margin-bottom: 2px;
}

.subreddit-members {
    font-size: 11px;
    color: #666;
}

/* 最右侧竖着区域 */
.right-edge-section {
    width: 60px;
    min-width: 60px;
    background-color: transparent;
}

/* 内容工具栏（通用） */
.content-toolbar {
    margin-bottom: 5px;
    padding: 0;
    padding-bottom: 5px;
    border-bottom: 1px solid #e0e0e0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 下拉菜单按钮（预留） */
.dropdown {
    position: relative;
}

.dropdown-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: none;
    border: none;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.dropdown-btn:hover {
    background-color: #f5f5f5;
}

.dropdown-btn i {
    font-size: 10px;
    color: #999;
}

/* 通用操作按钮（帖子/内容页操作区复用） */
.post-action {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: none;
    border: none;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.post-action:hover {
    background-color: #f5f5f5;
    color: #181C1F;
}

.post-action i {
    font-size: 14px;
}

.post-action.liked {
    color: #ff6600;
}

/* 响应式设计 */

/* 第一步：隐藏右侧竖框（当窗口宽度小于1400px时） */
@media (max-width: 1400px) {
    .right-edge-section {
        display: none;
    }
}

/* 第二步：隐藏右侧边栏（当窗口宽度小于1200px时） */
@media (max-width: 1200px) {
    .right-sidebar {
        display: none;
    }

    .content-area {
        max-width: 100%;
    }
}

/* 第三步：隐藏左侧菜单，但保留切换按钮（当窗口宽度小于992px时） */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1002;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
        transition: transform 0.3s ease;
    }

    /* 移动端默认隐藏侧边栏 */
    .sidebar.hidden {
        transform: translateX(-100%);
    }

    /* 当侧边栏不隐藏时显示 */
    .sidebar:not(.hidden) {
        transform: translateX(0);
    }

    .content-area {
        margin-left: 0;
        max-width: 100%;
    }

    /* 确保切换按钮始终可见 */
    .sidebar-toggle {
        position: fixed;
        z-index: 1003;
    }

    .sidebar-toggle-edge {
        left: 0;
        transform: translateX(50%);
    }

    /* 侧边栏遮罩层 */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1001;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* 第四步：缩小搜索框和其他元素（当窗口宽度小于768px时） */
@media (max-width: 768px) {
    .header-container {
        padding: 0 12px;
        gap: 8px;
    }

    .header-center {
        flex: 0 0 auto;
        max-width: 150px;
        min-width: 100px;
    }

    .search-box {
        min-width: 100px;
    }

    .search-input {
        padding: 8px 12px 8px 32px;
        font-size: 13px;
    }

    .search-box i {
        left: 10px;
        font-size: 12px;
    }

    .header-left {
        gap: 8px;
    }

    /* 手机端：把侧边栏切换按钮收进顶部栏（Logo 前） */
    .sidebar-toggle-edge {
        position: static;
        top: auto;
        left: auto;
        transform: none;
        background: none;
        border: none;
        box-shadow: none;
        width: 44px;
        height: 44px;
        border-radius: 50%;
    }

    .logo {
        height: 32px;
    }

    .header-icon-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .header-create-btn {
        padding: 10px 16px;
        font-size: 15px;
        min-width: 44px;
        min-height: 44px;
    }

    .header-create-btn span {
        display: none;
    }

    .header-create-btn i {
        font-size: 20px;
    }

    .user-avatar {
        width: 38px;
        height: 38px;
        font-size: 17px;
        border: 2px solid #ffffff;
    }

    .header-right {
        gap: 4px;
    }

    .main-content {
        padding: 10px 12px;
    }

    .content-toolbar {
        padding-bottom: 8px;
    }
}

/* 第五步：进一步优化小屏幕（当窗口宽度小于480px时） */
@media (max-width: 480px) {
    .header-container {
        padding: 0 8px;
        gap: 6px;
    }

    .header-center {
        max-width: 120px;
        min-width: 80px;
    }

    .search-input {
        padding: 6px 10px 6px 28px;
        font-size: 12px;
    }

    .search-box i {
        left: 8px;
        font-size: 11px;
    }

    .logo {
        height: 28px;
    }

    .header-icon-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .header-create-btn {
        padding: 10px 16px;
        font-size: 15px;
        min-width: 44px;
        min-height: 44px;
    }

    .header-create-btn i {
        font-size: 20px;
    }

    .user-avatar {
        width: 38px;
        height: 38px;
        font-size: 17px;
        border: 2px solid #ffffff;
    }

    .header-right {
        gap: 4px;
    }

    .sidebar-toggle {
        width: 40px;
        height: 40px;
        font-size: 18px;
        margin-right: 4px;
    }

    .main-content {
        padding: 10px 10px;
    }
}

/* 滚动条样式 */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #999;
}

