/* style.css */
body {
    margin: 0;
    padding: 0;
    background-color: #F5F5F5;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
}

/* 导航栏样式 */
.nav-bar {
    position: fixed;
    top: 0;
    width: 100%;
    height: 50px;
    background-color:#556B55;
    display: flex;
    align-items: center;
    padding: 0 10px;
    box-sizing: border-box;
    z-index: 100;
    justify-content: center; 
}

.back-btn {
    color: #F5F5F5;
    font-size: 24px;
    cursor: pointer;
    position: absolute;  /* ← 新增定位 */
    left: 10px;         /* ← 固定左侧位置 */
}

.title {
    color: #F5F5F5;
    font-size: 18px;
    font-weight: 500;
}

/* 内容区域 */
.content-wrapper {
    margin-top: 60px;
    padding: 10px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}

.card-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

/* 社区卡片 */
.community-card {
    background: #FFFFFF;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.community-card:active {
    transform: scale(0.98);
}

.avatar {
    width: 40%;
    aspect-ratio: 1/1;
    background-color: #556B55;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
  }

.info {
    margin-left: 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.community-name {
    color: #6B8B6F;
    font-size: 16px;
    margin: 0;
    font-weight: 500;
}

.post-count {
    color: #A8A8A8;
    font-size: 12px;
    margin: 4px 0 0 0;
}

/* 页面容器基础样式 */
.page {
    display: none;
    position: fixed;
    width: 100%;
    height: 100vh;
    top: 0;
    left: 0;
    background: #F5F5F5;
    overflow-y: auto;
}

.page.active {
    display: block;
}

/* 详情页头部特殊样式 */
.detail-header {
    position: sticky;
    top: 0;
    background: white;
    z-index: 100;
    padding: 15px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* 添加详情页样式 */
/* 标题行布局 */
.title-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: nowrap;
}

.detail-avatar {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 10px;
}

.community-header {
    display: flex;
    align-items: center;
    padding: 8px;
    background: white;
    margin-bottom: 5px;
    border-radius: 6px; 
    width: calc(100% - 16px);
    margin: 0 auto 8px;       
}

.community-info h2 {
    color: #556B55;     /* [!code ++] 使用导航栏同款绿色 */
    font-size: 20px;    /* [!code ++] 原默认16px */
    margin: 0 0 4px 0; /* [!code ++] 调整间距 */
    white-space: nowrap;
}

.description {
    color: #888888;     /* [!code ++] 更浅的灰色 */
    font-size: 13px;    /* [!code ++] 可选缩小字号 */
    line-height: 1.4;   /* [!code ++] 紧凑行高 */
    margin: 0;          /* [!code ++] 移除默认外边距 */
}

.post-list {
    padding: 0 8px; 
    max-width: 800px; 
    margin: 0 auto; 
}

.post-card {
    background: white;
    padding: 8px 12px; 
    border-radius: 8px;
    margin-bottom: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    width: calc(100% - 16px); 
    margin-left: auto;  
    margin-right: auto; 
}

.post-content {
    margin: 0 0 8px 0; /* 下边距减少 */
    line-height: 1.4;   /* 行高更紧凑 */
    font-size: 14px;
}

.post-image {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    margin-top: 10px;
    border-radius: 4px;
}

/* detail.html 专用样式 */
.detail-content {
    margin-top: 50px;
    padding: 15px;
    z-index: 1; 
    padding-bottom: 70px; /* 留出底部按钮空间 */
}

@media (max-width: 480px) {
    .card-container {
        grid-template-columns: 1fr;
    }
    
    .community-card {
        flex-direction: column;
    }
    
    .avatar {
        width: 100%;
        height: 120px;
    }
}

/* 缩略图样式 */
.thumbnail-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    margin: 10px 0;
}

.thumbnail {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    cursor: zoom-in;
    transition: transform 0.2s;
}

.thumbnail:hover {
    transform: scale(1.05);
}

/* 图片查看器 */
#imageViewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#imageViewer.hidden {
    display: none;
}

.image-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

#fullImage {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    color: white;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
}

/* 底部输入栏样式 */
.comment-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 8px 15px 6px; 
    display: flex;
    gap: 10px;
    box-shadow: 0 -1px 6px rgba(0,0,0,0.08);
    z-index: 1000;
}

.comment-input {
    flex: 3;
    min-height: 36px;
    padding: 6px 14px;
    border: 2px solid #d0d0d0;
    border-radius: 20px;
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05); /* 内阴影 */
}

/* 添加聚焦状态 */
.comment-input:focus {
    border-color: #556B55;
    outline: none;
    box-shadow: 0 0 0 2px rgba(85, 107, 85, 0.2);
}

.add-image-btn {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #f5f5f5;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    position: relative; 
}

.add-image-btn span {
    color: #556B55;
    font-size: 24px;
    line-height: 1;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* 精准居中 */
    transition: transform 0.2s; /* 添加动效 */
}

.send-btn {
    flex: none;
    background: #556B55;
    color: white;
    border: none;
    border-radius: 18px;
    padding: 4px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.3s;
    min-width: 60px;     /* 设置最小宽度 */
    height: 32px;        /* 固定高度 */
    line-height: 1;      /* 文字垂直居中 */
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 图片预览容器 */
.preview-container {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.preview-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #eee;
}

/* 关注按钮样式 */
.follow-btn {
    background-color: #556B55;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    flex-shrink: 0; /* 防止按钮被压缩 */
    margin-left: 8px; /* 直接控制左边距 */
}

.follow-btn.followed {
    background-color: #e0e0e0;
    color: #666;
}

/* 确保标题不会换行 */
.community-info h2 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px; /* 根据实际需要调整 */
}

/* 点赞和踩 */
.vote-section {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    justify-content: flex-end; /* 移动到右侧 */
}

.vote-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #556B55;
    background: none;
    cursor: pointer;
    transition: all 0.3s;
    color: #556B55; /* 保持主色调一致 */
}
  
.vote-btn:hover {
    background: rgba(85, 107, 85, 0.1);
}
  
.vote-btn.active {
    background: #556B55;
    color: white;
    border-color: transparent;
}

.more-community-tip {
    position: fixed;
    bottom: 40px;
    left: 0;
    right: 0;
    text-align: center;
    color: #999;
    font-size: 17px;
    pointer-events: none; /* 防止点击穿透 */
}