:root {
    --primary-color: #4F46E5; /* Indigo */
    --primary-hover: #4338ca;
    --secondary-color: #10B981; /* Emerald */
    --accent-color: #8B5CF6; /* Purple */
    --bg-color: #F3F4F6;
    --sidebar-bg: #1F2937;
    --card-bg: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: white;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary-color);
}

.user-profile-mini {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.avatar {
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.user-info h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.level-badge {
    font-size: 0.75rem;
    background: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.xp-container {
    margin-top: -1rem;
}

.xp-bar {
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

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

.xp-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-links li {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #D1D5DB;
    transition: var(--transition);
}

.nav-links li:hover, .nav-links li.active {
    background-color: rgba(255,255,255,0.1);
    color: white;
}

.nav-links li.active {
    background-color: var(--primary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.top-bar h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.search-bar {
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
    width: 300px;
}

.search-bar input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 0.9rem;
}

/* View Sections */
.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.icon-box {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.icon-box.blue { background: #E0E7FF; color: var(--primary-color); }
.icon-box.green { background: #D1FAE5; color: var(--secondary-color); }
.icon-box.purple { background: #EDE9FE; color: var(--accent-color); }

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-info span {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Feed */
.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.filter-tabs {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.filter-btn:hover, .filter-btn.active {
    background: var(--text-main);
    color: white;
    border-color: var(--text-main);
}

.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.lesson-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border-left: 5px solid var(--primary-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: var(--transition);
    position: relative;
}

.lesson-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.project-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
}

.card-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: #F3F4F6;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.card-body h4 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    margin-bottom: 0.2rem;
}

.card-body p {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.card-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.author {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.author i { color: var(--primary-color); }

.reactions {
    display: flex;
    gap: 1rem;
}

.reaction-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.2s;
}

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

/* Form Styles */
.form-container {
    background: white;
    max-width: 800px;
    margin: 0 auto;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.form-container h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-color);
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: flex;
    gap: 1.5rem;
}

.form-group.half {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-main);
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group.highlight textarea {
    background-color: #F0FDF4; /* Light green bg for recommendation */
    border-color: #86EFAC;
}

.submit-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    justify-content: center;
    transition: var(--transition);
}

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

.xp-reward {
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
}

/* Leaderboard */
.leaderboard-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    max-width: 900px;
    margin: 0 auto;
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 0.5fr 3fr 1fr 1fr;
    padding: 1rem;
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.8rem;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 0.5fr 3fr 1fr 1fr;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.rank-circle {
    width: 30px;
    height: 30px;
    background: var(--bg-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-muted);
}

.leaderboard-item.top-1 .rank-circle { background: #FEF3C7; color: #D97706; }
.leaderboard-item.top-2 .rank-circle { background: #E5E7EB; color: #4B5563; }
.leaderboard-item.top-3 .rank-circle { background: #FFEDD5; color: #C2410C; }

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    transform: translateY(150%);
    transition: transform 0.4s ease;
    z-index: 1000;
    border-left: 5px solid var(--secondary-color);
}

.toast.show {
    transform: translateY(0);
}

.toast-icon {
    background: #D1FAE5;
    color: var(--secondary-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast.hidden { display: none; }

/* Achievements Grid */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.achievement-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
    opacity: 0.6;
    filter: grayscale(1);
    transition: var(--transition);
}

.achievement-card.unlocked {
    opacity: 1;
    filter: grayscale(0);
    border: 2px solid var(--secondary-color);
}

.achievement-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.achievement-card h4 {
    margin-bottom: 0.5rem;
}

.achievement-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* CSS Updates for New Features */

.card-meta-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.meta-badge {
    font-size: 0.75rem;
    background: #F3F4F6;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #E5E7EB;
}

.recommendation-box {
    background: #F0FDF4; 
    padding: 1rem; 
    border-radius: var(--radius-md); 
    margin-top: 0.5rem; 
    border-left: 4px solid var(--secondary-color);
}

.task-btn {
    background: var(--text-main);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.task-btn:hover {
    background: black;
    transform: translateY(-1px);
}

.task-status {
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
}

.task-status.assigned {
    background: #DBEAFE;
    color: #1E40AF;
}

.task-status.locked {
    background: #F3F4F6;
    color: #6B7280;
}

.task-status.completed {
    background: #D1FAE5;
    color: #065F46;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    background: white;
    border-radius: var(--radius-lg);
    grid-column: 1 / -1;
    border: 2px dashed var(--border-color);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 450px;
    width: 90%;
    animation: slideUp 0.4s ease;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-content.wide-modal {
    max-width: 800px;
}

.modal-body-scroll {
    overflow-y: auto;
    padding-right: 0.5rem;
}

.modal-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section h4 {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* Add Lesson Button Banner */
.cta-banner {
    display: flex;
    justify-content: flex-end; /* or center if preferred */
    margin-bottom: 1.5rem;
}

.main-add-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--radius-lg);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.main-add-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    filter: brightness(1.1);
}

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

.modal-header {
    text-align: center;
    margin-bottom: 2rem;
}

.modal-header h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-header p {
    color: var(--text-muted);
}
