/* Root Variables */
:root {
    --primary-color: #2e7d32;
    --primary-light: #4caf50;
    --primary-dark: #1b5e20;
    --secondary-color: #1976d2;
    --success-color: #43a047;
    --warning-color: #ffa726;
    --danger-color: #e53935;
    --background: #f5f5f5;
    --surface: #ffffff;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
}

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

/* Header */
header {
    background: var(--surface);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    text-align: center;
}

header h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 2.5em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1em;
}

.back-link {
    text-align: right;
    margin-bottom: 15px;
}

.back-link a {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 1.1em;
    transition: color 0.3s;
}

.back-link a:hover {
    color: var(--primary-color);
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Courses Grid */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.course-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

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

.course-card h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.5em;
}

.course-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 15px 0;
}

.stat-item {
    background: var(--background);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}

.stat-item .number {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--primary-color);
}

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

.course-progress {
    margin-top: 15px;
}

.course-progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

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

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

/* Progress Section */
.progress-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--background);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-top: 5px;
}

.progress-bar-container {
    height: 30px;
    background: var(--border-color);
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    transition: width 0.5s ease;
    border-radius: 15px;
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #1565c0;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Filter Controls */
.filter-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    justify-content: center;
}

.filter-btn {
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    background: var(--surface);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1em;
}

.filter-btn:hover {
    border-color: var(--primary-color);
}

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

/* Lessons Container */
.lessons-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lesson {
    background: var(--surface);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    border-right: 5px solid var(--border-color);
}

.lesson.completed {
    background: #e8f5e9;
    border-right-color: var(--success-color);
}

.lesson.hidden {
    display: none;
}

.lesson-header {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 15px;
}

.lesson-checkbox {
    width: 28px;
    height: 28px;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
    margin-top: 5px;
}

.lesson-title {
    flex: 1;
}

.lesson-title h3 {
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 1.4em;
}

.lesson-meta {
    color: var(--text-secondary);
    font-size: 0.95em;
    margin-bottom: 10px;
}

.lesson-content {
    margin-right: 43px;
}

.lesson-resources {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.resource-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.resource-icon {
    font-size: 1.2em;
}

.resource-link {
    color: var(--secondary-color);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    background: #e3f2fd;
    transition: all 0.3s;
    font-size: 0.95em;
}

.resource-link:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateX(-3px);
}

.resource-file {
    color: var(--warning-color);
    background: #fff3e0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    font-family: monospace;
}

.lesson-preview {
    margin-top: 15px;
    padding: 15px;
    background: var(--background);
    border-radius: 8px;
    border-right: 3px solid var(--primary-light);
}

.lesson-preview summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.lesson-preview-content {
    color: var(--text-secondary);
    font-size: 0.95em;
    line-height: 1.8;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    margin-top: 40px;
}

/* Responsive */
@media (max-width: 768px) {
    .courses-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-row {
        grid-template-columns: 1fr 1fr;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* RTL Specific */
[dir="rtl"] .lesson-content {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .lesson {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .lesson.completed {
    border-right: 4px solid var(--success-color);
}

[dir="rtl"] .lesson-preview {
    text-align: right;
    direction: rtl;
}

/* Save Indicator Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}
