/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 固定滚动条显示，避免显示隐藏时元素移位 */
html {
    overflow-y: scroll;
    scrollbar-width: thin;
    scrollbar-color: var(--text-light) var(--secondary-color);
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-color);
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #f3f4f6;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --border-color: #e5e7eb;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s ease;
    --bg-color: #ffffff;
    --header-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --footer-bg: #f9fafb;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

/* 容器 */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* 头部 */
.header {
    background-color: var(--header-bg);
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    gap: 1rem;
}

.header-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.header-row:first-child {
    justify-content: space-between;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-container {
    position: relative;
    flex: 1;
    min-width: 250px;
    max-width: 600px;
}

.search-input {
    width: 100%;
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    transition: var(--transition);
    background-color: var(--bg-color);
    color: var(--text-color);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.clear-search {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.clear-search:hover {
    background-color: var(--secondary-color);
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: var(--transition);
    color: var(--text-color);
    height: 36px;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--secondary-color);
}

/* 分类导航 */
.category-nav {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    width: 100%;
}

.category-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    border-radius: 0.4rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    color: var(--text-color);
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
}

.category-btn:hover {
    background-color: var(--secondary-color);
}

.category-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 语言切换 */
.language-toggle {
    display: flex;
    gap: 0.3rem;
}

.language-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    cursor: pointer;
    border-radius: 0.3rem;
    transition: var(--transition);
    color: var(--text-color);
    font-size: 0.8rem;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

.language-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.language-btn:hover {
    background-color: var(--secondary-color);
}

.language-btn.active:hover {
    background-color: var(--primary-hover);
}

/* 暗色主题样式 */
body.dark-theme {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --secondary-color: #374151;
    --text-color: #e5e7eb;
    --text-light: #9ca3af;
    --border-color: #4b5563;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --bg-color: #1f2937;
    --header-bg: #1f2937;
    --sidebar-bg: #1f2937;
    --footer-bg: #111827;
}

body.dark-theme .search-input {
    background-color: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

body.dark-theme .search-input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

body.dark-theme .category-btn {
    background-color: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

body.dark-theme .category-btn:hover {
    background-color: #4b5563;
}

body.dark-theme .language-btn {
    background-color: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

body.dark-theme .language-btn:hover {
    background-color: #4b5563;
}

body.dark-theme .theme-toggle:hover {
    background-color: #374151;
}

/* 主体内容 */
.main {
    flex: 1;
    padding: 1.5rem 0;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-count {
    font-size: 0.9rem;
    color: var(--text-light);
}

.options-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
}

.view-btn {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    cursor: pointer;
    border-radius: 0.3rem;
    transition: var(--transition);
    color: var(--text-color);
}

.view-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 加载状态 */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--secondary-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* 无结果状态 */
.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.no-results h3 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

/* 图片画廊 */
.gallery {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.gallery-item {
    background-color: var(--sidebar-bg);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    aspect-ratio: 17/30;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.gallery-image-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* 图片缺失占位符样式 */
.image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--sidebar-bg);
    border: 2px dashed var(--border-color);
    border-radius: 0.5rem;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    color: var(--text-light);
}

.placeholder-text {
    font-size: 0.9rem;
    color: var(--text-light);
    text-align: center;
    padding: 0 1rem;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: var(--transition);
}

.gallery-item:hover .gallery-image {
    transform: scale(1.05);
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    font-size: 0.9rem;
}

.gallery-item:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 1);
}

.gallery-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 1rem 0.5rem 0.5rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 列表视图 */
.gallery.list-view {
    grid-template-columns: 1fr;
}

.gallery.list-view .gallery-item {
    aspect-ratio: auto;
    height: auto;
    display: flex;
    flex-direction: row;
    gap: 1rem;
}

.gallery.list-view .gallery-image-container {
    width: 20%; /* 缩小图片框尺寸 */
    height: auto;
    aspect-ratio: 17/30;
    max-width: 150px;
    min-width: 100px;
}

/* 列表视图标题样式 */
.gallery.list-view .gallery-title {
    position: static;
    background: none;
    color: var(--text-color);
    padding: 0;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
}

/* 列表视图详情区域 */
.gallery.list-view .gallery-details {
    flex: 1;
    padding: 0.8rem 0.8rem 0.8rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.gallery.list-view .gallery-prompt {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.gallery.list-view .gallery-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.gallery.list-view .gallery-tag {
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 500;
}

/* 网格视图标题样式（图片内部下居中） */
.gallery-title.grid-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 1rem 0.5rem 0.5rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    z-index: 1;
}

/* 列表视图隐藏网格标题 */
.gallery.list-view .gallery-title.grid-title {
    display: none;
}

/* 列表视图标题样式 */
.gallery-title.list-title {
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

/* 网格视图隐藏详情区域（包括列表标题） */
.gallery:not(.list-view) .gallery-details {
    display: none;
}

/* 详情模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--sidebar-bg);
    border-radius: 0.5rem;
    max-width: 900px;
    max-height: 90%;
    width: 90%;
    overflow: auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.modal-body {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    min-height: 400px;
}

.modal-image {
    flex: 0 0 40%;
    border-radius: 0.5rem;
    overflow: hidden;
    max-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 0.5rem;
}

.modal-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.info-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-section h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-color);
}

.prompt-container {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 1rem;
    background-color: var(--secondary-color);
    border-radius: 0.5rem;
    position: relative;
}

.prompt-container p {
    margin: 0;
    flex: 1;
    line-height: 1.5;
    color: var(--text-color);
}

.prompt-container .copy-btn {
    position: static;
    opacity: 1;
    background: var(--primary-color);
    color: white;
    flex-shrink: 0;
}

.prompt-container .copy-btn:hover {
    background: var(--primary-hover);
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.modal-tags .tag {
    padding: 0.3rem 0.8rem;
    background-color: var(--secondary-color);
    border-radius: 0.3rem;
    font-size: 0.85rem;
    color: var(--text-color);
}

/* 模态框底部导航 */
.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    gap: 1rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.2rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.nav-arrow {
    font-size: 1.2rem;
    font-weight: bold;
}

.page-info {
    font-size: 1rem;
    color: var(--text-color);
    font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .modal-body {
        flex-direction: column;
    }
    
    .modal-image {
        flex: none;
        max-height: 300px;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-btn {
        width: 100%;
        justify-content: center;
    }
}

/* 灯箱 */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    background-color: var(--sidebar-bg);
    border-radius: 0.5rem;
    max-width: 800px;
    max-height: 90%;
    overflow: auto;
    margin: 2rem;
    position: relative;
    display: flex;
    flex-direction: column;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    z-index: 1;
}

.lightbox-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.lightbox-image {
    width: 100%;
    display: block;
    border-radius: 0.5rem 0.5rem 0 0;
}

.lightbox-info {
    padding: 1.5rem;
}

.lightbox-info h3 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: var(--text-color);
}

.lightbox-info p {
    margin-bottom: 1.5rem;
    line-height: 1.6;
    color: var(--text-light);
}

.lightbox-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* 页脚 */
.footer {
    background-color: var(--footer-bg);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 2rem;
}

.footer p {
    margin: 0.5rem 0;
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.3s ease;
}

.github-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.github-link i {
    font-size: 1.2rem;
}

/* 复制提示 */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
@media (max-width: 1200px) {
    .gallery {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .gallery.list-view {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 992px) {
    .gallery {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .gallery.list-view {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .search-container {
        width: 100%;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .gallery {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .gallery.list-view {
        grid-template-columns: 1fr;
    }
    
    .modal-body {
        flex-direction: column;
    }
    
    .modal-image {
        width: 100%;
        height: 200px;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .gallery.list-view {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem auto;
    }
    
    .lightbox-content {
        width: 95%;
        margin: 1rem auto;
    }
    
    .category-nav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .category-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}