/* 全局重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    height: 100vh; /* Fixed height for full screen layout */
    overflow: hidden; /* Prevent body scroll */
    display: flex;
    flex-direction: column;
}

#site-header {
    height: 20vh;
    width: 100%;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
    flex-shrink: 0; /* Prevent header from shrinking */
    transition: height 0.3s ease-in-out, opacity 0.3s ease-in-out;
    overflow: hidden;
}

#site-header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #333;
}

#site-header p {
    font-size: 1.2rem;
    color: #666;
}

.container {
    display: flex;
    flex: 1; /* Take remaining height */
    overflow: hidden; /* Contain children */
    max-width: 100%;
}

/* 侧边栏样式 */
.sidebar {
    width: 250px;
    background-color: #f7f7f7;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 20px 0;
    /* Remove sticky, now part of flex layout */
    height: 100%;
    overflow-y: auto;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-count {
    background-color: #e0e0e0;
    color: #666;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    min-width: 24px;
    text-align: center;
}

.sidebar-nav li.active .category-count {
    background-color: #333;
    color: #fff;
}

.sidebar-nav li:hover {
    background-color: #eee;
}

.sidebar-nav li.active {
    background-color: #e6e6e6;
    font-weight: 600;
    color: #000;
    border-left: 4px solid #333;
}

/* 主内容区样式 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    overflow: hidden; /* Prevent main content from scrolling itself, let wrapper scroll */
}

.top-bar {
    padding: 15px 30px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Remove sticky, now fixed by flex layout */
    background-color: #fff;
    z-index: 100; 
    flex-shrink: 0;
}

.search-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 600px;
    gap: 15px;
}

.sort-btn {
    height: 40px;
    padding: 0 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background-color: #fff;
    color: #555;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.sort-btn:hover {
    background-color: #f9f9f9;
    border-color: #999;
    color: #333;
}

.search-container {
    position: relative;
    flex: 1;
}

#search-input {
    width: 100%;
    height: 40px;
    padding: 0 40px 0 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background-color: #f9f9f9;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

#search-input:focus {
    border-color: #999;
    background-color: #fff;
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

/* 卡片网格样式 */
.scroll-wrapper {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-top: 20px; /* Gap between top-bar and cards */
}

.card-grid {
    /* Removed flex/padding styles that conflict with wrapper */
    padding: 30px;
    position: relative;
    /* margin-top: 20px; Removed, handled by wrapper padding */
    transition: opacity 0.2s ease-in-out;
}

/* 卡片样式 */
.card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.3s, transform 0.2s, border-color 0.3s;
    position: absolute; /* Changed to absolute for masonry */
    width: 240px; /* Fixed width as requested */
    /* margin-bottom: 25px; Removed, handled by JS */
    height: auto;
    will-change: transform; /* Optimize for transform animations */
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    transform: translateY(-2px);
    z-index: 1; /* Bring to front on hover */

}

/* 图片容器 */
.card-image-container {
    width: 100%;
    /* aspect-ratio: 1 / 1; Removed */
    position: relative;
    background-color: #f0f0f0;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    line-height: 0; /* Fix extra space below image */
}

.card-image {
    position: relative; /* Changed from absolute */
    width: 100%;
    height: auto; /* Changed from 100% */
    object-fit: cover; /* Changed back to cover to fix gap */
    transition: opacity 0.3s, transform 0.3s;
    display: block;
}

.card:hover .card-image {
    transform: scale(1.05);
}

/* 精选图标样式 */
.collection-icon {
    position: absolute;
    top: -1px;
    left: 10px;
    width: 24px;
    height: 24px;
    z-index: 2;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* 轮播指示器 (已移除) */
/*
.carousel-dots {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 5px;
    pointer-events: none;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: rgba(255,255,255,0.5);
    border-radius: 50%;
    transition: background-color 0.3s;
}

.dot.active {
    background-color: #fff;
}
*/

/* 卡片内容 */
.card-body {
    padding: 15px;
    /* flex: 1; Removed for masonry layout flow */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-header {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    margin-bottom: 10px;
    font-size: 14px;
    flex-shrink: 0;
}

.card-title {
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.card-author {
    color: #999;
    font-size: 12px;
}

.card-prompt {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 15px;
    /* flex: 1; Removed */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4; /* Limit lines to prevent very long cards */
    -webkit-box-orient: vertical;
}

/* 骨架屏样式 (加载前) */
.skeleton-text {
    background-color: #eee;
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: 4px;
    width: 100%;
}

/* 卡片底部操作栏 */
.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* margin-top: auto; Removed */
    padding-top: 10px;
    border-top: 1px solid #f5f5f5;
    flex-shrink: 0;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #777;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 20px; /* Increased from 4px to make it capsule-shaped */
    transition: color 0.2s, background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.action-btn:hover:not(:disabled) {
    color: #333;
    background-color: #f0f0f0;
}

/* 卡片中的复制并尝试按钮特定样式 */
.card-actions .copy-btn {
    background-color: #0079ff;
    color: white;
    padding: 5px 10px; /* 增加水平内边距以增强胶囊形状效果 */
}

.card-actions .copy-btn:hover:not(:disabled) {
    background-color: #0066d6;
    color: white;
}

.action-btn:disabled {
    color: #ddd;
    cursor: not-allowed;
}

/* 模态框样式 */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.85); 
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    transition: transform 0.3s; /* Smooth transition */
}

/* Modal Navigation Buttons */
.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    padding: 16px;
    user-select: none;
    transition: 0.3s;
    z-index: 1002;
    background-color: rgba(0,0,0,0.3);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-nav-btn:hover {
    background-color: rgba(0,0,0,0.8);
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 1001;
}

.close-modal:hover,
.close-modal:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* 提示词模态框内容样式 */
.prompt-modal-content {
    background-color: #fff;
    width: 90%;
    max-width: 600px;
    padding: 30px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-prompt-text {
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #eee;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.modal-copy-btn, .modal-copy-try-btn {
    padding: 10px 25px;
    border-radius: 20px;
    font-size: 14px;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
}

.modal-copy-btn {
    background-color: #eee;
    color: #333;
}

.modal-copy-btn:hover {
    background-color: #ddd;
    color: #000;
}

.modal-copy-try-btn {
    background-color: #0079ff;
    color: white;
}

.modal-copy-try-btn:hover {
    background-color: #0066d6;
    color: white;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding: 10px 0;
    }
    
    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 0 10px;
    }
    
    .sidebar-nav li {
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
        padding: 10px 15px;
    }
    
    .sidebar-nav li.active {
        border-left: none;
        border-bottom: 3px solid #333;
    }

    .card-grid {
        padding: 15px;
    }
}
