/*
 * SRIS responsive foundation
 * Scope is intentionally limited to student pages and the public login screen.
 * It contains presentation/accessibility rules only; no module behavior is changed.
 */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.sris-role-student,
body.sris-login-page {
    overflow-x: hidden;
}

body.sris-role-student *,
body.sris-login-page * {
    box-sizing: border-box;
}

body.sris-role-student img,
body.sris-login-page img {
    max-width: 100%;
    height: auto;
}

body.sris-role-student a:focus-visible,
body.sris-role-student button:focus-visible,
body.sris-role-student input:focus-visible,
body.sris-role-student select:focus-visible,
body.sris-role-student textarea:focus-visible,
body.sris-login-page a:focus-visible,
body.sris-login-page button:focus-visible,
body.sris-login-page input:focus-visible,
body.sris-login-page select:focus-visible {
    outline: 3px solid rgba(14, 165, 233, .35);
    outline-offset: 2px;
}

body.sris-role-student .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

body.sris-role-student table {
    max-width: 100%;
}

body.sris-role-student .form-control,
body.sris-role-student .select2-container,
body.sris-role-student .select2-choice,
body.sris-role-student .select2-selection {
    max-width: 100%;
}

/* Shared student data screens: Subjects, Grades, Payments, and LMS listings. */
body.sris-role-student .dataTables_wrapper {
    width: 100%;
    max-width: 100%;
}

body.sris-role-student .dataTables_wrapper::after {
    display: table;
    clear: both;
    content: "";
}

body.sris-role-student .dataTables_wrapper .dataTables_filter input,
body.sris-role-student .dataTables_wrapper .dataTables_length select {
    max-width: 100%;
}

body.sris-role-student .panel-heading {
    overflow-wrap: anywhere;
}

body.sris-role-student .alert,
body.sris-role-student .help-block,
body.sris-role-student td,
body.sris-role-student th {
    overflow-wrap: anywhere;
}

body.sris-role-student iframe,
body.sris-role-student video,
body.sris-role-student object,
body.sris-role-student embed {
    width: 100%;
    max-width: 100%;
}

body.sris-role-student .student-profile-settings #blah {
    display: block;
    width: min(200px, 100%);
    height: auto;
    margin-top: 12px;
    border-radius: 10px;
    object-fit: cover;
}

/* People directories, downloadable resources, and live-quiz entry. */
body.sris-role-student.sris-page-teacher .table-responsive img,
body.sris-role-student.sris-page-class_mate .table-responsive img {
    width: 38px;
    height: 38px;
    max-width: none;
    object-fit: cover;
}

body.sris-role-student.sris-page-assignment .table-responsive td:nth-child(2) img,
body.sris-role-student.sris-page-study_material .table-responsive td:nth-child(2) img {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

body.sris-role-student.sris-page-assignment .btn-circle,
body.sris-role-student.sris-page-study_material .btn-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

body.sris-role-student .join-live {
    width: min(100%, 520px);
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(49, 46, 129, .12);
}

body.sris-role-student .join-live input {
    max-width: 100%;
}

body.sris-role-student .student-routine-note,
body.sris-role-student .student-routine-empty {
    margin-bottom: 14px;
}

body.sris-role-student .student-routine-table td {
    vertical-align: middle;
}

body.sris-role-student .student-routine-table small {
    color: #64748b;
}

body.sris-role-student .student-routine-time-separator {
    display: inline-block;
    margin: 0 3px;
    color: #94a3b8;
}

/* Login stays operable above mobile keyboards and display safe areas. */
body.sris-login-page .login-register {
    min-height: 100vh;
    min-height: 100dvh;
}

body.sris-login-page .login-sidebar .form-control,
body.sris-login-page .login-sidebar button {
    min-height: 44px;
}

body.sris-login-page .sris-login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 14px;
}

body.sris-login-page .sris-recovery-note {
    margin-bottom: 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.55;
    text-align: left;
}

@media (max-width: 767px) {
    body.sris-role-student {
        --sris-mobile-gutter: clamp(12px, 4vw, 18px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    body.sris-role-student .navbar-static-top {
        position: sticky;
        top: 0;
        z-index: 1040;
        min-height: 60px;
        padding-top: env(safe-area-inset-top, 0px);
    }

    body.sris-role-student .navbar-header {
        min-height: 60px;
    }

    body.sris-role-student .navbar-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 48px;
        margin: 6px 4px 6px 8px;
        border: 0;
        color: #fff;
    }

    body.sris-role-student .top-left-part {
        position: static;
        display: inline-block;
        width: auto !important;
        max-width: calc(100vw - 150px);
    }

    body.sris-role-student .top-left-part .logo {
        display: flex;
        align-items: center;
        min-height: 60px;
        padding: 0 8px;
    }

    body.sris-role-student .top-left-part .logo b,
    body.sris-role-student .top-left-part .logo img {
        width: 42px !important;
        height: 42px !important;
        flex: 0 0 42px;
    }

    body.sris-role-student .navbar-top-links.navbar-right {
        position: absolute;
        top: env(safe-area-inset-top, 0px);
        right: max(4px, env(safe-area-inset-right, 0px));
        margin: 0;
    }

    body.sris-role-student .navbar-top-links > li > a {
        min-width: 44px;
        min-height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 10px;
    }

    body.sris-role-student .navbar-top-links .profile-pic img {
        width: 36px;
        height: 36px;
        object-fit: cover;
    }

    body.sris-role-student .navbar-top-links .dropdown-menu {
        position: fixed !important;
        top: calc(60px + env(safe-area-inset-top, 0px)) !important;
        right: max(8px, env(safe-area-inset-right, 0px)) !important;
        left: auto !important;
        width: min(300px, calc(100vw - 16px)) !important;
        max-height: calc(100dvh - 76px - env(safe-area-inset-top, 0px)) !important;
        overflow-y: auto !important;
        transform: none !important;
    }

    body.sris-role-student .right-side-toggle {
        display: none;
    }

    body.sris-role-student .navbar-default.sidebar {
        top: calc(60px + env(safe-area-inset-top, 0px));
        max-height: calc(100dvh - 60px - env(safe-area-inset-top, 0px));
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    body.sris-role-student .sidebar-nav,
    body.sris-role-student .slimScrollDiv,
    body.sris-role-student .slimscrollsidebar {
        height: auto !important;
        min-height: 100%;
        overflow: visible !important;
    }

    body.sris-role-student #side-menu > li > a,
    body.sris-role-student #side-menu .nav-second-level > li > a {
        display: flex;
        align-items: center;
        min-height: 46px;
        white-space: normal;
    }

    body.sris-role-student #page-wrapper {
        width: 100%;
        min-width: 0;
        margin-left: 0 !important;
    }

    body.sris-role-student #page-wrapper > .container-fluid {
        width: 100%;
        min-width: 0;
        padding-left: var(--sris-mobile-gutter);
        padding-right: var(--sris-mobile-gutter);
    }

    body.sris-role-student .bg-title {
        margin-left: calc(-1 * var(--sris-mobile-gutter)) !important;
        margin-right: calc(-1 * var(--sris-mobile-gutter)) !important;
        padding: 14px var(--sris-mobile-gutter) !important;
    }

    body.sris-role-student .bg-title .page-title {
        font-size: 18px;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    body.sris-role-student .row {
        min-width: 0;
    }

    body.sris-role-student [class*="col-"] {
        min-width: 0;
    }

    body.sris-role-student .white-box,
    body.sris-role-student .panel,
    body.sris-role-student .student-panel,
    body.sris-role-student .student-card {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    body.sris-role-student .white-box,
    body.sris-role-student .panel-body {
        padding-left: 14px;
        padding-right: 14px;
    }

    body.sris-pro-ui.sris-role-student .panel-heading {
        display: flex !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        min-height: 52px !important;
        padding: 13px 14px !important;
        line-height: 1.35 !important;
    }

    body.sris-pro-ui.sris-role-student .panel-heading .pull-right {
        float: none !important;
        margin-left: auto !important;
    }

    body.sris-pro-ui.sris-role-student .panel-heading .pull-right .btn,
    body.sris-pro-ui.sris-role-student .panel-heading > .btn.pull-right {
        min-height: 36px !important;
        white-space: normal !important;
    }

    body.sris-role-student input,
    body.sris-role-student select,
    body.sris-role-student textarea,
    body.sris-role-student .form-control {
        font-size: 16px;
    }

    body.sris-role-student input:not([type="checkbox"]):not([type="radio"]),
    body.sris-role-student select,
    body.sris-role-student .btn,
    body.sris-role-student button {
        min-height: 44px;
    }

    body.sris-role-student .form-inline {
        display: flex;
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    body.sris-role-student .form-inline .form-group,
    body.sris-role-student .form-inline label,
    body.sris-role-student .form-inline .form-control {
        display: block;
        width: 100%;
        margin: 0;
    }

    body.sris-role-student .dataTables_wrapper .dataTables_length,
    body.sris-role-student .dataTables_wrapper .dataTables_filter,
    body.sris-role-student .dataTables_wrapper .dataTables_info,
    body.sris-role-student .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        width: 100% !important;
        margin: 0 0 12px !important;
        text-align: left !important;
    }

    body.sris-role-student .dataTables_wrapper .dataTables_filter label,
    body.sris-role-student .dataTables_wrapper .dataTables_length label {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 7px;
        width: 100%;
    }

    body.sris-pro-ui.sris-role-student .dataTables_wrapper .dataTables_filter input {
        flex: 1 1 180px;
        width: auto !important;
        min-width: 0;
        min-height: 44px !important;
        margin-left: 0 !important;
        font-size: 16px !important;
    }

    body.sris-pro-ui.sris-role-student .dataTables_wrapper .dataTables_length select {
        width: auto !important;
        min-height: 44px !important;
        font-size: 16px !important;
    }

    body.sris-role-student .dataTables_wrapper .dataTables_paginate {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 4px;
    }

    body.sris-role-student .dataTables_wrapper .dataTables_paginate .paginate_button {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        min-height: 40px;
        margin: 0 !important;
    }

    body.sris-role-student .table-responsive {
        margin-bottom: 16px;
        border: 0;
    }

    body.sris-role-student .table-responsive > table,
    body.sris-role-student .dataTables_wrapper table {
        width: max-content !important;
        min-width: 100%;
    }

    body.sris-role-student .table-responsive td,
    body.sris-role-student .table-responsive th {
        max-width: min(260px, 72vw);
        white-space: normal !important;
    }

    body.sris-role-student .table-responsive td .btn {
        margin: 2px;
        white-space: normal;
    }

    body.sris-role-student.sris-page-teacher .table-responsive td,
    body.sris-role-student.sris-page-class_mate .table-responsive td {
        vertical-align: middle !important;
    }

    body.sris-role-student.sris-page-assignment .btn-circle,
    body.sris-role-student.sris-page-study_material .btn-circle {
        width: 44px !important;
        min-width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
        padding: 0 !important;
    }

    body.sris-role-student.sris-page-assignment .table-responsive td:nth-child(7),
    body.sris-role-student.sris-page-study_material .table-responsive td:nth-child(7) {
        min-width: min(240px, 70vw);
    }

    body.sris-role-student.sris-page-class_routine .student-routine-table td:nth-child(2),
    body.sris-role-student.sris-page-class_routine .student-routine-table th:nth-child(2) {
        min-width: 170px;
        white-space: nowrap !important;
    }

    body.sris-role-student.sris-page-class_routine .student-routine-table td:nth-child(3),
    body.sris-role-student.sris-page-class_routine .student-routine-table th:nth-child(3) {
        min-width: min(230px, 68vw);
    }

    body.sris-role-student .student-dashboard {
        width: 100%;
        min-width: 0;
    }

    body.sris-role-student .student-hero,
    body.sris-role-student .student-grid,
    body.sris-role-student .student-main,
    body.sris-role-student .lms-row {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    body.sris-role-student .student-hero {
        gap: 16px;
        padding: 20px 16px;
    }

    body.sris-role-student .student-hero h2 {
        font-size: clamp(22px, 7vw, 30px);
        overflow-wrap: anywhere;
    }

    body.sris-role-student .student-badges {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    body.sris-role-student .student-progress-ring {
        margin: 0;
    }

    body.sris-role-student .student-panel {
        padding: 16px;
    }

    body.sris-role-student .period-row {
        grid-template-columns: minmax(80px, .8fr) minmax(80px, 1.2fr) auto !important;
        gap: 8px;
    }

    body.sris-role-student .student-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    body.sris-role-student .quick-actions a {
        display: flex;
        align-items: center;
        min-height: 46px;
    }

    /* LMS assessment and result pages retain their application behavior. */
    body.sris-role-student .student-assessment-page {
        width: 100%;
        max-width: 100%;
    }

    body.sris-role-student .student-assessment-header,
    body.sris-role-student .student-security-strip,
    body.sris-role-student .student-assessment-actions {
        flex-wrap: wrap;
    }

    body.sris-role-student .student-assessment-timer {
        position: sticky;
        top: calc(66px + env(safe-area-inset-top, 0px));
        z-index: 20;
    }

    body.sris-role-student .student-question-card,
    body.sris-role-student .student-assessment-form {
        padding-left: 14px;
        padding-right: 14px;
    }

    body.sris-role-student .student-question-title {
        flex-wrap: wrap;
        overflow-wrap: anywhere;
    }

    body.sris-role-student .student-question-points {
        margin-left: 38px;
    }

    body.sris-role-student .student-answer-option {
        min-height: 48px;
        touch-action: manipulation;
    }

    body.sris-role-student .student-answer-text {
        min-height: 44px;
        font-size: 16px !important;
    }

    body.sris-role-student .secure-assessment-overlay {
        overflow-y: auto;
        padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    }

    body.sris-role-student .secure-assessment-dialog {
        width: min(100%, 520px);
        max-height: calc(100dvh - 32px);
        overflow-y: auto;
        padding: 22px 16px;
    }

    body.sris-role-student.sris-page-examResult .panel-body > .btn-lg,
    body.sris-role-student.sris-page-examReview .panel-body > .btn,
    body.sris-role-student.sris-page-results td .btn,
    body.sris-role-student.sris-page-studentExams td .btn {
        width: 100%;
        margin: 4px 0;
        white-space: normal;
    }

    body.sris-role-student.sris-page-examReview .alert {
        white-space: pre-wrap !important;
        word-break: break-word;
    }

    body.sris-role-student .student-profile-settings > [class*="col-"] {
        float: none;
        width: 100%;
    }

    body.sris-role-student .student-profile-settings input[type="file"] {
        height: auto;
        min-height: 48px;
        padding: 9px;
    }

    body.sris-role-student .modal {
        padding-right: 0 !important;
    }

    body.sris-role-student .modal-dialog {
        width: auto;
        max-width: calc(100vw - 20px);
        margin: max(10px, env(safe-area-inset-top, 0px)) auto;
    }

    body.sris-role-student .modal-content {
        max-height: calc(100dvh - 20px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        overflow-y: auto !important;
        overscroll-behavior: contain;
    }

    body.sris-role-student .modal-footer {
        display: flex;
        align-items: stretch;
        flex-wrap: wrap;
        gap: 8px;
    }

    body.sris-role-student .modal-footer .btn {
        flex: 1 1 130px;
        margin: 0 !important;
    }

    body.sris-role-student .join-live {
        margin: 16px auto;
        padding: clamp(20px, 6vw, 28px) 16px;
    }

    body.sris-role-student .join-live h2 {
        font-size: clamp(22px, 7vw, 30px);
        overflow-wrap: anywhere;
    }

    body.sris-role-student .join-live input {
        height: 58px;
        padding-left: 8px;
        padding-right: 8px;
        font-size: clamp(20px, 7vw, 27px) !important;
        letter-spacing: clamp(2px, 1.5vw, 6px);
    }

    /* Live Quiz owns an immersive UI; these rules add viewport/safe-area guards only. */
    body.sris-role-student.sris-page-quizLiveWaiting .live-student-area {
        padding-left: max(8px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(8px, env(safe-area-inset-right, 0px)) !important;
        padding-bottom: max(88px, calc(76px + env(safe-area-inset-bottom, 0px))) !important;
    }

    body.sris-role-student.sris-page-quizLiveWaiting .reaction-dock {
        bottom: max(10px, env(safe-area-inset-bottom, 0px)) !important;
        max-width: calc(100vw - 16px);
        overflow-x: auto;
        overscroll-behavior-inline: contain;
    }

    body.sris-role-student.sris-page-quizLiveWaiting .reaction-dock button {
        flex: 0 0 44px;
        width: 44px !important;
        height: 44px !important;
        min-height: 44px;
    }

    body.sris-role-student.sris-page-quizLiveWaiting .character-controls select,
    body.sris-role-student.sris-page-quizLiveWaiting .qbit-option select,
    body.sris-role-student.sris-page-quizLiveWaiting #live-answer-fields input,
    body.sris-role-student.sris-page-quizLiveWaiting #live-answer-fields textarea {
        min-height: 44px !important;
        font-size: 16px !important;
    }

    body.sris-role-student.sris-page-quizLiveWaiting .qbit-head,
    body.sris-role-student.sris-page-quizLiveWaiting .qbit-actions {
        flex-wrap: wrap;
        gap: 10px;
    }

    body.sris-login-page .login-register {
        position: fixed;
        inset: 0;
        overflow-x: hidden;
        overflow-y: auto;
        padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
        -webkit-overflow-scrolling: touch;
    }

    body.sris-login-page .login-box.login-sidebar {
        position: relative;
        inset: auto;
        width: 100%;
        min-height: 100%;
        height: auto;
        margin: 0;
        overflow: visible;
    }

    body.sris-login-page .login-sidebar .white-box {
        width: min(100%, 460px);
        min-height: 100%;
        margin: 0 auto;
        padding: clamp(20px, 6vw, 36px);
    }

    body.sris-login-page .login-box > br,
    body.sris-login-page #loginform > br,
    body.sris-login-page #recoverform > br {
        display: none;
    }

    body.sris-login-page #loginform,
    body.sris-login-page #recoverform {
        padding-bottom: 24px;
    }

    body.sris-login-page .form-group .pull-left,
    body.sris-login-page .form-group .pull-right {
        float: none !important;
    }

    body.sris-login-page #recoverform .col-xs-6 {
        width: 100%;
    }

    body.sris-login-page #to-recover {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        margin-top: 8px;
    }
}

@media (max-width: 420px) {
    body.sris-role-student .navbar-top-links > li > a {
        padding-left: 7px;
        padding-right: 7px;
    }

    body.sris-role-student .period-row {
        grid-template-columns: 1fr auto !important;
    }

    body.sris-role-student .period-row .period-track {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    body.sris-role-student.sris-page-quizLiveWaiting .character-controls,
    body.sris-role-student.sris-page-quizLiveWaiting .secure-live {
        max-width: 54%;
        font-size: 11px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.sris-role-student *,
    body.sris-login-page * {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
