/**
 * Dashboard/Index Page - Main page layout and components
 * Loaded AFTER styles.css to override/extend base styles
 */

/* ========== SEARCH SECTION ========== */

.search-section {
    background: rgba(24, 28, 58, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    color: #e0e6ed;
}

.search-filters-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: 100%;
}

/* Player Found Button */
#playerFoundBtn {
    border-radius: 8px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

#playerFoundBtn:hover {
    background: #27ae60;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.search-input {
    padding: 10px 15px;
    border: 2px solid #ffb300;
    border-radius: 8px;
    font-size: 14px;
    background: #23234a;
    color: #fff;
    min-width: 250px;
}

.search-input:focus {
    outline: none;
    border-color: #ff6a00;
}

/* Filter Buttons (501 / League) */
.filter-btn-501, .filter-btn-league {
    font-size: 1.15rem;
    font-weight: 800;
    padding: 14px 36px;
    border-radius: 12px;
    margin-right: 12px;
    margin-bottom: 0;
    box-shadow: 0 2px 8px #0002;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    border: none;
    cursor: pointer;
}

.filter-btn-501 {
    background: linear-gradient(90deg, #ffb300 0%, #ff6a00 100%);
    color: #181c3a;
}

.filter-btn-league {
    background: linear-gradient(90deg, #2a5298 0%, #1e3c72 100%);
    color: #fff;
}

.filter-btn-501.active, .filter-btn-league.active {
    box-shadow: 0 4px 16px #ffb30055, 0 0px 2px #fff2;
    outline: 2px solid #fff;
    filter: brightness(1.1);
}

.filter-btn-league.active {
    outline: 2px solid #ffb300;
}

/* Date Filter */
.date-filter-box {
    display: flex;
    align-items: center;
}

.date-range-select {
    padding: 10px 15px;
    border: 2px solid #ffb300;
    border-radius: 8px;
    font-size: 14px;
    background: #23234a;
    color: #fff;
    cursor: pointer;
    min-width: 120px;
}

.date-range-select:focus {
    outline: none;
    border-color: #ff6a00;
}

.custom-date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(35, 35, 74, 0.8);
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid #ffb300;
}

.date-input {
    padding: 8px 12px;
    border: 1px solid #ffb300;
    border-radius: 6px;
    background: #181c3a;
    color: #fff;
    font-size: 14px;
}

.date-input:focus {
    outline: none;
    border-color: #ff6a00;
}

/* ========== MAIN CONTENT GRID ========== */

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: start; /* Don't stretch grid items - let them size naturally */
    min-height: 60vh;
    margin-top: 0.5rem;
    padding-top: 0;
    height: calc(100vh - 245px);
    max-height: calc(100vh - 245px);
}

/* ========== MATCH LIST SECTION ========== */

.match-list-section {
    background: var(--color-bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    padding: 5px;
    padding-left: var(--spacing-lg);
    box-shadow: var(--shadow-lg);
    color: var(--color-text-primary);
    padding-right: 16px;
    margin-right: var(--spacing-md);
    height: 100%;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.match-list-section .filters-row {
    margin-right: 20px;
}

.match-header-row .filters-row {
    margin-top: 15px;
    margin-bottom: 10px;
}

.match-list-section h2 {
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-lg);
    font-size: 1.5rem;
    font-weight: 900;
    text-shadow: var(--shadow-text);
}

.match-list-scrollbox {
    flex: 1 1 0%; /* Grow to fill available space in match-list-section */
    min-height: 0;
    max-height: none; /* Remove max-height restriction - let it fill parent */
    overflow-y: auto;
    padding: 5px 8px 5px 0;
}

.match-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0; /* Allow flex shrinking to prevent overflow */
}

/* .match-card moved to styles.css - shared component with status variants (.ongoing, .closed, .tournament) */

/* .pagination moved to styles.css - shared component */

#pageInfo {
    color: #ffb300;
    font-weight: 700;
    font-size: 1rem;
}

/* ========== RIGHT PANEL ========== */

.right-panel {
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    margin-top: 0;
    margin-left: 12px; /* Half of grid gap for visual separation */
    padding-top: 0;
    align-self: stretch; /* Fill grid cell height */
    overflow: hidden; /* Prevent children from expanding the panel */
}

/* Top Players panel background removed for cleaner look */

.top-players-section,
.match-details-section {
    width: 100%;
    min-height: 0; /* Allow flex shrinking */
    flex: 1; /* Grow to fill available space in right-panel */
    margin-top: 0;
    padding-top: 0;
    overflow-y: auto;
}

.top-players-section {
    display: block;
    padding: 0 20px;
}

.match-details-section {
    display: none;
}

/* .clickable-player defined in styles.css - shared component */

/* ========== LEADERBOARD SECTION ========== */

.leaderboard-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.leaderboard-title {
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px #000a;
}

.leaderboard-subtitle {
    font-size: 1.2rem;
    font-weight: bold;
    color: #ffb300;
    margin-top: 0.5rem;
}

.leaderboard-grid,
#topPlayersTableContainer .leaderboard-grid,
#leagueTopPlayersTableContainer .leaderboard-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
}

#topPlayersTableContainer,
#leagueTopPlayersTableContainer {
    text-align: center;
    padding: 20px;
}

/* Stats Section */
.stats-section {
    background: rgba(24, 28, 58, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 179, 0, 0.2);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

.stats-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #ffb300 50%, transparent 100%);
}

.stats-section h3 {
    margin: 0 0 15px 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 1.1rem;
    line-height: 1.3;
    color: #ffb300;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    padding-bottom: 8px;
}

.stats-section h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, #ffb300 0%, #ff6a00 100%);
    border-radius: 1px;
}

/* ========== LOADING OVERLAYS ========== */

.panel-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(24, 28, 58, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 15px;
}

.panel-loading-overlay .spinner {
    border: 4px solid rgba(255, 179, 0, 0.3);
    border-top: 4px solid #ffb300;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.top-players-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(24, 28, 58, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

/* ========== RESPONSIVE - MOBILE ========== */

@media (max-width: 768px) {
    .main-content {
        display: flex;
        flex-direction: column;
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
        min-height: 0;
        gap: 12px;
    }

    .match-list-scrollbox {
        max-height: 50vh;
    }

    .leaderboard-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .search-filters-row {
        flex-wrap: wrap;
    }

    .search-input {
        min-width: 200px;
    }

    .match-list-section {
        margin-bottom: 0.1rem;
    }

    .right-panel {
        margin-top: 0;
        padding-top: 0;
    }

    .top-players-section {
        margin-top: 0;
        padding-top: 0;
    }
}

/* ========== COMPACT STYLING ========== */

.main-content {
    margin-top: 0;
    padding-top: 0;
    gap: 4px;
}

.leaderboard-grid {
    gap: 12px;
}

.stats-section {
    padding: 10px 8px 8px 8px;
    border-radius: 10px;
    margin: 0 !important; /* Consolidated */
    margin-bottom: 6px;
    border: none !important; /* Consolidated */
    box-shadow: none !important; /* Consolidated */
}

/* Remove yellow underline below stat section titles */
.stats-section h3 {
    position: relative;
    margin-bottom: 0.5rem;
    text-transform: none !important;
}

.stats-section h3::after {
    display: none !important;
}

#topPlayersTableContainer, 
#leagueTopPlayersTableContainer {
    margin: 0 !important;
    padding: 0 !important;
}

/* Remove border around leaderboard tables */
.leaderboard-table {
    border: none !important;
    box-shadow: none !important;
}

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

/* ========== UTILITY CLASSES (from inline styles migration) ========== */

/* Logo link styling */
.logo-link {
    text-decoration: none;
    display: inline-block;
    line-height: 0;
}

.logo-image {
    cursor: pointer;
    display: block;
}

/* Positioned container for overlays */
.positioned-container {
    position: relative;
}

/* Header row with flex layout */
.header-flex-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.header-flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

/* No bottom margin variant */
.no-bottom-margin {
    margin-bottom: 0;
}

/* Search and filters styling */
.search-filters-flex {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.search-box-container {
    position: relative;
}

.custom-date-flex {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Player found button styling */
.player-found-btn {
    background: #27ae60;
    color: #fff;
    font-weight: 700;
}

/* ========== INDEX-SPECIFIC STYLES (from styles.css cleanup) ========== */

/* Close button for match/league details */
#closeDetails:hover {
    background-color: #dc3545 !important;
    color: #fff !important;
    border-color: #dc3545 !important;
}

/* Search Section */
.search-section {
    background: rgba(24, 28, 58, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    color: #e0e6ed;
}

.search-filters-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: 100%;
}

/* Player Found Button */
#playerFoundBtn {
    border-radius: 8px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

#playerFoundBtn:hover {
    background: #219150 !important;
    transform: translateY(-1px);
}

/* Mobile responsive for player found button */
@media (max-width: 768px) {
    #playerFoundBtn {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
    
    #playerFoundBtn span {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Filters */
.filters {
    display: flex;
    gap: 15px;
}

#refreshBtn, #ongoingBtn {
    margin-left: 0;
}

/* ========== LEAGUE DETAILS CONTAINER (from styles.css cleanup) ========== */

.league-details-container {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.league-details-container.show {
    display: flex;
}

.match-details-section.league-details .league-details-container.show {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Ensure proper styling for league content inside the container */
.league-details-container .league-content-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: transparent;
}

.league-details-container .league-header-fixed {
    position: sticky;
    top: 0;
    background: rgba(24, 28, 58, 0.98);
    backdrop-filter: blur(10px);
    padding: 20px;
    padding-left: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 179, 0, 0.15);
    z-index: 10;
    border-radius: 15px 15px 0 0;
}

.league-details-container .match-info {
    margin-bottom: 10px;
}

.match-info {
    padding-top: 20px;
    margin-bottom: 10px;
}

/* Ensure all league styling works inside the container */
.league-details-container .league-details-cards {
    display: flex;
    gap: 18px;
    margin-bottom: 18px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.league-details-container .league-detail-card {
    background: var(--gradient-card-alt);
    border-radius: var(--radius-lg);
    padding: 16px 22px;
    min-width: 110px;
    text-align: center;
    color: var(--color-text-secondary);
    box-shadow: var(--shadow-sm);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.league-details-container .league-detail-card b {
    font-size: 1.05em;
    color: var(--color-primary);
    margin-bottom: var(--spacing-xs);
    font-weight: 700;
}

.league-details-container .section-header {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 6px;
    margin-top: 10px;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px #000a;
}

.league-details-container .participants-list {
    padding: 10px 0 10px 0;
}

.league-details-container .matchup-cards {
    padding: 10px 0 10px 0;
}

.league-details-container .league-participants,
.league-details-container .match-stats,
.league-details-container .league-matchups {
    padding: 14px 0 0 0;
    margin-bottom: 10px;
}

.league-details-container .stats-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.league-details-container .stats-grid.league-stats {
    grid-template-columns: repeat(3, 1fr);
}

.league-details-container .stat-card {
    background: var(--gradient-card);
    border-radius: var(--radius-md);
    padding: 15px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    color: #f1f1f1;
    font-weight: 500;
    border: 2px solid var(--border-primary);
}

.league-details-container .stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 5px;
    text-shadow: var(--shadow-text);
}

.league-details-container .stat-card .stat-label {
    font-size: 0.95rem;
    color: var(--color-text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.85;
    display: block;
    text-align: center;
    margin: 0 auto;
}

/* Player pills and other league elements */
.league-details-container .player-link-btn {
    background: var(--color-primary) !important;
    color: var(--color-bg-card-alt) !important;
    font-weight: 600;
    border-radius: var(--radius-md);
    padding: var(--spacing-xs) 16px;
    margin: 0 var(--spacing-sm) var(--spacing-sm) 0;
    cursor: pointer;
    border: none;
    font: inherit;
    outline: none;
    transition: var(--transition-fast);
}

.league-details-container .player-link-btn:hover {
    background: #e09f00 !important;
    transform: translateY(-1px);
}

.league-details-container .winner-crown-emoji {
    display: inline-block;
    font-size: 1.35em;
    margin-left: 6px;
}

.league-header-fixed {
    position: sticky;
    top: 0;
    background: rgba(24, 28, 58, 0.98);
    backdrop-filter: blur(10px);
    padding: 20px;
    padding-bottom: 10px;
    z-index: 10;
    border-radius: 15px 15px 0 0;
    border-bottom: 1px solid rgba(255, 179, 0, 0.15);
}

.league-content-scrollable {
    padding: 5px 10px 15px 20px; /* Reduced right padding to give scrollbar space */
    overflow-y: auto !important;
    flex: 1 1 0%;
    min-height: 0;
    margin-right: 5px; /* Space between content and scrollbar */
}

/* Custom scrollbar styling for league details to prevent cutoff */
.league-content-scrollable::-webkit-scrollbar {
    width: 8px;
}

.league-content-scrollable::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    margin: 5px 0; /* Add margin to prevent track from touching rounded corners */
}

.league-content-scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 179, 0, 0.5);
    border-radius: 10px;
}

.league-content-scrollable::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 179, 0, 0.7);
}

