/* Leader页面移动端优化样式 */

/* 基础字体大小设置 */
html {
    font-size: 16px;
}

/* 响应式字体大小 */
@media screen and (max-width: 375px) {
    html { font-size: 14px; }
}

@media screen and (min-width: 414px) {
    html { font-size: 18px; }
}

/* 帖子卡片样式 */
.post-card {
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    overflow: hidden;
    contain: layout style paint;
    transform: translateZ(0);
    will-change: transform;
}

/* 用户信息区 */
.user-info {
    min-height: 2.5rem;
}

/* 内容预览区 */
.content-preview {
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.content-preview:active {
    opacity: 0.8;
}

/* 行数限制 */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.line-clamp-10 {
    display: -webkit-box;
    -webkit-line-clamp: 10;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: pre-wrap; /* 保留换行符 */
    line-height: 1.5;
}

/* 图片网格布局 - 微信朋友圈风格 */
.image-grid {
    display: grid;
    gap: 0.25rem;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

/* 单张图片 */
.image-grid.grid-1 {
    grid-template-columns: 1fr;
}

.image-grid.grid-1 .image-item {
    max-width: 15rem;
    aspect-ratio: 4/3;
}

/* 2张图片 */
.image-grid.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* 3张图片 */
.image-grid.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* 4张图片 - 2x2布局 */
.image-grid.grid-4 {
    grid-template-columns: repeat(2, 1fr);
}

/* 5-9张图片 - 3x3布局 */
.image-grid.grid-5,
.image-grid.grid-6,
.image-grid.grid-7,
.image-grid.grid-8,
.image-grid.grid-9 {
    grid-template-columns: repeat(3, 1fr);
}

/* 图片项 */
.image-item {
    position: relative;
    overflow: hidden;
    border-radius: 0.25rem;
    background-color: #f3f4f6;
    aspect-ratio: 1; /* 正方形 */
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: #f3f4f6;
    display: block;
}

/* 懒加载图片 */
.image-item .lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease;
    background: #f3f4f6 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><path fill="%23ddd" d="M20 5a15 15 0 100 30 15 15 0 000-30zm0 4a11 11 0 110 22 11 11 0 010-22zm-2 5v12h4V14h-4zm0 14v4h4v-4h-4z"/></svg>') center/40px no-repeat;
}

.image-item .lazy-image.loaded {
    opacity: 1 !important;
    background: none;
}

/* 更多图片标记 */
.more-images {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    backdrop-filter: blur(2px);
}

/* 分类标签 */
.category-tag {
    white-space: nowrap;
    flex-shrink: 0;
}

/* 互动栏 */
.interaction-bar {
    min-height: 2.5rem;
}

.interaction-bar span {
    display: flex;
    align-items: center;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.5rem;
    margin: -0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-radius: 0.375rem;
}

.interaction-bar span:active {
    background-color: #f3f4f6;
}

/* 分类标签滚动条优化 */
#categoryTabs {
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.125rem;
}

/* 搜索框优化 */
input[type="text"] {
    font-size: 1rem;
    -webkit-appearance: none;
}

/* 发帖按钮优化 */
#createPostBtn {
    min-height: 2.75rem;
    font-size: 1rem;
    position: relative;
    z-index: 20;
}

/* 加载动画 */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* 下拉刷新样式 */
.pull-to-refresh {
    position: absolute;
    top: -3rem;
    left: 0;
    right: 0;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    z-index: 10;
    pointer-events: none;
}

.pull-to-refresh.active {
    transform: translateY(3rem);
}

.pull-to-refresh .refresh-icon {
    width: 1.5rem;
    height: 1.5rem;
    transition: transform 0.3s ease;
}

.pull-to-refresh.refreshing .refresh-icon {
    animation: spin 1s linear infinite;
}

/* 无限滚动加载指示器 */
.load-more {
    padding: 1rem;
    text-align: center;
    color: #6b7280;
}

.load-more.loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 空状态 */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: #6b7280;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #d1d5db;
}

/* 安全区域适配 */
.container {
    padding-bottom: env(safe-area-inset-bottom);
    padding-bottom: constant(safe-area-inset-bottom);
}

/* 优化触摸反馈 */
* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* 性能优化 */
.post-card img {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Phase 2: 增强帖子卡片样式 */

/* 帖子卡片容器 - 确保内容能够完整显示 */
.post-card-enhanced {
    /* 移除高度限制，让内容自然流动 */
    overflow: visible;
}

/* 可展开内容区 */
.post-content-expandable {
    max-height: 75vh;
    overflow: hidden;
    position: relative;
    transition: max-height 0.3s ease;
}

.post-content-expandable.expanded {
    max-height: none;
}

/* 展开按钮 */
.expand-btn {
    background: none;
    border: none;
    padding: 0.25rem 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* 增强互动栏 */
.interaction-bar-enhanced {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.interaction-bar-enhanced button {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}

.interaction-bar-enhanced button:active {
    transform: scale(0.95);
    background-color: #f3f4f6;
}

.interaction-bar-enhanced button.liked {
    color: #ef4444;
}

.interaction-bar-enhanced button.collected {
    color: #eab308;
}

/* 评论区紧凑样式 */
.comments-compact {
    /* 移除高度限制，显示所有评论 */
}

.comment-list {
    space-y: 0.5rem;
}

.comment-list .comment-item {
    padding: 0.25rem 0;
    word-break: break-word;
}

.comment-list .comment-author {
    font-weight: 600;
    color: #1f2937;
    margin-right: 0.25rem;
}

.comment-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.comment-input {
    flex: 1;
}

.comment-input:disabled {
    background-color: #f9fafb;
    cursor: not-allowed;
}

/* 右上角操作按钮 */
.top-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-share-top {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 图片点击效果 */
.image-item {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.image-item:active {
    transform: scale(0.95);
}

/* 图片Lightbox */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.image-lightbox.active {
    display: flex;
}

.lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 24px;
    z-index: 10000;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 20px;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 14px;
    padding: 5px 15px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.image-lightbox.active {
    animation: fadeIn 0.3s ease;
}

.lightbox-image {
    animation: scaleIn 0.3s ease;
}

/* Phase 4: 评论系统样式 */
.comments-compact {
    transition: all 0.3s ease;
    /* 移除固定高度限制，让内容自然展开 */
}

.comments-compact.expanded {
    /* 展开时显示所有内容 */
}

.comment-list {
    /* 移除滚动限制，显示所有评论 */
    /* 不设置max-height，让内容自然展开 */
}

.comment-list::-webkit-scrollbar {
    width: 4px;
}

.comment-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.comment-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 2px;
}

.comment-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.comment-item {
    word-wrap: break-word;
    line-height: 1.5;
}

.comment-author {
    color: #1a73e8;
}

.comment-input:focus {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.comment-input:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
}

/* Emoji选择器样式 */
.emoji-picker-global {
    position: fixed;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-item {
    transition: background-color 0.2s;
    cursor: pointer;
    user-select: none;
}

.emoji-item:hover {
    background-color: #f3f4f6;
    transform: scale(1.2);
}

.emoji-item:active {
    transform: scale(0.95);
}

/* 评论提交按钮动画 */
.btn-send:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-send:not(:disabled):active {
    transform: translateY(0);
}

/* 深色模式支持（预留） */
@media (prefers-color-scheme: dark) {
    /* 深色模式样式可以在此添加 */
}