/**
 * Enhanced styles for the engagement leaderboard with dynamic profile filtering
 */

/* Container styles */
.dtc-leaderboard-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    margin-bottom: 30px;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Title styles */
.dtc-leaderboard-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
}

/* Main filter styles */
.dtc-leaderboard-filters {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.dtc-leaderboard-filters select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background-color: #f9f9f9;
    font-size: 14px;
    min-width: 150px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: border-color 0.2s, background-color 0.2s;
}

.dtc-leaderboard-filters select:focus {
    outline: none;
    border-color: #007cba;
    background-color: #fff;
}

/* Profile filter styles - separate row */
.dtc-leaderboard-profile-filters {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.dtc-leaderboard-profile-filters select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ced4da;
    background-color: #ffffff;
    font-size: 14px;
    min-width: 150px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.dtc-leaderboard-profile-filters select:hover {
    border-color: #adb5bd;
}

.dtc-leaderboard-profile-filters select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.25);
}

/* Profile filter label styling for options with italic text */
.dtc-leaderboard-profile-filters select option[style*="italic"] {
    font-style: italic;
    color: #6c757d;
}

/* Chart styles */
#dtc-leaderboard-chart {
    margin-bottom: 30px;
    border-radius: 8px;
    overflow: hidden;
}

/* Table styles */
.dtc-leaderboard-table-container {
    position: relative;
    margin-top: 20px;
    overflow-x: auto;
}

.dtc-leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    table-layout: fixed;
}

.dtc-leaderboard-table th,
.dtc-leaderboard-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
    /* Ensure content doesn't break words aggressively unless necessary */
    word-break: normal; 
}

.dtc-leaderboard-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
}

.dtc-leaderboard-table tbody tr:hover {
    background-color: #f5f9ff;
}

.dtc-leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

/* Enhanced table styles for better readability */
.dtc-leaderboard-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.dtc-leaderboard-table tbody tr:hover {
    background-color: #f0f7ff;
}

/* Column widths */
.rank-col {
    width: 60px;
    text-align: center;
}

.user-col {
    width: auto; /* Will take up remaining space */
    /* To handle long names and prevent overlap: */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 150px;
}

.points-col {
    width: 100px;
    text-align: right;
}

.level-col {
    width: 100px;
    text-align: center;
}

.tier-breakdown-col {
    width: 150px;
}

.percent-col {
    width: 90px;
    text-align: right;
}

/* Rank badges */
.rank-badge {
    display: inline-block;
    margin-left: 5px;
    font-size: 16px;
    vertical-align: middle;
}

/* Level badges */
.level-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    min-width: 75px; 
    text-align: center;
    box-sizing: border-box;
    vertical-align: middle;
}

/* .level-0 {
    background-color: #adb5bd;
}

.level-1 {
    background-color: #20c997;
}

.level-2 {
    background-color: #0dcaf0;
}

.level-3 {
    background-color: #6610f2;
}

.level-4 {
    background-color: #fd7e14;
}

.level-5 {
    background-color: #dc3545;
} */
.level-0 { background-color: #dee2e6; /* Soft cool gray for inactive */ }
.level-1 { background-color: #51cf66; /* Fresh mint green for entry level */ }
.level-2 { background-color: #339af0; /* Clear sky blue for rising engagement */ }
.level-3 { background-color: #845ef7; /* Violet purple for active contributors */ }
.level-4 { background-color: #fcc419; /* Warm sunflower yellow for amplifiers */ }
.level-5 { background-color: #ff6b6b; /* Energetic coral red for creators */ }

/* Tier bars */
.tier-bars {
    display: flex;
    height: 12px;
    width: 100%;
    background-color: #f0f0f0;
    border-radius: 5px;
    overflow: hidden;
}

.tier-bar {
    height: 100%;
    transition: width 0.5s ease-in-out;
}

.tier-1 {
    background-color: #8dd3c7;
}

.tier-2 {
    background-color: #bebada;
}

.tier-3 {
    background-color: #fb8072;
}

.tier-4 {
    background-color: #80b1d3;
}

.tier-5 {
    background-color: #fdb462;
}

/* Improvement indicators */
.positive-change {
    color: #28a745;
    font-weight: 600;
}

.negative-change {
    color: #dc3545;
    font-weight: 600;
}

/* No data message */
.dtc-no-data-message {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
}

/* Loading spinner animation */
@keyframes dtc-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.dtc-loading-spinner-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 1000;
    border-radius: 8px;
}

.dtc-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: dtc-spin 1s linear infinite;
}

/* Pagination styles */
.dtc-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 10px 0;
    flex-wrap: wrap;
    gap: 10px;
    border-top: 1px solid #eee;
}

.dtc-pagination-info {
    color: #666;
    font-size: 14px;
}

.dtc-pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dtc-pagination-button {
    padding: 6px 12px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.dtc-pagination-button:hover:not([disabled]) {
    background-color: #e9ecef;
}

.dtc-pagination-button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.dtc-pagination-pages {
    margin: 0 8px;
    color: #666;
    font-size: 14px;
}

/* Information badge */
.dtc-chart-info {
    margin-top: 20px;
    text-align: center;
}

.dtc-info-badge {
    display: inline-block;
    background-color: #e3f2fd;
    color: #1976d2;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    border: 1px solid #bbdefb;
}

.dtc-info-icon {
    margin-right: 5px;
    font-weight: bold;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .dtc-leaderboard-filters {
        flex-direction: column;
        align-items: center;
    }
    
    .dtc-leaderboard-filters select {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .dtc-leaderboard-profile-filters {
        flex-direction: column;
        align-items: center;
        padding: 10px;
    }
    
    .dtc-leaderboard-profile-filters select {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .dtc-leaderboard-table th, 
    .dtc-leaderboard-table td {
         padding: 10px 8px; /* Adjust padding for mobile */
        font-size: 13px;  
    }
    
    .tier-breakdown-col {
        display: none;
    }
    
    .dtc-pagination {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dtc-pagination-controls {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }
}

@media (max-width: 480px) {
    .dtc-leaderboard-container {
        padding: 15px;
    }
    
    .dtc-leaderboard-title {
        font-size: 20px;
    }
    
    .dtc-leaderboard-filters select,
    .dtc-leaderboard-profile-filters select {
        min-width: auto;
        width: 100%;
    }
}

/* Enhanced visual feedback for filters */
.dtc-leaderboard-filters select:focus,
.dtc-leaderboard-profile-filters select:focus {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Subtle animations */
.dtc-leaderboard-table tbody tr {
    transition: background-color 0.2s ease;
}

.tier-bar {
    transition: width 0.5s ease-in-out, opacity 0.3s ease;
}

.tier-bar:hover {
    opacity: 0.8;
}