/* 图片预览页面 - iOS风格瀑布流布局 */

/* 基础样式重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* 视图切换控件样式 */
.view-switcher {
    display: flex;
    align-items: center;
    background-color: #f2f2f7;
    border-radius: 10px;
    padding: 3px;
    margin: 0 15px;
}

.view-switch-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 8px;
    color: #8e8e93;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.view-switch-btn svg {
    margin-right: 5px;
}

.view-switch-btn.active {
    background-color: #ffffff;
    color: #000000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* 图片预览容器 */
.gallery-view-container {
    padding: 20px;
    max-width: 1600px;
    margin: 60px auto 0;
}

/* 图库标题和过滤器 */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 0 10px;
}

.gallery-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #000000;
}

.gallery-filters {
    display: flex;
    gap: 8px;
}

.filter-btn {
    background-color: #f2f2f7;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #8e8e93;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background-color: #e5e5ea;
}

.filter-btn.active {
    background-color: #007aff;
    color: #ffffff;
}

/* 【新】JS驱动的瀑布流布局 */
.waterfall-container {
    display: flex;
    gap: 2.5px; /* 列之间的间距 */
    width: 100%;
    align-items: flex-start; /* 对齐到顶部 */
}

.waterfall-column {
    display: flex;
    flex-direction: column;
    gap: 2.5px; /* 列内图片之间的垂直间距 */
    flex: 1; /* 让所有列平分宽度 */
    min-width: 0; /* 防止内容溢出，非常重要 */
}

/* 改进的图片卡片样式 */
.gallery-item {
    position: relative;
    border-radius: 4px; /* 减小圆角 */
    overflow: hidden;
    background-color: #f0f0f0; 
    transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 0.3s ease;
    width: 100%;
    /* 移除 break-inside 和 margin-bottom，因为不再使用 column-count */
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

/* 当图片加载完成时，让图片显示出来 */
.gallery-item.loaded img {
    opacity: 1;
}

/* 当图片加载完成时，背景变为透明 */
.gallery-item.loaded {
    background-color: transparent;
}

.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.4) 50%, transparent);
    padding: 16px;
    color: #ffffff;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-prompt {
    font-size: 12px;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.gallery-item-actions {
    display: flex;
    gap: 12px;
}

.gallery-item-action {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    backdrop-filter: blur(4px);
    background-color: rgba(255, 255, 255, 0.1);
}

.gallery-item-action:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* 加载更多按钮 */
.load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 32px;
    padding-bottom: 40px;
}

.load-more-btn {
    background-color: #f2f2f7;
    border: none;
    border-radius: 20px;
    padding: 10px 24px;
    font-size: 16px;
    font-weight: 500;
    color: #007aff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-more-btn:hover {
    background-color: #e5e5ea;
}

/* 图片预览模态框样式 */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
}

.image-preview-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    max-height: 800px;
    background-color: #1c1c1e;
    border-radius: 16px;
    overflow: hidden;
    z-index: 1001;
    display: flex;
    flex-direction: row;
    color: #ffffff;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.close-modal-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1002;
    color: #e5e5e5;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.close-modal-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.modal-image-wrapper {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000000;
    padding: 20px;
    height: 100%;
}

.modal-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.modal-info-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #2c2c2e;
    overflow: hidden;
}

.scrollable-info {
    flex-grow: 1;
    overflow-y: auto;
    padding: 40px 30px 20px;
}

.info-section {
    margin-bottom: 30px;
}

.info-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #8e8e93;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-section p {
    font-size: 15px;
    line-height: 1.6;
    color: #e5e5e5;
}

.modal-actions {
    margin-top: 0;
    padding: 20px 30px;
    background-color: #2c2c2e;
    box-shadow: 0 -10px 15px -5px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

.modal-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.modal-action-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.download-btn {
    display: none;
}

.generate-btn {
    background-color: #34c759;
    color: #ffffff;
}

.comments-section h3 {
    margin-bottom: 20px;
}

.comment-input-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.comment-input-box input {
    width: 100%;
    background-color: #3a3a3c;
    border: 1px solid #4a4a4c;
    border-radius: 18px;
    padding: 8px 15px;
    color: #e5e5e5;
    font-size: 14px;
    outline: none;
}

.comment-input-box input::placeholder {
    color: #8e8e93;
}

.comment-list .comment {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.comment-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.comment-author {
    font-size: 14px;
    color: #8e8e93;
}

.comment-text {
    font-size: 15px;
    color: #f2f2f7;
}

.comment-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 12px;
    color: #8e8e93;
}

.comment-actions {
    margin-left: auto;
    display: flex;
    gap: 15px;
}

.comment-meta button {
    background: none;
    border: none;
    color: #8e8e93;
    cursor: pointer;
    font-size: 12px;
}

/* 响应式设计 */
@media screen and (max-width: 1400px) {
    /* .waterfall-container { column-count: 4; } */
}

@media screen and (max-width: 1100px) {
    /* .waterfall-container { column-count: 3; } */
}

@media screen and (max-width: 768px) {
    .gallery-view-container {
        padding: 16px;
        margin-top: 70px;
    }
    
    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    /* .waterfall-container { column-count: 2; } */
    
    .view-switcher {
        display: none;
    }
}

@media screen and (max-width: 480px) {
    /* .waterfall-container { column-count: 1; } */
    
    .gallery-filters {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-wrap: nowrap;
    }
    
    .filter-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .modal-content {
        width: 95%;
        flex-direction: column;
        height: 85vh;
    }

    .modal-image-wrapper {
        min-height: 50%;
    }

    .modal-info-wrapper {
        padding: 20px;
    }

    .scrollable-info {
        padding: 0;
    }

    .modal-actions {
        padding: 20px 0 0;
        box-shadow: none;
        background: transparent;
    }
}