/* 社区图库专属样式 */

/* 全局变量 - 优化配色方案 */
:root {
    --gallery-primary: #1a1a1a;
    --gallery-secondary: #333333;
    --gallery-accent: #ff6b6b;
    --gallery-bg: #fafafa;
    --gallery-card-bg: #ffffff;
    --gallery-text: #1a1a1a;
    --gallery-text-light: #666666;
    --gallery-border: #e0e0e0;
    --gallery-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --gallery-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
    --gallery-radius: 8px;
}

/* 主内容区 */
.main-content {
    min-height: calc(100vh - 80px);
    background: var(--gallery-bg);
    padding-top: 80px;
}

/* Hero Section - 优雅的顶部图片滑动 */
.hero-section {
    position: relative;
    height: 400px;
    overflow: hidden;
    background: var(--gallery-bg);
}

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

/* 无限滑动轨道 */
.slideshow-track {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 40px;
    animation: slideshow-scroll 60s linear infinite;
    will-change: transform;
}

@keyframes slideshow-scroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

.slide {
    flex: 0 0 auto;
    width: 260px;
    height: 320px;
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}

.slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 暂停动画 */
.slideshow-container:hover .slideshow-track {
    animation-play-state: paused;
}

/* 幻灯片标题 */
.slide-caption {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 15px 20px;
    border-radius: var(--gallery-radius);
    backdrop-filter: blur(10px);
}

.slide-caption h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 500;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.6) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
    z-index: 2;
}

.hero-container {
    max-width: 820px;
    padding: 0 24px;
    background: transparent;
}

.hero-title {
    font-size: 2.4rem;
    font-weight: 600;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
    color: #ffffff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

.hero-subtitle {
    font-size: 1.1rem;
    font-weight: 400;
    opacity: 0.98;
    margin-bottom: 40px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

/* 搜索栏重新设计 */
.search-container {
    max-width: 520px;
    width: 100%;
    position: relative;
}

/* 搜索栏 - 极简设计 */
.search-input {
    width: 100%;
    padding: 14px 50px 14px 20px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 28px;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    color: var(--gallery-text);
}

.search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.search-input::placeholder {
    color: rgba(107, 114, 128, 0.9);
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 登录提示样式 */
.login-prompt {
    margin: 20px 0;
}

.login-link {
    display: inline-block;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.login-link:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* 筛选区域 */
.filter-section {
    padding: 30px 20px;
    background: white;
    border-bottom: 1px solid var(--gallery-border);
}

.filter-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 30px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: 500;
    color: var(--gallery-text);
}

.filter-select {
    padding: 8px 15px;
    border: 1px solid var(--gallery-border);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--gallery-primary);
}

/* 精选区域 */
.featured-section {
    padding: 60px 20px 40px;
    background: white;
    display: none; /* 隐藏精选区域，直接展示所有 */
}

.section-header {
    max-width: 1200px;
    margin: 0 auto 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--gallery-text);
}

/* 图库标题区域左右布局 */
.section-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sort-label {
    font-weight: 500;
    color: var(--gallery-text);
}

.sort-select {
    min-width: 120px;
}

.featured-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* 图库区域 */
.gallery-section {
    padding: 40px 20px 60px;
}

.total-count {
    color: var(--gallery-text-light);
    font-size: 1rem;
}

/* 加载动画 */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--gallery-border);
    border-top: 4px solid var(--gallery-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 图片网格 - Pinterest 瀑布流布局 */
.gallery-grid {
    max-width: 1200px;
    margin: 0 auto;
    column-count: 5;
    column-gap: 16px;
}

/* 提示词卡片 - Pinterest 风格 */
.prompt-card {
    background: var(--gallery-card-bg);
    border-radius: var(--gallery-radius);
    overflow: hidden;
    box-shadow: var(--gallery-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    animation: fadeIn 0.5s ease-out;
    break-inside: avoid;
    margin-bottom: 16px;
    position: relative;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.prompt-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--gallery-shadow-hover);
}

.card-image-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--gallery-primary), var(--gallery-secondary));
}

/* 卡片图片 - 填满整个卡片 */
.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.prompt-card:hover .card-image {
    transform: scale(1.05);
}

/* 悬浮信息覆盖层 - 底部渐变遮罩 */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top,
        rgba(0,0,0,0.95) 0%,
        rgba(0,0,0,0.85) 40%,
        rgba(0,0,0,0.6) 70%,
        rgba(0,0,0,0.2) 100%);
    color: white;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.prompt-card:hover .card-overlay {
    opacity: 1;
}

.overlay-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.overlay-prompt {
    font-size: 0.8rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0.9;
}

/* 隐藏原有的文本元素 */
.card-category,
.card-content {
    display: none;
}

/* 隐藏加载更多按钮 */
.load-more-container {
    display: none !important;
}

/* 模态框 - 只针对提示词详情模态框，不覆盖登录模态框 */
#promptModal.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

#promptModal .modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 0;
    border-radius: var(--gallery-radius);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: white;
    color: var(--gallery-text);
}

.modal-header {
    padding: 30px 30px 20px;
    border-bottom: 1px solid var(--gallery-border);
    position: relative;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--gallery-text);
}

.modal-stats {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.modal-body {
    padding: 30px;
}

/* 图片展示区域 */
.image-gallery {
    margin-bottom: 30px;
}

.main-image-container {
    text-align: center;
    margin-bottom: 20px;
}

.main-image {
    max-width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    border-radius: var(--gallery-radius);
    box-shadow: var(--gallery-shadow);
    background: #f5f5f5;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.main-image:hover {
    transform: scale(1.02);
}

/* 系列图片缩略图 */
.thumbnail-container {
    margin-top: 20px;
}

.thumbnail-container h4 {
    margin-bottom: 15px;
    color: var(--gallery-text);
    font-size: 1.1rem;
}

.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.thumbnail {
    aspect-ratio: 1;
    border-radius: var(--gallery-radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--gallery-shadow);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.thumbnail:hover {
    transform: translateY(-5px);
    box-shadow: var(--gallery-shadow-hover);
}

.thumbnail:hover img {
    transform: scale(1.1);
}

.thumbnail.active {
    border: 3px solid var(--gallery-primary);
}

/* 图片对比 - 保留原样式以备不时之需 */
.image-comparison {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.image-container {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.comparison-image {
    width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: contain;
    border-radius: var(--gallery-radius);
    box-shadow: var(--gallery-shadow);
    background: #f5f5f5;
}

.image-label {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.85rem;
    backdrop-filter: blur(10px);
}

.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gallery-primary);
    min-width: 40px;
}

/* 提示词内容 */
.prompt-content {
    margin-bottom: 30px;
}

.prompt-content h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: var(--gallery-text);
}

.prompt-text-container {
    background: var(--gallery-bg);
    padding: 20px;
    border-radius: var(--gallery-radius);
    position: relative;
}

.prompt-text {
    margin: 0;
    line-height: 1.8;
    color: var(--gallery-text);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--gallery-primary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: var(--gallery-secondary);
}

/* 操作按钮 */
.modal-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.like-btn {
    background: #ff6b6b;
    color: white;
}

.like-btn:hover {
    background: #ff5252;
    transform: translateY(-2px);
}

.action-btn:not(.like-btn) {
    background: var(--gallery-primary);
    color: white;
}

.action-btn:not(.like-btn):hover {
    background: var(--gallery-secondary);
    transform: translateY(-2px);
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 0.95rem;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toast.show {
    opacity: 1;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .gallery-grid {
        column-count: 4;
    }
}

@media (max-width: 992px) {
    .gallery-grid {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
        flex-direction: column;
        gap: 10px;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .filter-container {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .filter-group {
        justify-content: space-between;
    }

    .gallery-grid {
        column-count: 2;
        column-gap: 12px;
    }

    .image-comparison {
        flex-direction: column;
        align-items: center;
    }

    .vs-divider {
        transform: rotate(90deg);
        margin: 10px 0;
    }

    .image-container {
        width: 100%;
        min-width: auto;
    }

    .comparison-image {
        max-height: 350px;
    }

    .modal-content {
        width: 95%;
        margin: 20px auto;
    }

    .modal-header,
    .modal-body {
        padding: 20px;
    }

    .modal-actions {
        flex-direction: column;
    }

    .action-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        column-count: 1;
        column-gap: 0;
    }

    .prompt-card {
        margin-bottom: 12px;
    }

    .hero-section {
        padding: 60px 20px;
    }
}

/* 深色模式支持（可选） */
@media (prefers-color-scheme: dark) {
    :root {
        --gallery-bg: #1a1a1a;
        --gallery-card-bg: #2d2d2d;
        --gallery-text: #f0f0f0;
        --gallery-text-light: #b0b0b0;
        --gallery-border: #404040;
    }

    .filter-section,
    .featured-section {
        background: var(--gallery-card-bg);
    }
}

/* ==================== 性能优化：平滑过渡动画 ==================== */

/* 网格平滑过渡 - 消除切换排序时的视觉跳动 */
.gallery-grid {
    transition: opacity 0.2s ease-out;
}

/* 卡片加载动画 - 优化后的版本 */
.prompt-card {
    animation: fadeInSmooth 0.3s ease-out;
}

@keyframes fadeInSmooth {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
