/**
 * Rankings CSS - World Archery Inspired Design
 *
 * Styles for yearly ranking listing and single ranking pages
 *
 * @package FPETARCO
 * @since   1.4.0
 */

/* ========================================
   Rankings Listing Page
   ======================================== */

.fpetarco-rankings-listing {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.fpetarco-rankings-listing .page-header {
    text-align: center;
    margin-bottom: 3rem;
}

.fpetarco-rankings-listing .page-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
}

.fpetarco-rankings-listing .page-description {
    font-size: 1.125rem;
    color: #666;
}

.ranking-year-group {
    margin-bottom: 3rem;
}

.ranking-year-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #0066cc;
}

.ranking-type-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.ranking-card {
    display: flex;
    flex-direction: column;
    padding: 2rem;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    position: relative;
}

.ranking-card:hover {
    border-color: #0066cc;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.15);
    transform: translateY(-2px);
}

.ranking-card-indoor {
    border-left: 5px solid #ff6b35;
}

.ranking-card-outdoor {
    border-left: 5px solid #00a651;
}

.ranking-card-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 1rem;
}

.ranking-card-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.stat-item {
    font-size: 0.95rem;
    color: #666;
}

.stat-item strong {
    font-size: 1.25rem;
    color: #0066cc;
    display: block;
}

.ranking-card-arrow {
    margin-top: auto;
    align-self: flex-end;
    font-size: 1.5rem;
    color: #0066cc;
    transition: transform 0.3s ease;
}

.ranking-card:hover .ranking-card-arrow {
    transform: translateX(5px);
}

.loading-spinner {
    text-align: center;
    padding: 3rem;
    font-size: 1.125rem;
    color: #666;
}

.no-rankings,
.error-message {
    text-align: center;
    padding: 3rem;
    font-size: 1.125rem;
    color: #666;
    background: #f5f5f5;
    border-radius: 8px;
}

.error-message {
    color: #d32f2f;
    background: #ffebee;
}

/* ========================================
   Single Ranking Page
   ======================================== */

.fpetarco-single-ranking {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.ranking-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #e0e0e0;
}

.ranking-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
}

.ranking-subtitle {
    font-size: 1.25rem;
    color: #666;
}

.ranking-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f5f5f5;
    border-radius: 8px;
}

.filter-group {
    flex: 1;
    min-width: 250px;
}

.filter-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    transition: border-color 0.3s ease;
}

.filter-input:focus {
    outline: none;
    border-color: #0066cc;
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid #e0e0e0;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    border-color: #0066cc;
    background: #f0f7ff;
}

.filter-btn.active {
    border-color: #0066cc;
    background: #0066cc;
    color: #fff;
}

.category-section {
    margin-bottom: 3rem;
}

.category-header {
    background: #f5f5f5;
    padding: 1rem 1.5rem;
    border-left: 5px solid #0066cc;
    margin-bottom: 1.5rem;
}

.category-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

.athlete-list {
    display: grid;
    gap: 0.75rem;
}

.athlete-card {
    display: grid;
    grid-template-columns: 60px 80px 1fr auto auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.athlete-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #0066cc;
}

.athlete-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #666;
}

.athlete-rank img {
    width: 32px;
    height: 32px;
}

.athlete-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e0e0e0;
}

.athlete-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.athlete-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a1a1a;
    text-decoration: none;
    transition: color 0.3s ease;
}

.athlete-name:hover {
    color: #0066cc;
}

.athlete-club {
    font-size: 0.95rem;
    color: #666;
}

.athlete-score {
    text-align: right;
}

.score-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0066cc;
}

.score-details {
    font-size: 0.875rem;
    color: #999;
}

.athlete-expand-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0066cc;
    background: #f0f7ff;
    border: 1px solid #0066cc;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.athlete-expand-btn:hover {
    background: #0066cc;
    color: #fff;
}

.competition-scores {
    grid-column: 1 / -1;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
    display: none;
}

.competition-scores.expanded {
    display: block;
}

.competition-scores-title {
    font-size: 1rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.75rem;
}

.competition-score-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #f9f9f9;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.comp-name {
    font-weight: 500;
    color: #1a1a1a;
}

.comp-date {
    font-size: 0.875rem;
    color: #999;
}

.comp-position {
    font-size: 0.875rem;
    color: #666;
}

.comp-score {
    font-weight: 600;
    color: #0066cc;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Tablet */
@media (max-width: 1024px) {
    .fpetarco-rankings-listing .page-title,
    .ranking-title {
        font-size: 2rem;
    }
    
    .ranking-type-cards {
        grid-template-columns: 1fr;
    }
    
    .athlete-card {
        grid-template-columns: 50px 70px 1fr auto;
        gap: 0.75rem;
    }
    
    .athlete-photo {
        width: 70px;
        height: 70px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .fpetarco-rankings-listing,
    .fpetarco-single-ranking {
        padding: 1rem 0.75rem;
    }
    
    .fpetarco-rankings-listing .page-title,
    .ranking-title {
        font-size: 1.75rem;
    }
    
    .ranking-filters {
        flex-direction: column;
    }
    
    .filter-buttons {
        flex-direction: column;
    }
    
    /* Simplified 2-column mobile layout: left column (rank+photo) | right column (stacked content) */
    .athlete-card {
        grid-template-columns: 80px 1fr;
        grid-template-rows: auto auto auto;
        gap: 0.75rem;
        padding: 0.75rem;
        align-items: start;
    }
    
    /* Left column: Rank and photo stacked vertically */
    .athlete-rank {
        grid-row: 1;
        grid-column: 1;
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
    
    .athlete-photo {
        width: 60px;
        height: 60px;
        grid-row: 2;
        grid-column: 1;
        justify-self: center;
    }
    
    /* Right column: Info, score, and button stacked */
    .athlete-info {
        grid-row: 1;
        grid-column: 2;
        align-self: center;
    }
    
    .athlete-score {
        grid-row: 2;
        grid-column: 2;
        text-align: left;
    }
    
    .athlete-expand-btn {
        grid-row: 3;
        grid-column: 1 / -1;
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        margin-top: 0.5rem;
        min-height: 44px;
    }
    
    .score-value {
        font-size: 1.5rem;
    }
    
    .competition-score-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .fpetarco-rankings-listing .page-title,
    .ranking-title {
        font-size: 1.5rem;
    }
    
    .athlete-card {
        grid-template-columns: 70px 1fr;
        gap: 0.5rem;
        padding: 0.625rem;
    }
    
    .athlete-photo {
        width: 50px;
        height: 50px;
    }
    
    .athlete-name {
        font-size: 1rem;
    }
    
    .athlete-club {
        font-size: 0.875rem;
    }
    
    .score-value {
        font-size: 1.25rem;
    }
    
    .athlete-expand-btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }
}

/* ========================================
   Loading & Empty States
   ======================================== */

.rankings-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0066cc;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.no-results {
    text-align: center;
    padding: 3rem;
    font-size: 1.125rem;
    color: #999;
}

/* ========================================
   Accessibility
   ======================================== */

.filter-btn:focus,
.athlete-expand-btn:focus,
.filter-input:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.athlete-card:focus-within {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* ========================================
   Rankings Table Layout
   ======================================== */

.rankings-table-wrapper {
    overflow-x: auto;
    margin-top: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
}

.rankings-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

/* Table Headers */
.rankings-table thead {
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    border-bottom: 2px solid #0066cc;
}

.rankings-table th {
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-right: 1px solid #dee2e6;
}

.rankings-table th:last-child {
    border-right: none;
}

.rankings-table th.col-athlete {
    text-align: left;
    min-width: 250px;
}

.rankings-table th.col-rank {
    width: 60px;
}

.rankings-table th.col-competition {
    width: 70px;
    font-size: 0.75rem;
    padding: 0.75rem 0.25rem;
}

.rankings-table th.col-total {
    width: 90px;
    background: linear-gradient(to bottom, #e8f4fd, #d1e7f7);
    font-size: 0.95rem;
    color: #0066cc;
}

/* Month header link */
.month-header {
    color: #0066cc;
    text-decoration: none;
    font-weight: 700;
    display: block;
    padding: 0.25rem;
    transition: all 0.2s ease;
}

.month-header:hover {
    color: #004999;
    text-decoration: underline;
    background: rgba(0, 102, 204, 0.05);
    border-radius: 4px;
}

/* Table Body */
.rankings-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.15s ease;
}

.rankings-table tbody tr:hover {
    background-color: #f8f9fa;
}

.rankings-table tbody tr:last-child {
    border-bottom: none;
}

.rankings-table td {
    padding: 0.75rem 0.5rem;
    text-align: center;
    vertical-align: middle;
    border-right: 1px solid #f1f3f5;
}

.rankings-table td:last-child {
    border-right: none;
}

/* Rank Cell */
.cell-rank {
    font-size: 1.25rem;
    font-weight: 700;
    color: #495057;
}

.cell-rank img {
    width: 32px;
    height: 32px;
    display: inline-block;
}

/* Athlete Cell */
.cell-athlete {
    text-align: left;
}

.athlete-info-block {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.athlete-photo-small {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #dee2e6;
    flex-shrink: 0;
}

.athlete-details {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.athlete-name-link {
    font-size: 1rem;
    font-weight: 600;
    color: #212529;
    text-decoration: none;
    transition: color 0.2s ease;
    line-height: 1.3;
}

.athlete-name-link:hover {
    color: #0066cc;
}

.athlete-club-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.club-logo-table {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

.club-name-table {
    font-size: 0.875rem;
    color: #6c757d;
    line-height: 1.2;
}

/* Score Cells */
.cell-score {
    font-size: 1.05rem;
    font-weight: 600;
    color: #212529;
}

.cell-score.non-counting {
    color: #868e96;
    font-style: italic;
    position: relative;
}

.cell-score.empty {
    color: #ced4da;
    font-weight: 400;
    font-size: 1.2rem;
}

/* Asterisk for non-counting scores */
.cell-score.non-counting::after {
    content: '*';
    color: #ff6b35;
    font-size: 1.1rem;
    font-weight: 700;
    vertical-align: super;
    margin-left: 2px;
}

/* Total Cell */
.cell-total {
    background: linear-gradient(to right, #e8f4fd, #f0f8ff);
    border-left: 2px solid #0066cc;
}

.total-score {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0066cc;
}

/* Table Legend */
.table-legend {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: #6c757d;
    font-style: italic;
}

.table-legend::before {
    content: '*';
    color: #ff6b35;
    font-weight: 700;
    margin-right: 0.25rem;
}

/* ========================================
   Responsive Table Adjustments
   ======================================== */

@media (max-width: 1024px) {
    .rankings-table {
        font-size: 0.9rem;
    }

    .rankings-table th,
    .rankings-table td {
        padding: 0.5rem 0.35rem;
    }

    .athlete-photo-small {
        width: 42px;
        height: 42px;
    }

    .rankings-table th.col-competition {
        font-size: 0.7rem;
    }
}

@media (max-width: 768px) {
    .rankings-table-wrapper {
        -webkit-overflow-scrolling: touch;
        border-radius: 4px;
    }

    .rankings-table {
        min-width: 800px;
    }

    .rankings-table th.col-athlete {
        min-width: 200px;
    }

    .athlete-info-block {
        gap: 0.5rem;
    }

    .athlete-photo-small {
        width: 40px;
        height: 40px;
    }

    .athlete-name-link {
        font-size: 0.9rem;
    }

    .club-logo-table {
        width: 18px;
        height: 18px;
    }

    .club-name-table {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .rankings-table th,
    .rankings-table td {
        padding: 0.4rem 0.25rem;
    }

    .cell-score {
        font-size: 0.95rem;
    }

    .total-score {
        font-size: 1.15rem;
    }

    .athlete-photo-small {
        width: 36px;
        height: 36px;
    }

    .athlete-name-link {
        font-size: 0.85rem;
    }

    .club-logo-table {
        width: 16px;
        height: 16px;
    }

    .club-name-table {
        font-size: 0.75rem;
    }
}

/* ========================================
   Mobile Card Layout
   ======================================== */

/* Hide mobile view by default (show on mobile only) */
.mobile-view {
    display: none;
}

.desktop-view {
    display: block;
}

.athlete-card-mobile {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(to bottom, #fafafa, #fff);
    border-bottom: 1px solid #f0f0f0;
}

.card-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.card-rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: #495057;
    min-width: 40px;
    text-align: center;
}

.card-rank img {
    width: 36px;
    height: 36px;
}

.card-athlete-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.card-name-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-athlete-name {
    font-size: 1rem;
    font-weight: 600;
    color: #212529;
    text-decoration: none;
    line-height: 1.3;
}

.card-athlete-name:hover {
    color: #0066cc;
}

.club-logo-card {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

.card-club-name {
    font-size: 0.875rem;
    color: #6c757d;
}

.card-right {
    text-align: right;
}

.card-total-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.card-total-score {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0066cc;
}

.card-scores {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 0.5rem;
    padding: 1rem;
    background: #fafafa;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.score-item.non-counting {
    background: #f8f9fa;
    border-color: #dee2e6;
}

.score-item.empty {
    opacity: 0.5;
}

.score-month {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.score-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #212529;
}

.score-item.non-counting .score-value {
    color: #868e96;
}

.score-item.empty .score-value {
    color: #ced4da;
    font-size: 1.5rem;
}

/* Star icon for non-counting scores */
.score-item.non-counting .score-value {
    position: relative;
}

/* Mobile-specific adjustments */
@media (max-width: 767px) {
    /* Hide desktop table, show mobile cards */
    .desktop-view {
        display: none !important;
    }

    .mobile-view {
        display: block !important;
    }

    .card-scores {
        grid-template-columns: repeat(3, 1fr);
    }

    .card-total-score {
        font-size: 1.5rem;
    }

    .score-value {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .card-header {
        padding: 0.75rem;
    }

    .card-left {
        gap: 0.5rem;
    }

    .card-rank {
        font-size: 1.25rem;
        min-width: 35px;
    }

    .card-rank img {
        width: 30px;
        height: 30px;
    }

    .card-athlete-name {
        font-size: 0.9rem;
    }

    .card-club-name {
        font-size: 0.8rem;
    }

    .club-logo-card {
        width: 18px;
        height: 18px;
    }

    .card-total-score {
        font-size: 1.35rem;
    }

    .card-scores {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.4rem;
        padding: 0.75rem;
    }

    .score-item {
        padding: 0.4rem;
    }

    .score-month {
        font-size: 0.7rem;
    }

    .score-value {
        font-size: 1rem;
    }
}
