/**
 * Main Stylesheet
 * Theme: Blue-Green Education
 * SMK Negeri Bansari - Leaderboard Kedisiplinan
 */

/* ================================================
   CSS Custom Properties (Theme Variables)
   ================================================ */

:root {
    /* Primary Colors */
    --color-primary: #1a5276;
    --color-primary-light: #2980b9;
    --color-primary-dark: #154360;
    --color-primary-rgb: 26, 82, 118;

    /* Status Colors */
    --color-success: #27ae60;
    --color-success-light: #2ecc71;
    --color-success-rgb: 39, 174, 96;
    --color-warning: #f39c12;
    --color-warning-light: #f1c40f;
    --color-warning-rgb: 243, 156, 18;
    --color-danger: #e74c3c;
    --color-danger-light: #ec7063;
    --color-danger-rgb: 231, 76, 60;

    /* Neutrals */
    --color-surface: #ffffff;
    --color-background: #f0f2f5;
    --color-text: #2c3e50;
    --color-text-light: #5d6d7e;
    --color-text-muted: #7f8c8d;
    --color-border: #e0e6ed;
    --color-border-light: #ecf0f1;

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-heading: 'Poppins', 'Inter', sans-serif;

    /* Font Sizes - Fluid */
    --text-xs: clamp(0.7rem, 0.8vw, 0.75rem);
    --text-sm: clamp(0.8rem, 1vw, 0.875rem);
    --text-base: clamp(0.9rem, 1.2vw, 1rem);
    --text-lg: clamp(1rem, 1.5vw, 1.125rem);
    --text-xl: clamp(1.15rem, 2vw, 1.25rem);
    --text-2xl: clamp(1.3rem, 2.5vw, 1.5rem);
    --text-3xl: clamp(1.6rem, 3vw, 2rem);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Z-index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 300;
}

/* ================================================
   Base Styles
   ================================================ */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--color-text);
    background-color: var(--color-background);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ================================================
   Typography
   ================================================ */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text);
}

h1 {
    font-size: var(--text-3xl);
}

h2 {
    font-size: var(--text-2xl);
}

h3 {
    font-size: var(--text-xl);
}

h4 {
    font-size: var(--text-lg);
}

p {
    margin-bottom: var(--space-md);
}

a {
    color: var(--color-primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* ================================================
   Layout
   ================================================ */

.container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.main-content {
    flex: 1;
    padding: var(--space-xl) 0;
}

/* ================================================
   Header
   ================================================ */

.header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #ffffff;
    padding: var(--space-lg) 0;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
    pointer-events: none;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.school-logo {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.school-logo svg {
    width: 100%;
    height: 100%;
}

.school-info h1 {
    color: #ffffff;
    font-size: var(--text-2xl);
    margin-bottom: var(--space-xs);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.school-info .subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: var(--text-sm);
    margin: 0;
    font-weight: 400;
}

.header-actions {
    display: flex;
    gap: var(--space-md);
}

/* ================================================
   Filter Bar
   ================================================ */

.filter-bar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md) 0;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-sm);
}

.filter-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.filter-group label {
    font-weight: 600;
    color: var(--color-text-light);
    font-size: var(--text-sm);
    white-space: nowrap;
}

.grade-tabs {
    display: flex;
    gap: var(--space-xs);
}

/* ================================================
   Cards
   ================================================ */

.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border-light);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border-light);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.card-actions {
    display: flex;
    gap: var(--space-sm);
}

/* ================================================
   Summary Cards - Modern Design
   ================================================ */

.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xl) var(--space-lg);
    background: linear-gradient(135deg, var(--color-surface) 0%, #f8f9fa 100%);
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.stat-card-success::before {
    background: linear-gradient(180deg, var(--color-success) 0%, #2ecc71 100%);
}

.stat-card-warning::before {
    background: linear-gradient(180deg, var(--color-warning) 0%, #f39c12 100%);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.stat-icon svg {
    width: 28px;
    height: 28px;
    color: #ffffff;
}

.stat-info {
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.1;
    margin-bottom: var(--space-xs);
    word-wrap: break-word;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-sub {
    font-size: var(--text-xs);
    color: var(--color-text-light);
    margin: var(--space-xs) 0 0 0;
    font-weight: 600;
}

/* ================================================
   Charts Section - Modern Design
   ================================================ */

.charts-section {
    margin-bottom: var(--space-xl);
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    width: 100%;
}

.chart-card {
    min-height: 400px;
    background: linear-gradient(135deg, var(--color-surface) 0%, #fafbfc 100%);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.04);
    width: 100%;
    box-sizing: border-box;
}

.chart-card-doughnut {
    display: none;
}

.chart-container {
    position: relative;
    height: 380px;
    margin-top: var(--space-lg);
    width: 100%;
}

.chart-container-small {
    height: 280px;
}

.chart-container-tall {
    height: 420px;
}

/* ================================================
   Leaderboard Table - Modern Design
   ================================================ */

.leaderboard-section {
    margin-bottom: var(--space-xl);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary-light) var(--color-background);
}

.table-responsive::-webkit-scrollbar {
    height: 8px;
}

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

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

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

.leaderboard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-sm);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.leaderboard-table thead th {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #ffffff;
    font-weight: 700;
    padding: var(--space-md) var(--space-sm);
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 1px;
}

.leaderboard-table thead th:first-child {
    border-radius: var(--radius-lg) 0 0 0;
}

.leaderboard-table thead th:last-child {
    border-radius: 0 var(--radius-lg) 0 0;
}

.leaderboard-table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--color-border-light);
}

.leaderboard-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(41, 128, 185, 0.05) 0%, rgba(39, 174, 96, 0.05) 100%);
    transform: scale(1.01);
}

.leaderboard-table tbody td {
    padding: var(--space-md) var(--space-sm);
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}

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

.th-rank,
.th-class,
.th-students,
.th-ontime,
.th-late,
.th-score,
.th-status {
    text-align: center;
    padding: var(--space-md) var(--space-md);
}

.th-status,
.td-status {
    display: none;
}

.th-rank { min-width: 90px; }
.th-class { text-align: left; min-width: 120px; }
.th-students { min-width: 80px; }
.th-ontime { min-width: 100px; }
.th-late { min-width: 90px; }
.th-score { min-width: 100px; }
.th-status { min-width: 150px; }

.td-rank {
    text-align: center;
    white-space: nowrap;
    padding: var(--space-md) var(--space-sm);
}

.td-class {
    text-align: left;
    font-weight: 700;
    color: var(--color-primary);
    padding-left: var(--space-md);
}

.td-students,
.td-ontime,
.td-late {
    text-align: center;
    color: var(--color-text-light);
    font-weight: 500;
    padding: var(--space-md) var(--space-sm);
}

.td-score {
    text-align: center;
    font-weight: 800;
    font-size: var(--text-base);
    color: var(--color-success);
    padding: var(--space-md) var(--space-sm);
}

.td-status {
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    padding: var(--space-md) var(--space-sm);
}

/* ================================================
   Certificate Button
   ================================================ */

.btn-certificate {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
    border: none;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.btn-certificate:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.6);
}

.btn-certificate:active {
    transform: scale(0.95);
}

/* ================================================
   Rank Indicators - Modern Design
   ================================================ */

.rank-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    font-weight: 800;
    font-size: var(--text-base);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.rank-default {
    background: linear-gradient(135deg, #e8ecef 0%, #d5dbdb 100%);
    color: var(--color-text);
}

.rank-gold {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
    color: #000;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.5);
    animation: pulse-gold 2s infinite;
}

@keyframes pulse-gold {
    0%, 100% { box-shadow: 0 4px 20px rgba(255, 215, 0, 0.5); }
    50% { box-shadow: 0 4px 30px rgba(255, 215, 0, 0.8); }
}

.rank-silver {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
    color: #000;
    box-shadow: 0 4px 15px rgba(192, 192, 192, 0.5);
}

.rank-bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #e6a860 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(205, 127, 50, 0.5);
}

.rank-icon {
    font-size: var(--text-xl);
    margin-left: var(--space-xs);
}

.rank-change {
    display: inline-flex;
    align-items: center;
    font-size: var(--text-xs);
    margin-left: var(--space-sm);
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.rank-up {
    color: var(--color-success);
    background: rgba(39, 174, 96, 0.1);
}

.rank-down {
    color: var(--color-danger);
    background: rgba(231, 76, 60, 0.1);
}

.rank-same {
    color: var(--color-text-muted);
    background: var(--color-background);
}

.rank-new {
    color: var(--color-primary-light);
    font-style: italic;
    background: rgba(41, 128, 185, 0.1);
}

/* ================================================
   Status Badges - Modern Design
   ================================================ */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.status-icon {
    width: 16px;
    height: 16px;
}

.status-icon svg {
    width: 100%;
    height: 100%;
}

.status-success {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

.status-primary {
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(41, 128, 185, 0.4);
}

.status-warning {
    background: linear-gradient(135deg, #f39c12 0%, #f1c40f 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

.status-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #ec7063 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

/* ================================================
   Class Name Button
   ================================================ */

.class-name-btn,
.mobile-card-class-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--color-primary-light);
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.class-name-btn:hover,
.mobile-card-class-btn:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* ================================================
   Buttons
   ================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--color-primary-light);
    color: #ffffff;
    border-color: var(--color-primary-light);
}

.btn-primary:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #ffffff;
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-light);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--color-background);
    color: var(--color-text);
    text-decoration: none;
}

.btn-sm {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-xs);
}

.btn-sm svg {
    width: 16px;
    height: 16px;
}

/* ================================================
   Form Elements
   ================================================ */

.form-select {
    appearance: none;
    background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235d6d7e' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E") no-repeat right 12px center;
    background-size: 12px;
    padding: var(--space-sm) var(--space-2xl) var(--space-sm) var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-select:hover {
    border-color: var(--color-primary-light);
}

.form-select:focus {
    outline: none;
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

/* Grade Tab Buttons */
.grade-tab {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-light);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.grade-tab:hover {
    border-color: var(--color-primary-light);
    color: var(--color-primary);
}

.grade-tab.active {
    background: var(--color-primary-light);
    border-color: var(--color-primary-light);
    color: #ffffff;
}

/* ================================================
   Score Display
   ================================================ */

.score-value {
    display: inline-block;
    min-width: 50px;
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-background);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: var(--text-base);
}

/* ================================================
   Detail View
   ================================================ */

.detail-view {
    margin-top: var(--space-xl);
}

.detail-view.hidden {
    display: none;
}

.detail-content {
    margin-top: var(--space-lg);
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.detail-stat {
    text-align: center;
    padding: var(--space-lg);
    background: var(--color-background);
    border-radius: var(--radius-md);
}

.detail-stat-label {
    display: block;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.detail-stat-value {
    display: block;
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-text);
}

.detail-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
}

.detail-chart-card {
    background: var(--color-background);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
}

.detail-chart-card h3 {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--color-text);
}

.detail-chart-card-full {
    grid-column: 1 / -1;
}

/* Comparison Bar */
.comparison-bar {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.comparison-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.comparison-label {
    width: 120px;
    font-size: var(--text-sm);
    color: var(--color-text-light);
    flex-shrink: 0;
}

.comparison-track {
    flex: 1;
    height: 24px;
    background: var(--color-surface);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.comparison-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary-light), var(--color-primary));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.comparison-fill-avg {
    background: linear-gradient(90deg, var(--color-success-light), var(--color-success));
}

.comparison-value {
    width: 60px;
    text-align: right;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--color-text);
}

/* Chart Note */
.chart-note {
    text-align: center;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-top: var(--space-md);
    font-style: italic;
}

/* ================================================
   Trend View
   ================================================ */

.trend-view {
    margin-top: var(--space-xl);
}

.trend-view.hidden {
    display: none;
}

.trend-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-lg);
}

.trend-chart-card {
    background: var(--color-background);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
}

.trend-table {
    background: var(--color-background);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    max-height: 400px;
    overflow-y: auto;
}

.trend-table table {
    width: 100%;
    border-collapse: collapse;
}

.trend-table th {
    background: var(--color-primary);
    color: #ffffff;
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-size: var(--text-sm);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.trend-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border-light);
    font-size: var(--text-sm);
}

.trend-up {
    color: var(--color-success);
    font-weight: 600;
}

.trend-down {
    color: var(--color-danger);
    font-weight: 600;
}

.trend-same {
    color: var(--color-text-muted);
}

/* ================================================
   Footer
   ================================================ */

.footer {
    background: var(--color-primary-dark);
    color: rgba(255, 255, 255, 0.9);
    padding: var(--space-lg) 0;
    margin-top: auto;
}

.footer-content {
    text-align: center;
}

.footer-content p {
    margin: 0;
    font-size: var(--text-sm);
}

.footer-update {
    margin-top: var(--space-sm) !important;
    font-size: var(--text-xs) !important;
    color: rgba(255, 255, 255, 0.7);
}

/* ================================================
   Utilities
   ================================================ */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-sm {
    margin-bottom: var(--space-sm);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

/* ================================================
   Print Styles
   ================================================ */

@media print {
    body {
        background: #ffffff;
    }

    .header {
        background: var(--color-primary) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .filter-bar,
    .header-actions,
    .card-actions,
    .footer {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .leaderboard-table thead th {
        background: var(--color-primary) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .status-badge {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ================================================
   Modal Base Styles
   ================================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    justify-content: center;
    align-items: center;
}

.modal.show,
.modal[style*="display: flex"] {
    display: flex;
}

/* Ensure header and other elements are below modal */
.header {
    position: relative;
    z-index: 1;
}

.filter-bar {
    position: relative;
    z-index: 1;
}

/* ================================================
   Spin Animation (for loading states)
   ================================================ */

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

.spin {
    animation: spin 1s linear infinite;
}

/* ================================================
   Button States
   ================================================ */

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-success {
    background: var(--color-success);
    color: #ffffff;
    border-color: var(--color-success);
}

.btn-success:hover {
    background: #219a52;
    border-color: #219a52;
}

/* ================================================
   Certificate Styles - Modern Design (A4 Landscape)
   ================================================ */

.certificate {
    background: white;
    background-size: cover;
    background-position: center;
    padding: 0;
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    position: relative;
    width: 297mm;
    height: 210mm;
    margin: 0 auto;
    box-sizing: border-box;
    overflow: hidden;
    color: #552d8b;
}

.certificate-border {
    display: none;
}

.certificate-border-inner {
    display: none;
}

.certificate-title {
    font-size: 3rem;
    color: #552d8b;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-weight: 700;
    text-align: right;
    padding-right: 50px;
    letter-spacing: 1px;
}

.certificate-subtitle {
    font-size: 1.2rem;
    color: #552d8b;
    margin-bottom: 1rem;
    text-align: right;
    padding-right: 50px;
    font-weight: 400;
}

.certificate-text {
    font-size: 1rem;
    color: #444;
    line-height: 1.7;
    margin-bottom: 1rem;
    text-align: center;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.certificate-class {
    font-size: 4rem;
    color: #552d8b;
    font-weight: 700;
    margin: 1.5rem auto;
    padding: 0.5rem 2rem;
    display: inline-block;
    border-bottom: 4px solid #552d8b;
    text-align: center;
}

.certificate-date {
    font-size: 0.95rem;
    color: #552d8b;
    margin-top: 1.5rem;
    text-align: center;
    font-weight: 600;
}

.certificate-signature {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-right: 50px;
}

.certificate-signature-box {
    text-align: center;
    width: 250px;
}

.certificate-signature-line {
    border-top: 2px solid #552d8b;
    margin-top: 4rem;
    padding-top: 0.5rem;
}

.certificate-signature-name {
    font-weight: 600;
    color: #552d8b;
    font-size: 0.95rem;
}

.certificate-signature-title {
    font-size: 0.85rem;
    color: #552d8b;
}

.certificate-quote {
    margin-top: 1.5rem;
    font-style: italic;
    color: #552d8b;
    font-size: 0.9rem;
    text-align: center;
}

/* Modal Overlay Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    cursor: pointer;
}

/* Modal Content - Floating Center */
#certificate-modal .modal-content {
    position: relative;
    z-index: 1001;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 95%;
    max-width: 1200px;
    margin: auto;
}

/* Certificate print styles */
@media print {
    .modal {
        display: none !important;
    }

    .modal-overlay {
        display: none !important;
    }

    #certificate-modal .modal-content {
        position: static;
        transform: none;
        box-shadow: none;
        width: 100%;
        max-width: none;
        margin: 0;
        max-height: none;
    }

    .certificate {
        width: 297mm;
        height: 210mm;
        padding: 40px 50px;
        box-shadow: none;
        border: none;
        transform: none;
        margin: 0;
        page-break-inside: avoid;
    }

    .certificate-border {
        border-color: #000;
    }

    .certificate-border-inner {
        border-color: #666;
    }

    body {
        background: white;
        margin: 0;
        padding: 0;
    }

    @page {
        size: A4 landscape;
        margin: 0;
    }
}
