/* JLearn Educational Platform Styles
 * Version: 3.2.0
 * Author: Junrel R. Sapanta
 * Description: Comprehensive styling for educational platform with mobile optimization
 * 
 * LATEST UPDATES v3.2.0:
 * - NUCLEAR CLOSE SYSTEM: Bulletproof document viewer close button
 * - Anti-hang detection system for Google Viewer
 * - Aggressive performance optimizations for iframe rendering
 * - Pulsing nuclear close button with highest z-index (99999999)
 * - Complete iframe performance overhaul
 * - Emergency force close with page reload fallback
 * - Hardware acceleration and GPU optimization
 * - Cross-platform compatibility for all devices
 * 
 * PREVIOUS UPDATES v3.1.0:
 * - Ultimate floating close button for document viewer
 * - Enhanced iframe performance optimizations
 * - Submit assessment button sticky positioning removed
 * - Cross-platform compatibility improvements
 * - Hardware acceleration for smooth scrolling
 * - Emergency recovery systems implemented
 */

/* Root Variables */
:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --secondary-color: #06b6d4;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --hover-bg: #f1f5f9;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #312e81;
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --text-color: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --hover-bg: #334155;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: var(--transition);
    font-size: 16px; /* ✅ Standard base font size for better mobile readability */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

.navbar {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Hide mobile menu elements on desktop */
.mobile-menu-toggle,
.mobile-menu-overlay {
    display: none;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
}

.nav-brand i {
    font-size: 1.8rem;
}

.nav-links, .nav-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
}

.theme-toggle:hover {
    background-color: var(--bg-color);
}

.hero {
    padding: 4rem 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.hero-content {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.hero-illustration {
    text-align: center;
    margin-top: 3rem;
}

.hero-illustration i {
    font-size: 8rem;
    opacity: 0.2;
}

.features {
    padding: 4rem 0;
}

.features h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature-card {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

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

.feature-card i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.feature-card h3 {
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--text-secondary);
}

.feature-card p.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-height: 40px; /* Ensure consistent button height */
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 40px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    text-decoration: none;
}

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

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

.btn-primary:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-secondary:hover {
    background-color: #0891b2;
    transform: translateY(-2px);
}

.btn-secondary:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

.btn-secondary:active {
    transform: translateY(0);
}

.btn-text {
    background: none;
    color: var(--text-color);
}

.btn-text:hover {
    background-color: var(--bg-color);
}

.btn-text:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Disabled button states */
.btn:disabled,
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    pointer-events: none;
}

/* Button loading state */
.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

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

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-success {
    background-color: #10b981;
    color: white;
}

.btn-success:hover {
    background-color: #059669;
    transform: translateY(-2px);
}

.btn-info {
    background-color: #3b82f6;
    color: white;
}

.btn-info:hover {
    background-color: #2563eb;
    transform: translateY(-2px);
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

.login-container {
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
}

.login-card {
    background-color: var(--surface-color);
    padding: 3rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 450px;
    width: 100%;
}

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

.login-header i {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.login-header h2 {
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
}

.login-help {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--bg-color);
    border-radius: var(--radius);
    text-align: center;
    font-size: 0.9rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.format-guide {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--bg-color);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius);
}

.format-guide strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.5rem;
}

.format-guide ul {
    margin: 0;
    padding-left: 1.5rem;
}

.format-guide li {
    margin-bottom: 0.5rem;
    color: var(--text-color);
    line-height: 1.6;
}

.format-guide li strong {
    display: inline;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
    background-color: var(--surface-color);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

.error-message {
    white-space: pre-line;
    line-height: 1.6;
    text-align: left;
    max-width: 100%;
    word-wrap: break-word;
    margin: 1rem 0;
    padding: 1.5rem;
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    color: #991b1b;
    border-radius: 12px;
    border-left: 5px solid #dc2626;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.15);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.95rem;
    display: none;
    animation: slideIn 0.3s ease-out;
}

.error-message.show {
    display: block;
}

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

/* Mobile responsive error messages */
@media (max-width: 768px) {
    .error-message {
        font-size: 0.9rem;
        padding: 1rem;
        margin: 0.5rem 0;
        border-radius: 8px;
    }
}

.success-message {
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: #d4edda;
    color: #155724;
    border-radius: var(--radius);
    border: 1px solid #c3e6cb;
}

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

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

.login-footer a {
    text-decoration: none;
    transition: opacity 0.3s ease;
}

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

.lesson-container {
    padding: 2rem 0;
    min-height: calc(100vh - 80px);
}

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

.lesson-progress {
    margin-top: 1rem;
    color: var(--text-secondary);
}

.video-section {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.video-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.video-wrapper video {
    width: 100%;
    border-radius: var(--radius);
}

#youtube-player-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%; /* Full width on all devices */
}

#youtube-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--radius);
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: white;
    border-radius: var(--radius);
}

.video-overlay i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* OLD fullscreen button (inside video) - DEPRECATED */
.fullscreen-btn {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* NEW fullscreen button (outside video player) */
.fullscreen-btn-external {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.fullscreen-btn-external:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.fullscreen-btn-external:active {
    transform: translateY(0);
}

.fullscreen-btn-external i {
    font-size: 1.2rem;
}

/* Mobile Auto-Rotate Notice */
.mobile-rotate-notice {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    animation: slideIn 0.5s ease-out;
}

.mobile-rotate-notice i {
    font-size: 1.5rem;
    flex-shrink: 0;
}

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

.video-wrapper:fullscreen .fullscreen-btn i::before,
.video-wrapper:fullscreen .fullscreen-btn-external i::before {
    content: "\f066"; /* fa-compress icon */
}

.video-wrapper:-webkit-full-screen .fullscreen-btn i::before,
.video-wrapper:-webkit-full-screen .fullscreen-btn-external i::before {
    content: "\f066";
}

.video-wrapper:-moz-full-screen .fullscreen-btn i::before,
.video-wrapper:-moz-full-screen .fullscreen-btn-external i::before {
    content: "\f066";
}

.video-wrapper:-ms-fullscreen .fullscreen-btn i::before,
.video-wrapper:-ms-fullscreen .fullscreen-btn-external i::before {
    content: "\f066";
}

.video-info {
    margin-top: 1rem;
    text-align: center;
}

/* Video Complete Section */
.video-complete-section {
    max-width: 600px;
    margin: 2rem auto;
}

.completion-card {
    background-color: var(--surface-color);
    padding: 3rem 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.completion-icon {
    font-size: 4rem;
    color: var(--success-color);
    margin-bottom: 1.5rem;
}

.completion-card h3 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.completion-card p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.completion-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    min-width: 200px;
}

/* Assessment Instructions */
.instructions-content {
    margin-bottom: 1.5rem;
}

.instruction-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--bg-color);
    border-radius: var(--radius);
    align-items: flex-start;
}

.instruction-item > i {
    font-size: 1.5rem;
    color: var(--primary-color);
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.instruction-item strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-size: 1.05rem;
}

.instruction-item p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.instruction-item ul {
    margin: 0.5rem 0 0 0;
    padding-left: 1.5rem;
}

.instruction-item li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.instructions-warning {
    padding: 1rem;
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: var(--radius);
    color: #856404;
    line-height: 1.6;
}

[data-theme="dark"] .instructions-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

/* Assessment Tabs */
.assessment-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.75rem 1rem;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: var(--primary-color);
    background-color: var(--bg-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.tab-btn i {
    font-size: 1rem;
}

.assessment-tab-content {
    display: none;
}

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

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

/* Assessment Pages System */
.assessment-pages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--bg-color);
    border-radius: var(--radius);
}

.pages-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
}

.page-tab {
    padding: 0.75rem 1.25rem;
    background-color: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.page-tab.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

#assessment-pages-container {
    position: relative;
}

.assessment-page {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.assessment-page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--bg-color);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
}

.page-header h4 {
    margin: 0;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.video-progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.assessment-section {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.assessment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.quiz-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.question-card {
    background-color: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.question-text {
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

.question-number {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.15rem;
}

.answer-option {
    display: flex;
    align-items: center;
    padding: 1rem;
    background-color: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.answer-option:hover {
    border-color: var(--primary-color);
}

.answer-option input[type="radio"] {
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.option-letter {
    font-weight: 700;
    color: var(--primary-color);
    margin-right: 0.75rem;
    font-size: 1.05rem;
    flex-shrink: 0;
    min-width: 30px;
}

.option-text {
    flex: 1;
    line-height: 1.5;
}

.results-section {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.results-card {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.results-icon {
    font-size: 5rem;
    color: var(--success-color);
    margin-bottom: 1rem;
}

.score-display {
    margin: 2rem 0;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.score-circle span {
    font-size: 2.5rem;
    font-weight: bold;
    color: white;
}

.results-details {
    text-align: left;
    margin: 2rem 0;
}

.dashboard-container {
    min-height: calc(100vh - 80px);
}

.dashboard-container .container {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    padding-top: 2rem;
}

.dashboard-sidebar {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 100px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-item {
    padding: 1rem;
    border: none;
    background: none;
    text-align: left;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-color);
    font-size: 1rem;
}

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

.menu-item.active {
    background-color: var(--primary-color);
    color: white;
}

.dashboard-content {
    min-height: 500px;
}

.dashboard-section {
    display: none;
}

.dashboard-section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

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

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

.stat-card i {
    font-size: 3rem;
    color: var(--primary-color);
}

.stat-info h3 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.stat-info p {
    color: var(--text-secondary);
}

.table-container {
    background-color: var(--surface-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background-color: var(--bg-color);
}

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 600;
}

.data-table tbody tr:hover {
    background-color: var(--bg-color);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

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

.lesson-card {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

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

.lesson-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.lesson-code {
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.lesson-card-body h3 {
    margin-bottom: 0.5rem;
}

.lesson-card-footer {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

.empty-state-card {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state-card i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.group-header {
    background-color: var(--primary-color) !important;
}

.group-header td {
    background-color: var(--primary-color) !important;
    color: white !important;
    font-weight: 600 !important;
    padding: 0.75rem !important;
}

.group-header:hover {
    background-color: var(--primary-dark) !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 999;
}

.modal-overlay.active {
    display: block;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--surface-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    display: none;
    z-index: 1000;
}

.modal.active {
    display: block;
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

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

.modal form, .result-details-content {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ========================================
   MOBILE & TABLET RESPONSIVE STYLES
   ======================================== */

/* Tablet Styles (768px - 1024px) */
@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }
    
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .modal-content {
        max-width: 90%;
        margin: 2rem auto;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-row .form-group {
        width: 100%;
    }
}

/* Mobile Styles (max-width: 768px) - STUDENT PORTAL ONLY */
@media (max-width: 768px) {
    /* Typography */
    .hero h1 {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    h4 {
        font-size: 1.1rem;
    }
    
    /* Navigation */
    .navbar {
        padding: 0.75rem 0;
    }
    
    .nav-brand {
        font-size: 1.25rem;
    }
    
    .nav-brand i {
        font-size: 1.5rem;
    }
    
    .nav-links {
        gap: 0.5rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .hero-buttons .btn {
        width: 100%;
    }
    
    /* Feature Grid */
    .feature-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-control, textarea, select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    textarea {
        min-height: 150px;
    }
    
    /* Login/Register */
    .login-container {
        padding: 1rem;
    }
    
    .login-card {
        padding: 1.5rem;
    }
    
    /* Video Section - BIGGER */
    #video-container {
        height: auto;
        max-height: 75vh; /* ✅ Bigger video player */
    }
    
    .video-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .video-controls .btn {
        flex: 1;
        min-width: 120px;
    }
    
    /* Assessment */
    .question-card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .answer-option {
        padding: 0.75rem;
        font-size: 0.95rem;
    }
    
    .quiz-navigation {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .quiz-navigation .btn {
        width: 100%;
    }
    
    .page-indicator {
        order: -1;
        text-align: center;
        padding: 0.75rem;
    }
    
    /* Assessment Pages */
    .assessment-pages-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .pages-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }
    
    .page-tab {
        white-space: nowrap;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .page-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    /* Materials */
    .material-field {
        padding: 1rem !important;
    }
    
    .materials-grid {
        grid-template-columns: 1fr;
    }
    
    /* Results */
    .result-details-content {
        padding: 1rem;
    }
    
    /* Timer */
    .quiz-timer {
        font-size: 1.25rem;
        padding: 0.75rem;
    }
    
    /* Student Portal - Lesson View */
    .lesson-header {
        padding: 1rem;
    }
    
    .lesson-header h2 {
        font-size: 1.35rem;
        margin-bottom: 0.5rem;
    }
    
    .lesson-meta {
        font-size: 0.9rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .lesson-content {
        padding: 1rem;
    }
    
    .content-section {
        margin-bottom: 1.5rem;
    }
    
    .content-section h3 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }
    
    /* Student Info Display */
    .student-info {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    /* Materials Section */
    .materials-list {
        gap: 0.75rem;
    }
    
    .material-item {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .material-item i {
        font-size: 1.25rem;
    }
    
    /* Lesson Status */
    #lesson-status {
        font-size: 0.95rem;
        padding: 0.75rem;
    }
}

/* Small Mobile Styles (max-width: 480px) */
@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .nav-brand {
        font-size: 1.1rem;
    }
    
    .nav-brand span {
        display: none;
    }
    
    .btn {
        padding: 0.65rem 1rem;
        font-size: 0.9rem;
    }
    
    .modal-content {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
    
    /* Dashboard - DESKTOP ONLY (No Small Mobile Styles) */
    
    /* Student Portal - Small Mobile */
    .lesson-header {
        padding: 0.75rem;
    }
    
    .lesson-header h2 {
        font-size: 1.2rem;
    }
    
    .lesson-meta {
        font-size: 0.85rem;
    }
    
    .lesson-content {
        padding: 0.75rem;
    }
    
    .student-info {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    #video-container {
        height: auto;
        max-height: 70vh; /* ✅ Bigger video player */
    }
    
    .question-number {
        font-size: 1rem;
    }
    
    .option-letter {
        min-width: 30px;
    }
    
    /* Tables and Buttons - DESKTOP ONLY (No Small Mobile Styles) */
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    #video-container {
        height: auto;
        max-height: 85vh; /* ✅ Bigger video player */
    }
    
    .modal-content {
        max-height: 95vh;
    }
}

/* Quiz Navigation Styles */
#quiz-navigation {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    align-items: center;
    flex-wrap: wrap;
    padding: 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Ensure assessment section has proper spacing on all devices */
#assessment-section {
    padding-bottom: 2rem;
}

/* Ensure questions don't get covered by submit button */
.question-container {
    margin-bottom: 2rem;
}

#page-indicator {
    text-align: center;
    color: var(--text-color);
    font-weight: bold;
    min-width: 120px;
}

#prev-page-btn,
#next-page-btn {
    flex: 1;
    min-width: 120px;
}

#submit-quiz-btn {
    width: 100%;
}

/* Mobile Quiz Navigation */
@media (max-width: 768px) {
    #quiz-navigation {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    #prev-page-btn,
    #next-page-btn,
    #submit-quiz-btn {
        width: 100%;
        flex: none;
    }
    
    #page-indicator {
        order: -1;
        width: 100%;
        padding: 0.5rem;
        background: var(--bg-secondary);
        border-radius: var(--radius);
    }
}

/* Fullscreen Button Mobile Fix */
.fullscreen-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.75rem 1.5rem;
}

@media (max-width: 768px) {
    .fullscreen-btn {
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* Touch-friendly improvements - STUDENT PORTAL ONLY */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets for student portal only */
    .btn:not(.dashboard-section .btn):not(.section-header .btn):not(.menu-item), .page-tab {
        min-height: 44px;
        min-width: 44px;
    }
    
    .answer-option {
        min-height: 50px;
    }
    
    input[type="radio"],
    input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
    
    /* Remove hover effects on touch devices - student portal only */
    .btn:not(.dashboard-section .btn):not(.section-header .btn):not(.menu-item):hover {
        transform: none;
    }
    
    /* Add active states for touch feedback - student portal only */
    .btn:not(.dashboard-section .btn):not(.section-header .btn):not(.menu-item):active {
        transform: scale(0.98);
    }
}

/* ============================================ */
/* COMPREHENSIVE MOBILE IMPROVEMENTS */
/* ============================================ */

/* Navbar Mobile Improvements */
@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem 0;
    }
    
    .nav-brand {
        font-size: 1.25rem;
    }
    
    .nav-links {
        gap: 0.5rem;
    }
    
    .nav-links .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* Login/Register Mobile */
@media (max-width: 768px) {
    .login-container {
        padding: 1rem;
        min-height: 100vh;
        display: flex;
        align-items: center;
    }
    
    .login-card {
        width: 100%;
        max-width: 100%;
        padding: 1.5rem;
        margin: 0;
    }
    
    .login-card h2 {
        font-size: 1.5rem;
    }
    
    .form-tabs {
        gap: 0.5rem;
    }
    
    .form-tab {
        flex: 1;
        padding: 0.75rem;
        font-size: 0.95rem;
    }
}

/* ============================================ */
/* TEACHER DASHBOARD MOBILE-FIRST DESIGN */
/* ============================================ */

/* Mobile Navigation & Hamburger Menu */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

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

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 80px; /* Start below navbar */
    left: 280px; /* Start after sidebar width */
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040; /* Lower than sidebar but higher than content */
    opacity: 0;
    transition: opacity 0.3s ease;
    /* Only allow clicks on the overlay itself, not on sidebar area */
    pointer-events: auto;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
    /* When active, cover the area to the right of sidebar */
    left: 280px;
}

/* Mobile Dashboard Layout - Enhanced Scrolling */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Ensure full viewport scrolling */
    body {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        /* Safe area support */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .dashboard-container {
        /* Ensure container can scroll */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* Full height minus navbar */
        min-height: calc(100vh - 80px);
    }
    
    .dashboard-container .container {
        grid-template-columns: 1fr;
        gap: 0;
        padding-top: 0;
        /* Ensure content doesn't get cut off */
        padding-bottom: 2rem;
    }
    
    .dashboard-sidebar {
        position: fixed;
        top: 80px; /* Start below navbar */
        left: -280px;
        width: 280px;
        height: calc(100vh - 80px); /* Adjust height to account for navbar */
        background-color: var(--surface-color);
        z-index: 9998 !important; /* Maximum z-index */
        transition: left 0.3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        padding: 1rem;
        /* Force sidebar to be interactive */
        pointer-events: auto !important;
        /* Debug background */
        border: 2px solid red !important;
    }
    
    .dashboard-sidebar.active {
        left: 0;
        /* Ensure active sidebar is fully interactive */
        pointer-events: auto;
    }
    
    .sidebar-menu {
        flex-direction: column;
        gap: 0.5rem;
        padding-top: 0.5rem; /* Reduced since sidebar now starts below navbar */
        /* Ensure menu is interactive */
        pointer-events: auto;
    }
    
    .menu-item {
        width: 100% !important;
        padding: 1rem !important;
        text-align: left !important;
        border-radius: 8px !important;
        font-size: 1rem !important;
        min-height: 48px !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.75rem !important;
        transition: all 0.2s ease !important;
        /* Force button properties */
        background: none !important;
        border: none !important;
        color: var(--text-color) !important;
        font-family: inherit !important;
        /* Enhanced touch interaction */
        cursor: pointer !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        user-select: none !important;
        -webkit-user-select: none !important;
        /* Ensure always clickable */
        position: relative !important;
        z-index: 1060 !important; /* Higher than sidebar */
    }
    
    .menu-item i {
        font-size: 1.2rem;
        width: 20px;
        text-align: center;
    }
    
    .menu-item:hover {
        background-color: var(--bg-color) !important;
        transform: translateX(4px) !important;
    }
    
    .menu-item.active {
        background-color: var(--primary-color) !important;
        color: white !important;
        box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3) !important;
    }
    
    .menu-item:active {
        transform: scale(0.98) !important;
        background-color: var(--primary-color) !important;
        color: white !important;
    }
    
    .dashboard-content {
        padding: 1rem;
        margin-top: 0;
        /* Enhanced scrolling for dashboard content */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        /* Ensure content doesn't get cut off by mobile UI */
        padding-bottom: 2rem;
        /* Safe area support */
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }
    
    /* Dashboard sections scroll optimization */
    .dashboard-section {
        /* Ensure sections can scroll if content is long */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* Better scroll performance */
        will-change: scroll-position;
    }
}

/* Mobile Stats Grid */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.5rem;
        display: flex;
        align-items: center;
        gap: 1rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: transform 0.2s ease;
    }
    
    .stat-card:active {
        transform: scale(0.98);
    }
    
    .stat-card i {
        font-size: 2.5rem;
        color: var(--primary-color);
        flex-shrink: 0;
    }
    
    .stat-info {
        flex: 1;
    }
    
    .stat-info h3 {
        font-size: 2rem;
        margin-bottom: 0.25rem;
        color: var(--primary-color);
    }
    
    .stat-info p {
        font-size: 0.9rem;
        color: var(--text-secondary);
        margin: 0;
    }
}

@media (max-width: 480px) {
    .stat-card {
        flex-direction: column;
        text-align: center;
        padding: 1.25rem;
    }
    
    .stat-card i {
        font-size: 3rem;
    }
    
    .stat-info h3 {
        font-size: 2.5rem;
    }
}

/* Mobile Section Headers */
@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        padding: 1rem;
        background-color: var(--surface-color);
        border-radius: 12px;
        margin-bottom: 1.5rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    .section-header h2 {
        font-size: 1.4rem;
        margin-bottom: 0;
        color: var(--text-color);
    }
    
    .section-header > div {
        display: flex;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .section-header .btn {
        flex: 1;
        min-width: 140px;
        min-height: 48px;
        font-size: 0.9rem;
        font-weight: 600;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        transition: all 0.2s ease;
    }
    
    .section-header .btn:active {
        transform: scale(0.98);
    }
}

/* Mobile Lessons Grid */
@media (max-width: 768px) {
    .lessons-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .lesson-card {
        padding: 1.5rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
    }
    
    .lesson-card:active {
        transform: scale(0.98);
    }
    
    .lesson-card-header {
        flex-wrap: wrap;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .lesson-card-body h3 {
        font-size: 1.2rem;
        margin-bottom: 0.75rem;
        line-height: 1.3;
    }
    
    .lesson-info {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
        color: var(--text-secondary);
    }
    
    .lesson-card-footer {
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1.25rem;
    }
    
    .lesson-card-footer .btn {
        width: 100%;
        min-height: 48px;
        font-size: 0.9rem;
        font-weight: 600;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }
}

/* Mobile Dashboard Tables - Compact Design with Scrolling */
@media (max-width: 768px) {
    /* Students, In Progress, Results Tables - NO STICKY BUTTONS */
    #students-section .table-container,
    #in-progress-section .table-container,
    #results-section-teacher .table-container {
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        border-radius: 8px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
        /* Enhanced scroll performance */
        will-change: scroll-position;
        /* Compact height for more content visibility */
        max-height: 65vh;
        scroll-behavior: smooth;
        /* Compact spacing */
        font-size: 0.8rem;
    }
    
    /* Compact table design for dashboard tabs */
    #students-section .data-table,
    #in-progress-section .data-table,
    #results-section-teacher .data-table {
        min-width: 600px;
        font-size: 0.75rem; /* Smaller font */
        line-height: 1.3;
    }
    
    #students-section .data-table th,
    #in-progress-section .data-table th,
    #results-section-teacher .data-table th {
        padding: 0.5rem 0.4rem; /* Reduced padding */
        font-size: 0.7rem; /* Smaller header font */
        font-weight: 600;
        text-align: left;
        background-color: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color); /* Thinner border */
        white-space: nowrap;
        /* NO STICKY - Let it scroll naturally */
        position: static;
        z-index: auto;
    }
    
    #students-section .data-table td,
    #in-progress-section .data-table td,
    #results-section-teacher .data-table td {
        padding: 0.4rem 0.4rem; /* Very compact padding */
        white-space: nowrap;
        border-bottom: 1px solid var(--border-color);
        font-size: 0.75rem; /* Smaller content font */
        line-height: 1.2;
    }
    
    /* Other tables keep normal styling */
    .data-table:not(#students-section .data-table):not(#in-progress-section .data-table):not(#results-section-teacher .data-table) {
        min-width: 700px;
        font-size: 0.9rem;
    }
    
    .data-table th:not(#students-section .data-table th):not(#in-progress-section .data-table th):not(#results-section-teacher .data-table th) {
        padding: 1rem 0.75rem;
        font-size: 0.85rem;
        font-weight: 600;
        text-align: left;
        background-color: var(--bg-secondary);
        border-bottom: 2px solid var(--border-color);
        white-space: nowrap;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .data-table td:not(#students-section .data-table td):not(#in-progress-section .data-table td):not(#results-section-teacher .data-table td) {
        padding: 1rem 0.75rem;
        white-space: nowrap;
        border-bottom: 1px solid var(--border-color);
    }
    
    /* Compact buttons for dashboard tables - NO STICKY */
    #students-section .data-table .btn,
    #in-progress-section .data-table .btn,
    #results-section-teacher .data-table .btn {
        padding: 0.3rem 0.5rem; /* Much smaller padding */
        font-size: 0.7rem; /* Smaller font */
        min-width: 36px; /* Smaller width */
        min-height: 36px; /* Smaller height */
        margin: 0.1rem; /* Reduced margin */
        border-radius: 6px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;
        /* NO STICKY - scroll naturally */
        position: static;
        z-index: auto;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    }
    
    #students-section .data-table .btn i,
    #in-progress-section .data-table .btn i,
    #results-section-teacher .data-table .btn i {
        font-size: 0.8rem; /* Smaller icons */
        pointer-events: none;
    }
    
    #students-section .data-table td:last-child,
    #in-progress-section .data-table td:last-child,
    #results-section-teacher .data-table td:last-child {
        min-width: 120px; /* Narrower action column */
        text-align: center;
        /* NO STICKY - let it scroll with content */
        position: static;
        background: transparent;
        border-left: none;
    }
    
    /* Other table buttons keep normal styling */
    .data-table .btn:not(#students-section .data-table .btn):not(#in-progress-section .data-table .btn):not(#results-section-teacher .data-table .btn) {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
        min-width: 48px;
        min-height: 48px;
        margin: 0.25rem;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;
        position: relative;
        z-index: 10;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .data-table .btn:active {
        transform: scale(0.95);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    }
    
    .data-table .btn:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 1px;
    }
    
    .data-table .btn i:not(#students-section .data-table .btn i):not(#in-progress-section .data-table .btn i):not(#results-section-teacher .data-table .btn i) {
        font-size: 1rem;
        pointer-events: none;
    }
    
    .data-table td:last-child:not(#students-section .data-table td:last-child):not(#in-progress-section .data-table td:last-child):not(#results-section-teacher .data-table td:last-child) {
        min-width: 160px;
        text-align: center;
        position: sticky;
        right: 0;
        background: var(--surface-color);
        border-left: 1px solid var(--border-color);
    }
}

/* Mobile Dashboard Sections - Compact Design */
@media (max-width: 768px) {
    /* Compact section headers for Students, In Progress, Results */
    #students-section .section-header,
    #in-progress-section .section-header,
    #results-section-teacher .section-header {
        padding: 0.75rem !important;
        margin-bottom: 0.5rem !important;
        background: var(--surface-color) !important;
        border-radius: 8px !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    }
    
    #students-section .section-header h2,
    #in-progress-section .section-header h2,
    #results-section-teacher .section-header h2 {
        font-size: 1.1rem !important; /* Smaller header */
        margin: 0 !important;
    }
    
    /* Compact search containers */
    #students-section .dashboard-section > div[style*="padding"],
    #in-progress-section .dashboard-section > div[style*="padding"],
    #results-section-teacher .dashboard-section > div[style*="padding"] {
        padding: 0.75rem !important;
        background: var(--surface-color) !important;
        border-radius: 8px !important;
        margin-bottom: 0.75rem !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    }
    
    /* Other sections keep normal styling */
    .dashboard-section > div[style*="padding"]:not(#students-section .dashboard-section > div):not(#in-progress-section .dashboard-section > div):not(#results-section-teacher .dashboard-section > div) {
        padding: 1rem !important;
        background: var(--surface-color) !important;
        border-radius: 12px !important;
        margin-bottom: 1.5rem !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
    }
    
    /* Compact search inputs for dashboard tabs */
    #student-search-input,
    #progress-search-input,
    #results-search-input {
        width: 100% !important;
        min-height: 40px !important; /* Smaller height */
        padding: 0.6rem 0.75rem !important; /* Reduced padding */
        font-size: 14px !important; /* Smaller font but still prevents iOS zoom */
        border: 1px solid var(--border-color) !important;
        border-radius: 6px !important; /* Smaller radius */
        background-color: var(--bg-color) !important;
        transition: all 0.2s ease !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important; /* Subtler shadow */
    }
    
    #student-search-input:focus,
    #progress-search-input:focus,
    #results-search-input:focus {
        outline: none !important;
        border-color: var(--primary-color) !important;
        box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1), 0 1px 2px rgba(0, 0, 0, 0.1) !important; /* Smaller focus ring */
        transform: translateY(-1px) !important;
    }
}

/* Mobile Progress & Results Sections */
@media (max-width: 768px) {
    /* Progress section optimizations */
    #in-progress-section .table-container,
    #results-section-teacher .table-container {
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }
    
    /* Results table mobile optimization */
    #results-section-teacher .data-table {
        min-width: 800px; /* Wider for more columns */
    }
    
    /* Empty state improvements */
    .empty-state,
    .empty-state-card {
        padding: 2rem 1rem !important;
        text-align: center !important;
        color: var(--text-secondary) !important;
        font-size: 1rem !important;
        border-radius: 12px !important;
        background: var(--surface-color) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
    }
    
    .empty-state-card i {
        font-size: 3rem !important;
        color: var(--text-secondary) !important;
        margin-bottom: 1rem !important;
        opacity: 0.5 !important;
    }
}

/* Mobile Responsive Improvements for Small Screens */
@media (max-width: 480px) {
    .dashboard-content {
        padding: 0.75rem;
    }
    
    .section-header {
        padding: 0.75rem;
    }
    
    .section-header h2 {
        font-size: 1.25rem;
    }
    
    .section-header .btn {
        min-width: 120px;
        font-size: 0.85rem;
        padding: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .lesson-card {
        padding: 1.25rem;
    }
    
    .modal-header {
        padding: 0.75rem 1rem !important;
    }
    
    .modal-body,
    .modal form {
        padding: 1rem !important;
        padding-bottom: 5rem !important;
    }
    
    .modal-actions {
        padding: 0.75rem 1rem !important;
    }
}

/* Mobile Teacher Dashboard Modals - CRITICAL SCROLLING FIX */
@media (max-width: 768px) {
    /* LESSON MODALS: Create & Edit - Full Scrolling Access */
    #add-lesson-modal,
    #edit-lesson-modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        transform: none !important;
        z-index: 1001 !important;
        /* CRITICAL: Full modal scrolling to access ALL buttons */
        overflow-y: scroll !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        scroll-behavior: smooth !important;
        will-change: scroll-position !important;
        /* Ensure content flows naturally */
        display: block !important;
        padding: 0 !important;
    }
    
    /* All other modals - Enhanced scrolling */
    .modal:not(#add-lesson-modal):not(#edit-lesson-modal) {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        transform: none !important;
        display: flex !important;
        flex-direction: column !important;
        z-index: 1001 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        scroll-behavior: smooth !important;
        will-change: scroll-position !important;
    }
    
    /* Lesson modal active states */
    #add-lesson-modal.active,
    #edit-lesson-modal.active {
        display: block !important;
    }
    
    .modal.active {
        display: flex !important;
    }
    
    .modal:not(.active) {
        display: none !important;
    }
    
    /* LESSON MODAL CONTENT: Ensure all content is scrollable and accessible */
    #add-lesson-modal .modal-header,
    #edit-lesson-modal .modal-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 1010 !important;
        background: var(--surface-color) !important;
        border-bottom: 1px solid var(--border-color) !important;
        padding: 1rem 1.5rem !important;
        flex-shrink: 0 !important;
    }
    
    #add-lesson-modal .modal-body,
    #edit-lesson-modal .modal-body,
    #add-lesson-modal form,
    #edit-lesson-modal form {
        padding: 1.5rem !important;
        padding-bottom: 2rem !important;
        /* Allow natural content flow */
        overflow: visible !important;
        min-height: auto !important;
        flex: none !important;
    }
    
    #add-lesson-modal .modal-actions,
    #edit-lesson-modal .modal-actions {
        position: relative !important;
        background: var(--surface-color) !important;
        border-top: 1px solid var(--border-color) !important;
        padding: 1.5rem !important;
        margin-top: 1rem !important;
        /* Ensure buttons are always accessible */
        flex-shrink: 0 !important;
        display: flex !important;
        flex-direction: column-reverse !important;
        gap: 0.75rem !important;
    }
    
    /* LESSON MODAL BUTTONS: Always accessible via scroll */
    #add-lesson-modal .modal-actions .btn,
    #edit-lesson-modal .modal-actions .btn {
        width: 100% !important;
        min-height: 52px !important;
        font-size: 1rem !important;
        font-weight: 600 !important;
        border-radius: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        transition: all 0.2s ease !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        /* Ensure buttons are always clickable */
        pointer-events: auto !important;
        position: relative !important;
        z-index: 1020 !important;
    }
    
    #add-lesson-modal .modal-actions .btn:active,
    #edit-lesson-modal .modal-actions .btn:active {
        transform: scale(0.98) !important;
    }
    
    /* Modal Header - Sticky */
    .modal-header {
        flex-shrink: 0 !important;
        padding: 1rem 1.5rem !important;
        background: var(--surface-color) !important;
        border-bottom: 1px solid var(--border-color) !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 20 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: wrap !important;
        gap: 1rem !important;
    }
    
    .modal-header h3 {
        font-size: 1.3rem !important;
        margin: 0 !important;
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    .modal-header .btn {
        flex-shrink: 0 !important;
        min-height: 44px !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
        border-radius: 8px !important;
    }
    
    /* Modal Body - Enhanced Scrolling Support */
    .modal-body,
    .modal form {
        flex: 1 !important;
        /* Allow content to expand and scroll naturally */
        overflow: visible !important;
        padding: 1.5rem !important;
        padding-bottom: 1.5rem !important;
        /* Ensure content can scroll properly */
        min-height: auto !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        /* Better content flow */
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    /* Specific scrolling for Create/Edit Lesson modals */
    #add-lesson-modal .modal-body,
    #edit-lesson-modal .modal-body,
    #add-lesson-modal form,
    #edit-lesson-modal form {
        /* Ensure lesson modals can scroll all content */
        overflow: visible !important;
        min-height: fit-content !important;
        flex-grow: 1 !important;
    }
    
    /* Ensure content doesn't get cut off */
    .modal-body > *,
    .modal form > * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Modal Actions - Scrollable with Content */
    .modal-actions {
        flex-shrink: 0 !important;
        position: relative !important; /* Changed from fixed to relative */
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        background: var(--surface-color) !important;
        border-top: 1px solid var(--border-color) !important;
        padding: 1rem 1.5rem !important;
        /* Safe area support for devices with notches */
        padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
        display: flex !important;
        flex-direction: column-reverse !important;
        gap: 0.75rem !important;
        z-index: 1002 !important;
        box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.15) !important;
        /* Ensure proper spacing */
        margin-top: 1rem !important;
        /* Better backdrop */
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    
    .modal-actions .btn {
        width: 100% !important;
        min-height: 52px !important; /* Larger for better accessibility */
        font-size: 1rem !important;
        font-weight: 600 !important;
        border-radius: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        transition: all 0.2s ease !important;
        /* Enhanced touch accessibility */
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        user-select: none !important;
        -webkit-user-select: none !important;
        /* Ensure buttons are always clickable */
        position: relative !important;
        z-index: 1003 !important;
        /* Better visual feedback */
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    }
    
    .modal-actions .btn:active {
        transform: scale(0.98) !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    }
    
    .modal-actions .btn:focus {
        outline: 2px solid var(--primary-color) !important;
        outline-offset: 2px !important;
    }
    
    /* Enhanced scroll indicators for lesson modals */
    .modal::-webkit-scrollbar,
    .modal-body::-webkit-scrollbar,
    .modal form::-webkit-scrollbar,
    .table-container::-webkit-scrollbar,
    .dashboard-content::-webkit-scrollbar,
    #add-lesson-modal::-webkit-scrollbar,
    #edit-lesson-modal::-webkit-scrollbar {
        width: 6px !important; /* Slightly wider for better visibility */
        height: 6px !important;
    }
    
    .modal::-webkit-scrollbar-track,
    .modal-body::-webkit-scrollbar-track,
    .modal form::-webkit-scrollbar-track,
    .table-container::-webkit-scrollbar-track,
    .dashboard-content::-webkit-scrollbar-track,
    #add-lesson-modal::-webkit-scrollbar-track,
    #edit-lesson-modal::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1) !important;
        border-radius: 3px !important;
    }
    
    .modal::-webkit-scrollbar-thumb,
    .modal-body::-webkit-scrollbar-thumb,
    .modal form::-webkit-scrollbar-thumb,
    .table-container::-webkit-scrollbar-thumb,
    .dashboard-content::-webkit-scrollbar-thumb,
    #add-lesson-modal::-webkit-scrollbar-thumb,
    #edit-lesson-modal::-webkit-scrollbar-thumb {
        background: var(--primary-color) !important;
        border-radius: 3px !important;
        opacity: 0.8 !important;
    }
    
    .modal::-webkit-scrollbar-thumb:hover,
    .modal-body::-webkit-scrollbar-thumb:hover,
    .modal form::-webkit-scrollbar-thumb:hover,
    .table-container::-webkit-scrollbar-thumb:hover,
    .dashboard-content::-webkit-scrollbar-thumb:hover,
    #add-lesson-modal::-webkit-scrollbar-thumb:hover,
    #edit-lesson-modal::-webkit-scrollbar-thumb:hover {
        opacity: 1 !important;
        background: var(--primary-color) !important;
    }
    
    /* Form Elements in Modals */
    .modal .form-group {
        margin-bottom: 1.5rem !important;
    }
    
    .modal .form-group label {
        font-size: 1rem !important;
        font-weight: 600 !important;
        margin-bottom: 0.5rem !important;
        display: block !important;
        color: var(--text-color) !important;
    }
    
    .modal .form-control,
    .modal input,
    .modal select,
    .modal textarea {
        width: 100% !important;
        min-height: 48px !important;
        padding: 0.875rem !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        border: 1px solid var(--border-color) !important;
        border-radius: 8px !important;
        background-color: var(--bg-color) !important;
        transition: border-color 0.2s ease !important;
    }
    
    .modal .form-control:focus,
    .modal input:focus,
    .modal select:focus,
    .modal textarea:focus {
        outline: none !important;
        border-color: var(--primary-color) !important;
        box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1) !important;
    }
    
    .modal textarea {
        min-height: 120px !important;
        resize: vertical !important;
    }
    
    /* Grid layouts in modals */
    .modal .form-group div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Enhanced scrolling for lesson modal content */
    .modal #videos-container,
    .modal #documents-container {
        gap: 1rem !important;
        /* Ensure containers can expand and scroll */
        overflow: visible !important;
        max-height: none !important;
    }
    
    .modal .video-input-group,
    .modal .document-input-group {
        padding: 1rem !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 8px !important;
        background: var(--bg-secondary) !important;
        margin-bottom: 1rem !important;
        /* Ensure input groups don't restrict scrolling */
        overflow: visible !important;
    }
    
    /* Assessment pages in modals - Enhanced scrolling */
    .modal .assessment-page {
        margin-bottom: 1.5rem !important;
        padding: 1rem !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 8px !important;
        background: var(--bg-secondary) !important;
        /* Allow assessment pages to expand fully */
        overflow: visible !important;
        max-height: none !important;
    }
    
    .modal .assessment-page textarea {
        min-height: 150px !important;
        /* Ensure textareas can expand */
        max-height: none !important;
        resize: vertical !important;
    }
    
    /* Assessment tabs container scrolling */
    .modal #assessment-pages-container {
        overflow: visible !important;
        max-height: none !important;
        /* Allow full expansion of assessment content */
        flex-grow: 1 !important;
    }
    
    /* Form groups in lesson modals */
    .modal .form-group {
        overflow: visible !important;
        top: 0;
        background: var(--surface-color);
        z-index: 10;
        border-bottom: 1px solid var(--border-color);
    }
    
    #assessment-instructions-modal .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Password modals for student portal */
    #forgot-password-modal form,
    #resend-verification-modal form {
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
    
    /* Documents Viewer Modal - Enhanced Mobile Scrolling */
    .documents-viewer-modal {
        /* Ensure proper mobile scrolling */
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        scroll-behavior: smooth !important;
    }

    .documents-viewer-modal > div:last-child {
        /* Content area scrolling */
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        scroll-behavior: smooth !important;
        /* Ensure it can scroll on mobile */
        overflow-y: auto !important;
        max-height: calc(100vh - 120px) !important;
    }

    /* Document Fullscreen Modal - Enhanced Mobile Support */
    .document-fullscreen-modal {
        /* Ensure proper mobile display */
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
    }

    .document-fullscreen-modal iframe {
        /* Better mobile iframe handling */
        width: 100% !important;
        height: 100% !important;
        border: none !important;
        /* Mobile scroll support */
        -webkit-overflow-scrolling: touch !important;
        overflow: auto !important;
    }
    
    /* PERFORMANCE: Optimized page transitions to prevent lag */
    .page {
        /* Hardware acceleration for smooth transitions */
        will-change: transform, opacity;
        transform: translateZ(0);
        backface-visibility: hidden;
        /* Prevent layout thrashing */
        contain: layout style paint;
        /* Smooth transitions */
        transition: opacity 0.2s ease-in-out;
    }

    .page:not(.active) {
        opacity: 0;
        pointer-events: none;
        /* Prevent invisible pages from affecting layout */
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .page.active {
        opacity: 1;
        pointer-events: auto;
        position: relative;
        top: auto;
        left: auto;
    }

    /* PERFORMANCE: Optimized student portal elements */
    #student-portal {
        /* Optimize for frequent updates */
        will-change: contents;
        contain: layout style;
    }

    /* MOBILE: Student Portal Scrolling & Take Assessment Button */
    @media (max-width: 768px) {
        #student-lesson-page {
            /* Enable full page scrolling */
            overflow-y: auto !important;
            -webkit-overflow-scrolling: touch !important;
            overscroll-behavior: contain !important;
            scroll-behavior: smooth !important;
            height: 100vh !important;
            max-height: 100vh !important;
        }
        
        /* Take Assessment Button - Always Accessible */
        #document-take-assessment-btn {
            /* Ensure button is always visible and accessible */
            position: relative !important;
            z-index: 100 !important;
            background: var(--surface-color) !important;
            border-radius: 12px !important;
            margin: 1rem 0.5rem !important;
            padding: 1rem !important;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
            /* Ensure it's not hidden by other elements */
            min-height: 80px !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
        }
        
        #document-take-assessment-btn .btn {
            /* Mobile-optimized button */
            width: 100% !important;
            max-width: 300px !important;
            min-height: 52px !important;
            font-size: 1.1rem !important;
            font-weight: 600 !important;
            padding: 15px 20px !important;
            border-radius: 8px !important;
            /* Touch-friendly */
            touch-action: manipulation !important;
            -webkit-tap-highlight-color: transparent !important;
            /* Ensure it's clickable */
            pointer-events: auto !important;
            position: relative !important;
            z-index: 101 !important;
        }
        
        /* Video Action Buttons - Mobile Optimized */
        #video-action-buttons {
            /* Ensure video action buttons are accessible */
            position: relative !important;
            z-index: 100 !important;
            margin: 1rem 0.5rem !important;
            padding: 1rem !important;
            background: var(--surface-color) !important;
            border-radius: 12px !important;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        }
        
        #video-action-buttons .btn {
            /* Mobile-friendly video action buttons */
            min-height: 48px !important;
            font-size: 1rem !important;
            padding: 12px 16px !important;
            margin: 0.25rem !important;
            touch-action: manipulation !important;
            -webkit-tap-highlight-color: transparent !important;
        }
        
        /* Materials Section - Scrollable */
        #materials-section {
            /* Ensure materials section is scrollable */
            overflow: visible !important;
            max-height: none !important;
            margin-bottom: 2rem !important;
        }
        
        /* Video Section - Scrollable */
        #video-section {
            /* Ensure video section doesn't block scrolling */
            overflow: visible !important;
            max-height: none !important;
            margin-bottom: 1rem !important;
        }
        
        /* Student Portal Content - Enhanced Mobile Scrolling */
        .student-content {
            /* Ensure all content is scrollable */
            overflow: visible !important;
            max-height: none !important;
            padding-bottom: 2rem !important;
        }
        
        /* Assessment Instructions Modal - Mobile Scrolling */
        #assessment-instructions-modal {
            /* Ensure modal is fully scrollable on mobile */
            overflow-y: auto !important;
            -webkit-overflow-scrolling: touch !important;
            overscroll-behavior: contain !important;
            max-height: 100vh !important;
        }
        
        /* Documents Viewer - Enhanced Mobile Support */
        .documents-viewer-modal {
            /* Better mobile scrolling */
            overflow-y: auto !important;
            -webkit-overflow-scrolling: touch !important;
            overscroll-behavior: contain !important;
        }
        
        /* Ensure all buttons are touch-friendly */
        .btn {
            /* Enhanced touch targets for mobile */
            min-height: 44px !important;
            touch-action: manipulation !important;
            -webkit-tap-highlight-color: transparent !important;
            user-select: none !important;
        }
        
        /* Student lesson page specific optimizations */
        #student-lesson-page .container {
            /* Remove any height restrictions */
            max-height: none !important;
            overflow: visible !important;
            padding-bottom: 3rem !important;
        }
    }

    /* ASSESSMENT MODE: Hide video and Take Assessment button during assessment */
    #assessment-section:not([style*="display: none"]) ~ #video-section,
    #assessment-section:not([style*="display: none"]) ~ #materials-section #document-take-assessment-btn,
    #assessment-section:not([style*="display: none"]) ~ #video-section #video-action-buttons {
        display: none !important;
    }

    /* Alternative approach: When assessment section is visible, hide other elements */
    .assessment-active #video-section,
    .assessment-active #document-take-assessment-btn,
    .assessment-active #video-action-buttons,
    .assessment-active .floating-documents-btn,
    .assessment-active .btn:contains("Take Assessment"),
    .assessment-active button[onclick*="startAssessment"],
    .assessment-active button[onclick*="showAssessmentInstructions"],
    .assessment-active #take-assessment-btn-bottom,
    .assessment-active #video-take-assessment-btn {
        display: none !important;
    }

    /* Ensure assessment section takes full focus */
    .assessment-active #assessment-section {
        display: block !important;
        position: relative !important;
        z-index: 10 !important;
    }

    /* Specific targeting for Take Assessment buttons */
    .assessment-active [class*="take-assessment"],
    .assessment-active [id*="take-assessment"],
    .assessment-active [class*="start-assessment"],
    .assessment-active [id*="start-assessment"] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* DESKTOP FIX: Ensure document modal close button is always clickable */
    @media (min-width: 769px) {
        #close-documents-modal {
            pointer-events: auto !important;
            cursor: pointer !important;
            z-index: 10003 !important;
            position: relative !important;
            background: var(--danger-color) !important;
            color: white !important;
            border: none !important;
            padding: 10px 15px !important;
            border-radius: 4px !important;
            font-weight: 500 !important;
            transition: all 0.2s ease !important;
        }
        
        #close-documents-modal:hover {
            background: #dc2626 !important;
            transform: translateY(-1px) !important;
            box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3) !important;
        }
        
        #close-documents-modal:active {
            transform: translateY(0) !important;
            box-shadow: 0 1px 4px rgba(220, 38, 38, 0.3) !important;
        }
        
        /* Ensure modal header doesn't interfere */
        .documents-viewer-modal .modal-header {
            pointer-events: auto !important;
            z-index: 10002 !important;
        }
        
        /* Ensure modal content doesn't block close button */
        .documents-viewer-modal .modal-content {
            pointer-events: auto !important;
        }
        
        /* PERFORMANCE: Optimize Google Viewer iframes with scroll fix */
        .documents-viewer-modal iframe,
        .fullscreen-document-modal iframe {
            /* Hardware acceleration for smooth scrolling */
            will-change: transform !important;
            contain: layout style !important;
            transform: translate3d(0, 0, 0) !important;
            backface-visibility: hidden !important;
            perspective: 1000px !important;
            isolation: isolate !important;
            
            /* Smooth scrolling optimizations */
            overflow: auto !important;
            -webkit-overflow-scrolling: touch !important;
            overscroll-behavior: contain !important;
            scroll-behavior: auto !important;
            
            /* Performance optimizations */
            image-rendering: optimizeSpeed !important;
            pointer-events: auto !important;
            user-select: none !important;
            
            /* Memory management */
            max-height: calc(100vh - 80px) !important;
            max-width: 100vw !important;
            
            /* CRITICAL: Prevent iframe from blocking close button */
            z-index: 1 !important;
        }
        
        /* CRITICAL: Ensure close button always stays on top */
        #close-documents-modal,
        #doc-close-btn {
            pointer-events: auto !important;
            cursor: pointer !important;
            z-index: 10005 !important;
            position: fixed !important;
            background: var(--danger-color) !important;
            color: white !important;
            border: none !important;
            padding: 12px 18px !important;
            border-radius: 6px !important;
            font-weight: 600 !important;
            font-size: 14px !important;
            transition: all 0.2s ease !important;
            box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4) !important;
        }
        
        /* Enhanced hover effects for close button */
        #close-documents-modal:hover,
        #doc-close-btn:hover {
            background: #dc2626 !important;
            transform: translateY(-2px) !important;
            box-shadow: 0 6px 16px rgba(220, 38, 38, 0.5) !important;
        }
        
        /* Active state for close button */
        #close-documents-modal:active,
        #doc-close-btn:active {
            transform: translateY(0) !important;
            box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4) !important;
        }
        
        /* ULTIMATE: Floating close button that always works */
        #floating-close-btn {
            position: fixed !important;
            top: 20px !important;
            right: 20px !important;
            z-index: 999999 !important;
            background: #dc2626 !important;
            color: white !important;
            border: none !important;
            padding: 15px 20px !important;
            border-radius: 8px !important;
            font-weight: bold !important;
            font-size: 16px !important;
            cursor: pointer !important;
            pointer-events: auto !important;
            box-shadow: 0 4px 20px rgba(220, 38, 38, 0.6) !important;
            transition: all 0.2s ease !important;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
            user-select: none !important;
            -webkit-user-select: none !important;
            -moz-user-select: none !important;
            -ms-user-select: none !important;
            display: block !important;
            visibility: visible !important;
            opacity: 1 !important;
        }
        
        #floating-close-btn:hover {
            background: #b91c1c !important;
            transform: scale(1.05) !important;
            box-shadow: 0 6px 25px rgba(220, 38, 38, 0.8) !important;
        }
        
        #floating-close-btn:active {
            transform: scale(0.95) !important;
            box-shadow: 0 2px 15px rgba(220, 38, 38, 0.6) !important;
        }
        
        /* NUCLEAR: Force close system that cannot be blocked */
        #nuclear-close-overlay {
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            right: 0 !important;
            bottom: 0 !important;
            background: transparent !important;
            z-index: 9999999 !important;
            pointer-events: none !important;
            display: block !important;
        }
        
        #nuclear-close-btn {
            position: absolute !important;
            top: 10px !important;
            right: 10px !important;
            z-index: 2147483647 !important;
            background: #ff0000 !important;
            color: white !important;
            border: 3px solid #ffffff !important;
            padding: 20px 25px !important;
            border-radius: 12px !important;
            font-weight: 900 !important;
            font-size: 18px !important;
            cursor: pointer !important;
            pointer-events: auto !important;
            box-shadow: 0 0 30px rgba(255, 0, 0, 0.8) !important;
            transition: none !important;
            font-family: Arial, sans-serif !important;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.8) !important;
            animation: pulse 1s infinite !important;
            display: block !important;
            visibility: visible !important;
            opacity: 1 !important;
            isolation: isolate !important;
            contain: layout style paint !important;
            will-change: transform !important;
            transform: translateZ(0) !important;
            backface-visibility: hidden !important;
        }
        
        #nuclear-close-btn:hover {
            background: #cc0000 !important;
            transform: scale(1.1) !important;
            box-shadow: 0 0 40px rgba(255, 0, 0, 1) !important;
        }
        
        #nuclear-close-btn:active {
            transform: scale(0.9) !important;
            box-shadow: 0 0 50px rgba(255, 0, 0, 1) !important;
        }
        
        /* NUCLEAR: Pulse animation for nuclear close button */
        @keyframes pulse {
            0% { 
                transform: scale(1); 
                box-shadow: 0 0 30px rgba(255, 0, 0, 0.8); 
            }
            50% { 
                transform: scale(1.1); 
                box-shadow: 0 0 40px rgba(255, 0, 0, 1); 
            }
            100% { 
                transform: scale(1); 
                box-shadow: 0 0 30px rgba(255, 0, 0, 0.8); 
            }
        }
        
        /* NUCLEAR: Ensure nuclear system works on all devices */
        @media (max-width: 768px) {
            #nuclear-close-btn {
                top: 15px !important;
                right: 15px !important;
                padding: 18px 22px !important;
                font-size: 16px !important;
            }
        }
        
        @media (max-width: 480px) {
            #nuclear-close-btn {
                top: 20px !important;
                right: 20px !important;
                padding: 16px 20px !important;
                font-size: 14px !important;
            }
        }
        
        /* GOOGLE DRIVE PROTECTION: Force visibility on all browsers and prevent Google Drive interference */
        #nuclear-close-btn,
        #floating-close-btn {
            -webkit-appearance: none !important;
            -moz-appearance: none !important;
            appearance: none !important;
            outline: none !important;
            border-style: solid !important;
            border-width: 3px !important;
            position: fixed !important;
            z-index: 2147483647 !important;
            pointer-events: auto !important;
            display: block !important;
            visibility: visible !important;
            opacity: 1 !important;
        }
        
        /* GOOGLE DRIVE PROTECTION: Prevent iframe from interfering with close buttons */
        iframe[src*="docs.google.com"] {
            z-index: 1 !important;
            position: relative !important;
        }
        
        /* GOOGLE DRIVE PROTECTION: Ensure modal overlay doesn't interfere */
        .fullscreen-document-modal,
        .documents-viewer-modal {
            z-index: 10001 !important;
        }
        
        /* GOOGLE DRIVE PROTECTION: Force nuclear overlay to be on top */
        #nuclear-close-overlay {
            z-index: 2147483646 !important;
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            right: 0 !important;
            bottom: 0 !important;
            pointer-events: none !important;
            background: transparent !important;
        }
        
        /* Prevent iframe from causing layout thrashing */
        .fullscreen-document-modal {
            contain: layout style paint !important;
            will-change: auto !important;
            transform: translateZ(0) !important;
        }

        /* ADDITIONAL LEARNING MATERIALS: Button styling for View and Open buttons */
        .material-card .btn {
            min-width: 80px;
            font-size: 0.875rem;
            padding: 0.5rem 1rem;
            border-radius: 6px;
            font-weight: 600;
            transition: all 0.2s ease;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            white-space: nowrap;
        }
    }
    
    .form-group label {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        display: block;
    }
    
    /* Assessment pages container mobile */
    #assessment-pages-container {
        margin-bottom: 2rem;
    }
    
    .assessment-page {
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 1rem;
        background: var(--surface-color);
    }
    
    .page-header {
        padding: 1rem;
        background: var(--bg-color);
        border-bottom: 1px solid var(--border-color);
        border-radius: 8px 8px 0 0;
    }
    
    .page-header h4 {
        font-size: 1.1rem;
        margin: 0;
    }
    
    /* Page tabs mobile */
    .page-tabs {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        padding: 0.5rem;
        background: var(--bg-color);
        border-bottom: 1px solid var(--border-color);
        -webkit-overflow-scrolling: touch;
    }
    
    .page-tab {
        flex-shrink: 0;
        padding: 0.5rem 1rem;
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        cursor: pointer;
        font-size: 0.9rem;
        white-space: nowrap;
    }
    
    .page-tab.active {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }
}

/* Form Inputs Mobile */
@media (max-width: 768px) {
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="datetime-local"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 0.875rem;
        border-radius: 8px;
    }
    
    textarea {
        min-height: 150px;
        resize: vertical;
    }
    
    .form-group label {
        font-size: 0.95rem;
        font-weight: 600;
    }
}

/* Assessment Pages Mobile */
@media (max-width: 768px) {
    .assessment-pages-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .pages-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .page-tab {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
        min-width: 100px;
    }
    
    .page-content {
        padding: 1rem;
    }
    
    .page-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .page-header .btn {
        width: 100%;
    }
}

/* Student Portal - Lesson View Mobile */
@media (max-width: 768px) {
    .lesson-header {
        padding: 1rem;
    }
    
    .lesson-header h2 {
        font-size: 1.35rem;
        line-height: 1.3;
    }
    
    .lesson-meta {
        flex-wrap: wrap;
        gap: 0.75rem;
        font-size: 0.9rem;
    }
    
    .lesson-meta span {
        display: flex;
        align-items: center;
        gap: 0.35rem;
    }
    
    .student-info {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .lesson-content {
        padding: 1rem;
    }
    
    .content-section {
        margin-bottom: 1.5rem;
    }
    
    .content-section h3 {
        font-size: 1.15rem;
        margin-bottom: 0.75rem;
    }
}

/* Video Player Mobile - BIGGER */
@media (max-width: 768px) {
    #video-container {
        height: auto;
        max-height: 75vh; /* ✅ Bigger video player */
        border-radius: 8px;
    }
    
    .video-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .video-controls .btn {
        flex: 1;
        min-width: 140px;
    }
}

@media (max-width: 480px) {
    #video-container {
        height: auto;
        max-height: 70vh; /* ✅ Bigger video player */
    }
    
    .video-controls .btn {
        width: 100%;
        flex: none;
    }
}

/* Materials Section Mobile */
@media (max-width: 768px) {
    .materials-list {
        gap: 0.75rem;
    }
    
    .material-item {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .material-info {
        width: 100%;
    }
    
    .material-item .btn {
        width: 100%;
    }
}

/* Assessment/Quiz Mobile */
@media (max-width: 768px) {
    .quiz-container {
        padding: 1rem;
    }
    
    .quiz-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .quiz-timer {
        font-size: 1.5rem;
        padding: 0.75rem 1.25rem;
        width: 100%;
        text-align: center;
    }
    
    .question-card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .question-number {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }
    
    .question-text {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .answer-option {
        padding: 1rem;
        min-height: 54px;
        font-size: 0.95rem;
    }
    
    .answer-option input[type="radio"] {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }
    
    .option-letter {
        min-width: 35px;
        height: 35px;
        font-size: 1rem;
        flex-shrink: 0;
    }
    
    .option-text {
        flex: 1;
        line-height: 1.5;
    }
    
    /* Text inputs for other question types */
    .answer-input {
        font-size: 16px !important;
        padding: 0.875rem;
        width: 100%;
    }
    
    textarea.answer-input {
        min-height: 120px;
    }
}

/* Quiz Navigation Mobile */
@media (max-width: 768px) {
    #quiz-navigation {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
        background: var(--surface-color);
        position: relative;
        margin-top: 2rem;
        margin-bottom: 2rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
    }
    
    /* Ensure assessment content has enough bottom space */
    #assessment-section {
        padding-bottom: 3rem !important;
    }
    
    /* Ensure quiz questions have proper spacing */
    .question-container:last-child {
        margin-bottom: 3rem !important;
    }
    
    #page-indicator {
        order: -1;
        width: 100%;
        padding: 0.75rem;
        background: var(--bg-color);
        border-radius: 8px;
        font-size: 1rem;
    }
    
    #prev-page-btn,
    #next-page-btn,
    #submit-quiz-btn {
        width: 100%;
        flex: none;
        min-height: 48px;
        font-size: 1rem;
    }
}

/* Results View Mobile */
@media (max-width: 768px) {
    .results-container {
        padding: 1rem;
    }
    
    .results-header {
        padding: 1.25rem;
    }
    
    .results-header h2 {
        font-size: 1.35rem;
    }
    
    .score-display {
        font-size: 2.5rem;
        padding: 1.5rem;
    }
    
    .results-summary {
        gap: 1rem;
    }
    
    .summary-item {
        padding: 1rem;
    }
    
    .summary-item h4 {
        font-size: 0.9rem;
    }
    
    .summary-item p {
        font-size: 1.5rem;
    }
}

/* Documents Viewer Mobile */
@media (max-width: 768px) {
    .documents-viewer {
        padding: 0;
    }
    
    .documents-viewer-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        background: var(--surface-color);
        z-index: 10;
    }
    
    .documents-list {
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .document-item {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .document-info {
        width: 100%;
    }
    
    .document-item .btn {
        width: 100%;
    }
}

/* Buttons Mobile Improvements */
@media (max-width: 768px) {
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .btn i {
        font-size: 1.1rem;
    }
    
    .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        min-height: 36px;
    }
    
    .btn-lg {
        padding: 1rem 1.5rem;
        font-size: 1.05rem;
        min-height: 52px;
    }
}

/* Empty States Mobile */
@media (max-width: 768px) {
    .empty-state-card {
        padding: 2rem 1rem;
    }
    
    .empty-state-card i {
        font-size: 3rem;
    }
    
    .empty-state-card p {
        font-size: 1rem;
    }
}

/* Loading States Mobile */
@media (max-width: 768px) {
    .loading {
        font-size: 1rem;
        padding: 2rem 1rem;
    }
}

/* Alerts Mobile */
@media (max-width: 768px) {
    .alert {
        padding: 1rem;
        font-size: 0.95rem;
        border-radius: 8px;
    }
}

/* Prevent text selection on buttons (better UX) - STUDENT PORTAL ONLY */
.btn:not(.dashboard-section .btn):not(.section-header .btn):not(.menu-item), .page-tab, .answer-option {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth scrolling for mobile */
html {
    scroll-behavior: smooth;
}

/* Better tap highlight color */
* {
    -webkit-tap-highlight-color: rgba(79, 70, 229, 0.1);
}

/* Prevent pull-to-refresh on mobile */
body {
    overscroll-behavior-y: contain;
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .navbar,
    .modal-header,
    .modal-footer,
    #quiz-navigation {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .navbar {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .modal-footer,
    #quiz-navigation {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* ============================================
   ✅ ENHANCED MOBILE IMPROVEMENTS
   ======================================== */

/* Better Mobile Typography */
@media (max-width: 768px) {
    body {
        font-size: 15px; /* Slightly smaller on mobile for better fit */
    }
    
    p, li, span, div {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .question-card h4 {
        font-size: 1.1rem;
        line-height: 1.4;
        margin-bottom: 1rem;
    }
    
    .question-card p {
        font-size: 0.95rem;
    }
    
    label {
        font-size: 0.95rem;
    }
    
    input, textarea, select {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .question-card h4 {
        font-size: 1rem;
    }
}

/* Better Mobile Spacing */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .question-card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }
}

/* Mobile-Friendly Buttons & Touch Optimization */
@media (max-width: 768px) {
    .btn {
        min-height: 48px; /* Touch-friendly size */
        font-size: 1rem;
        padding: 0.875rem 1.5rem;
        font-weight: 600;
        border-radius: 8px;
        transition: all 0.2s ease;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .btn:active {
        transform: scale(0.98);
    }
    
    .btn-sm {
        min-height: 44px;
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }
    
    .btn-lg {
        min-height: 56px;
        font-size: 1.1rem;
        padding: 1rem 2rem;
    }
    
    /* Dashboard specific button optimizations */
    .dashboard-section .btn,
    .section-header .btn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        position: relative;
        z-index: 1;
        min-height: 48px;
        font-weight: 600;
    }
    
    .dashboard-section .btn:active,
    .section-header .btn:active {
        transform: scale(0.98);
    }
    
    /* CRITICAL: Force menu items to be clickable */
    .dashboard-sidebar .menu-item,
    .dashboard-sidebar.active .menu-item {
        /* Highest priority clickability */
        pointer-events: auto !important;
        cursor: pointer !important;
        z-index: 10 !important;
    }
    
    .dashboard-sidebar .menu-item:active,
    .dashboard-sidebar.active .menu-item:active {
        transform: scale(0.95) !important;
        background-color: var(--primary-color) !important;
        color: white !important;
    }
    
    .dashboard-sidebar .menu-item.active,
    .dashboard-sidebar.active .menu-item.active {
        background-color: var(--primary-color) !important;
        color: white !important;
    }
    
    .dashboard-sidebar .menu-item:hover,
    .dashboard-sidebar.active .menu-item:hover {
        background-color: var(--bg-color) !important;
        transform: translateX(4px) !important;
    }
    
    .dashboard-sidebar .menu-item:hover.active,
    .dashboard-sidebar.active .menu-item:hover.active {
        background-color: var(--primary-color) !important;
        color: white !important;
    }
}

/* Mobile Video Player Improvements - MUCH BIGGER SCREENS */
@media (max-width: 768px) {
    #video-container {
        height: auto;
        aspect-ratio: 16 / 9; /* Maintains proper video ratio */
        max-height: 80vh !important; /* ✅ MASSIVE INCREASE - 80vh for bigger mobile video */
        margin: 0 !important;
        width: 100% !important;
    }
    
    #youtube-player-container {
        height: auto;
        aspect-ratio: 16 / 9;
        max-height: 80vh !important; /* ✅ MASSIVE INCREASE - 80vh */
        width: 100% !important;
    }
    
    #youtube-player {
        width: 100% !important;
        height: 100% !important;
    }
    
    .video-wrapper {
        max-height: 80vh !important;
        width: 100% !important;
    }
    
    #lesson-video {
        max-height: 80vh !important;
        width: 100% !important;
        object-fit: contain;
    }
}

@media (max-width: 480px) {
    #video-container,
    #youtube-player-container {
        max-height: 75vh !important; /* ✅ MASSIVE INCREASE from 50vh to 75vh */
    }
    
    .video-wrapper {
        max-height: 75vh !important;
    }
}

/* Mobile Assessment Improvements */
@media (max-width: 768px) {
    .quiz-header {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    
    .quiz-timer {
        font-size: 1.25rem;
        padding: 0.75rem 1.5rem;
    }
    
    .quiz-questions {
        padding: 1rem;
    }
    
    .option-label {
        padding: 1rem;
        font-size: 0.95rem;
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    
    textarea.form-control {
        font-size: 16px !important;
        min-height: 120px;
        padding: 1rem;
    }
    
    input[type="text"].form-control {
        font-size: 16px !important;
        min-height: 48px;
        padding: 0.875rem;
    }
}

/* Mobile Table Improvements */
@media (max-width: 768px) {
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.75rem 0.5rem;
    }
    
    .table-container {
        border-radius: 8px;
    }
}

/* Additional Mobile Modal Improvements for smaller screens */
@media (max-width: 480px) {
    .modal-header {
        padding: 0.75rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
        text-align: center;
        margin-bottom: 0.5rem;
    }
    
    .modal-header > div {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    
    .modal form {
        padding: 0.75rem;
        padding-bottom: 7rem;
    }
    
    .modal-actions {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .modal-actions .btn {
        padding: 1rem;
        font-size: 0.95rem;
        border-radius: 8px;
    }
    
    /* Button improvements for mobile */
    .btn {
        min-height: 44px; /* Touch target size */
        border-radius: 8px;
        font-weight: 600;
        transition: all 0.2s ease;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;
    }
    
    /* Dashboard buttons - DESKTOP ONLY (No Mobile Touch Styles) */
    
    .btn-sm {
        min-height: 36px;
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    /* Form grid improvements */
    .form-group div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Video container mobile */
    #videos-container {
        gap: 1rem !important;
    }
    
    .video-input-group {
        padding: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        background: var(--bg-color);
    }
    
    /* Documents container mobile */
    #documents-container {
        gap: 1rem !important;
    }
    
    .document-input-group {
        padding: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        background: var(--bg-color);
    }
    
    /* Assessment pages mobile */
    .assessment-page {
        margin-bottom: 1.5rem;
    }
    
    .assessment-page textarea {
        min-height: 200px;
        font-size: 14px;
        line-height: 1.5;
    }
    
    /* Preview buttons mobile */
    .btn[onclick*="preview"] {
        width: 100%;
        margin-top: 0.5rem;
        padding: 0.75rem;
    }
}

/* Mobile Navigation Improvements */
@media (max-width: 768px) {
    #quiz-navigation {
        padding: 1rem;
        gap: 0.75rem;
    }
    
    #quiz-navigation .btn {
        flex: 1;
        min-width: 0;
    }
    
    .page-indicator {
        font-size: 1rem;
        font-weight: 600;
        padding: 0.5rem;
    }
}

/* Mobile Dashboard - DESKTOP ONLY (No Mobile Styles) */

/* Mobile Login/Register Improvements */
@media (max-width: 768px) {
    .login-card {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .login-card h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
}

/* Landscape Mobile Optimizations - AUTO-ROTATE FEATURE */
@media (max-width: 768px) and (orientation: landscape) {
    /* Video player takes full screen in landscape */
    #video-container,
    #youtube-player-container {
        max-height: 95vh !important; /* ✅ Nearly full screen in landscape */
        height: 95vh !important;
    }
    
    .video-wrapper {
        max-height: 95vh !important;
        height: 95vh !important;
    }
    
    /* Hide mobile notice in landscape (already in landscape!) */
    .mobile-rotate-notice {
        display: none !important;
    }
    
    /* Compact fullscreen button in landscape */
    .fullscreen-btn-external {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        margin-top: 0.5rem;
    }
    
    /* Compact video info in landscape */
    .video-info {
        margin-top: 0.5rem;
        font-size: 0.85rem;
    }
    
    .quiz-container {
        padding: 0.75rem;
    }
    
    .question-card {
        padding: 1rem;
    }
}

/* Mobile Portrait - Show rotate notice */
@media (max-width: 768px) and (orientation: portrait) {
    .mobile-rotate-notice {
        display: flex !important;
    }
    
    .fullscreen-btn-external {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }
}

/* Document Viewer Mobile Optimizations */
.document-fullscreen-modal {
    /* Mobile-friendly scrolling */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.document-fullscreen-modal iframe {
    /* Enable pinch-to-zoom on mobile */
    touch-action: pan-x pan-y pinch-zoom;
    /* Better rendering on mobile */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

@media (max-width: 768px) {
    .document-fullscreen-modal {
        /* Full screen on mobile */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
    }
    
    .document-fullscreen-modal iframe {
        /* Better mobile PDF viewing */
        min-height: 100vh !important;
        width: 100% !important;
        /* Enable smooth scrolling */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

@media (max-width: 480px) {
    .document-fullscreen-modal iframe {
        /* Extra height for small mobile screens */
        min-height: 120vh !important;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Enhanced error message styling for blocking messages */
.error-message {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.95rem;
    padding: 1.5rem;
    margin: 1rem 0;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.2);
    border-left: 5px solid #dc2626;
}

.error-message.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

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

/* Mobile responsive error messages */
@media (max-width: 768px) {
    .error-message {
        font-size: 0.9rem;
        padding: 1rem;
        margin: 0.5rem 0;
    }
}

/* ADDITIONAL LEARNING MATERIALS: Button styling for View and Open buttons */
.material-card .btn {
    min-width: 80px;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.material-card .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.material-card .btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.material-card .btn-success {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

.material-card .btn-success:hover {
    background: #218838;
    border-color: #1e7e34;
}

/* MOBILE: Additional Learning Materials button optimization */
@media (max-width: 768px) {
    .material-card {
        padding: 0.75rem !important;
    }
    
    .material-card > div {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }
    
    .material-card .btn {
        min-width: 100%;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        margin: 0.25rem 0;
    }
    
    .material-card > div > div:last-child {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .material-card .btn {
        padding: 0.875rem 1rem;
        font-size: 1rem;
        min-height: 44px; /* Touch-friendly minimum */
    }
}

/* VIDEO NAVIGATION CONTROLS: Mobile optimization */
.video-navigation-controls {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 1rem !important;
    margin-top: 1rem !important;
    padding: 1rem !important;
    background: var(--bg-secondary) !important;
    border-radius: 8px !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 10 !important;
}

.video-nav-btn {
    min-width: 100px !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    white-space: nowrap !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.video-nav-btn:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

.video-nav-btn:active {
    transform: translateY(0) !important;
}

.video-nav-info {
    text-align: center !important;
    min-width: 200px !important;
    flex: 1 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* MOBILE: Video navigation responsive design */
@media (max-width: 768px) {
    .video-navigation-controls {
        flex-direction: column !important;
        gap: 1rem !important;
        padding: 1.5rem 1rem !important;
    }
    
    .video-nav-btn {
        min-width: 100% !important;
        padding: 1rem 1.5rem !important;
        font-size: 1rem !important;
        min-height: 50px !important;
    }
    
    .video-nav-info {
        min-width: 100% !important;
        order: -1 !important;
        margin-bottom: 1rem !important;
    }
    
    .video-prev-btn {
        order: 1 !important;
    }
    
    .video-next-btn {
        order: 2 !important;
    }
}

@media (max-width: 480px) {
    .video-navigation-controls {
        margin: 1rem -1rem !important;
        border-radius: 0 !important;
        padding: 1.5rem !important;
    }
    
    .video-nav-btn {
        padding: 1.25rem 1.5rem !important;
        font-size: 1.1rem !important;
        min-height: 56px !important; /* Extra touch-friendly */
        font-weight: 700 !important;
    }
    
    .video-nav-btn .btn-text {
        display: inline !important;
    }
    
    .video-nav-info {
        padding: 1rem 0 !important;
        font-size: 1rem !important;
    }
    
    .video-nav-info div {
        font-size: 1.1rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .video-nav-info small {
        font-size: 0.95rem !important;
    }
}
