/**
 * Mobile-optimized CSS for ngager Student Engagement Platform
 * Targets screens with max-width: 768px
 * Requirements: 15.3 - Mobile-optimized web interface
 * 
 * Touch-friendly design guidelines:
 * - Minimum tap target size: 44x44px (WCAG 2.1 AAA)
 * - Adequate spacing between interactive elements
 * - Responsive layouts for 320px - 768px viewport widths
 */

/* CSS Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    /* Prevent font scaling in landscape while allowing user zoom */
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.5;
    color: #333;
    background-color: #ffffff;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile browsers */
    overflow-x: hidden;
    /* Smooth scrolling for better UX */
    -webkit-overflow-scrolling: touch;
}

/* App Container */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Connection Status Indicator */
.connection-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.connection-status.connected {
    background-color: #4caf50;
    color: white;
}

.connection-status.disconnected {
    background-color: #f44336;
    color: white;
}

.connection-status.degraded {
    background-color: #ff9800;
    color: white;
}

.connection-status.hidden {
    display: none;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: currentColor;
}

/* Main Content */
#main-content {
    flex: 1;
    padding: 16px;
    padding-top: 60px; /* Space for connection status */
}

/* Loading Screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Touch-friendly Button Styles */
/* Minimum 44x44px tap targets per WCAG 2.1 accessibility guidelines */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 48px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    /* Ensure touch-friendly spacing */
    margin: 4px 0;
    /* Prevent text selection on double-tap */
    -webkit-user-select: none;
    user-select: none;
    /* Improve touch responsiveness */
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: #4a90d9;
    color: white;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: #3a7bc8;
}

.btn-secondary {
    background-color: #e0e0e0;
    color: #333;
}

.btn-secondary:hover, .btn-secondary:focus {
    background-color: #d0d0d0;
}

.btn-success {
    background-color: #4caf50;
    color: white;
}

.btn-danger {
    background-color: #f44336;
    color: white;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

/* Touch-friendly form inputs - minimum 44px height for tap targets */
.form-input {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px; /* Prevents iOS zoom on focus */
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background-color: white;
    transition: border-color 0.2s ease;
    /* Improve touch responsiveness */
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: #4a90d9;
}

.form-input.error {
    border-color: #f44336;
}

.form-error {
    color: #f44336;
    font-size: 14px;
    margin-top: 4px;
}

/* Card Component */
.card {
    background-color: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #333;
}

/* Timer Display - Optimized for small screens */
.timer {
    font-size: 48px;
    font-weight: 700;
    text-align: center;
    padding: 24px;
    border-radius: 12px;
    background-color: #f5f5f5;
    /* Ensure timer is readable on small screens */
    min-width: 120px;
    line-height: 1.2;
}

/* Responsive timer for very small screens */
@media (max-width: 360px) {
    .timer {
        font-size: 40px;
        padding: 20px 16px;
    }
}

/* Extra small screens (320px) */
@media (max-width: 320px) {
    .timer {
        font-size: 36px;
        padding: 16px 12px;
    }
}

.timer.warning {
    background-color: #fff3e0;
    color: #e65100;
}

.timer.critical {
    background-color: #ffebee;
    color: #c62828;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Question Display */
.question-container {
    margin-bottom: 24px;
}

.question-text {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 20px;
    line-height: 1.6;
    /* Ensure readability on small screens */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Responsive question text for small screens */
@media (max-width: 360px) {
    .question-text {
        font-size: 16px;
        margin-bottom: 16px;
    }
}

/* Answer Options - Touch-friendly with adequate spacing */
.answer-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Touch-friendly answer option - minimum 44px tap target */
.answer-option {
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 16px;
    background-color: #f5f5f5;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    /* Improve touch responsiveness */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

.answer-option:hover {
    background-color: #e8e8e8;
}

.answer-option.selected {
    background-color: #e3f2fd;
    border-color: #4a90d9;
}

.answer-option input[type="radio"] {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    /* Ensure radio buttons are touch-friendly */
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #4a90d9;
}

/* Answer option label text */
.answer-option-text {
    flex: 1;
    font-size: 16px;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Yes/No Buttons - Large touch targets */
.yes-no-container {
    display: flex;
    gap: 16px;
}

.yes-no-container .btn {
    flex: 1;
    min-height: 64px;
    font-size: 18px;
    font-weight: 600;
}

/* Responsive Yes/No for small screens */
@media (max-width: 360px) {
    .yes-no-container {
        gap: 12px;
    }
    
    .yes-no-container .btn {
        min-height: 56px;
        font-size: 16px;
        padding: 12px 16px;
    }
}

/* Short Answer Input - Touch-friendly textarea */
.short-answer-input {
    width: 100%;
    min-height: 100px;
    padding: 16px;
    font-size: 16px; /* Prevents iOS zoom on focus */
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    resize: vertical;
    /* Improve touch responsiveness */
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.short-answer-input:focus {
    outline: none;
    border-color: #4a90d9;
}

/* Lesson Join Screen - Responsive layout */
.join-screen {
    max-width: 400px;
    margin: 0 auto;
    padding-top: 40px;
    padding-left: 16px;
    padding-right: 16px;
}

/* Responsive join screen for small screens */
@media (max-width: 360px) {
    .join-screen {
        padding-top: 24px;
        padding-left: 12px;
        padding-right: 12px;
    }
}

.join-screen .logo {
    text-align: center;
    margin-bottom: 32px;
}

.join-screen .logo h1 {
    font-size: 32px;
    color: #4a90d9;
}

/* QR Scanner Container - Optimized for mobile camera viewport */
.qr-scanner-container {
    width: 100%;
    max-width: 300px;
    margin: 0 auto 24px;
    aspect-ratio: 1;
    background-color: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

/* QR Scanner video element - optimized for camera feed */
.qr-scanner-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Ensure video fills container properly on all devices */
    transform: scaleX(-1); /* Mirror for front camera if needed */
}

/* QR Scanner overlay for better UX */
.qr-scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* QR Scanner viewfinder frame */
.qr-scanner-viewfinder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
}

/* QR Scanner corner markers */
.qr-scanner-viewfinder::before,
.qr-scanner-viewfinder::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: #4a90d9;
    border-style: solid;
}

.qr-scanner-viewfinder::before {
    top: -3px;
    left: -3px;
    border-width: 4px 0 0 4px;
    border-radius: 8px 0 0 0;
}

.qr-scanner-viewfinder::after {
    bottom: -3px;
    right: -3px;
    border-width: 0 4px 4px 0;
    border-radius: 0 0 8px 0;
}

/* QR Scanner instruction text */
.qr-scanner-instruction {
    position: absolute;
    bottom: 16px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Responsive QR scanner for different screen sizes */
@media (max-width: 360px) {
    .qr-scanner-container {
        max-width: 260px;
        margin-bottom: 20px;
    }
}

/* Larger QR scanner for tablets in portrait */
@media (min-width: 500px) and (max-width: 768px) {
    .qr-scanner-container {
        max-width: 350px;
    }
}

/* Landscape orientation optimization for QR scanner */
@media (orientation: landscape) and (max-height: 500px) {
    .qr-scanner-container {
        max-width: 200px;
        margin-bottom: 16px;
    }
    
    .join-screen {
        padding-top: 16px;
    }
}

/* Text Muted */
.text-muted {
    color: #888;
    font-size: 14px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

.mt-16 {
    margin-top: 16px;
}

.mb-16 {
    margin-bottom: 16px;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.gap-8 {
    gap: 8px;
}

.gap-16 {
    gap: 16px;
}


/* Lesson Creation Styles */
.mode-selection {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mode-selection .btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    min-height: 72px;
}

.mode-description {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.8;
    margin-top: 4px;
}

/* Student Upload Tabs */
.student-upload-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.btn-tab {
    flex: 1;
    min-height: 40px;
    padding: 8px 12px;
    font-size: 14px;
}

.btn-tab.active {
    background-color: #4a90d9;
    color: white;
}

.upload-panel {
    padding: 12px 0;
}

.form-hint {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

/* Student Entry Row */
.student-entry-row {
    margin-bottom: 12px;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.student-entry-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.student-entry-fields .form-input {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 14px;
}

.student-entry-fields .btn-sm {
    grid-column: span 2;
    min-height: 36px;
    padding: 6px 12px;
}

/* Student Preview */
.student-preview-list {
    max-height: 150px;
    overflow-y: auto;
    margin-top: 8px;
}

.student-preview-item {
    padding: 8px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

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

/* Warning Text */
.text-warning {
    color: #e65100;
    font-size: 14px;
}


/* Question Creation Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
}

.modal-content {
    background-color: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #888;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.btn-close:hover {
    color: #333;
}

#question-form {
    padding: 20px;
}

.question-textarea {
    min-height: 80px;
    resize: vertical;
}

.modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.modal-footer .btn {
    flex: 1;
}

/* Multiple Choice Option Styles */
.mc-option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.mc-radio {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.mc-option-input {
    flex: 1;
}

.mc-option-row .btn-sm {
    min-height: 36px;
    min-width: 36px;
    padding: 6px;
    flex-shrink: 0;
}

/* Yes/No Selection Styles */
.yes-no-selection {
    display: flex;
    gap: 16px;
}

.yes-no-selection .answer-option {
    flex: 1;
    justify-content: center;
    min-height: 48px;
}

.yes-no-selection .answer-option input[type="radio"] {
    margin-right: 8px;
}


/* Summary Preview Styles */
.summary-preview {
    padding: 12px 0;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #333;
}

.stat-value.stat-correct {
    color: #4caf50;
}

.stat-value.stat-incorrect {
    color: #f44336;
}

.stat-value.stat-unanswered {
    color: #ff9800;
}

.stat-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    margin-top: 2px;
}

/* Accuracy Bar */
.summary-accuracy {
    text-align: center;
}

.accuracy-bar {
    height: 10px;
    background-color: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.accuracy-fill {
    height: 100%;
    background-color: #4caf50;
    border-radius: 5px;
    transition: width 0.5s ease;
}

.accuracy-text {
    font-size: 13px;
    color: #555;
    margin-top: 6px;
}

/* Top Students Preview */
.top-students {
    border-top: 1px solid #e0e0e0;
    padding-top: 12px;
}

.top-students h4 {
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

.mb-8 {
    margin-bottom: 8px;
}

/* Summary Table Mobile */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.summary-table th,
.summary-table td {
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.summary-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #555;
    font-size: 11px;
}

/* Summary Warning */
.summary-warning {
    padding: 10px 12px;
    background-color: #fff3e0;
    border-radius: 6px;
    border-left: 3px solid #ff9800;
    font-size: 13px;
}

/* Lesson List Styles */
.lesson-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.lesson-list-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

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

.lesson-number-badge {
    font-size: 14px;
    font-weight: 700;
    color: #4a90d9;
    background-color: #e3f2fd;
    padding: 6px 10px;
    border-radius: 6px;
    min-width: 70px;
    text-align: center;
}

.lesson-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lesson-status {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 8px;
    display: inline-block;
    width: fit-content;
}

.lesson-status.status-draft {
    background-color: #e0e0e0;
    color: #666;
}

.lesson-status.status-ready {
    background-color: #e3f2fd;
    color: #1976d2;
}

.lesson-status.status-active {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.lesson-status.status-ended {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.lesson-date {
    font-size: 12px;
    color: #666;
}

.lesson-mode {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
}

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

.lesson-actions .btn {
    flex: 1;
}

.btn-sm {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
}

.lesson-list-header {
    flex-direction: column;
    gap: 12px;
}

.mt-24 {
    margin-top: 24px;
}

.mb-24 {
    margin-bottom: 24px;
}

.gap-24 {
    gap: 24px;
}


/* ==================== Additional Mobile Optimizations ==================== */

/* Small Screen Responsive Adjustments (320px - 360px) */
@media (max-width: 360px) {
    /* Reduce padding on cards for small screens */
    .card {
        padding: 16px;
        border-radius: 10px;
    }
    
    .card-title {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    /* Compact form groups */
    .form-group {
        margin-bottom: 12px;
    }
    
    /* Smaller button padding but maintain tap target */
    .btn {
        padding: 10px 16px;
        font-size: 15px;
    }
    
    /* Compact answer options */
    .answer-option {
        min-height: 52px;
        padding: 12px;
    }
    
    /* Smaller modal for small screens */
    .modal-content {
        margin: 8px;
        max-height: calc(100vh - 16px);
    }
    
    .modal-header {
        padding: 12px 16px;
    }
    
    #question-form {
        padding: 16px;
    }
}

/* Extra Small Screen Adjustments (320px) */
@media (max-width: 320px) {
    html {
        font-size: 14px;
    }
    
    .join-screen .logo h1 {
        font-size: 28px;
    }
    
    .card {
        padding: 12px;
    }
    
    .form-input {
        padding: 10px 12px;
        min-height: 44px;
    }
    
    .btn {
        min-height: 44px;
        padding: 8px 12px;
    }
    
    /* Stack student entry fields vertically on very small screens */
    .student-entry-fields {
        grid-template-columns: 1fr;
    }
    
    .student-entry-fields .btn-sm {
        grid-column: span 1;
    }
}

/* ==================== Summary Screen Mobile Optimization ==================== */

/* Summary stats grid - responsive */
.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

@media (max-width: 360px) {
    .summary-stats {
        gap: 8px;
        padding: 12px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 9px;
    }
}

/* Summary table - horizontal scroll on small screens */
.summary-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.summary-table {
    width: 100%;
    min-width: 300px;
    border-collapse: collapse;
    font-size: 13px;
}

@media (max-width: 360px) {
    .summary-table {
        font-size: 12px;
    }
    
    .summary-table th,
    .summary-table td {
        padding: 6px 4px;
    }
}

/* Student results list - mobile optimized */
.student-results-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.student-result-card {
    background-color: white;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

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

.student-result-name {
    font-weight: 600;
    font-size: 16px;
}

.student-result-score {
    font-weight: 700;
    color: #4a90d9;
}

/* ==================== Touch Interaction Improvements ==================== */

/* Active/pressed states for touch feedback */
.btn:active,
.answer-option:active,
.lesson-list-item:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* Prevent accidental double-tap zoom */
.btn,
.answer-option,
.form-input,
.lesson-list-item,
input[type="radio"],
input[type="checkbox"] {
    touch-action: manipulation;
}

/* Improve checkbox and radio touch targets */
input[type="checkbox"],
input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
    cursor: pointer;
}

/* ==================== Safe Area Insets for Notched Devices ==================== */

/* Support for devices with notches (iPhone X+, etc.) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    
    #main-content {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    
    .connection-status {
        padding-top: max(8px, env(safe-area-inset-top));
    }
}

/* ==================== Landscape Orientation Adjustments ==================== */

@media (orientation: landscape) and (max-height: 500px) {
    /* Reduce vertical spacing in landscape */
    .join-screen {
        padding-top: 16px;
    }
    
    .card {
        padding: 12px 16px;
    }
    
    .form-group {
        margin-bottom: 10px;
    }
    
    .timer {
        font-size: 36px;
        padding: 16px;
    }
    
    /* Side-by-side layout for yes/no in landscape */
    .yes-no-container .btn {
        min-height: 48px;
    }
    
    /* Compact answer options in landscape */
    .answer-option {
        min-height: 48px;
        padding: 10px 12px;
    }
    
    /* Reduce modal height in landscape */
    .modal-content {
        max-height: 90vh;
    }
}

/* ==================== Loading and Waiting States ==================== */

/* Improved spinner for mobile */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* Skeleton loading states */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==================== Accessibility Improvements ==================== */

/* Focus states for keyboard/screen reader users */
.btn:focus-visible,
.form-input:focus-visible,
.answer-option:focus-visible {
    outline: 3px solid #4a90d9;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .answer-option {
        border: 2px solid #333;
    }
    
    .form-input {
        border-width: 3px;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .spinner {
        animation: none;
        border-top-color: #4a90d9;
        border-right-color: #4a90d9;
    }
}

/* ==================== Print Styles (for summary) ==================== */

@media print {
    .connection-status,
    .btn,
    .qr-scanner-container {
        display: none !important;
    }
    
    body {
        background-color: white;
        color: black;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}


/* ==================== Landing Page Styles - Mobile ==================== */

.landing-page {
    padding: 32px 16px;
}

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

.landing-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 8px;
}

.landing-subtitle {
    font-size: 15px;
    color: #666;
}

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

.landing-card {
    background-color: white;
    border-radius: 12px;
    padding: 28px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    text-align: center;
    border: 2px solid transparent;
}

.landing-card-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.landing-card h2 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.landing-card p {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 20px;
}

.landing-card-link {
    margin-top: 10px;
    font-size: 14px;
}

.landing-card-link a {
    color: #4a90d9;
    text-decoration: none;
}

.landing-divider {
    text-align: center;
    margin: 24px 0;
    position: relative;
}

.landing-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background-color: #e0e0e0;
}

.landing-divider span {
    position: relative;
    background-color: #ffffff;
    padding: 0 16px;
    color: #888;
    font-size: 13px;
}

.landing-quick-start {
    display: flex;
    justify-content: center;
}

.landing-card-wide {
    width: 100%;
}

/* ==================== Dashboard Styles - Mobile ==================== */

.dashboard {
    padding: 20px 16px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.dashboard-logo {
    max-width: 140px;
    height: auto;
}

.dashboard-content h2 {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.dashboard-content > p {
    font-size: 14px;
    color: #666;
}

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.dashboard-card {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    text-align: center;
    border: 2px solid transparent;
}

.dashboard-card-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.dashboard-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.dashboard-card p {
    font-size: 13px;
    color: #666;
}

/* ==================== End Lesson Bar - Mobile ==================== */

.end-lesson-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
}

.lesson-info-text {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}


/* ==================== Site Header (top bar) - Mobile ==================== */

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
}

.site-header-logo img {
    max-height: 36px;
    width: auto;
    display: block;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-nav-link {
    color: #444;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

/* ==================== Site Footer - Mobile ==================== */

.site-footer {
    margin-top: 48px;
    border-top: 1px solid #e8e8e8;
    background-color: #fafafa;
}

.site-footer-inner {
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.site-footer-social {
    display: flex;
    gap: 16px;
}

.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e8eef5;
    color: #4a90d9;
}

.site-footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px 20px;
}

.site-footer-links a {
    color: #666;
    text-decoration: none;
    font-size: 13px;
}

.site-footer-copyright {
    color: #999;
    font-size: 12px;
    text-align: center;
}


/* ==================== Subscription Page - Mobile ==================== */

.subscription-page {
    padding: 24px 16px;
    text-align: center;
}

.subscription-title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.subscription-subtitle {
    font-size: 15px;
    color: #666;
    margin-bottom: 28px;
}

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

.plan-card {
    background: #fff;
    border: 2px solid #e8e8e8;
    border-radius: 14px;
    padding: 24px 20px;
    position: relative;
}

.plan-card.selected {
    border-color: #4a90d9;
}

.plan-card-featured {
    border-color: #4a90d9;
}

.plan-badge {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #4a90d9;
    margin-bottom: 12px;
}

.plan-amount {
    font-size: 34px;
    font-weight: 700;
    color: #333;
}

.plan-period {
    font-size: 15px;
    color: #888;
}

.plan-original {
    font-size: 15px;
    color: #999;
    min-height: 20px;
    margin-bottom: 8px;
}

.plan-save {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: #2e7d32;
    background: #e8f5e9;
    padding: 4px 12px;
    border-radius: 12px;
    margin-bottom: 12px;
}

.plan-select-btn { margin-top: 12px; }

.coupon-section {
    margin-bottom: 24px;
    text-align: left;
}

.coupon-row {
    display: flex;
    gap: 10px;
}

.coupon-row .form-input {
    flex: 1;
    margin-bottom: 0;
}

.coupon-msg {
    margin-top: 10px;
    font-size: 14px;
}

.coupon-success { color: #2e7d32; }
.coupon-error { color: #c62828; }

.checkout-area {
    padding: 20px;
    border: 1px solid #e8e8e8;
    border-radius: 14px;
    background: #fafafa;
}

.checkout-summary {
    font-size: 16px;
    color: #333;
    margin-bottom: 16px;
}

.checkout-note {
    font-size: 12px;
    color: #888;
    margin-top: 10px;
    text-align: center;
}
