/*
 * CẬP NHẬT MỚI NHẤT:
 * - Đã fix lỗi banner tràn chiều ngang trên mobile.
 * - Đã thêm nhãn (data-label) cho mỗi ô thông tin trên mobile để người dùng dễ đọc.
 */

/* wp-content/themes/Newspaper/css/rankings.css */

/* Fonts và Nền */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
:root {
    --bg-light: #f5f7fa; /* Nền sáng */
    --text-primary: #333; /* Chữ đậm */
    --text-secondary: #777; /* Chữ phụ */
    --brand-color: #007bff; /* Màu thương hiệu - xanh dương */
    --brand-color-light: #e6f2ff; /* Màu thương hiệu nhẹ */
    --card-bg: #ffffff; /* Nền card */
    --border-color: #e0e0e0; /* Màu viền */
    --shadow-light: rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box; /* Đảm bảo padding và border không làm tăng kích thước phần tử */
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    background-color: transparent;
    background-image: url('https://besttriathlon.vn/wp-content/uploads/besttriathlon_bg.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden; /* Ngăn chặn cuộn ngang toàn bộ trang */
}

/* Lớp phủ màu trắng (overlay) ban đầu đã được comment lại để hiển thị hình nền rõ hơn */
/*
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: -1;
}
*/

/* Các lớp container chung */
.ranking-page-container {
    max-width: 92%; /*1200px*/
    margin: 20px auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    position: relative;
    z-index: 2;
}

.page-title, .ranking-header h2 {
    text-align: center;
    color: var(--brand-color);
    font-weight: 700;
    margin-bottom: 20px;
}

.page-description {
    text-align: center;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto 40px;
}

/* Kiểu thẻ "Card" cho trang chủ */
.ranking-card {
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: 0 5px 20px var(--shadow-light);
    padding: 30px;
    margin-bottom: 40px;
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

.ranking-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--shadow-light);
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.ranking-header h2 {
    text-align: left;
    margin: 0;
    font-size: 1.8rem;
}

.view-all-link {
    font-weight: 500;
    color: var(--brand-color);
    text-decoration: none;
    transition: color 0.3s;
}

.view-all-link:hover {
    color: #0056b3;
}

/* Bảng xếp hạng chung */
.ranking-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 20px;
    background-color: transparent;
    border-radius: 10px;
    overflow: hidden;
}

.ranking-table thead {
    background-color: var(--brand-color-light);
}

.ranking-table th, .ranking-table td {
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.ranking-table td a {
    text-decoration: none;
    font-weight: bold;
    font-size: larger;
}

.ranking-table th {
    color: var(--brand-color);
    font-weight: 600;
    font-size: 1rem;
    text-transform: uppercase;
}

.ranking-table tbody tr {
    transition: background-color 0.3s ease;
}

.ranking-table tbody tr:nth-child(odd) {
    background-color: #fcfcfc;
}

.ranking-table tbody tr:hover {
    background-color: #f0f0f0;
    cursor: pointer;
}

/* Điểm nhấn top 3 */
.ranking-table tbody tr.is-top-1 {
    background-color: #fff8e1;
}
.ranking-table tbody tr.is-top-2 {
    background-color: #eceff1;
}
.ranking-table tbody tr.is-top-3 {
    background-color: #fbe9e7;
}

/* Thanh điều khiển, lọc và tìm kiếm */
.ranking-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap; /* Thêm dòng này để cho phép các nút xuống hàng */
    justify-content: center; /* Căn giữa các nút khi xuống hàng */
}

.filter-btn {
    background-color: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 50px;
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 5px var(--shadow-light);
}

.filter-btn:hover {
    background-color: #f0f0f0;
}

.filter-btn.active {
    background-color: var(--brand-color);
    color: #fff;
    border-color: var(--brand-color);
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.3);
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 10px 15px 10px 45px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px var(--shadow-light);
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.search-box input:focus {
    outline: none;
    border-color: var(--brand-color);
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3);
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* Phân trang */
.pagination {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

.pagination-inner a, .pagination-inner span {
    display: inline-block;
    padding: 10px 15px;
    margin: 0 5px;
    color: var(--brand-color);
    text-decoration: none;
    border-radius: 50%;
    transition: background-color 0.3s, color 0.3s;
}

.pagination-inner a:hover {
    background-color: var(--brand-color-light);
}

.pagination-inner .current-page {
    background-color: var(--brand-color);
    color: #fff;
    font-weight: bold;
}

/* Vị trí quảng cáo */
.ad-container {
    text-align: center;
    margin-bottom: 30px;
}
.ad-container-mobile {
    display: none;
    text-align: center;
    margin-bottom: 30px;
}
.ad-leaderboard {
    margin: 30px auto;
}

/* Ẩn banner sticky trên mobile */
.ad-mobile-sticky {
    display: none;
}

.header-image img {
    max-width: 100%;
    height: auto;
    display: block; /* Loại bỏ khoảng trắng dưới ảnh */
}

.ad-rectangle-desktop {
    position: sticky;
    top: 20px;
}
.main-content {
    display: flex;
    gap: 20px;
}
.table-wrapper {
    flex: 1;
}

/* Responsive */
@media (max-width: 1024px) {
    .ranking-page-container {
        padding: 10px;
    }
    .ranking-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .search-box, .filters {
        width: 100%;
        justify-content: center;
    }
    .main-content {
        flex-direction: column;
    }
    .ad-rectangle-desktop {
        position: static;
    }
}

@media (max-width: 768px) {
    /* Ẩn header của bảng trên mobile */
    .ranking-table thead {
        display: none;
    }
    .ad-container-mobile {
        display: block;
    }
    .ad-container-desktop {
        display: none;
    }
    .ad-leaderboard {
        display: block !important;
        margin: 20px auto;
    }

    .ad-rectangle-desktop {
        display: none;
    }
    
    .ranking-table, .ranking-table tbody, .ranking-table tr, .ranking-table td {
        display: block;
        width: 100%;
    }
    .ranking-table tr {
        margin-bottom: 15px;
        border-radius: 8px;
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        padding: 10px;
    }
    .ranking-table td {
        text-align: left;
        border-bottom: none;
        padding: 5px 10px;
        flex-grow: 1;
        width: auto;
        flex-basis: auto; /* Đặt lại giá trị ban đầu để flexbox tự động tính toán */
    }
    /* Tùy chỉnh hiển thị gọn gàng hơn cho mobile */
    .ranking-table td::before {
        font-weight: bold;
        text-transform: uppercase;
        color: var(--brand-color);
        display: inline;
        margin-right: 5px;
    }
    /* Chỉnh lại độ rộng cho cột hạng và tên VĐV để hiển thị trên cùng một dòng */
    .ranking-table td:first-child {
        width: 100%; /* Cột Hạng chiếm 25% */
        flex: none; /* Không cho phép giãn nở */
        text-align: center; /* Căn giữa cho cột hạng */
    }
    .ranking-table td:nth-child(1)::before
    , .ranking-table td:nth-child(2)::before
    , .ranking-table td:nth-child(3)::before, .ranking-table td:nth-child(4)::before, .ranking-table td:nth-child(5)::before
    , .ranking-table td:nth-child(6)::before, .ranking-table td:nth-child(7)::before, .ranking-table td:nth-child(8)::before {
        content: attr(data-label) ': ';
    }
    .ranking-table td:nth-child(2) {
        width: 100%; /* Cột Tên VĐV chiếm phần còn lại */
        flex: 1; /* Cho phép giãn nở để lấp đầy khoảng trống */
        text-align: left; /* Căn trái cho tên VĐV */
    }
    /* Các cột còn lại sẽ tự động chiếm 100% width để hiển thị dọc */
    .ranking-table td:nth-child(n+3) {
        width: 100%;
    }

    /* Đảm bảo banner không bị tràn ra ngoài màn hình */
    .ad-container img {
        max-width: 100%;
        height: auto;
    }
}

