/* ============================================================================
   TEACHER DASHBOARD STYLES
   ============================================================================ */

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* ============================================================================
   LOADING SCREEN
   ============================================================================ */
.loading-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #3730a3 100%);
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

.loading-content p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* ============================================================================
   LOGIN SCREEN
   ============================================================================ */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #3730a3 100%);
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.login-form,
.signup-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form .form-group,
.signup-form .form-group {
    margin-bottom: 0;
}

.login-form label,
.signup-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.login-form .input-field,
.signup-form .input-field {
    padding: 14px 16px;
    font-size: 1rem;
    border-radius: 10px;
}

.login-divider {
    display: flex;
    align-items: center;
    margin: 8px 0;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

.login-divider span {
    padding: 0 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.btn-google {
    background: white;
    color: var(--text-primary);
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.btn-google:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-full {
    width: 100%;
    padding: 14px 24px;
}

.login-footer {
    text-align: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.login-footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.login-footer a:hover {
    text-decoration: underline;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
}

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

.error-message {
    color: #dc2626;
    font-size: 0.9rem;
    padding: 8px 12px;
    background: #fef2f2;
    border-radius: 8px;
    display: none;
}

.error-message:not(:empty) {
    display: block;
}

/* ============================================================================
   DASHBOARD CONTAINER
   ============================================================================ */

.teacher-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    background: var(--bg-alt);
}

/* ============================================================================
   SIDEBAR
   ============================================================================ */

.sidebar {
    background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 100%);
    color: white;
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.sidebar-header {
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-header h2 {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.sidebar-header p {
    font-size: 0.9rem;
    opacity: 0.8;
}

.nav-menu {
    list-style: none;
    margin-bottom: 40px;
}

.nav-menu li {
    margin-bottom: 8px;
}

.nav-menu a {
    display: block;
    padding: 12px 16px;
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-menu a:hover, .nav-menu a.active {
    background: rgba(255, 255, 255, 0.15);
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */

.main-content {
    padding: 40px;
    overflow-y: auto;
}

.main-content h1 {
    font-size: 2rem;
    margin-bottom: 32px;
    color: var(--text-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ============================================================================
   FORMS
   ============================================================================ */

.lesson-form-card {
    background: white;
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 800px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ============================================================================
   MULTI-CLASS SELECTOR FOR LESSON CREATION
   ============================================================================ */

.class-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.class-selector-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.class-selector-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.class-selector-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

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

.class-selector-info span {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.class-selector-info small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.empty-hint {
    color: var(--text-secondary);
    font-style: italic;
    padding: 8px;
}

/* Class checkbox list for reassignment modal */
.class-checkbox-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
}

.class-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.class-checkbox-item:hover {
    border-color: var(--primary);
}

.class-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.class-checkbox-info {
    flex: 1;
}

.class-checkbox-info span {
    display: block;
    font-weight: 500;
}

.class-checkbox-info small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.assign-classes-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================================================
   CLASSES GRID
   ============================================================================ */

.classes-grid, .lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.class-card, .lesson-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.class-card:hover, .lesson-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.class-header, .lesson-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.class-header h3, .lesson-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.class-code {
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.lesson-badge {
    background: var(--bg-alt);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.class-info, .lesson-info {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.class-info p, .lesson-info p {
    margin-bottom: 6px;
}

.class-actions, .lesson-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================================================
   ANALYTICS
   ============================================================================ */

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.analytics-controls {
    background: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.analytics-controls label {
    margin-right: 12px;
    font-weight: 500;
}

.analytics-controls select {
    min-width: 250px;
}

.analytics-section {
    background: white;
    padding: 32px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.analytics-section h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--text-primary);
}

/* ============================================================================
   HEATMAP
   ============================================================================ */

.heatmap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.heatmap-table th {
    background: var(--bg-alt);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}

.heatmap-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.heatmap-table .student-name {
    font-weight: 500;
    color: var(--text-primary);
}

.heatmap-table .cell {
    text-align: center;
    font-weight: 600;
    border-radius: var(--radius-sm);
}

.heatmap-table .cell.strong {
    background: #d1fae5;
    color: #065f46;
}

.heatmap-table .cell.okay {
    background: #fef3c7;
    color: #92400e;
}

.heatmap-table .cell.needs-work {
    background: #fee2e2;
    color: #991b1b;
}

.heatmap-table tr:hover {
    background: var(--bg-alt);
    cursor: pointer;
}

/* ============================================================================
   INSIGHTS
   ============================================================================ */

.insights-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.insight-item {
    padding: 20px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
}

.insight-item strong {
    display: block;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 1.05rem;
}

.insight-item ul {
    list-style: none;
    padding-left: 0;
}

.insight-item li {
    padding: 6px 0;
    color: var(--text-secondary);
}

.insight-item li::before {
    content: "• ";
    color: var(--primary);
    font-weight: bold;
    margin-right: 8px;
}

/* ============================================================================
   ENHANCED ANALYTICS DASHBOARD
   ============================================================================ */

.analytics-controls-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
    background: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.analytics-controls-bar .control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.analytics-controls-bar .control-group:last-child {
    flex-direction: row;
    margin-left: auto;
    align-items: center;
    gap: 8px;
}

.analytics-controls-bar label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.analytics-controls-bar select {
    min-width: 180px;
}

/* Dashboard Grid */
.analytics-dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.dashboard-card h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 600;
}

/* Health Metrics */
.health-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.metric {
    text-align: center;
    padding: 12px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
}

.metric-value {
    display: block;
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 4px;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Attention Needed */
.attention-list {
    max-height: 200px;
    overflow-y: auto;
}

.attention-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fef2f2;
    border-radius: var(--radius-md);
    border-left: 3px solid #ef4444;
}

.attention-item .student-name {
    font-weight: 500;
    color: var(--text-primary);
}

.attention-item .mastery-badge {
    font-size: 0.85rem;
    font-weight: 600;
    color: #991b1b;
}

.attention-item.warning {
    background: #fffbeb;
    border-left-color: #f59e0b;
}

.attention-item.warning .mastery-badge {
    color: #92400e;
}

/* Topic Performance Bars */
.topic-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.topic-bar-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.topic-bar-item .topic-name {
    font-size: 0.85rem;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
}

.topic-bar-item .bar-container {
    height: 8px;
    background: var(--bg-alt);
    border-radius: 4px;
    overflow: hidden;
}

.topic-bar-item .bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.topic-bar-item .bar-fill.high { background: #10b981; }
.topic-bar-item .bar-fill.medium { background: #f59e0b; }
.topic-bar-item .bar-fill.low { background: #ef4444; }

/* Student Table */
.student-table-section {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.section-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.table-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    min-width: 200px;
}

.student-table-container {
    overflow-x: auto;
}

.student-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.student-table th {
    background: var(--bg-alt);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
}

.student-table th:hover {
    background: #e2e8f0;
}

.student-table th .sort-icon {
    margin-left: 4px;
    opacity: 0.5;
}

.student-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.student-table tr:hover {
    background: var(--bg-alt);
    cursor: pointer;
}

.student-table .student-name-cell {
    font-weight: 500;
}

.student-table .mastery-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mastery-bar-small {
    width: 60px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.mastery-bar-small .fill {
    height: 100%;
    border-radius: 3px;
}

.mastery-bar-small .fill.high { background: #10b981; }
.mastery-bar-small .fill.medium { background: #f59e0b; }
.mastery-bar-small .fill.low { background: #ef4444; }

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.mastered { background: #d1fae5; color: #065f46; }
.status-badge.ontrack { background: #fef3c7; color: #92400e; }
.status-badge.struggling { background: #fee2e2; color: #991b1b; }

/* Student Detail Panel */
.student-detail-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 1000;
    transform: translateX(0);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.student-detail-panel.hidden {
    transform: translateX(100%);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.panel-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.close-panel-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: white;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.close-panel-btn:hover {
    background: #fee2e2;
    color: #991b1b;
}

.panel-content {
    padding: 24px;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-section h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.concept-mastery-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.concept-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.concept-row .concept-name {
    flex: 1;
    font-size: 0.9rem;
}

.concept-row .concept-bar {
    width: 100px;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.concept-row .concept-bar .fill {
    height: 100%;
    border-radius: 4px;
}

.concept-row .concept-percent {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

.lesson-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lesson-history-item {
    padding: 12px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.lesson-history-item .lesson-topic {
    font-weight: 500;
    margin-bottom: 4px;
}

.lesson-history-item .lesson-meta {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 1024px) {
    .teacher-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 1000;
    }
    
    .sidebar.open {
        left: 0;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 20px;
    }
    
    .main-content h1 {
        font-size: 1.5rem;
    }
    
    .lesson-form-card {
        padding: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .classes-grid, .lessons-grid {
        grid-template-columns: 1fr;
    }
    
    .header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .analytics-controls {
        padding: 16px;
    }
    
    .analytics-controls select {
        min-width: 100%;
        margin-top: 8px;
    }
    
    .heatmap-table {
        font-size: 0.8rem;
    }
    
    .heatmap-table th,
    .heatmap-table td {
        padding: 8px 6px;
    }
    
    /* Analytics Dashboard Responsive */
    .analytics-controls-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .analytics-controls-bar .control-group:last-child {
        margin-left: 0;
        justify-content: center;
    }
    
    .analytics-dashboard {
        grid-template-columns: 1fr;
    }
    
    .health-metrics {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .table-controls {
        flex-direction: column;
    }
    
    .search-input {
        min-width: 100%;
    }
    
    .student-detail-panel {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .class-actions, .lesson-actions {
        flex-direction: column;
    }
    
    .class-actions .btn, .lesson-actions .btn {
        width: 100%;
    }
}

/* ============================================================================
   LESSON PREVIEW MODAL
   ============================================================================ */
.lesson-preview-modal,
.lesson-edit-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
    padding: 20px;
}

.lesson-preview-content,
.lesson-edit-content {
    background: white;
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Modal body content padding (everything except header and footer) */
.lesson-edit-content > .form-group,
.lesson-edit-content > .form-row,
.lesson-edit-content > .edit-status,
.lesson-edit-content > .class-checkbox-list,
.lesson-edit-content > .version-list,
.lesson-edit-content > .empty-state,
.lesson-edit-content > p,
.lesson-edit-content > .modal-subtitle,
.lesson-edit-content > .assign-classes-footer {
    padding-left: 24px;
    padding-right: 24px;
}

/* First element after header needs top padding */
.lesson-edit-header + .form-group,
.lesson-edit-header + .form-row,
.lesson-edit-header + .modal-subtitle,
.lesson-edit-header + p {
    padding-top: 20px;
}

/* Actions/footer area */
.lesson-edit-actions {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    border-top: 1px solid #e2e8f0;
    margin-top: 16px;
    background: #f8fafc;
    border-radius: 0 0 16px 16px;
}

.lesson-preview-header,
.lesson-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.lesson-preview-header h2,
.lesson-edit-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.close-preview,
.close-edit {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 4px;
    border-radius: 4px;
}

.close-preview:hover,
.close-edit:hover {
    background: #f1f5f9;
}

.lesson-preview-meta,
.lesson-edit-info {
    padding: 16px 24px;
    background: #f8fafc;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.lesson-edit-info {
    flex-direction: column;
    align-items: flex-start;
}

.lesson-edit-info strong {
    font-size: 1.1rem;
}

.lesson-edit-info span {
    color: #64748b;
    font-size: 0.9rem;
}

.lesson-preview-meta .badge {
    background: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid #e2e8f0;
}

.lesson-preview-phases {
    padding: 24px;
}

.preview-phase {
    margin-bottom: 24px;
}

.preview-phase h4 {
    margin: 0 0 12px 0;
    color: #1e293b;
    font-size: 1rem;
}

.preview-phase ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.preview-phase li {
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.preview-phase .item-type {
    font-weight: 600;
    margin-right: 8px;
}

.lesson-preview-actions,
.lesson-edit-actions {
    padding: 20px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Edit Modal Specific */
.edit-prompt-section {
    padding: 24px;
}

.edit-prompt-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: #1e293b;
}

.edit-prompt-section textarea {
    width: 100%;
    min-height: 150px;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.2s;
}

.edit-prompt-section textarea:focus {
    outline: none;
    border-color: #4f46e5;
}

.edit-prompt-section textarea::placeholder {
    color: #94a3b8;
}

.edit-status {
    padding: 0 24px;
    min-height: 24px;
    font-size: 0.9rem;
}

.edit-status.info {
    color: #0369a1;
}

.edit-status.success {
    color: #059669;
}

.edit-status.error {
    color: #dc2626;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 600px) {
    .lesson-preview-actions,
    .lesson-edit-actions {
        flex-direction: column;
    }
    
    .lesson-preview-actions .btn,
    .lesson-edit-actions .btn {
        width: 100%;
    }
}

/* ============================================================================
   FULL LESSON PREVIEW STYLES
   ============================================================================ */

.lesson-preview-modal.full-preview .lesson-preview-content.full {
    max-width: 900px;
    max-height: 90vh;
}

.lesson-preview-modal.full-preview .lesson-preview-header {
    flex-wrap: wrap;
    gap: 12px;
}

.lesson-preview-modal.full-preview .header-info {
    flex: 1;
}

.lesson-preview-modal.full-preview .header-info h2 {
    margin-bottom: 8px;
}

.lesson-preview-body {
    padding: 24px;
}

.preview-phase-section {
    margin-bottom: 32px;
}

.preview-phase-section:last-child {
    margin-bottom: 0;
}

.phase-title {
    font-size: 1.1rem;
    color: #1e293b;
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.phase-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.preview-item {
    background: #f8fafc;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.preview-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.item-number {
    font-weight: 600;
    color: #64748b;
    font-size: 0.85rem;
}

.item-type-badge {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 12px;
    background: white;
    border: 1px solid #e2e8f0;
}

.preview-item-content {
    padding: 16px;
}

.preview-item-content.explanation .explanation-text {
    line-height: 1.7;
    color: #334155;
}

.preview-item-content .question-prompt {
    font-size: 1rem;
    line-height: 1.6;
    color: #1e293b;
    margin: 0 0 16px 0;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.options-list .option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.options-list .option.correct {
    background: #f0fdf4;
    border-color: #22c55e;
}

.option-letter {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.85rem;
    color: #64748b;
}

.option.correct .option-letter {
    background: #22c55e;
    color: white;
}

.option-text {
    flex: 1;
}

.correct-marker {
    color: #22c55e;
    font-weight: bold;
}

.expected-answer,
.answer-explanation {
    padding: 12px 16px;
    background: #fffbeb;
    border-radius: 8px;
    margin-top: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.answer-explanation {
    background: #f0fdf4;
}

.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 12px 0;
}

/* Diagram styles for preview */
.diagram-container {
    margin: 16px 0;
    text-align: center;
}

.diagram-container svg {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    background: white;
}

.diagram-caption {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #64748b;
    font-style: italic;
}

.diagram-placeholder {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 32px;
}

.placeholder-content {
    font-size: 2rem;
    color: #94a3b8;
}

.diagram-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.diagram-fallback {
    background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.diagram-fallback .fallback-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.diagram-fallback .fallback-icon {
    font-size: 2rem;
}

.diagram-fallback .fallback-text {
    color: #78350f;
    font-size: 0.9rem;
    margin: 0;
}

.diagram-description {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 12px;
    padding: 20px;
    text-align: left;
}

.diagram-description .description-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.diagram-description .description-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.diagram-description .description-content p {
    margin: 0;
    line-height: 1.6;
    color: #0c4a6e;
}

/* TikZ/SVG Diagram Styles */
.tikz-diagram,
.svg-diagram {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tikz-diagram iframe,
.svg-diagram svg {
    max-width: 100%;
    height: auto;
}

.tikz-diagram .diagram-caption,
.svg-diagram .diagram-caption {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #6b7280;
    text-align: center;
}

/* Fallback for failed TikZ conversion */
.tikz-failed {
    background: #f9fafb;
    border: 2px dashed #d1d5db;
}

.tikz-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    color: #6b7280;
}

.tikz-fallback .fallback-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.tikz-fallback .fallback-text {
    margin: 0;
    font-style: italic;
}

/* SVG Diagram Text Styles */
.physics-svg .chart-title {
    font-size: 14px;
    font-weight: 600;
    fill: #1e293b;
}

.physics-svg .bar-value {
    font-size: 12px;
    font-weight: 600;
}

.physics-svg .bar-label {
    font-size: 11px;
    fill: #374151;
}

.physics-svg .comparison-title {
    font-size: 14px;
    font-weight: 600;
}

.physics-svg .comparison-desc {
    font-size: 11px;
    fill: #374151;
}

.physics-svg .vs-label {
    font-size: 12px;
    font-weight: 600;
    fill: #64748b;
}

.physics-svg .step-number {
    font-size: 16px;
    font-weight: 600;
}

.physics-svg .step-label {
    font-size: 11px;
}

.physics-svg .label-text {
    font-size: 11px;
}

.physics-svg .center-label {
    font-size: 12px;
    fill: #374151;
}

.no-items,
.no-phases {
    color: #94a3b8;
    font-style: italic;
    padding: 16px;
    text-align: center;
}

.btn-outline {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: #64748b;
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

@media (max-width: 768px) {
    .lesson-preview-modal.full-preview .lesson-preview-content.full {
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
    }
    
    .lesson-preview-body {
        padding: 16px;
    }
    
    .preview-item-content {
        padding: 12px;
    }
}

/* Checkbox styling for adaptive level */
.checkbox-group {
    margin: 16px 0;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 12px 16px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.checkbox-label:hover {
    border-color: var(--primary);
    background: #f0f7ff;
}

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

.checkbox-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.checkbox-text strong {
    color: var(--text-primary);
    font-size: 0.95rem;
}

.checkbox-text small {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Teacher notes in preview */
.teacher-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: #f0f7ff;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
    border-left: 3px solid var(--primary);
}

/* Grading rubric in preview */
.grading-rubric {
    background: #f0fdf4;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin: 12px 0;
    border-left: 3px solid #10b981;
}

.grading-rubric strong {
    color: #065f46;
    display: block;
    margin-bottom: 8px;
}

.grading-rubric ul {
    margin: 0;
    padding-left: 20px;
}

.grading-rubric li {
    color: #047857;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

/* AI graded indicator */
.expected-answer.ai-graded {
    background: #eff6ff;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary);
}

.expected-answer.ai-graded strong {
    color: var(--primary);
}

/* Code sections in preview */
.code-section,
.solution-section {
    margin: 12px 0;
}

.code-section strong,
.solution-section strong {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.solution-section .code-block {
    background: #f0fdf4;
    border-color: #10b981;
}

/* ============================================================================
   ADVANCED LESSON EDITOR
   ============================================================================ */

.lesson-editor-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
    padding: 20px;
}

.lesson-editor-content {
    background: white;
    border-radius: 16px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
}

.lesson-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
    border-radius: 16px 16px 0 0;
}

.editor-title-section h2 {
    margin: 0 0 4px;
    font-size: 1.25rem;
}

.editor-lesson-name {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.close-editor {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.close-editor:hover {
    background: var(--border);
    color: var(--text-primary);
}

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
}

.toolbar-hint {
    font-size: 0.9rem;
    color: #92400e;
}

.lesson-editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-alt);
}

.editor-phase {
    background: white;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.editor-phase-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    color: white;
}

.editor-phase-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.phase-comment-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.phase-comment-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.phase-comment-area {
    padding: 16px 20px;
    background: #fefce8;
    border-bottom: 1px solid #fde68a;
}

.phase-comment-area textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    resize: vertical;
    font-family: inherit;
}

.editor-phase-items {
    padding: 16px 20px;
}

.editor-item {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
}

.editor-item:last-child {
    margin-bottom: 0;
}

.editor-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: white;
    border-bottom: 1px solid var(--border);
}

.item-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    text-transform: uppercase;
}

.add-comment-btn {
    background: none;
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.add-comment-btn:hover {
    background: #fef3c7;
    border-color: #fcd34d;
}

.add-comment-btn.has-comment {
    background: #fef3c7;
    border-color: #f59e0b;
}

.editor-item-content {
    padding: 14px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.editor-explanation {
    color: var(--text-primary);
}

/* Diagrams in editor */
.editor-item-content .diagram-container {
    margin: 16px 0;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.editor-item-content .diagram-caption {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 8px;
    text-align: center;
    font-style: italic;
}

.editor-item-content .diagram-description {
    background: #fefce8;
    border-color: #fde68a;
}

/* Code blocks in editor */
.editor-code-block {
    margin: 12px 0;
    background: #1e293b;
    border-radius: 6px;
    overflow: hidden;
}

.editor-code-block pre {
    margin: 0;
    padding: 12px 16px;
    overflow-x: auto;
}

.editor-code-block code {
    color: #e2e8f0;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.starter-code {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px;
    margin-top: 8px;
    overflow-x: auto;
}

.starter-code code {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.85rem;
}

.editor-mcq .question-text,
.editor-short-answer .question-text {
    font-weight: 500;
    margin-bottom: 12px;
}

.options-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.option-row.correct {
    background: #f0fdf4;
    border-color: #10b981;
}

.opt-letter {
    font-weight: 600;
    color: var(--text-secondary);
    width: 24px;
}

.correct-tag {
    margin-left: auto;
    color: #10b981;
    font-weight: bold;
}

/* Inline Editing Styles */
.editable-field {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.editable-field:hover {
    background: #f8fafc;
}

.editable-field .field-content {
    flex: 1;
    min-width: 0;
}

.editable-field .field-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
}

.edit-field-btn {
    flex-shrink: 0;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    font-size: 0.9rem;
}

.editable-field:hover .edit-field-btn {
    opacity: 1;
}

.edit-field-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.editable-field.editing {
    background: #eff6ff;
    padding: 8px;
    border: 1px solid #bfdbfe;
}

.editable-field.edited {
    background: #f0fdf4;
    border-left: 3px solid #10b981;
}

.inline-edit-textarea,
.inline-edit-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
}

.inline-edit-textarea:focus,
.inline-edit-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.inline-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

/* MCQ Option Editing */
.options-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.option-row-editable {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.option-row-editable:hover {
    background: #f8fafc;
}

.option-row-editable.correct {
    background: #f0fdf4;
    border-color: #10b981;
}

.option-row-editable .option-field {
    flex: 1;
    padding: 0;
}

.option-row-editable .option-field:hover {
    background: transparent;
}

.correct-toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    font-size: 1rem;
    color: #9ca3af;
    transition: all 0.15s;
}

.correct-toggle:hover {
    border-color: #10b981;
    color: #10b981;
}

.correct-toggle.is-correct {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

/* Diagram container in editor */
.editor-diagram-container {
    margin: 12px 0;
    padding: 12px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
}

.regenerate-diagram-btn {
    margin-top: 8px;
    font-size: 0.8rem;
}

/* Hint field styling */
.hint-field {
    margin-top: 12px;
    padding: 8px 12px;
    background: #fefce8;
    border-radius: var(--radius-sm);
    border: 1px solid #fde68a;
}

.hint-field .field-label {
    color: #92400e;
}

/* Save button success style */
.btn-success {
    background: #10b981;
    color: white;
    border: none;
}

.btn-success:hover {
    background: #059669;
}

.btn-success:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.sample-answer {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 8px;
}

.raw-content {
    background: var(--bg-alt);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    overflow-x: auto;
}

.item-comment-area {
    padding: 12px 14px;
    background: #fefce8;
    border-top: 1px solid #fde68a;
}

.item-comment-area textarea {
    width: 100%;
    min-height: 60px;
    padding: 10px;
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    resize: vertical;
    font-family: inherit;
}

.item-comment-area textarea:focus,
.phase-comment-area textarea:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.editor-global-comment {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid var(--border);
}

.editor-global-comment label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.editor-global-comment textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    resize: vertical;
    font-family: inherit;
}

.editor-global-comment textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.lesson-editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: white;
    border-top: 1px solid var(--border);
    border-radius: 0 0 16px 16px;
}

.comment-summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#comment-count {
    font-weight: 500;
}

.editor-actions {
    display: flex;
    gap: 12px;
}

/* Editor responsive */
@media (max-width: 768px) {
    .lesson-editor-content {
        max-height: 95vh;
        border-radius: 12px;
    }
    
    .editor-toolbar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .lesson-editor-footer {
        flex-direction: column;
        gap: 12px;
    }
    
    .editor-actions {
        width: 100%;
    }
    
    .editor-actions .btn {
        flex: 1;
    }
}

/* ============================================================================
   LESSON MANAGEMENT MENU
   ============================================================================ */

/* Lesson card enhancements */
.lesson-card.archived {
    opacity: 0.6;
    border-style: dashed;
}

.lesson-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.lesson-badge.adaptive {
    background: #dbeafe;
    color: #1e40af;
}

.lesson-badge.archived {
    background: #f3f4f6;
    color: #6b7280;
}

/* Lesson menu modal */
.lesson-menu-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.lesson-menu-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.lesson-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.lesson-menu-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.close-menu {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.close-menu:hover {
    background: var(--bg-alt);
}

.lesson-menu-title {
    padding: 12px 20px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
}

.lesson-menu-section {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.lesson-menu-section:last-child {
    border-bottom: none;
}

.lesson-menu-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin: 0 0 8px 4px;
}

.lesson-menu-section.danger h4 {
    color: #dc2626;
}

.menu-btn {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.menu-btn:hover {
    background: var(--bg-alt);
}

.menu-btn.delete:hover {
    background: #fef2f2;
}

.menu-btn.archive:hover {
    background: #fefce8;
}

.menu-btn.restore:hover {
    background: #f0fdf4;
}

.menu-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.menu-text {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.menu-btn.delete .menu-text {
    color: #dc2626;
}

.menu-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: normal;
    margin-top: 2px;
}

/* Menu toggle item (for settings like adaptive mode) */
.menu-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

.menu-toggle-item:hover {
    background: var(--bg-hover);
}

.menu-toggle-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle-info .menu-icon {
    font-size: 1.25rem;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Compact modal variant */
.lesson-edit-content.compact {
    max-width: 380px;
}

.modal-subtitle {
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    font-size: 0.9rem;
}

/* Version history */
.version-list {
    max-height: 400px;
    overflow-y: auto;
    margin: 16px 0;
}

.empty-state {
    color: var(--text-secondary);
    text-align: center;
    padding: 32px 24px;
    font-style: italic;
}

.version-item {
    padding: 12px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.version-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.version-date {
    font-weight: 500;
    font-size: 0.9rem;
}

.version-type {
    font-size: 0.75rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 12px;
}

.version-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.version-details p {
    margin: 2px 0;
}

/* Import preview */
.import-preview {
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin: 16px 0;
}

.import-preview h4 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.import-preview p {
    margin: 4px 0;
    font-size: 0.9rem;
}

/* Delete confirmation modal */
.delete-confirm-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
}

.delete-confirm-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.delete-confirm-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.delete-confirm-content h3 {
    margin: 0 0 12px;
    font-size: 1.25rem;
}

.delete-confirm-content p {
    color: var(--text-secondary);
    margin: 0 0 24px;
}

.delete-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Form row for side-by-side inputs */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 500px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .lesson-menu-content {
        max-height: 90vh;
    }
}

/* Lesson filter bar */
.lesson-filter-bar {
    padding: 16px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.filter-bar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-bar-row:not(:last-child) {
    margin-bottom: 12px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.filter-bar-results {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.filter-bar-results .count {
    font-weight: 600;
    color: var(--text-primary);
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.filter-toggle input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.filter-toggle:hover {
    color: var(--text-primary);
}

/* ============================================================================
   LESSON SEARCH & FILTER
   ============================================================================ */

.lesson-search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 16px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.search-input-wrapper input {
    width: 100%;
    padding: 10px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    background: white;
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 1rem;
    border-radius: var(--radius-sm);
}

.search-clear:hover {
    background: var(--border);
    color: var(--text-primary);
}

.filter-dropdowns {
    display: flex;
    gap: 8px;
}

.filter-select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    min-width: 130px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

.archive-toggle {
    margin-left: auto;
}

.search-results-info {
    padding: 0 4px 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.search-results-count {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.search-results-count .results-count {
    font-weight: 500;
}

.search-results-info a {
    color: var(--primary);
    text-decoration: none;
}

.search-results-info a:hover {
    text-decoration: underline;
}

/* Lessons grid layout */
.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 8px;
}

/* Highlight search matches */
.lesson-card mark {
    background: #fef08a;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

@media (max-width: 768px) {
    .lesson-search-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-input-wrapper {
        min-width: 100%;
    }
    
    .filter-dropdowns {
        flex-wrap: wrap;
    }
    
    .filter-select {
        flex: 1;
        min-width: 45%;
    }
    
    .archive-toggle {
        margin-left: 0;
    }
}

/* ============================================================================
   ONBOARDING TOUR
   ============================================================================ */

.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.onboarding-tooltip {
    position: absolute;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    animation: tooltipFadeIn 0.3s ease;
}

.onboarding-tooltip.centered {
    position: relative;
}

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

.onboarding-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.onboarding-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.onboarding-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.onboarding-close:hover {
    background: var(--bg-alt);
    color: var(--text-primary);
}

.onboarding-content {
    padding: 20px 24px;
    color: var(--text-primary);
    line-height: 1.6;
}

.onboarding-content p {
    margin: 0 0 12px;
}

.onboarding-content p:last-child {
    margin-bottom: 0;
}

.onboarding-content ul,
.onboarding-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.onboarding-content li {
    margin: 6px 0;
}

.onboarding-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-alt);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.onboarding-progress {
    display: flex;
    gap: 6px;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.2s ease;
}

.progress-dot.active {
    background: var(--primary);
    transform: scale(1.2);
}

.progress-dot.completed {
    background: var(--success);
}

.onboarding-actions {
    display: flex;
    gap: 8px;
}

/* Highlight effect for tour targets */
.onboarding-highlight {
    position: relative;
    z-index: 10001;
    box-shadow: 0 0 0 4px var(--primary), 0 0 20px rgba(37, 99, 235, 0.4);
    border-radius: var(--radius-md);
    animation: highlightPulse 2s ease infinite;
}

@keyframes highlightPulse {
    0%, 100% {
        box-shadow: 0 0 0 4px var(--primary), 0 0 20px rgba(37, 99, 235, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px var(--primary), 0 0 30px rgba(37, 99, 235, 0.6);
    }
}

/* Tooltip arrow */
.onboarding-tooltip.right::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 30px;
    border: 10px solid transparent;
    border-right-color: white;
}

.onboarding-tooltip.bottom::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 30px;
    border: 10px solid transparent;
    border-bottom-color: white;
}

@media (max-width: 768px) {
    .onboarding-tooltip {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        right: auto !important;
        margin: 20px;
    }
    
    .onboarding-tooltip::before {
        display: none;
    }
}

/* Help button for restarting tour */
.help-tour-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.help-tour-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(37, 99, 235, 0.4);
}

/* ============================================================================
   ENHANCED ANALYTICS
   ============================================================================ */

/* Lesson Progress Bar (3-segment) */
.progress-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lesson-progress-bar {
    display: flex;
    width: 80px;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.lesson-progress-bar .segment {
    height: 100%;
    transition: width 0.3s ease;
}

.lesson-progress-bar .segment.completed {
    background: var(--success);
}

.lesson-progress-bar .segment.in-progress {
    background: var(--warning);
}

.lesson-progress-bar .segment.not-started {
    background: #d1d5db;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 36px;
}

.progress-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
}

.legend-dot.completed { background: var(--success); }
.legend-dot.in-progress { background: var(--warning); }
.legend-dot.not-started { background: #d1d5db; }

/* Misconception indicator */
.misconception-indicator {
    margin-left: 6px;
    cursor: help;
}

/* Status badges - enhanced */
.status-badge.not-started {
    background: #f3f4f6;
    color: #6b7280;
}

.status-badge.in-progress {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.no-lessons {
    background: #e5e7eb;
    color: #6b7280;
}

/* Attention list - enhanced */
.attention-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.attention-item:hover {
    background: #f1f5f9;
}

.attention-item.not-started {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.attention-item.misconception {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

.attention-item.struggling {
    border-left-color: #f97316;
    background: #fff7ed;
}

.attention-item.inactive {
    border-left-color: #6b7280;
    background: #f9fafb;
}

.attention-icon {
    font-size: 1.2rem;
}

.attention-info {
    display: flex;
    flex-direction: column;
}

.attention-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.attention-reason {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Lesson Progress View */
.lesson-progress-header {
    margin-bottom: 16px;
}

.lesson-progress-header h4 {
    margin: 0 0 4px;
}

.section-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

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

.lesson-progress-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lesson-progress-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.lp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.lp-topic {
    font-weight: 500;
    font-size: 0.95rem;
}

.lp-mastery {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    background: #f3f4f6;
}

.lp-mastery.high { background: #d1fae5; color: #065f46; }
.lp-mastery.medium { background: #fef3c7; color: #92400e; }
.lp-mastery.low { background: #fee2e2; color: #991b1b; }

.lp-bar {
    display: flex;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.lp-fill {
    height: 100%;
}

.lp-fill.completed { background: var(--success); }
.lp-fill.in-progress { background: var(--warning); }

.lp-stats {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
}

.lp-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

/* Lesson Progress Detail Modal */
.lesson-progress-detail {
    max-height: 400px;
    overflow-y: auto;
}

.progress-section {
    margin-bottom: 20px;
    padding: 16px;
    border-radius: var(--radius-md);
}

.progress-section h4 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.progress-section.not-started {
    background: #fef2f2;
}

.progress-section.in-progress {
    background: #fffbeb;
}

.progress-section.completed {
    background: #f0fdf4;
}

.student-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.student-chip {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.9rem;
}

.student-chip:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.student-chip small {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.student-chip.high { border-color: var(--success); }
.student-chip.medium { border-color: var(--warning); }
.student-chip.low { border-color: var(--error); }

.student-chip .mastery-badge {
    font-weight: 600;
}

/* Student Detail - Lesson Status */
.lesson-status-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lesson-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-alt);
    border-radius: var(--radius-sm);
}

.lesson-status-row.completed {
    background: #f0fdf4;
}

.lesson-status-row.in-progress {
    background: #fffbeb;
}

.lesson-status-row.not-started {
    background: #f9fafb;
}

.lesson-status-icon {
    font-size: 1rem;
}

.lesson-status-topic {
    flex: 1;
    font-size: 0.9rem;
}

.lesson-mastery {
    font-weight: 600;
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 10px;
}

.lesson-mastery.high { background: #d1fae5; color: #065f46; }
.lesson-mastery.medium { background: #fef3c7; color: #92400e; }
.lesson-mastery.low { background: #fee2e2; color: #991b1b; }

.lesson-status-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Misconceptions Section */
.misconceptions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.misconception-group {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.misconception-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fef3c7;
    font-weight: 500;
}

.misconception-icon {
    font-size: 1.1rem;
}

.misconception-type {
    flex: 1;
}

.misconception-count {
    background: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
}

.misconception-items {
    padding: 12px;
}

.misconception-item {
    padding: 8px 0;
    border-bottom: 1px solid #fde68a;
}

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

.misconception-detail {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.misconception-intervention {
    font-size: 0.85rem;
    color: #0369a1;
    background: #e0f2fe;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    margin-top: 6px;
}

.more-items {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 8px 0 0;
}

/* Intervention Recommendations */
.intervention-recommendations {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recommendation {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    border-left: 4px solid;
}

.recommendation.high {
    background: #fef2f2;
    border-left-color: #ef4444;
}

.recommendation.medium {
    background: #fffbeb;
    border-left-color: #f59e0b;
}

.recommendation.success {
    background: #f0fdf4;
    border-left-color: #10b981;
}

.rec-icon {
    font-size: 1.2rem;
}

.rec-content {
    flex: 1;
}

.rec-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.rec-action {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.placeholder.success {
    color: var(--success);
}

/* ============================================================================
   CLASS INSIGHTS ROW
   ============================================================================ */

.analytics-insights-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .analytics-insights-row {
        grid-template-columns: 1fr;
    }
}

.class-misconceptions-section,
.class-trends-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

/* ============================================================================
   CLASS MISCONCEPTIONS
   ============================================================================ */

.class-misconceptions-header {
    margin-bottom: 16px;
}

.class-misconceptions-header h4 {
    margin: 0 0 4px;
    font-size: 1.1rem;
}

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

.class-misconception-card {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: var(--radius-md);
    padding: 12px 16px;
}

.cm-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.cm-icon {
    font-size: 1.1rem;
}

.cm-type {
    font-weight: 500;
    font-size: 0.9rem;
}

.cm-count {
    margin-left: auto;
    background: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #92400e;
}

.cm-detail {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.cm-intervention {
    font-size: 0.85rem;
    background: #e0f2fe;
    color: #0369a1;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.cm-students {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cm-student-chip {
    background: white;
    border: 1px solid #fde68a;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.misconception-type-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.type-summary-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.85rem;
}

.type-icon {
    font-size: 1rem;
}

.type-label {
    color: var(--text-primary);
}

.type-count {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ============================================================================
   TREND CHARTS
   ============================================================================ */

.trend-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.trend-header h4 {
    margin: 0;
    font-size: 1.1rem;
}

.trend-summary {
    display: flex;
    align-items: center;
    gap: 16px;
}

.trend-metric {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.trend-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.trend-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.trend-change {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1.1rem;
}

.trend-change.positive {
    background: #d1fae5;
    color: #065f46;
}

.trend-change.negative {
    background: #fee2e2;
    color: #991b1b;
}

.change-label {
    font-size: 0.7rem;
    font-weight: 400;
}

/* Bar Chart */
.trend-chart {
    margin-bottom: 16px;
}

.chart-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    height: 100px;
    gap: 4px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    position: relative;
}

.bar-container.today {
    background: rgba(37, 99, 235, 0.05);
    border-radius: var(--radius-sm);
}

.bar {
    width: 100%;
    max-width: 20px;
    border-radius: 2px 2px 0 0;
    transition: height 0.3s ease;
    margin-top: auto;
}

.bar.high {
    background: var(--success);
}

.bar.medium {
    background: var(--warning);
}

.bar.low {
    background: var(--error);
}

.bar-label {
    position: absolute;
    bottom: -18px;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}

.legend-color.high { background: var(--success); }
.legend-color.medium { background: var(--warning); }
.legend-color.low { background: var(--error); }

/* Activity Summary */
.activity-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
}

.activity-metric {
    display: flex;
    flex-direction: column;
}

.activity-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.activity-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.activity-change {
    font-size: 0.9rem;
    font-weight: 500;
}

.activity-change.positive {
    color: var(--success);
}

.activity-change.negative {
    color: var(--error);
}

/* ============================================================================
   STUDENT TABLE TREND COLUMN
   ============================================================================ */

.trend-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.trend-indicator.improving {
    background: #d1fae5;
}

.trend-indicator.declining {
    background: #fee2e2;
}

.trend-indicator.stable {
    background: #f3f4f6;
}

.trend-indicator.new {
    background: #e0f2fe;
}

.trend-value {
    font-size: 0.75rem;
    font-weight: 500;
}

.trend-indicator.improving .trend-value {
    color: #065f46;
}

.trend-indicator.declining .trend-value {
    color: #991b1b;
}

.trend-legend-separator {
    color: var(--border);
    margin: 0 8px;
}

/* ============================================================================
   STUDENT DETAIL TREND SECTION
   ============================================================================ */

.student-trend-section {
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.student-trend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.student-trend-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
}

.student-trend-indicator.improving {
    color: var(--success);
}

.student-trend-indicator.declining {
    color: var(--error);
}

.student-trend-indicator.stable {
    color: var(--text-secondary);
}

.week-comparison {
    display: flex;
    gap: 24px;
}

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

.week-value {
    font-size: 1.3rem;
    font-weight: 700;
}

.week-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ============================================================================
   MATH SYMBOL PALETTE (Student App)
   ============================================================================ */

.symbol-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.symbol-tab {
    padding: 6px 12px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s ease;
}

.symbol-tab:hover {
    background: var(--border);
}

.symbol-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.symbol-palette.hidden {
    display: none !important;
}

/* ============================================================================
   SCREEN READER ONLY TEXT
   ============================================================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================================
   SMART DIAGRAM SYSTEM - Semantically-driven visuals
   ============================================================================ */

.smart-diagram {
    padding: 24px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.smart-diagram-title {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.smart-diagram-formula {
    font-family: 'Times New Roman', serif;
    font-size: 1.1rem;
    text-align: center;
    margin-top: 16px;
    padding: 12px;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

/* Height Reference Diagram (for PE, projectile motion, etc.) */
.height-diagram .height-visual {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 20px;
    min-height: 200px;
    padding: 20px;
    position: relative;
}

.height-diagram .height-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 150px;
}

.height-diagram .height-label {
    font-weight: 600;
    color: #3b82f6;
    font-size: 1rem;
    margin-bottom: 8px;
}

.height-diagram .height-line {
    width: 3px;
    flex: 1;
    background: linear-gradient(to bottom, #3b82f6, #3b82f6 45%, transparent 45%, transparent 55%, #3b82f6 55%);
    background-size: 100% 10px;
    position: relative;
}

.height-diagram .height-line::before,
.height-diagram .height-line::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}

.height-diagram .height-line::before {
    top: 0;
    border-bottom: 10px solid #3b82f6;
}

.height-diagram .height-line::after {
    bottom: 0;
    border-top: 10px solid #3b82f6;
}

.height-diagram .height-object {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 24px;
    background: white;
    border: 2px solid #64748b;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.height-diagram .object-emoji {
    font-size: 2rem;
    margin-bottom: 8px;
}

.height-diagram .object-label {
    font-weight: 500;
    color: var(--text-primary);
}

.height-diagram .ground-line {
    position: absolute;
    bottom: 20px;
    left: 10%;
    right: 10%;
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        #22c55e,
        #22c55e 10px,
        #16a34a 10px,
        #16a34a 20px
    );
    border-radius: 2px;
}

.height-diagram .ground-label {
    position: absolute;
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: #16a34a;
    font-weight: 500;
    white-space: nowrap;
}

/* Energy Transfer Diagram */
.energy-transfer-diagram .energy-states-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    min-height: 200px;
    padding: 20px 0;
}

.energy-transfer-diagram .energy-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.energy-transfer-diagram .state-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.energy-transfer-diagram .state-bars {
    display: flex;
    gap: 4px;
    align-items: flex-end;
    height: 120px;
    padding: 8px;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.energy-transfer-diagram .state-bar {
    width: 40px;
    min-height: 10px;
    border-radius: 4px 4px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 4px;
    transition: height 0.3s ease;
}

.energy-transfer-diagram .bar-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.energy-transfer-diagram .bar-value {
    font-size: 0.7rem;
    color: white;
    font-weight: 500;
}

.energy-transfer-diagram .state-label {
    margin-top: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-secondary);
}

.energy-transfer-diagram .state-arrow {
    font-size: 2rem;
    color: #94a3b8;
    padding-bottom: 60px;
}

.energy-transfer-diagram .total-energy-note {
    text-align: center;
    margin-top: 16px;
    padding: 8px 16px;
    background: #fef3c7;
    border-radius: var(--radius-md);
    font-weight: 500;
    color: #92400e;
    font-size: 0.9rem;
}

/* Object with Arrow Diagram */
.object-arrow-diagram .object-arrow-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px 20px;
    min-height: 150px;
}

.object-arrow-diagram .central-object {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 32px;
    background: white;
    border: 3px solid #64748b;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 1;
}

.object-arrow-diagram .central-object .object-emoji {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.object-arrow-diagram .central-object .object-label {
    font-weight: 600;
    color: var(--text-primary);
}

.object-arrow-diagram .diagram-arrow {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.object-arrow-diagram .diagram-arrow .arrow-symbol {
    font-size: 2.5rem;
}

.object-arrow-diagram .diagram-arrow .arrow-label {
    font-size: 0.9rem;
}

.object-arrow-diagram .diagram-arrow.left {
    flex-direction: row-reverse;
}

.object-arrow-diagram .diagram-arrow.left .arrow-symbol {
    transform: rotate(180deg);
}

.object-arrow-diagram .diagram-arrow.up {
    flex-direction: column-reverse;
}

.object-arrow-diagram .diagram-arrow.up .arrow-symbol {
    transform: rotate(-90deg);
}

.object-arrow-diagram .diagram-arrow.down {
    flex-direction: column;
}

.object-arrow-diagram .diagram-arrow.down .arrow-symbol {
    transform: rotate(90deg);
}

/* Concept Card */
.concept-card {
    text-align: center;
}

.concept-card .concept-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.concept-card .concept-emoji {
    font-size: 2.5rem;
}

.concept-card .concept-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.concept-card .concept-description {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.concept-card .concept-formula {
    font-family: 'Times New Roman', serif;
    font-size: 1.2rem;
    padding: 12px 24px;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: inline-block;
}

.concept-card .concept-bullets {
    text-align: left;
    list-style: none;
    padding: 0;
    margin: 16px auto;
    max-width: 400px;
}

.concept-card .concept-bullets li {
    padding: 8px 0 8px 24px;
    position: relative;
    color: var(--text-secondary);
}

.concept-card .concept-bullets li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #22c55e;
    font-weight: bold;
}

/* Side by Side Comparison */
.side-by-side-diagram .side-by-side-content {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 16px;
    padding: 20px;
}

.side-by-side-diagram .side-panel {
    flex: 1;
    max-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 2px solid;
    text-align: center;
}

.side-by-side-diagram .panel-emoji {
    font-size: 2rem;
    margin-bottom: 12px;
}

.side-by-side-diagram .panel-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.side-by-side-diagram .panel-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.side-by-side-diagram .connector {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Diagram description fallback */
.diagram-description {
    padding: 24px;
    background: #f8fafc;
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border);
}

.diagram-description .description-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.diagram-description .description-icon {
    font-size: 1.5rem;
}

.diagram-description .description-content p {
    margin: 0;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.5;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .side-by-side-diagram .side-by-side-content {
        flex-direction: column;
    }
    
    .side-by-side-diagram .side-panel {
        max-width: 100%;
    }
    
    .side-by-side-diagram .connector {
        transform: rotate(90deg);
        padding: 8px 0;
    }
    
    .energy-transfer-diagram .energy-states-row {
        flex-wrap: wrap;
    }
    
    .height-diagram .height-visual {
        flex-direction: column;
        align-items: center;
    }
}

/* ============================================================================
   MARKDOWN TABLES
   ============================================================================ */

.table-wrapper {
    overflow-x: auto;
    margin: 16px 0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.markdown-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.9rem;
    min-width: 300px;
}

.markdown-table th,
.markdown-table td {
    padding: 10px 14px;
    text-align: left;
    border: 1px solid #e5e7eb;
    vertical-align: top;
}

.markdown-table th {
    background: linear-gradient(135deg, #1e40af 0%, #3730a3 100%);
    color: white;
    font-weight: 600;
}

.markdown-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.markdown-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.markdown-table td strong {
    color: #1e40af;
}

/* First column styling */
.markdown-table td:first-child {
    font-weight: 500;
}

/* Responsive table */
@media (max-width: 600px) {
    .markdown-table {
        font-size: 0.8rem;
    }
    
    .markdown-table th,
    .markdown-table td {
        padding: 6px 8px;
    }
}

/* Small inline spinner for buttons */
.spinner-small {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Edit status indicator */
.edit-status-text {
    display: block;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #64748b;
    text-align: center;
}
