/* 排名頁面專用樣式 - Neo-Brutalism 設計風格 */

/* 主要佈局 */
.ranking-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: calc(100vh - 200px);
}

/* 導航連結 */
.header-nav {
    margin-top: 1rem;
}

.nav-link {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #FFFFFF;
    border: 3px solid #000000;
    box-shadow: 4px 4px 0px #000000;
    text-decoration: none;
    color: #000000;
    font-weight: bold;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: #FFD900;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #000000;
}

.nav-link:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #000000;
}

/* 排序控制區 */
.ranking-controls {
    background: #FFFFFF;
    border: 3px solid #000000;
    box-shadow: 8px 8px 0px #000000;
    padding: 2rem;
    margin-bottom: 2rem;
}

.ranking-controls h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #000000;
    font-weight: bold;
}

.sort-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.sort-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: #FFFFFF;
    border: 3px solid #000000;
    box-shadow: 4px 4px 0px #000000;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #000000;
}

.sort-btn:hover {
    background: #FFD900;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #000000;
}

.sort-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #000000;
}

.sort-btn.active {
    background: #00A8FF;
    color: #FFFFFF;
}

.sort-btn.active:hover {
    background: #0088CC;
}

.btn-icon {
    font-size: 1.2rem;
}

/* 排名顯示區 */
.ranking-display {
    background: #FFFFFF;
    border: 3px solid #000000;
    box-shadow: 8px 8px 0px #000000;
    overflow: hidden;
}

.ranking-header {
    background: #FFD900;
    border-bottom: 3px solid #000000;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.ranking-header h2 {
    font-size: 1.8rem;
    color: #000000;
    font-weight: bold;
    margin: 0;
}

.ranking-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: #000000;
    font-weight: 600;
}

/* 載入和錯誤狀態 */
.loading-state, .error-state {
    padding: 3rem 2rem;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #E0E0E0;
    border-top: 4px solid #00A8FF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #000000;
}

.retry-btn {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: #FF6B6B;
    border: 3px solid #000000;
    box-shadow: 4px 4px 0px #000000;
    color: #FFFFFF;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    background: #FF5252;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #000000;
}

/* 前三名頒獎台 */
.top-three {
    display: flex;
    justify-content: center;
    align-items: end;
    padding: 2rem;
    gap: 1rem;
    background: linear-gradient(135deg, #FFD900 0%, #FF8A00 100%);
    border-bottom: 3px solid #000000;
}

.podium-item {
    background: #FFFFFF;
    border: 3px solid #000000;
    box-shadow: 6px 6px 0px #000000;
    padding: 1.5rem 1rem;
    text-align: center;
    min-width: 140px;
    position: relative;
    transition: transform 0.2s ease;
}

.podium-item:hover {
    transform: translateY(-4px);
}

.podium-item.champion {
    transform: scale(1.1);
    background: #FFD900;
    z-index: 2;
}

.podium-item.champion:hover {
    transform: scale(1.1) translateY(-4px);
}

.podium-medal {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.podium-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #000000;
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.podium-stats {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: #000000;
    font-weight: 600;
}

.podium-rank {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #000000;
    color: #FFFFFF;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.podium-meta {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: #333333;
    font-weight: 600;
}

.podium-login {
    color: #555555;
    font-size: 0.8rem;
}

/* 排名表格 */
.ranking-table {
    padding: 0;
}

.table-header {
    display: grid;
    grid-template-columns: 80px 1.2fr 1fr 100px 120px 160px;
    background: #000000;
    color: #FFFFFF;
    font-weight: bold;
    font-size: 0.9rem;
    border-bottom: 3px solid #000000;
}

.table-header > div {
    padding: 1rem 0.75rem;
    text-align: center;
    border-right: 2px solid #333333;
}

.table-header > div:last-child {
    border-right: none;
}

/* 確保表格標題中的主題和更新時間欄位文字為白色 */
.table-header .col-topic,
.table-header .col-login {
    color: #FFFFFF !important;
}

.table-body {
    max-height: 600px;
    overflow-y: auto;
}

.ranking-row {
    display: grid;
    grid-template-columns: 80px 1.2fr 1fr 100px 120px 160px;
    border-bottom: 2px solid #E0E0E0;
    transition: background-color 0.2s ease;
}

.ranking-row:hover {
    background: #F5F5F5;
}

.ranking-row:nth-child(even) {
    background: #FAFAFA;
}

.ranking-row:nth-child(even):hover {
    background: #F0F0F0;
}

.ranking-row > div {
    padding: 1rem 0.75rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #E0E0E0;
    font-weight: 600;
}

.ranking-row > div:last-child {
    border-right: none;
}

.col-name {
    text-align: left !important;
    justify-content: flex-start !important;
    font-weight: bold;
    word-break: break-word;
}

.col-topic {
    text-align: left !important;
    justify-content: flex-start !important;
    font-weight: 600;
    color: #333333;
    word-break: break-word;
}

.col-login {
    font-size: 0.85rem;
    color: #444444;
}

.rank-number {
    font-weight: bold;
    color: #000000;
}

.level-badge {
    background: #00A8FF;
    color: #FFFFFF;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.card-count {
    color: #FF8A00;
    font-weight: bold;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .ranking-main {
        padding: 1rem 0.5rem;
    }
    
    .ranking-controls, .ranking-display {
        margin: 0 0.5rem 1rem;
    }
    
    .ranking-controls {
        padding: 1.5rem;
    }
    
    .sort-buttons {
        flex-direction: column;
    }
    
    .sort-btn {
        justify-content: center;
    }
    
    .ranking-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem 1.5rem;
    }
    
    .ranking-info {
        align-items: flex-start;
        width: 100%;
    }
    
    .top-three {
        flex-direction: column;
        align-items: center;
        padding: 1.5rem 1rem;
    }
    
    .podium-item {
        min-width: 200px;
        order: 2;
    }
    
    .podium-item.champion {
        order: 1;
        transform: none;
        margin-bottom: 1rem;
    }
    
    /* 手機版表格：隱藏主題和更新時間欄位 */
    .table-header .col-topic,
    .table-header .col-login,
    .ranking-row .col-topic,
    .ranking-row .col-login {
        display: none;
    }
    
    .table-header, .ranking-row {
        grid-template-columns: 60px 1.5fr 80px 100px;
        font-size: 0.8rem;
    }
    
    .table-header > div, .ranking-row > div {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .ranking-controls, .ranking-display {
        margin: 0 0 1rem;
        border-left: none;
        border-right: none;
        box-shadow: 0 4px 0px #000000;
    }
    
    .table-header, .ranking-row {
        grid-template-columns: 50px 1.5fr 70px 90px;
        font-size: 0.75rem;
    }
    
    .podium-item {
        min-width: 160px;
        padding: 1rem 0.75rem;
    }
    
    .podium-medal {
        font-size: 2rem;
    }
    
    .podium-name {
        font-size: 1rem;
    }
}
