:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

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

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 40px 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.header .subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

/* View Management */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* Grade Selection View */
.grade-selector {
    text-align: center;
}

.grade-selector h2 {
    font-size: 2em;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.grade-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-bottom: 40px;
}

.grade-btn {
    padding: 15px 40px;
    font-size: 1.1em;
    border: 2px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.grade-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.grade-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Course List View */
.view-header {
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.view-header h2 {
    flex: 1;
}

.btn-back {
    padding: 10px 20px;
    background: var(--border-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.btn-back:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

.course-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.course-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.course-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: var(--primary-color);
}

.course-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.course-card h3 {
    font-size: 1.3em;
    margin: 0;
    color: var(--text-primary);
    flex: 1;
}

.course-card-units {
    font-size: 0.9em;
    color: var(--text-secondary);
    background: var(--primary-light);
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    width: 100%;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color) 0%, var(--primary-color) 100%);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* Course Detail View */
.detail-header {
    display: flex;
    align-items: start;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.detail-title-section {
    flex: 1;
    min-width: 250px;
}

.detail-title-section h2 {
    margin-bottom: 15px;
}

.detail-progress {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-progress .progress-bar-container {
    min-width: 200px;
}

.units-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.unit {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.unit-header {
    background: var(--primary-light);
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.3s ease;
}

.unit-header:hover {
    background: #bfdbfe;
}

.unit-header h3 {
    font-size: 1.1em;
    margin: 0;
    flex: 1;
}

.unit-toggle {
    font-size: 1.2em;
    color: var(--primary-color);
    transition: transform 0.3s ease;
}

.unit.expanded .unit-toggle {
    transform: rotate(180deg);
}

.unit-content {
    display: none;
    padding: 20px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.unit.expanded .unit-content {
    display: block;
    max-height: 10000px;
}

.assignments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.assignment {
    display: flex;
    align-items: start;
    gap: 12px;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.assignment:hover {
    background: var(--primary-light);
}

.assignment input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--success-color);
    flex-shrink: 0;
}

.assignment label {
    flex: 1;
    cursor: pointer;
    font-size: 1em;
    line-height: 1.4;
}

.assignment input[type="checkbox"]:checked + label {
    color: var(--text-secondary);
    text-decoration: line-through;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .header {
        padding: 30px 15px;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .header .subtitle {
        font-size: 1em;
    }

    .course-cards {
        grid-template-columns: 1fr;
    }

    .grade-buttons {
        gap: 10px;
    }

    .grade-btn {
        min-width: 120px;
        padding: 12px 24px;
        font-size: 1em;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .detail-header {
        flex-direction: column;
    }

    .detail-title-section {
        width: 100%;
    }

    .detail-progress .progress-bar-container {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5em;
    }

    .grade-selector h2 {
        font-size: 1.3em;
    }

    .grade-btn {
        min-width: 100%;
    }

    .unit-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .unit-header h3 {
        width: 100%;
    }
}
