/* Mobile Optimizations for Year 7 SAT Testing Platform & Chapter Navigation */
/* This file provides responsive enhancements for all Section 11 components */

/* Base responsive utilities */
@media (max-width: 1200px) {
    .container {
        margin: 0 1rem;
        border-radius: 15px;
    }
    
    .main-content {
        padding: 1.5rem;
    }
}

/* Tablet optimizations */
@media (max-width: 768px) {
    /* === SAT Testing Platform Components === */
    
    /* Header adjustments */
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1.5rem;
    }
    
    .header-left h1 {
        font-size: 1.8rem;
    }
    
    .header-right {
        flex-direction: column;
        width: 100%;
    }
    
    .header-button {
        width: 100%;
        text-align: center;
    }
    
    /* Navigation tabs */
    .dashboard-tabs,
    .authoring-tabs,
    .analytics-nav {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .tab,
    .nav-item {
        width: 100%;
        text-align: center;
        padding: 1rem;
    }
    
    /* Grid layouts */
    .dashboard,
    .stats-overview,
    .analytics-overview,
    .dashboard-grid,
    .section-grid,
    .test-options,
    .topic-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Test interface */
    .test-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .test-info {
        flex-direction: column;
        gap: 1rem;
    }
    
    .navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-button {
        width: 100%;
    }
    
    /* Question display */
    .question-text {
        font-size: 1.1rem;
    }
    
    .multiple-choice {
        gap: 0.5rem;
    }
    
    .choice {
        padding: 0.75rem;
        font-size: 0.95rem;
    }
    
    /* Forms and inputs */
    .form-input,
    .exercise-input,
    .answer-input,
    .practice-input {
        width: 100%;
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    .difficulty-selector {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .difficulty-option {
        width: 100%;
    }
    
    /* Filter panels */
    .filters-panel,
    .search-filters,
    .filters {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .filter-select,
    .search-input {
        width: 100%;
    }
    
    .export-btn,
    .export-button {
        margin-left: 0;
        width: 100%;
    }
    
    /* Student list and cards */
    .student-card {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .student-stats {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    /* Charts and analytics */
    .chart-container {
        padding: 1rem;
    }
    
    .chart-title {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .comparison-chart {
        grid-template-columns: 1fr;
    }
    
    .results-details {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Tables */
    .data-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    /* Action buttons */
    .action-buttons,
    .button-group {
        flex-direction: column;
        gap: 1rem;
    }
    
    .button {
        width: 100%;
    }
    
    /* === Chapter Navigation & Calculator Components === */
    
    .chapter-nav {
        flex-direction: column !important;
        gap: 0.5rem !important;
        text-align: center !important;
        padding: 0.8rem !important;
    }
    
    .nav-left, .nav-right, .back-link {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.9rem !important;
        width: 150px !important;
    }
    
    .chapter-title {
        font-size: 1.8rem !important;
    }
    
    .chapter-content {
        padding: 1.5rem 1rem !important;
    }
    
    .input-section,
    .concepts-grid,
    .scenarios-grid,
    .comparison-grid,
    .types-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .vs-symbol {
        display: none !important;
    }
    
    .calc-input, .exercise-input {
        font-size: 1.1rem !important;
        padding: 0.8rem !important;
    }
    
    .exercise-input {
        width: 120px !important;
    }
    
    .calculate-button, .check-button {
        width: 200px !important;
        padding: 0.8rem 1.5rem !important;
        font-size: 1rem !important;
        display: block !important;
        margin: 0.8rem auto !important;
    }
    
    .result-item {
        flex-direction: column !important;
        gap: 0.5rem !important;
        text-align: center !important;
    }
    
    .step-calculation {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        font-size: 1rem !important;
    }
    
    .exercise-question {
        font-size: 1.1rem !important;
        line-height: 1.4 !important;
    }
    
    .calculator-tabs {
        flex-direction: column !important;
        align-items: center !important;
    }
    
    .tab-button {
        width: 200px !important;
        margin: 0.5rem 0 !important;
    }
}

/* Mobile phone optimizations */
@media (max-width: 480px) {
    /* === SAT Testing Platform Mobile === */
    
    /* Further reduce padding and margins */
    .container {
        margin: 0 0.5rem;
        border-radius: 10px;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .header {
        padding: 1rem;
    }
    
    .header-left h1 {
        font-size: 1.5rem;
    }
    
    .header-left p {
        font-size: 1rem;
    }
    
    /* Compact navigation */
    .tab,
    .nav-item {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Smaller cards */
    .stat-card,
    .metric-card,
    .test-card,
    .section-card {
        padding: 1rem;
    }
    
    .stat-number,
    .metric-number {
        font-size: 2rem;
    }
    
    /* Compact question display */
    .question-card {
        padding: 1rem;
    }
    
    .question-number {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    
    .question-text {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    /* Smaller form elements */
    .form-input,
    .answer-input {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    .choice {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    .choice-letter {
        width: 25px;
        height: 25px;
        font-size: 0.8rem;
    }
    
    /* Compact results */
    .results-details {
        grid-template-columns: 1fr;
    }
    
    .detail-card {
        padding: 1rem;
    }
    
    .detail-number {
        font-size: 1.5rem;
    }
    
    /* Smaller charts */
    .chart-container {
        padding: 0.75rem;
    }
    
    .chart-placeholder {
        height: 200px;
        font-size: 1rem;
    }
    
    /* Compact analytics */
    .progress-stats {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .insight-item,
    .recommendation-item {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Smaller tables */
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    /* Touch-friendly buttons */
    .button,
    .check-btn,
    .nav-button {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-height: 44px; /* iOS touch target minimum */
    }
    
    /* Question authoring on mobile */
    .choice-item {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .choice-input {
        width: 100%;
    }
    
    .correct-toggle {
        width: 100%;
        text-align: center;
    }
    
    /* Import/export on mobile */
    .import-area {
        padding: 2rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Analytics on mobile */
    .heatmap {
        grid-template-columns: repeat(7, 1fr);
        gap: 1px;
    }
    
    .heatmap-cell {
        font-size: 0.7rem;
    }
    
    /* === Chapter Navigation Mobile === */
    
    .chapter-title {
        font-size: 1.6rem !important;
    }
    
    .chapter-content {
        padding: 1rem 0.8rem !important;
    }
    
    .nav-left, .nav-right, .back-link {
        width: 130px !important;
        font-size: 0.8rem !important;
    }
    
    .exercise-input {
        width: 100px !important;
    }
    
    .calculate-button, .check-button {
        width: 180px !important;
        font-size: 0.9rem !important;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 1rem;
    }
    
    .header-left h1 {
        font-size: 1.6rem;
    }
    
    .test-header {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .test-info {
        flex-direction: row;
        gap: 2rem;
    }
    
    .navigation {
        flex-direction: row;
    }
    
    .nav-button {
        width: auto;
        min-width: 120px;
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .button,
    .nav-button,
    .check-btn {
        border-width: 0.5px;
    }
    
    .progress-bar,
    .topic-bar,
    .comparison-bar {
        height: 6px;
    }
    
    .star {
        width: 10px;
        height: 10px;
    }
}

/* Dark mode support (if device prefers) */
@media (prefers-color-scheme: dark) {
    .chart-placeholder {
        background: linear-gradient(135deg, #2c3e50, #34495e);
        color: #ecf0f1;
    }
    
    .table th {
        background: #34495e;
        color: #ecf0f1;
    }
    
    .form-input:focus {
        box-shadow: 0 0 20px rgba(52, 152, 219, 0.3);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles for reports */
@media print {
    .header,
    .navigation,
    .filters-panel,
    .action-buttons {
        display: none;
    }
    
    .container {
        box-shadow: none;
        border-radius: 0;
        margin: 0;
    }
    
    .chart-container,
    .data-table {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .insight-item,
    .recommendation-item {
        break-inside: avoid;
    }
}

/* Focus styles for keyboard navigation */
.button:focus,
.nav-button:focus,
.check-btn:focus,
.tab:focus,
.nav-item:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* Improved touch targets */
@media (pointer: coarse) {
    .button,
    .nav-button,
    .check-btn,
    .tab,
    .nav-item,
    .choice {
        min-height: 44px;
        min-width: 44px;
    }
    
    .heatmap-cell {
        min-width: 30px;
        min-height: 30px;
    }
}

/* Performance optimizations */
.chart-container,
.question-card,
.stat-card {
    will-change: transform;
    transform: translateZ(0);
}

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

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top: 2px solid #3498db;
    animation: spin 1s linear infinite;
}

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