/* Main CSS - Shared styles across all pages */

/* Modern Header Styles */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #1abc9c;
    --text-color: #ecf0f1;
    --bg-color: #f5f7fa;
    --card-background: #fff;
    --border-color: #bdc3c7;
    --error-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --header-height: 60px;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: #333; /* Darker text for better readability */
    line-height: 1.6;
    margin: 0;
    padding: 0;
    font-size: 15px;
}

/* Base typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}

h1 { 
    font-size: 2rem; 
    font-weight: bold;
}

h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #444;
}

a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* Content wrapper for consistent spacing */
.content-wrapper {
    background-color: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Stats bar styling */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid var(--secondary-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
    min-width: 120px;
}

.stat-label {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Table cell text */
td {
    color: #333;
    vertical-align: middle;
    padding: 12px 15px;
}

/* Make sure text in panels is readable */
.panel {
    color: #333;
}

.panel h3 {
    color: var(--primary-color);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #eee;
    margin-bottom: 1rem;
}

/* Main Header */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--text-color);
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
}

.header-content {
    width: 100%;
    max-width: 1400px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.main-nav ul {
    display: flex;
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
    height: 100%;
    align-items: center;
}

.main-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.main-nav a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-color);
}

.logo-text {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Main content area */
.main-content {
    padding-top: calc(var(--header-height) + 20px);
    padding-left: 20px;
    padding-right: 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
}

/* Common UI Elements */
button, .btn {
    cursor: pointer;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background-color: var(--secondary-color);
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
}

button:hover, .btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

button:active, .btn:active {
    transform: translateY(0);
}

/* Add focus styles for accessibility */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Table Container */
.table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 400px;
    position: relative;
    -webkit-overflow-scrolling: touch;
    background-color: var(--card-background);
    border-radius: 4px;
    isolation: isolate;
    transform: translateZ(0);
    margin: 1rem 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: auto;
    position: relative;
}

thead {
    position: sticky;
    top: 0;
    z-index: 1000;
    position: -webkit-sticky; /* For Safari */
    background-color: var(--primary-color);
    transform: translateZ(0);
}

th {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 12px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1000;
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 12px;
    border-bottom: 1px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    background-clip: padding-box;
}

th:not(.no-sort):hover {
    background-color: #34495e;
}

/* No-sort columns */
th.no-sort {
    cursor: default;
}

/* Sort indicators */
th:not(.no-sort).sorted-asc::after {
    content: ' ▲';
    font-size: 0.7em;
    opacity: 0.8;
}

th:not(.no-sort).sorted-desc::after {
    content: ' ▼';
    font-size: 0.7em;
    opacity: 0.8;
}

tbody {
    position: relative;
    z-index: 1;
}

tbody tr {
    transition: background-color 0.2s;
    position: relative;
    background-color: #ffffff;
}

tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

tbody tr:hover {
    background-color: #f5f9ff !important;
}

td {
    padding: 4px 12px;
    border-bottom: 1px solid var(--border-color);
    color: #212529;
    background-color: inherit;
    overflow: hidden;
    position: relative;
    z-index: auto;
    background-color: var(--card-background);
}

/* Column Specific Styles */
.narrow {
    width: 60px;
    max-width: 80px;
    text-align: center;
}

.rank-cell {
    text-align: center;
    font-weight: bold;
    color: #666;
    position: relative;
    padding-left: 24px;
    min-width: 60px;
}

.player-name, .viewer-name {
    font-weight: 500;
    color: #333;
    min-width: 150px;
}

.score-cell, .message-count {
    text-align: center;
    font-weight: bold;
    color: var(--secondary-color);
}

.timestamp {
    color: #666;
    font-size: 13px;
    white-space: nowrap;
}

.recent-message {
    color: #495057;
    font-style: italic;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Podium highlighting for leaderboards */
tr.podium {
    background-color: #fff3cd !important;
}

tr.podium:hover {
    background-color: #ffe8a1 !important;
}

tr.podium .rank-cell {
    color: #856404;
    font-size: 1.1em;
}

/* Hide rank number for top 3, showing only the icon */
.first .rank-cell,
.second .rank-cell,
.third .rank-cell {
    font-size: 0;
}

.first .rank-cell::before {
    content: '🥇';
    color: #ffd700;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3em;
}

.second .rank-cell::before {
    content: '🥈';
    color: #c0c0c0;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3em;
}

.third .rank-cell::before {
    content: '🥉';
    color: #cd7f32;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3em;
}


/* Scrollbar styling */
.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* Loading state */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

table.loading tbody {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Header Component Styles */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    color: var(--text-color);
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
}
.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo {
    height: 36px;
    width: 36px;
    border-radius: 50%;
    background: #fff2;
    border: 2px solid var(--secondary-color);
}
.brand {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-color);
    text-shadow: 1px 1px 3px #2226;
}
.main-nav ul {
    display: flex;
    gap: 18px;
    list-style: none;
}
.main-nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s ease;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.main-nav a:hover, .main-nav a:focus {
    background-color: var(--accent-color);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.main-nav a:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Style for the active page link */
.main-nav a.active {
    background-color: var(--accent-color);
    color: #fff;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

/* Footer Styles */
.main-footer {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--text-color);
    padding: 1rem 2rem;
    text-align: center;
    margin-top: 40px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.footer-links a {
    color: var(--text-color);
    text-decoration: none;
    margin: 0 10px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--accent-color);
}



/* Section Headers */
h2 {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--primary-color);
    font-size: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

h3 {
    margin-top: 0;
    margin-bottom: 12px;
    color: var(--primary-color);
    font-size: 16px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 6px;
}

/* Panels */
.panel {
    background-color: var(--card-background);
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 16px;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .main-content {
        padding-left: 10px;
        padding-right: 10px;
    }

    footer {
        padding: 15px 10px;
        font-size: 12px;
    }
}
