/* ranking-optimized.css - 優化的排行榜樣式 */
/* 適用於 300px - 1200px 寬度，特別優化側邊欄顯示 */

/* 排行榜列表容器 */
.ranking-list {
    background-color: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

/* 排行榜標題 */
.ranking-header {
    padding: 0.8rem 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 500;
    font-size: 1rem;
    color: #343a40;
    text-align: center;
}

/* 網格容器 - 響應式設計 */
.ranking-grid {
    display: block; /* 改為block，更適合窄屏幕 */
}

/* 排行榜項目 */
.ranking-item {
    display: flex;
    align-items: flex-start;
    padding: 0.8rem;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.2s ease;
    position: relative;
    min-height: 60px;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-item:hover {
    background-color: #f8f9fa;
}

/* 排名數字 - 大幅縮小，不再突兀 */
.ranking-number {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    background-color: #6c757d;
    color: #fff;
    font-weight: 600;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.8rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.ranking-number.top1 {
    background-color: #ffc107;
    color: #000;
}

.ranking-number.top2 {
    background-color: #adb5bd;
    color: #fff;
}

.ranking-number.top3 {
    background-color: #cd7f32;
    color: #fff;
}

/* 書籍資訊區域 */
.ranking-book-info {
    flex-grow: 1;
    min-width: 0;
    margin-right: 0.5rem;
}

/* 書籍標題 - 優化文字省略 */
.ranking-book-title {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
    margin-bottom: 0.3rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

.ranking-book-title a {
    color: #333;
    text-decoration: none;
}

.ranking-book-title a:hover {
    color: #5c7cfa;
}

/* 作者和分類資訊 */
.ranking-book-author {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 0.2rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}

.ranking-book-author a {
    color: #6c757d;
    text-decoration: none;
}

.ranking-book-author a:hover {
    color: #5c7cfa;
}

/* 分類標籤 - 縮小尺寸 */
.ranking-book-category {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background-color: #e9ecef;
    border-radius: 2px;
    font-size: 0.65rem;
    color: #495057;
    white-space: nowrap;
}

/* 章節連結 */
.ranking-book-info > div:last-child {
    font-size: 0.75rem;
    margin-top: 0.2rem;
}

.ranking-book-info > div:last-child a {
    color: #5c7cfa;
    text-decoration: none;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

/* 統計資訊 - 縮小並優化對齊 */
.ranking-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    flex-shrink: 0;
    text-align: right;
    min-width: 4rem;
}

.ranking-vote-count {
    font-weight: 600;
    font-size: 0.7rem;
    color: #dc3545;
    margin-bottom: 0.2rem;
    white-space: nowrap;
}

.ranking-update-time {
    font-size: 0.65rem;
    color: #adb5bd;
    white-space: nowrap;
}

/* 查看更多按鈕 */
.see-more {
    display: block;
    text-align: center;
    padding: 0.6rem;
    background-color: #f8f9fa;
    color: #5c7cfa;
    font-weight: 500;
    font-size: 0.8rem;
    border-top: 1px solid #e9ecef;
    transition: all 0.2s ease;
    text-decoration: none;
}

.see-more:hover {
    background-color: #e9ecef;
    color: #4263eb;
}

/* 響應式設計 */

/* 中等寬度 (400px - 768px) */
@media (min-width: 400px) and (max-width: 768px) {
    .ranking-header {
        font-size: 1.1rem;
        padding: 1rem;
    }
    
    .ranking-item {
        padding: 1rem;
        min-height: 70px;
    }
    
    .ranking-number {
        width: 2rem;
        height: 2rem;
        font-size: 0.8rem;
        margin-right: 1rem;
    }
    
    .ranking-book-title {
        font-size: 1rem;
    }
    
    .ranking-book-author {
        font-size: 0.8rem;
    }
    
    .ranking-vote-count {
        font-size: 0.75rem;
    }
    
    .ranking-update-time {
        font-size: 0.7rem;
    }
}

/* 大螢幕 (768px+) */
@media (min-width: 768px) {
    .ranking-header {
        font-size: 1.2rem;
        padding: 1.2rem;
    }
    
    .ranking-item {
        padding: 1.2rem;
        min-height: 80px;
    }
    
    .ranking-number {
        width: 2.2rem;
        height: 2.2rem;
        font-size: 0.9rem;
        margin-right: 1.2rem;
    }
    
    .ranking-book-title {
        font-size: 1.1rem;
    }
    
    .ranking-book-author {
        font-size: 0.85rem;
    }
    
    .ranking-vote-count {
        font-size: 0.8rem;
    }
    
    .ranking-update-time {
        font-size: 0.75rem;
    }
    
    /* 大螢幕下可以使用網格佈局 */
    .daily-top .ranking-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 0;
    }
    
    .daily-top .ranking-item {
        border-right: 1px solid #f1f3f4;
        border-bottom: 1px solid #f1f3f4;
    }
    
    .daily-top .ranking-item:nth-child(even) {
        border-right: none;
    }
}

/* 超小螢幕 (最大300px) 的特殊優化 - 重點優化 */
@media (max-width: 300px) {
    .ranking-header {
        padding: 0.6rem 0.5rem;
        font-size: 0.9rem;
    }
    
    .ranking-item {
        padding: 0.6rem 0.5rem;
        min-height: 55px;
    }
    
    .ranking-number {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.7rem;
        margin-right: 0.6rem;
    }
    
    .ranking-book-title {
        font-size: 0.85rem;
        -webkit-line-clamp: 1; /* 窄屏幕只顯示一行 */
    }
    
    .ranking-book-author {
        font-size: 0.7rem;
        margin-bottom: 0.1rem;
    }
    
    .ranking-book-category {
        font-size: 0.6rem;
        padding: 0.05rem 0.3rem;
    }
    
    .ranking-vote-count {
        font-size: 0.65rem;
    }
    
    .ranking-update-time {
        font-size: 0.6rem;
    }
    
    .ranking-stats {
        min-width: 3rem;
    }
    
    .see-more {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}

/* 覆寫原有的novel-ui.css中可能衝突的樣式 */
.ranking-list.user-recommend .ranking-grid,
.ranking-list.daily-top .ranking-grid {
    display: block;
}

@media (min-width: 768px) {
    .ranking-list.daily-top .ranking-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

/* 確保在所有螢幕尺寸下邊框都正確顯示 */
@media (min-width: 768px) {
    .daily-top .ranking-item:nth-child(3n) {
        border-right: none;
    }
    
    .daily-top .ranking-item:nth-child(2n) {
        border-right: 1px solid #f1f3f4;
    }
}

@media (max-width: 767px) {
    .daily-top .ranking-item {
        border-right: none !important;
    }
}