/* Global Styles */
body {
    font-family: "Inter", "Segoe UI", sans-serif;
    background: #f5f7fa;
    color: #333;
    margin: 0;
    padding: 0;
    /* Center all main content blocks */
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

/* Headings */
h1, h2 {
    text-align: center;
    color: #2c3e50;
    margin: 0 0 15px;
}
h1 {
    padding: 16px 0;
    font-weight: 700;
}
h2 {
    font-weight: 600;
}

/* File Upload Area */
.upload {
    width: 90%;
    max-width: 800px;
    display: flex;
    justify-content: center;
    /* Center upload container */
    margin: 12px auto;
}
/* Hides the default file input button */
#fileInput {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rect(0,0,0,0);
border: 0;
}
/* Styles the custom upload button */
.upload-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 6px;
    background: #9b59b6;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    justify-content: center;
}
.upload-label:hover {
    background: #8e44ad;
    /* Subtle lift on hover */
    transform: translateY(-1px);
}
.upload-hint {
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
    text-align: center;
}

/* Search, Filter, and Sort Controls */
#controls, #sortControls {
/* Responsive controls layout */
display: flex;
flex-wrap: wrap;
gap: 12px;
justify-content: center;
align-items: center;
/* Center the controls block */
margin: 20px auto;
max-width: 800px;
}
#controls input {
flex: 1;
min-width: 220px;
padding: 10px 14px;
border: 1px solid #d0d7de;
border-radius: 6px;
font-size: 14px;
}
#controls label {
font-weight: bold;
margin-right: 0.3rem;
color: #555;
}

/* Button Defaults */
button, #controls button, #sortControls button {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    /* Primary purple color */
    background: #9b59b6;
    color: #fff;
    transition: background 0.3s ease, transform 0.2s ease;
    text-align: center;
}
button:hover {
    background: #8e44ad;
    /* Subtle lift on hover */
    transform: translateY(-1px);
}
/* Secondary button style (if needed) */
button.secondary {
    background: #ecf0f1;
    color: #2c3e50;
}
button.secondary:hover {
    background: #bdc3c7;
}

/* Channel Data Table */
table {
    width: 90%;
    max-width: 900px;
    /* Center the table block */
    margin: 0 auto 20px;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
table th, table td {
    padding: 12px 15px;
    /* Text in cells is left-aligned */
    text-align: left;
}
table th {
    /* Header row color */
    background: #9b59b6;
    color: #fff;
    font-weight: 600;
}
/* Alternating row colors */
table tr:nth-child(even) {
    background: #f9f9f9;
}
table tr:hover {
    background: #f3eaf7;
}

/* Pagination Controls */
#pagination {
text-align: center;
margin: 20px 0;
}
#pagination button:disabled {
/* Muted style for disabled state */
background: #ccc;
cursor: not-allowed;
}

/* Chart Container & Canvas */
#chartContainer {
width: 100%;
max-width: 800px;
/* Center the chart container */
margin: 30px auto;
background: #fff;
padding: 20px;
border-radius: 12px;
box-shadow: 0 2px 12px rgba(0,0,0,0.1);
box-sizing: border-box;
/* Hides chart overflow */
overflow-x: hidden;
}
#chartContainer canvas {
/* Ensures Chart.js is responsive */
max-width: 100% !important;
height: auto !important;
}
#chartContainer button {
margin-top: 12px;
}

/* Results Visibility */
#resultsSection {
/* Initially hidden by JS */
display: none;
opacity: 0;
transition: opacity 0.4s ease;
width: 100%;
}
#resultsSection.show {
display: block;
opacity: 1;
}

/* Footer & Links */
footer {
    margin-top: 30px;
    text-align: center;
    padding: 10px;
}
footer small {
    color: #777;
    font-size: 12px;
}
/* Link colors */
a {
    color: #9b59b6;
    text-decoration: none;
    font-weight: 500;
}
a:hover {
    color: #8e44ad;
    text-decoration: underline;
}

/* Year Filter Button Style */
#yearFilter {
padding: 0.4rem 0.8rem;
font-size: 1rem;
border: none;
border-radius: 4px;
background-color: #9b59b6;
color: #fff;
cursor: pointer;
transition: background 0.2s ease-in-out;
}
#yearFilter:hover {
background-color: #8e44ad;
}

/* Select */
select {
    padding: 0.3rem 0.6rem;
    font-size: 1rem;
}

/* Dark Mode Overrides */
@media (prefers-color-scheme: dark) {
    body {
        background: #1e1e1e;
        color: #e0e0e0;
    }
    h1, h2 {
        color: #f0f0f0;
    }
    .upload-label {
        background: #a569bd;
    }
    .upload-label:hover {
        background: #884ea0;
    }
    .upload-hint {
        color: #aaa;
    }
    #controls input {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #e0e0e0;
    }
    button, #controls button, #sortControls button {
        background: #a569bd;
    }
    button:hover {
        background: #884ea0;
    }
    button.secondary {
        background: #333;
        color: #ddd;
    }
    button.secondary:hover {
        background: #444;
    }
    /* Dark table theme */
    table {
        background: #2a2a2a;
        box-shadow: 0 2px 8px rgba(0,0,0,0.6);
    }
    table th {
        background: #a569bd;
    }
    table tr:nth-child(even) {
        background: #242424;
    }
    table tr:hover {
        background: #333;
    }
    #chartContainer {
    background: #2a2a2a;
    box-shadow: 0 2px 12px rgba(0,0,0,0.6);
    }
    #pagination button:disabled {
    background: #555;
    color: #999;
    }
    footer small {
        color: #aaa;
    }
    a {
        color: #a569bd;
    }
    a:hover {
        color: #884ea0;
    }
}

/* Mobile Responsiveness (< 800px) */
@media (max-width: 800px) {
    /* Stack controls on mobile */
    #controls {
    display: block;
    text-align: center;
    }
    /* Full width search bar */
    #searchBox {
    width: calc(100% - 24px);
    margin: 0 12px 12px;
    box-sizing: border-box;
    }
    #yearFilter, #downloadBtn {
    display: inline-block;
    margin: 8px;
    text-align: center;
    }
    /* Taller chart for mobile readability */
    #chartContainer canvas {
    height: 400px !important;
    }
}

/* General container setup for centering and fluid width on mobile */
#chartContainer {
width: 95%;
margin: 20px auto;
}

/* Ensure canvas has a default height */
#channelChart {
width: 100% !important;
height: 400px;
}

/* Desktop Size Limits (> 601px) */
@media (min-width: 601px) {
    /* Set max width for large screens */
    #chartContainer {
    max-width: 800px;
    }
    /* Set a fixed height for desktop chart */
    #channelChart {
    height: 500px;
    max-height: 500px;
    }
}

/* Small screen adjustments */
@media (max-width: 450px) {
    #channelChart {
    height: 350px;
    }
}

/* Summary Card Styling */

/* Center the summary card block */
#summaryArea {
margin: 30px auto 40px auto;
max-width: 600px;
padding: 0 15px;
}

.summary-card {
    /* Gradient background */
    background: linear-gradient(135deg, #a750c7, #7e3a9b);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(155, 89, 182, 0.4);
    color: #fff;
    padding: 20px;
    text-align: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    position: relative;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 500;
    opacity: 0.8;
    margin-bottom: 15px;
    /* Separator line */
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
}

.stats-grid {
    /* Lays out the two stats */
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    padding: 0 15px;
}

/* Big number style */
.stat-number {
    font-size: 2.8rem;
    font-weight: 900;
    line-height: 1.1;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    margin-top: 5px;
}

/* Vertical line separator */
.stat-divider {
    width: 1px;
    height: 60px;
    background-color: rgba(255, 255, 255, 0.3);
}

.card-footer {
    margin-top: 20px;
    padding-top: 10px;
    /* Separator line */
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.9rem;
    opacity: 0.8;
}

/* No data message style */
.no-results-message {
    text-align: center;
    font-size: 1.2rem;
    padding: 20px;
    color: #e74c3c;
    border: 1px solid #e74c3c;
    border-radius: 8px;
    background-color: #ffe8e8;
}

/* Dark Mode Adaptation for No Results Message */
@media (prefers-color-scheme: dark) {
    .no-results-message {
        background-color: #3e2752;
        color: #f1c40f;
        border-color: #f1c40f;
    }
}
