/* Track Page - Material Design */
page[data-hash="track"] {
    .track-page {
        background: #f5f5f5;
        min-height: 100vh;
    }
    
    /* Action Bar */
    .action-bar {
        background: white;
        padding: 1.5rem;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .track-indicator {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        color: white;
    }
    
    .btn-elevated {
        background: white;
        border: 1px solid #e0e0e0;
        padding: 0.5rem 1rem;
        border-radius: 4px;
        font-weight: 500;
        transition: all 0.3s ease;
        color: #424242;
        cursor: pointer;
    }
    
    .btn-elevated:hover {
        background: #f5f5f5;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Material Card */
    .material-card {
        background: white;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        overflow: hidden;
    }
    
    .card-header-material {
        padding: 1.25rem 1.5rem;
        border-bottom: 1px solid #e0e0e0;
        font-weight: 600;
        font-size: 1rem;
        color: #212121;
    }
    
    .card-body-material {
        padding: 1.5rem;
    }
    
    /* Chip Button */
    .chip-button {
        padding: 0.375rem 0.875rem;
        background: transparent;
        border: 1px solid #e0e0e0;
        border-radius: 16px;
        font-size: 0.8125rem;
        font-weight: 500;
        color: #757575;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .chip-button:hover {
        background: #f5f5f5;
    }
    
    .chip-button.active {
        background: #1976d2;
        border-color: #1976d2;
        color: white;
    }
    
    /* Performance Metrics */
    .performance-metric {
        background: white;
        padding: 1.25rem;
        border-radius: 8px;
        border: 1px solid #e0e0e0;
        text-align: center;
        transition: all 0.3s ease;
    }
    
    .performance-metric:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }
    
    .metric-icon {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 0.75rem;
        font-size: 1.25rem;
        color: white;
    }
    
    .metric-icon.blue { background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%); }
    .metric-icon.green { background: linear-gradient(135deg, #388e3c 0%, #2e7d32 100%); }
    .metric-icon.purple { background: linear-gradient(135deg, #7b1fa2 0%, #6a1b9a 100%); }
    .metric-icon.orange { background: linear-gradient(135deg, #f57c00 0%, #ef6c00 100%); }
    
    .metric-value {
        font-size: 2rem;
        font-weight: bold;
        color: #212121;
        line-height: 1;
        margin-bottom: 0.5rem;
    }
    
    .metric-label {
        font-size: 0.875rem;
        color: #757575;
        font-weight: 500;
        margin-bottom: 0.5rem;
    }
    
    .metric-change {
        font-size: 0.75rem;
        font-weight: 600;
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
    }
    
    .metric-change.positive {
        background: #e8f5e9;
        color: #2e7d32;
    }
    
    .metric-change.negative {
        background: #ffebee;
        color: #c62828;
    }
    
    .metric-change.neutral {
        background: #f5f5f5;
        color: #757575;
    }
    
    /* Section Title */
    .section-title {
        font-size: 0.875rem;
        font-weight: 600;
        color: #424242;
        margin-bottom: 1rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    /* Grade Distribution */
    .grade-distribution {
        margin-top: 2rem;
    }
    
    .distribution-chart {
        margin-top: 1rem;
    }
    
    .distribution-bar {
        height: 40px;
        border-radius: 8px;
        display: flex;
        overflow: hidden;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        margin-bottom: 1rem;
    }
    
    .bar-segment {
        height: 100%;
        cursor: pointer;
        transition: opacity 0.2s ease;
    }
    
    .bar-segment:hover {
        opacity: 0.8;
    }
    
    .bar-segment.grade-a { background: #388e3c; }
    .bar-segment.grade-b { background: #1976d2; }
    .bar-segment.grade-c { background: #f57c00; }
    .bar-segment.grade-d { background: #d32f2f; }
    
    .distribution-legend {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .legend-item {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.875rem;
    }
    
    .legend-color {
        width: 16px;
        height: 16px;
        border-radius: 4px;
    }
    
    .legend-count {
        margin-left: auto;
        font-weight: 600;
        color: #424242;
    }
    
    /* Subject Performance Item */
    .subject-performance-item {
        padding: 1.5rem;
        border-bottom: 1px solid #f5f5f5;
    }
    
    .subject-performance-item:last-child {
        border-bottom: none;
    }
    
    .subject-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1.5rem;
    }
    
    .subject-info-track {
        display: flex;
        align-items: center;
        gap: 1rem;
    }
    
    .subject-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        color: white;
    }
    
    .subject-icon.english { background: #5e35b1; }
    .subject-icon.math { background: #1976d2; }
    .subject-icon.science { background: #00897b; }
    .subject-icon.history { background: #d84315; }
    
    .subject-name {
        font-weight: 600;
        font-size: 1.125rem;
        color: #212121;
        margin-bottom: 0.25rem;
    }
    
    .subject-stats {
        font-size: 0.8125rem;
        color: #757575;
    }
    
    .subject-grade {
        text-align: right;
    }
    
    .grade-value {
        font-size: 2rem;
        font-weight: bold;
        color: #212121;
        line-height: 1;
    }
    
    .grade-letter {
        font-size: 1rem;
        font-weight: 600;
        color: #757575;
        margin-bottom: 0.25rem;
    }
    
    .grade-trend {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        font-size: 0.75rem;
        font-weight: 600;
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
    }
    
    .grade-trend.positive {
        background: #e8f5e9;
        color: #2e7d32;
    }
    
    .grade-trend.negative {
        background: #ffebee;
        color: #c62828;
    }
    
    /* Performance Graph */
    .performance-graph {
        position: relative;
        height: 100px;
        margin-bottom: 1rem;
    }
    
    .graph-line {
        position: relative;
        height: 100%;
    }
    
    .graph-svg {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
    
    .graph-point {
        position: absolute;
        width: 10px;
        height: 10px;
        background: white;
        border: 3px solid #1976d2;
        border-radius: 50%;
        cursor: pointer;
        transition: all 0.2s ease;
        z-index: 2;
    }
    
    .graph-point:hover {
        transform: scale(1.5);
    }
    
    .graph-baseline {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: #e0e0e0;
    }
    
    .subject-actions {
        display: flex;
        justify-content: flex-end;
    }
    
    .btn-text {
        background: transparent;
        border: none;
        color: #1976d2;
        font-weight: 500;
        font-size: 0.875rem;
        cursor: pointer;
        padding: 0.5rem;
        transition: background 0.2s ease;
        border-radius: 4px;
    }
    
    .btn-text:hover {
        background: rgba(25, 118, 210, 0.08);
    }
    
    /* Results List */
    .results-list {
        padding: 0;
    }
    
    .result-item {
        display: flex;
        align-items: center;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid #f5f5f5;
        transition: background 0.2s ease;
        cursor: pointer;
    }
    
    .result-item:last-child {
        border-bottom: none;
    }
    
    .result-item:hover {
        background: #fafafa;
    }
    
    .result-icon {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.125rem;
        color: white;
        margin-right: 1rem;
    }
    
    .result-icon.english { background: #5e35b1; }
    .result-icon.math { background: #1976d2; }
    .result-icon.science { background: #00897b; }
    .result-icon.history { background: #d84315; }
    
    .result-content {
        flex: 1;
    }
    
    .result-title {
        font-weight: 600;
        color: #212121;
        margin-bottom: 0.25rem;
    }
    
    .result-meta {
        font-size: 0.8125rem;
        color: #757575;
        display: flex;
        gap: 0.5rem;
    }
    
    .result-grade {
        text-align: center;
        padding: 0.5rem 1rem;
        border-radius: 8px;
    }
    
    .result-grade.grade-a {
        background: #e8f5e9;
    }
    
    .result-grade.grade-b {
        background: #e3f2fd;
    }
    
    .result-grade.grade-c {
        background: #fff3e0;
    }
    
    .grade-score {
        font-size: 1.25rem;
        font-weight: bold;
        color: #212121;
        line-height: 1;
    }
    
    .grade-letter-small {
        font-size: 0.75rem;
        font-weight: 600;
        color: #757575;
    }
    
    /* Insight Card */
    .insight-card {
        display: flex;
        gap: 1rem;
        padding: 1rem;
        border-radius: 8px;
        margin-bottom: 1rem;
    }
    
    .insight-card:last-child {
        margin-bottom: 0;
    }
    
    .insight-card.strength {
        background: #e8f5e9;
    }
    
    .insight-card.improvement {
        background: #e3f2fd;
    }
    
    .insight-card.warning {
        background: #fff3e0;
    }
    
    .insight-card.info {
        background: #f3e5f5;
    }
    
    .insight-icon {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
        flex-shrink: 0;
    }
    
    .insight-card.strength .insight-icon {
        background: #388e3c;
        color: white;
    }
    
    .insight-card.improvement .insight-icon {
        background: #1976d2;
        color: white;
    }
    
    .insight-card.warning .insight-icon {
        background: #f57c00;
        color: white;
    }
    
    .insight-card.info .insight-icon {
        background: #7b1fa2;
        color: white;
    }
    
    .insight-content {
        flex: 1;
    }
    
    .insight-title {
        font-weight: 600;
        color: #212121;
        margin-bottom: 0.25rem;
        font-size: 0.875rem;
    }
    
    .insight-text {
        font-size: 0.8125rem;
        color: #424242;
        line-height: 1.4;
    }
    
    /* Goal Progress Item */
    .goal-progress-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1.25rem 1.5rem;
        border-bottom: 1px solid #f5f5f5;
    }
    
    .goal-progress-item:last-child {
        border-bottom: none;
    }
    
    .goal-info {
        flex: 1;
    }
    
    .goal-name {
        font-weight: 600;
        color: #212121;
        margin-bottom: 0.25rem;
    }
    
    .goal-status {
        font-size: 0.8125rem;
        color: #757575;
    }
    
    .goal-status.achieved {
        color: #388e3c;
        font-weight: 600;
    }
    
    .circular-progress {
        width: 60px;
        height: 60px;
    }
    
    .circular-progress svg {
        width: 100%;
        height: 100%;
        transform: rotate(-90deg);
    }
    
    .circular-progress .percentage {
        font-size: 0.5rem;
        font-weight: bold;
        fill: #212121;
        transform: rotate(90deg);
        transform-origin: center;
    }
    
    /* Upcoming List */
    .upcoming-list {
        padding: 0;
    }
    
    .upcoming-item {
        display: flex;
        align-items: center;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid #f5f5f5;
        gap: 1rem;
    }
    
    .upcoming-item:last-child {
        border-bottom: none;
    }
    
    .upcoming-date {
        text-align: center;
        padding: 0.5rem;
        border-radius: 8px;
        min-width: 60px;
    }
    
    .upcoming-item.urgent .upcoming-date {
        background: #ffebee;
    }
    
    .upcoming-item.warning .upcoming-date {
        background: #fff3e0;
    }
    
    .upcoming-item.normal .upcoming-date {
        background: #e3f2fd;
    }
    
    .date-day {
        font-size: 0.75rem;
        font-weight: 600;
        color: #757575;
        text-transform: uppercase;
    }
    
    .date-number {
        font-size: 1.5rem;
        font-weight: bold;
        color: #212121;
        line-height: 1;
    }
    
    .upcoming-content {
        flex: 1;
    }
    
    .upcoming-title {
        font-weight: 600;
        color: #212121;
        margin-bottom: 0.25rem;
    }
    
    .upcoming-subject {
        font-size: 0.8125rem;
        color: #757575;
    }
    
    .upcoming-badge {
        padding: 0.25rem 0.75rem;
        border-radius: 12px;
        font-size: 0.75rem;
        font-weight: 600;
    }
    
    .upcoming-badge.urgent {
        background: #ffebee;
        color: #c62828;
    }
    
    .upcoming-badge.warning {
        background: #fff3e0;
        color: #e65100;
    }
    
    .upcoming-badge.normal {
        background: #e3f2fd;
        color: #1976d2;
    }
    
    /* Input Styles */
    .input-label {
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
        font-weight: 500;
        color: #424242;
    }
    
    .material-input {
        width: 100%;
        padding: 0.75rem;
        border: 1px solid #e0e0e0;
        border-radius: 4px;
        font-size: 1rem;
        transition: all 0.2s ease;
    }
    
    .material-input:focus {
        outline: none;
        border-color: #1976d2;
        box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
    }
    
    .material-select-wrapper {
        position: relative;
    }
    
    .material-select {
        width: 100%;
        padding: 0.75rem;
        border: 1px solid #e0e0e0;
        border-radius: 4px;
        font-size: 1rem;
        background: white;
        cursor: pointer;
        appearance: none;
        transition: all 0.2s ease;
    }
    
    .material-select:focus {
        outline: none;
        border-color: #1976d2;
        box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
    }
    
    .material-select-wrapper::after {
        content: '\f078';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none;
        color: #757575;
    }
    
    .material-textarea {
        width: 100%;
        padding: 0.75rem;
        border: 1px solid #e0e0e0;
        border-radius: 4px;
        font-size: 1rem;
        font-family: 'Roboto', sans-serif;
        transition: all 0.2s ease;
        resize: vertical;
    }
    
    .material-textarea:focus {
        outline: none;
        border-color: #1976d2;
        box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
    }
    
    /* Modal Overrides */
    .modal-content {
        border-radius: 8px;
        border: none;
    }
    
    .modal-header {
        border-bottom: 1px solid #e0e0e0;
        padding: 1.5rem;
    }
    
    .modal-title {
        font-weight: 600;
        color: #212121;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    .modal-footer {
        border-top: 1px solid #e0e0e0;
        padding: 1rem 1.5rem;
    }
    
    /* Responsive */
    @media (max-width: 991px) {
        .action-bar {
            flex-direction: column;
            align-items: flex-start;
        }
        
        .distribution-legend {
            grid-template-columns: 1fr 1fr;
        }
        
        .subject-header {
            flex-direction: column;
            align-items: flex-start;
            gap: 1rem;
        }
        
        .subject-grade {
            text-align: left;
        }
    }
    
    @media (max-width: 576px) {
        .distribution-legend {
            grid-template-columns: 1fr;
        }
    }
    
    .loading-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(255, 255, 255, 0.7);
        z-index: 10;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
    }
    
    /* --- Manage Subjects Modal Enhancements --- */

/* Make the list items interactive */
.subject-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease-in-out;
    cursor: pointer;
}

.subject-list-item:hover {
    background-color: #f5f5f5;
}

.subject-list-item .subject-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.subject-list-item .subject-icon-display {
    width: 36px;
    height: 36px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    color: white;
    font-size: 1rem;
}

.subject-list-item .action-buttons .btn {
    padding: 0.25rem 0.5rem;
}

.icon-picker-wrapper {
    position: relative;
}

.icon-picker-preview {
    display: flex;
    align-items: center;
    justify-content: center; /* Center the icon */
    gap: 0.75rem;
    height: 38px; /* Match material-input height */
    border: 1px solid #ced4da;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    background-color: white;
    transition: border-color 0.15s ease-in-out;
}

.icon-picker-preview:hover {
    border-color: #86b7fe;
}

.icon-picker-popover {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1056; /* Higher than modal's z-index */
    background: white;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
}

.icon-picker-popover i {
    padding: 0.5rem;
    text-align: center;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 1.25rem;
    color: #4f4f4f;
    transition: background-color 0.2s, color 0.2s;
}

.icon-picker-popover i:hover {
    background-color: #e0e0e0;
    color: #000;
}

.custom-color-picker {
    position: relative;
    display: flex;
    align-items: center;
    height: 38px; /* Match material-input and icon-picker height */
    padding: 0.375rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background-color: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out;
}

.custom-color-picker:hover {
    border-color: #86b7fe; /* Bootstrap focus color */
}

.custom-color-picker .color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
    margin-right: 0.75rem;
}

.custom-color-picker .color-hex {
    font-family: monospace;
    font-size: 0.9em;
    color: #4f4f4f;
}

/* This is the magic: the native input is invisible but fully functional */
.custom-color-picker input[type="color"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* =================================================== */
/*   Grade Distribution Bar and Legend Colors          */
/*   (7-Point Scale)                                   */
/* =================================================== */

/* High Distinction (HD) */
.grade-hd { 
    background-color: #2E7D32; /* Dark Green */
}

/* Distinction (D) */
.grade-d { 
    background-color: #4CAF50; /* Green */
}

/* Credit (C) */
.grade-c { 
    background-color: #8BC34A; /* Light Green */
}

/* Pass (P) */
.grade-p { 
    background-color: #1976D2; /* Blue */
}

/* Marginal Fail (MF) */
.grade-mf { 
    background-color: #FFB300; /* Amber / Orange */
}

/* Fail (F) */
.grade-f { 
    background-color: #F4511E; /* Deep Orange */
}

/* Low Fail (LF) */
.grade-lf { 
    background-color: #D32F2F; /* Red */
}
}
