﻿/* ==========================================
   RANKINGS MODAL - Fixed Header + Scrolling Body + Fixed Footer
   Follows the My Bag modal pattern
   ========================================== */

/* Rankings Modal Content - Wider and uses flex column */
.rankings-modal-content {
    max-width: 900px !important;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Modal Body - Scrollable middle section */
.rankings-modal-content .hcp-modal-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* Modal Header */
.rankings-modal-content .hcp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.rankings-modal-content .hcp-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: 600;
}

/* Modal Footer - Fixed at bottom */
.rankings-modal-content .hcp-modal-footer {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.rankings-modal-content .hcp-modal-footer .btn {
    flex: 1;
    height: 48px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rankings-modal-content .hcp-modal-footer .btn:active {
    transform: scale(0.98);
}

/* Filters Section - Fixed at top, collapsible, OPAQUE */
.rankings-filters {
    background: var(--bg-card);
    padding: 8px;
    margin-bottom: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-color);
}

/* Ensure complete opacity - no transparency */
.rankings-filters::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    z-index: -1;
    border-radius: var(--radius-md);
}

/* Course + Collapse Button Row */
.filter-row-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 4px;
}

.course-select {
    min-width: 0; /* Allow shrinking */
}

.filters-toggle {
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: 18px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 48px;
}

.filters-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

.filters-toggle .toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.rankings-filters.collapsed .filters-toggle .toggle-icon {
    transform: rotate(-90deg);
}

/* Collapsible Content */
.filters-content {
    margin-top: 8px;
	display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 4px;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
    background: var(--bg-card);
}

.rankings-filters.collapsed .filters-content {
    max-height: 65px;
    /*opacity: 0;*/
    padding: 0 4px;
}

/* Fixed Content */
.filters-fixed-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0px 4px 4px 4px;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
    background: var(--bg-card);
}

/* Checkbox + Sorting Row (2 columns, 1 row) - ENSURE SAME ROW */
.filter-row-controls {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
}

.sort-select {
    min-width: 0; /* Allow shrinking */
}

/* Mobile: Stack vertically if needed */
/*@media (max-width: 480px) {
    .filter-row-controls {
        grid-template-columns: 1fr;
    }
}*/

/* Inline Load Button (in filters) */
.load-rankings-btn-inline {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.load-rankings-btn-inline:hover {
    background: var(--brand-blue);
    transform: translateY(-1px);
}

.load-rankings-btn-inline:active {
    transform: translateY(0);
}

.rankings-modal-footer {
    display: flex;
    gap: var(--space-4);
    justify-content: flex-end;
    padding: 12px 6px;
}

/* Add disabled button styles */
.rankings-modal-footer .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rankings-modal-footer .btn:disabled:hover {
    background: var(--primary);
    transform: none;
}

/* Hide when collapsed */
.rankings-filters.collapsed .load-rankings-btn-inline {
    display: none;
}

/* Filter Input Styles */
.filter-input {
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 18px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s;
    font-weight: 500;
}

.filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Date inputs on same row - ALWAYS */
.filter-row-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.date-input {
    color-scheme: dark;
}

/* Gender Buttons - ALWAYS 4 columns */
.gender-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.gender-btn {
    padding: 12px 8px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.gender-btn:hover {
    border-color: var(--primary);
    background: var(--bg-secondary);
}

.gender-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Checkbox */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-group label {
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    margin: 0;
    font-weight: 500;
}

/* Results Section */
.rankings-results {
    margin-top: 0;
}

/* Context Mode (locked filters) */
.rankings-context {
    background: rgba(59, 130, 246, 0.1);
    padding: 18px;
    border-radius: var(--radius-md);
    border: 2px solid var(--primary);
    margin-bottom: 16px;
}

.rankings-context h3 {
    margin: 0 0 5px 0;
    font-size: 18px;
    color: var(--primary);
    font-weight: 600;
}

.rankings-context p {
    margin: 0;
    font-size: 18px;
    color: var(--text-secondary);
}

/* Results Section */
.rankings-results {
    margin-top: 0;
}

/* Loading State */
.loading-spinner {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid var(--bg-secondary);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: rankingsSpinner 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* No Results */
.no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.no-results-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.no-results h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: var(--text-primary);
}

.no-results p {
    margin: 0;
    font-size: 14px;
}

/* Rankings Table (Desktop) */
@media (min-width: 768px) {
    .rankings-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 14px;
        background: var(--bg-secondary);
        border-radius: var(--radius-md);
        overflow: hidden;
    }
    
    .rankings-table thead {
        background: var(--primary);
        color: white;
    }
    
    .rankings-table th {
        padding: 10px 8px;
        text-align: center;
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
    }
    
    .rankings-table tbody tr {
        border-bottom: 1px solid var(--border-color);
        transition: background 0.2s;
    }
    
    .rankings-table tbody tr:hover {
        background: var(--bg-primary);
    }
    
    .rankings-table td {
        padding: 10px 8px;
        text-align: center;
        color: var(--text-primary);
        font-weight: 500;
    }
    
    /* Podium Highlighting */
    .rankings-table tbody tr.rank-1 {
        background: #854d0e !important;
    }
    
    .rankings-table tbody tr.rank-2 {
        background: #52525b !important;
    }
    
    .rankings-table tbody tr.rank-3 {
        background: #9a3412 !important;
    }
    
    .rank-cell {
        font-weight: 700;
        font-size: 16px;
    }
    
    .rank-1 .rank-cell {
        color: #fbbf24;
    }
    
    .rank-2 .rank-cell {
        color: #d4d4d8;
    }
    
    .rank-3 .rank-cell {
        color: #fb923c;
    }
    
    .name-cell {
        text-align: left;
        font-weight: 600;
        color: var(--text-primary);
    }
    
    .points-cell {
        font-weight: 700;
        color: var(--brand-green);
    }
    
    .score-positive {
        color: var(--brand-red);
        font-weight: 600;
    }
    
    .score-negative {
        color: var(--brand-green);
        font-weight: 600;
    }
    
    .score-even {
        color: var(--text-secondary);
    }
    
    .gender-icon {
        font-size: 16px;
    }
    
    .gender-M {
        color: var(--brand-blue);
    }
    
    .gender-F {
        color: #f472b6;
    }
}

/* Rankings Cards (Mobile) */
@media (max-width: 767px) {
    .rankings-table {
        display: none;
    }
    
    .rankings-cards {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .ranking-card {
        background: var(--bg-secondary);
        border: 2px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 6px 12px;
    }
    
	.ranking-card.rank-1 {
        /*background: #854d0e;
        border-color: #fbbf24;*/
        background: rgba(251,191,36,0.1);
        border-color: rgba(251,191,36,0.25);
    }

    .ranking-card.rank-2 {
        /*background: #52525b;
        border-color: #d4d4d8;*/
        background: rgba(212,212,216,0.1);
        border-color: rgba(212,212,216,0.25);
    }

    .ranking-card.rank-3 {
        /*background: #9a3412;
        border-color: #fb923c;*/
        background: rgba(154,52,18,0.1);
        border-color: rgba(154,52,18,0.25);
    }
    
    .card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
    }
    
    .card-rank {
        font-size: 24px;
        font-weight: 700;
    }
    
    .rank-1 .card-rank {
        color: #fbbf24;
    }
    
    .rank-2 .card-rank {
        color: #d4d4d8;
    }
    
    .rank-3 .card-rank {
        color: #fb923c;
    }
    
    .card-name {
        font-size: 18px;
        font-weight: 600;
        color: var(--text-primary);
        flex: 1;
        margin-left: 10px;
    }
    
    .card-gender {
        font-size: 18px;
    }
    
    .card-stats {
        display: flex;
        gap: 8%;
        font-size: 16px;
        color: var(--text-secondary);
        margin-top: 8px;
    }
    
    .card-stat {
        display: flex;
        flex-direction: column;
    }
    
    .card-stat-label {
        font-size: 16px;
        text-transform: uppercase;
        font-weight: 600;
    }
    
    .card-stat-value {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
        margin-top: 2px;
    }
    
    .card-stat.points .card-stat-value {
        color: var(--brand-green);
    }
    
    .card-info {
        display: flex;
        gap: 8px;
        font-size: 18px;
        color: var(--text-secondary);
    }
}

/* Desktop: Hide mobile cards */
@media (min-width: 768px) {
    .rankings-cards {
        display: none;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Mobile Adjustments */
@media (max-width: 640px) {
    .rankings-modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .rankings-modal-content .hcp-modal-body {
        padding: 10px;
    }
    
    .rankings-modal-content .hcp-modal-footer {
        padding: 10px;
    }
}
/* Date Input Groups with Labels */
.date-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.date-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-left: 4px;
}