/**
 * Unified High Scores Styles
 * Theme-compatible with ti-theme light/dark mode
 */

.unified-high-scores-container {
    margin: 20px 0;
    max-width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    color: hsl(var(--foreground));
}

/* ===========================================
   Score Filters
   =========================================== */

.score-filters {
    background-color: hsl(var(--muted));
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 24px;
    box-shadow: 0 2px 4px hsl(var(--foreground) / 0.05);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    margin-bottom: 6px;
    font-size: 14px;
}

.score-filter {
    padding: 10px 12px;
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
    background-color: hsl(var(--card));
    cursor: pointer;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: hsl(var(--foreground));
}

.score-filter:focus {
    border-color: hsl(var(--success));
    box-shadow: 0 0 0 3px hsl(var(--success) / 0.2);
    outline: none;
}

.score-filter:hover {
    border-color: hsl(var(--border));
}

.reset-filters-btn {
    padding: 7px 16px;
    background-color: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    height: fit-content;
    align-self: end;
}

.reset-filters-btn:hover {
    background-color: hsl(var(--border));
    color: hsl(var(--foreground));
}

/* ===========================================
   User Info Message
   =========================================== */

.user-info-message {
    margin-bottom: 16px;
    padding: 12px;
    background-color: hsl(var(--muted));
    border-left: 4px solid hsl(var(--success));
    border-radius: 4px;
    font-size: 14px;
}

.user-info-message a {
    color: hsl(var(--success));
    text-decoration: none;
    font-weight: 500;
}

.user-info-message a:hover {
    text-decoration: underline;
}

/* ===========================================
   Table Container
   =========================================== */

.scores-table-container {
    position: relative;
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 4px 6px hsl(var(--foreground) / 0.05);
}

/* ===========================================
   Loading States
   =========================================== */

.scores-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: hsl(var(--card) / 0.9);
    z-index: 10;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 200px;
    padding-top: 80px;
}

.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    animation: rotate 2s linear infinite;
}

.loading-path {
    stroke: hsl(var(--info));
    stroke-dasharray: 90, 150;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

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

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

.loading-overlay p {
    margin: 0;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
}

/* ===========================================
   High Scores Table
   =========================================== */

.high-scores-table {
    width: 100%;
    border-collapse: collapse;
    background: hsl(var(--card));
    margin-bottom: 1em;
    border-radius: 8px;
    overflow: hidden;
}

.high-scores-table th,
.high-scores-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid hsl(var(--border));
    font-size: 14px;
}

.high-scores-table th {
    background-color: hsl(var(--muted));
    font-weight: 600;
    color: hsl(var(--foreground));
    cursor: pointer;
    user-select: none;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
    transition: background-color 0.2s;
    position: sticky;
    top: 0;
    z-index: 5;
}

.high-scores-table th:hover {
    background-color: hsl(var(--border));
}

.high-scores-table th[data-sort]:after {
    content: ' ⇅';
    opacity: 0.5;
    margin-left: 5px;
}

.high-scores-table th.sort-asc:after {
    content: ' ↑';
    opacity: 1;
}

.high-scores-table th.sort-desc:after {
    content: ' ↓';
    opacity: 1;
}

.high-scores-table tbody tr {
    transition: background-color 0.2s ease;
}

.high-scores-table tbody tr:nth-child(even) {
    background-color: hsl(var(--muted) / 0.5);
}

.high-scores-table tbody tr:nth-child(odd) {
    background-color: hsl(var(--card));
}

.high-scores-table tbody tr:hover {
    background-color: hsl(var(--muted));
}

/* Current user row highlighting */
.high-scores-table tbody tr.current-user-row {
    background-color: hsl(var(--warning) / 0.2) !important;
    border-left: 4px solid hsl(var(--warning));
}

.high-scores-table tbody tr.current-user-row:hover {
    background-color: hsl(var(--warning) / 0.3) !important;
}

.high-scores-table tbody tr.current-user-row td:first-child {
    font-weight: 600;
    color: hsl(var(--warning-foreground));
}

/* Dark mode specific adjustment for current user row text */
.dark .high-scores-table tbody tr.current-user-row td:first-child {
    color: hsl(var(--warning));
}

/* ===========================================
   No Scores Message
   =========================================== */

.no-scores-message {
    padding: 20px;
    text-align: center;
    background-color: hsl(var(--warning) / 0.2);
    color: hsl(var(--warning-foreground));
    border-radius: 6px;
    margin: 20px 0;
    font-weight: 500;
}

.dark .no-scores-message {
    color: hsl(var(--warning));
}

/* ===========================================
   Play Again Button
   =========================================== */

.play-again {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    margin-top: 24px;
}

.start-game-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: bold;
    color: hsl(var(--success-foreground));
    background-color: hsl(var(--success));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px hsl(var(--foreground) / 0.1);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.start-game-button:hover {
    background-color: hsl(142 76% 30%);
    box-shadow: 0 6px 8px hsl(var(--foreground) / 0.15);
    transform: translateY(-2px);
}

.dark .start-game-button:hover {
    background-color: hsl(142 76% 40%);
}

.start-game-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px hsl(var(--foreground) / 0.1);
}

.start-game-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px hsl(var(--success) / 0.5), 0 4px 6px hsl(var(--foreground) / 0.1);
}

.start-game-button svg {
    margin-right: 10px;
    width: 20px;
    height: 20px;
}

/* ===========================================
   Game Info
   =========================================== */

.game-info {
    text-align: center;
    margin-top: 16px;
    font-style: italic;
    color: hsl(var(--muted-foreground));
    font-size: 14px;
}

/* ===========================================
   Error State
   =========================================== */

.scores-error {
    color: hsl(var(--destructive));
}

/* ===========================================
   Responsive Styles
   =========================================== */

@media (max-width: 768px) {
    .score-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .score-filter {
        min-width: 150px;
    }

    .high-scores-table {
        font-size: 0.9em;
    }

    .high-scores-table th,
    .high-scores-table td {
        padding: 8px 5px;
    }

    .start-game-button {
        padding: 12px 20px;
        font-size: 14px;
    }
}
