/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: #f8f9fa;
    color: #212529;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: white;
    padding: 30px 40px;
    margin-bottom: 30px;
    border-bottom: 1px solid #e9ecef;
}

.title {
    font-size: 2rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 1rem;
    color: #6c757d;
    font-weight: 400;
}

/* Navigation Bar */
.navigation-bar {
    background: white;
    padding: 15px 40px;
    margin-bottom: 30px;
    border: 1px solid #dee2e6;
}

.back-btn {
    padding: 10px 20px;
    background: #f8f9fa;
    color: #212529;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.back-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* Search Section */
.search-section {
    background: white;
    padding: 25px 40px;
    margin-bottom: 30px;
    border: 1px solid #dee2e6;
    position: relative;
}

#searchInput {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.15s ease-in-out;
}

#searchInput:focus {
    border-color: #495057;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 40px;
    right: 40px;
    background: white;
    border: 1px solid #ced4da;
    border-top: none;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestion-name {
    flex: 1;
}

.suggestion-badge {
    padding: 3px 8px;
    font-size: 0.7rem;
    background: #e9ecef;
    color: #495057;
    border-radius: 3px;
    font-weight: 600;
    margin-left: 10px;
}

.suggestion-item:hover {
    background: #f8f9fa;
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* Results Container */
.results-container {
    background: white;
    padding: 40px;
    border: 1px solid #dee2e6;
    min-height: 400px;
}

/* Home Page */
.home-page {
    animation: fadeIn 0.3s ease;
}

.home-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
    flex-wrap: wrap;
    gap: 20px;
}

.home-header h2 {
    font-size: 1.75rem;
    color: #212529;
    font-weight: 600;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-controls label {
    font-size: 0.95rem;
    color: #6c757d;
    font-weight: 500;
}

.sort-btn {
    padding: 8px 16px;
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.sort-btn:hover {
    background: #e9ecef;
}

.sort-btn.active {
    background: #212529;
    color: white;
    border-color: #212529;
}
/* Exam Type Controls */
.exam-type-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.exam-type-controls label {
    font-size: 0.95rem;
    color: #6c757d;
    font-weight: 500;
}

.radio-label {
    cursor: pointer;
    padding: 6px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
    transition: all 0.15s ease;
}

.radio-label:hover {
    background: #e9ecef;
}

.radio-label input[type="radio"] {
    margin-right: 5px;
}

.radio-label input[type="radio"]:checked {
    accent-color: #212529;
}

/* Filter Controls (Checkbox) */
.filter-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.filter-controls label {
    font-size: 0.95rem;
    color: #6c757d;
    font-weight: 500;
}

/* Subjects List */
.subjects-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.subject-card {
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.subject-card:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-2px);
}

.subject-card-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 10px;
}

.subject-card-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 0.75rem;
    background: #e9ecef;
    color: #495057;
    border-radius: 3px;
    font-weight: 600;
    margin-bottom: 8px;
}

.subject-card-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #6c757d;
}

.subject-card-stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    margin-bottom: 2px;
}

.stat-value {
    font-weight: 600;
    color: #212529;
}

/* Subject Display */
.subject-display {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.subject-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.subject-title {
    font-size: 1.75rem;
    color: #212529;
    font-weight: 600;
    margin-bottom: 10px;
}

.subject-badge-container {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.exam-type-badge,
.grade-system-badge {
    display: inline-block;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 4px;
}

.exam-type-badge {
    background: #0d6efd;
    color: white;
}

.grade-system-badge {
    background: #6c757d;
    color: white;
}

.subject-info {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    font-size: 0.95rem;
    color: #6c757d;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-label {
    font-weight: 500;
}

.info-value {
    color: #212529;
    font-weight: 600;
}

/* Charts Section */
.charts-section {
    margin-bottom: 40px;
}

.chart-wrapper {
    margin-bottom: 50px;
}

.chart-title {
    font-size: 1.25rem;
    color: #212529;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.chart-container {
    background: #f8f9fa;
    padding: 30px 20px;
    border-radius: 4px;
    overflow-x: auto;
}

.line-chart {
    display: flex;
    align-items: flex-end;
    height: 300px;
    gap: 8px;
    min-width: 100%;
    padding: 10px;
}

.chart-bar {
    flex: 1;
    min-width: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100%;
}

.bar-group {
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 100%;
}

.bar {
    width: 100%;
    background: #495057;
    border-radius: 3px 3px 0 0;
    position: relative;
    transition: all 0.2s ease;
    min-height: 2px;
}

.bar:hover {
    background: #212529;
}

.bar-value {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: #212529;
    white-space: nowrap;
}

.bar-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #495057;
    text-align: center;
    word-wrap: break-word;
}

.bar-sublabel {
    font-size: 0.7rem;
    color: #6c757d;
    text-align: center;
}

/* Multi-line chart for grades over years */
.multi-line-chart {
    display: flex;
    align-items: flex-end;
    height: 350px;
    gap: 12px;
    padding: 20px 10px;
    position: relative;
}

.year-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-width: 60px;
}

.bars-container {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    width: 100%;
    height: 100%;
    justify-content: center;
}

.grade-bar {
    flex: 1;
    min-width: 6px;
    max-width: 10px;
    border-radius: 2px 2px 0 0;
    position: relative;
    background: #adb5bd; /* Default background for any grade */
}

/* Letter grades (A-Level and GCSE A*-G) */
.grade-bar.a-star { background: #1a202c; }
.grade-bar.a { background: #2d3748; }
.grade-bar.b { background: #4a5568; }
.grade-bar.c { background: #718096; }
.grade-bar.d { background: #a0aec0; }
.grade-bar.e { background: #cbd5e0; }
.grade-bar.f { background: #e2e8f0; }
.grade-bar.g { background: #f1f3f5; }

/* Numeric grades (GCSE 9-1) - prefixed with 'g-' for valid CSS */
.grade-bar.g-9 { background: #0d1b2a; }
.grade-bar.g-8 { background: #1b263b; }
.grade-bar.g-7 { background: #415a77; }
.grade-bar.g-6 { background: #778da9; }
.grade-bar.g-5 { background: #a8c5e0; }
.grade-bar.g-4 { background: #c5ddf5; }
.grade-bar.g-3 { background: #d9e8f5; }
.grade-bar.g-2 { background: #e8f1f8; }
.grade-bar.g-1 { background: #f0f6fa; }

.year-label {
    margin-top: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #495057;
}

/* Summary Stats */
.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-box {
    padding: 20px;
    background: #f8f9fa;
    border-left: 4px solid #495057;
    border-radius: 4px;
}

.stat-box .stat-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-box .stat-value {
    font-size: 1.75rem;
    color: #212529;
    font-weight: 600;
}

.stat-context {
    font-size: 0.8rem;
    color: #868e96;
    margin-top: 4px;
}

/* Data Table */
.data-table-wrapper {
    overflow-x: auto;
    margin-top: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead {
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
    border-bottom: 2px solid #dee2e6;
}

.data-table thead tr.grade-system-header th {
    background: #495057;
    color: white;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
}

.data-table th.number-col {
    text-align: right;
}

.data-table tbody tr {
    border-bottom: 1px solid #e9ecef;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.data-table td {
    padding: 12px 16px;
    color: #212529;
}

.data-table td.number-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table td.year-col {
    font-weight: 600;
}

.data-table td.type-col {
    color: #6c757d;
    font-size: 0.85rem;
}

.grade-cell {
    font-weight: 500;
}

.pass-rate-cell {
    font-weight: 600;
    color: #198754;
}

/* Year row highlighting */
.data-table tbody tr.year-2025 {
    background: #f0f7ff;
}

.data-table tbody tr.year-2020.teacher {
    background: #fff8e6;
}

/* Highlight pre-2010 rows (no A* grade) */
.data-table tbody tr.pre-2010 {
    background: #f8f9fa;
}

/* Data Note */
.data-note {
    font-size: 0.9rem;
    color: #856404;
    line-height: 1.5;
}

.data-note strong {
    font-weight: 600;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    margin-top: 30px;
    color: #6c757d;
    font-size: 0.875rem;
    border-top: 1px solid #e9ecef;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 60px;
    font-size: 1rem;
    color: #6c757d;
}

/* Error State */
.error-message {
    text-align: center;
    padding: 40px;
    color: #dc3545;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header,
    .search-section,
    .results-container,
    .navigation-bar {
        padding: 20px;
    }

    .title {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .subjects-list {
        grid-template-columns: 1fr;
    }

    .home-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .summary-stats {
        grid-template-columns: 1fr;
    }

    .line-chart,
    .multi-line-chart {
        height: 250px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f3f5;
}

::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #868e96;
}

/* Print Styles */
@media print {
    .header,
    .search-section,
    .navigation-bar,
    .footer {
        display: none;
    }

    .results-container {
        border: none;
        padding: 0;
    }

    .data-table {
        page-break-inside: auto;
    }

    .data-table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
}