/* System-wide mobile polish for frontend, student, instructor, organization, and admin areas. */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

img,
svg,
video,
iframe,
canvas {
    max-width: 100%;
}

table {
    max-width: 100%;
}

.table-responsive,
.customers__table,
.dataTables_wrapper,
.table-responsive-fix {
    max-width: 100%;
}

.table-responsive,
.customers__table,
.dataTables_wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table,
.customers__table table,
.dataTables_wrapper table {
    min-width: 720px;
}

.form-control,
.form-select,
.select2-container,
input,
select,
textarea {
    max-width: 100%;
}

.btn,
.theme-btn,
.theme-button1,
.theme-button2,
.theme-button3 {
    white-space: normal;
}

@media (max-width: 991.98px) {
    body {
        min-width: 0;
    }

    .container,
    .container-fluid {
        width: 100%;
        max-width: 100%;
        padding-left: 14px;
        padding-right: 14px;
    }

    .row {
        --bs-gutter-x: 1rem;
    }

    .main-content,
    .page-content-wrap,
    .page-content,
    .instructor-profile-right-part,
    .instructor-dashboard-wrapper,
    .instructor-dashboard-page-content {
        width: 100%;
        max-width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .admin-order-report-table,
    .table-style,
    .table {
        font-size: 13px;
    }

    .page-content,
    .page-content-wrap {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .breadcrumb__content,
    .item-title,
    .instructor-my-courses-title,
    .header__navbar,
    .header__menu,
    .cart-order-summary-item-box,
    .section-title-wrap {
        flex-wrap: wrap;
        gap: 10px;
    }

    .breadcrumb__content__left,
    .breadcrumb__content__right,
    .item-title h2,
    .instructor-my-courses-title h6 {
        max-width: 100%;
    }

    .breadcrumb__title h2,
    .page-banner-heading,
    .section-title-custom,
    .banner-title,
    .final-cta-title {
        overflow-wrap: anywhere;
    }

    .modal-dialog {
        margin-left: 12px;
        margin-right: 12px;
    }

    .dropdown-menu {
        max-width: calc(100vw - 24px);
    }

    .header__area {
        position: sticky;
        top: 0;
        z-index: 1020;
    }

    .header__navbar {
        min-height: 58px;
    }

    .header__navbar__left,
    .header__navbar__right {
        min-width: 0;
    }

    .header__navbar__left .btn-blue {
        padding: 8px 10px;
        font-size: 12px;
    }

    .header__menu {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 6px;
        margin: 0;
        padding: 0;
    }

    .admin-header-icon-btn,
    .header__menu .btn-dropdown {
        width: 36px;
        height: 36px;
        min-width: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
    }

    .header__menu .dropdown-menu {
        position: absolute !important;
        left: 12px !important;
        right: auto !important;
        width: min(330px, calc(100vw - 24px));
        transform: none !important;
    }

    .sidebar__area {
        position: fixed !important;
        top: 0 !important;
        width: min(300px, 80vw) !important;
        max-width: 80vw !important;
        height: 100vh !important;
        z-index: 1050 !important;
        transition: left 0.3s ease, right 0.3s ease, visibility 0.3s ease !important;
        visibility: hidden !important;
        
        /* Fallback for LTR closed */
        left: -320px !important;
        right: auto !important;
    }

    .sidebar__area.active {
        /* Fallback for LTR active */
        left: 0 !important;
        right: auto !important;
        visibility: visible !important;
    }
    
    /* RTL overrides */
    body.direction-rtl .sidebar__area,
    html[dir="rtl"] .sidebar__area {
        right: -320px !important;
        left: auto !important;
    }

    body.direction-rtl .sidebar__area.active,
    html[dir="rtl"] .sidebar__area.active {
        right: 0 !important;
        left: auto !important;
        visibility: visible !important;
    }

    .sidebar__menu {
        padding-bottom: 28px;
    }

    .sidebar__menu a {
        min-height: 42px;
        line-height: 1.35;
    }

    .instructor-profile-page,
    .instructor-dashboard-wrapper .instructor-profile-page {
        padding-top: 18px;
    }

    .instructor-dashboard-two-part-join {
        margin-left: 0;
        margin-right: 0;
        overflow: visible;
    }

    .instructor-profile-left-part-wrap,
    .instructor-profile-left-part {
        width: 100%;
        max-width: 100%;
    }

    .instructor-profile-left-part {
        margin-bottom: 18px;
    }

    .instructor-sidebar-card,
    .student-sidebar-card {
        width: min(320px, 88vw) !important;
        max-width: 88vw !important;
    }

    .instructor-sidebar-user,
    .student-sidebar-user {
        padding: 16px 12px;
    }

    .instructor-sidebar-nav-list,
    .student-sidebar-nav-list {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 0 10px 12px;
    }

    .instructor-sidebar-nav-item,
    .instructor-sidebar-nav-item a,
    .student-sidebar-nav-item,
    .student-sidebar-nav-item a {
        width: 100%;
        min-width: 0;
    }

    .instructor-sidebar-nav-item a,
    .student-sidebar-nav-item a {
        min-height: 42px;
        padding: 9px 10px;
        border-radius: 10px;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .instructor-sidebar-nav-title,
    .student-sidebar-nav-title {
        margin: 14px 10px 8px;
        font-size: 13px;
    }

    .footer-area,
    .landing-footer {
        overflow: hidden;
    }

    .footer-top-part {
        row-gap: 22px;
    }
}

@media (max-width: 767.98px) {
    body {
        font-size: 14px;
    }

    h1,
    .h1 {
        font-size: 28px;
    }

    h2,
    .h2,
    .breadcrumb__title h2,
    .section-title-custom {
        font-size: 24px;
    }

    h3,
    .h3,
    .page-banner-heading {
        font-size: 21px;
    }

    .page-banner-header .section-overlay,
    .has-account-custom-navbar .page-banner-header:not(.blank-page-banner-header) .section-overlay {
        padding: 34px 0 24px !important;
        min-height: auto !important;
    }

    .customers__area,
    .bg-style,
    .instructor-my-courses-box,
    .order-summary-box,
    .card,
    .unit-card,
    .result-card-premium {
        border-radius: 12px !important;
    }

    .customers__area,
    .instructor-my-courses-box,
    .order-summary-box {
        padding: 14px !important;
    }

    .item-title,
    .instructor-my-courses-title {
        align-items: flex-start !important;
    }

    .item-title h2,
    .instructor-my-courses-title h6 {
        font-size: 18px;
        line-height: 1.35;
    }

    .form-control,
    .form-select,
    .input-group-text,
    .select2-container .select2-selection--single {
        min-height: 42px;
        font-size: 14px;
    }

    textarea.form-control {
        min-height: 110px;
    }

    .input-group {
        flex-wrap: nowrap;
        min-width: 0;
    }

    .input-group > .form-control,
    .input-group > .form-select {
        min-width: 0;
    }

    .btn,
    .theme-btn,
    .theme-button1,
    .theme-button2,
    .theme-button3 {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        line-height: 1.25;
    }

    td .btn,
    td .theme-btn,
    .action__buttons .btn-action,
    form.d-inline:not(td form) .btn {
        width: 100%;
        margin: 3px 0;
    }

    form.d-inline:not(td form),
    .action__buttons {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 6px;
        width: 100%;
    }

    form.d-inline:not(td form) .form-control {
        width: 100% !important;
    }

    /* Preserve horizontal layout for buttons/forms inside scrollable tables on mobile */
    .table-responsive td .btn,
    .table-responsive td form,
    .customers__table td .btn,
    .customers__table td form,
    .dataTables_wrapper td .btn,
    .dataTables_wrapper td form {
        width: auto !important;
        display: inline-block !important;
        margin: 2px !important;
    }

    .dataTables_wrapper .row,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: start !important;
        width: 100%;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin: 6px 0 0;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 4px;
    }

    .account-custom-navbar .navbar-collapse {
        max-height: calc(100vh - 76px);
    }

    .acn-notif-menu,
    .acn-user-menu,
    .custom-lang-dropdown .dropdown-menu {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
    }

    .hero-section-custom {
        min-height: auto;
    }

    .hero-banner-wrapper,
    .hero-banner-img {
        min-height: 180px;
    }

    .features-bento-grid,
    .stats-panel .row,
    .stats-row,
    .learning-path-grid,
    .final-cta-stats {
        gap: 12px;
    }

    .stats-panel,
    .final-cta-card,
    .learning-card,
    .path-card {
        padding: 16px !important;
    }

    .course-sidebar-area,
    .courses-sidebar-area,
    .consultation-sidebar-area {
        margin-bottom: 18px;
    }
}

@media (max-width: 575.98px) {
    .container,
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    .row {
        --bs-gutter-x: 0.75rem;
    }

    .page-content,
    .page-content-wrap {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .header__navbar {
        gap: 8px;
    }

    .header__navbar__left {
        flex: 1 1 auto;
        min-width: 0;
    }

    .header__navbar__right {
        flex: 0 0 auto;
    }

    .header__navbar__left .btn-blue {
        max-width: 92px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header__menu {
        gap: 4px;
    }

    .admin-header-icon-btn,
    .header__menu .btn-dropdown {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .admin-header-icon-btn img,
    .header__menu .btn-dropdown img {
        max-width: 20px;
        max-height: 20px;
    }

    .instructor-sidebar-nav-list {
        grid-template-columns: 1fr;
    }

    .instructor-sidebar-name,
    .instructor-sidebar-email {
        overflow-wrap: anywhere;
    }

    .table-responsive table,
    .customers__table table,
    .dataTables_wrapper table {
        min-width: 640px;
    }

    .customers__area,
    .instructor-my-courses-box,
    .order-summary-box {
        padding: 12px !important;
    }

    .modal-dialog {
        margin: 8px;
    }

    .modal-content {
        border-radius: 14px !important;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 12px !important;
    }

    .footer-widget,
    .footer-about,
    .footer-contact-info {
        text-align: center;
    }

    .footer-links,
    .footer-links ul,
    .footer-social ul,
    .footer-bottom-nav ul {
        justify-content: center;
        align-items: center;
    }

    .footer-payment img,
    .footer-about img {
        margin-left: auto;
        margin-right: auto;
    }

    .pwa-install-btn {
        right: auto !important;
        left: 10px !important;
        bottom: 10px !important;
    }
}

@media (max-width: 380px) {
    h1,
    .h1 {
        font-size: 24px;
    }

    h2,
    .h2,
    .breadcrumb__title h2,
    .section-title-custom {
        font-size: 21px;
    }

    .btn,
    .theme-btn,
    .theme-button1,
    .theme-button2,
    .theme-button3 {
        font-size: 13px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .table-responsive table,
    .customers__table table,
    .dataTables_wrapper table {
        min-width: 580px;
    }
}
