/* Mobile / narrow-window layout for the tutor + admin app.
   Loaded LAST in index.html. unified-final.css resets .dashboard to a fixed
   two-column grid after components.css's mobile rule, which is why the sidebar and
   content stayed side by side and got squashed on phones. Everything here is
   inside a media query, so desktop is untouched. */

@media (max-width: 900px) {
    .container { padding: 10px; }

    /* Header: logo / banner / user info stack and shrink instead of overflowing */
    .header {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
        text-align: center;
    }
    .header .logo { gap: 10px; flex-wrap: wrap; justify-content: center; }
    .logo-image, .banner-image { height: 64px; max-width: 100%; }
    .header .user-info { justify-content: center; flex: 1 1 auto; min-width: 0; }

    /* One column: menu on top, content below. minmax(0,1fr) stops wide content
       (tables, long emails) from stretching the column past the screen. */
    .dashboard {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        min-height: 0;
        align-content: start;
    }
    .dashboard > .sidebar { order: 1; }
    .dashboard > .content-area,
    .dashboard > :not(.sidebar) { order: 2; min-width: 0; }

    .sidebar { padding: 16px; }
    .sidebar-header { padding: 8px 0; margin-bottom: 10px; }
    /* Menu becomes a compact wrapping row of chips rather than 13 tall rows */
    .sidebar .nav-section {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }
    .sidebar .nav-item {
        padding: 8px 12px;
        font-size: 14px;
        gap: 6px;
    }
    .sidebar .nav-item:hover { transform: none; }

    .content-area { padding: 16px; overflow-x: auto; min-width: 0; }
    .content-title { font-size: 1.5rem; }

    /* Rows of buttons wrap instead of running off the edge */
    .flex, .actions-section, .student-management-actions, .content-header,
    .student-filter-controls, .form-actions, .modal-actions {
        flex-wrap: wrap;
    }
    .btn { max-width: 100%; white-space: normal; }
    input, select, textarea { max-width: 100%; box-sizing: border-box; }

    /* Multi-column grids go to a single column */
    .grid, .grid--auto-fit, .grid--three-cols, .grid--two-cols,
    .form-row, .student-info-grid, .analytics-cards {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    /* Student cards */
    .student-card, .student-card * { min-width: 0; }
    .student-card { word-break: break-word; }
    .student-card-actions, .student-actions { flex-direction: column; align-items: stretch; }
    .student-card-actions .btn, .student-card-actions button,
    .student-actions .btn { width: 100%; }

    /* Pop-up windows fit the screen and scroll inside */
    .modal-content, .modal-content.large, .modal-content.extra-large {
        width: 96vw !important;
        max-width: 96vw !important;
        min-width: 0;
        max-height: 92vh;
        margin: 4vh auto;
        overflow-y: auto;
    }
    .modal-header { padding: 14px 16px; }
    .modal-body { padding: 14px 16px; }
    .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .bulk-students-list { max-height: 240px; }

    /* Wide tables scroll sideways inside their own box, not the whole page */
    table { max-width: 100%; }
}

@media (max-width: 480px) {
    .logo-image, .banner-image { height: 48px; }
    .content-area { padding: 12px; }
    .modal-content, .modal-content.large, .modal-content.extra-large {
        width: 100vw !important;
        max-width: 100vw !important;
        margin: 0 auto;
        border-radius: 12px;
    }
}
