/* ===================================================================
   text-overflow-fixes.css
   Task 4: Defensive CSS overrides for text overflow & truncation.
   Include this AFTER the main style.css to patch overlap issues.
   =================================================================== */

/* Prevent long words from breaking out of containers */
body {
    overflow-wrap: break-word;
    word-wrap: break-word; /* legacy support */
}

/* Table cells - prevent text from overflowing */
table td,
table th {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Card titles & descriptions - prevent overflow */
.blog-wiki-card h4,
.blog-wiki-card p,
.discussion-inner h4,
.discussion-inner p {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Navigation items - prevent text from wrapping badly */
.simapt-menus li a,
.student-menusul li a {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress bars - cap at 100% width to prevent overflow */
.progress-bar,
.bar,
[role="progressbar"] {
    max-width: 100% !important;
}

/* Panel titles in admin panel */
.panel-title,
.page-ttle {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Form labels - prevent wrapping onto inputs */
.form-group label {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Breadcrumb overflow */
.breadcrumb,
.innerbreadcrumbul {
    overflow: hidden;
    text-overflow: ellipsis;
    flex-wrap: wrap;
}

/* Alert messages - don't overflow container */
.alert {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Mobile responsive text fixes */
@media (max-width: 768px) {
    .simapt-menus li a {
        white-space: normal;
    }
    
    table {
        table-layout: fixed;
        width: 100%;
    }
    
    table td,
    table th {
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Global mobile stabilization layer for legacy responsive conflicts */
@media (max-width: 991px) {
    body.mobile-nav-open {
        overflow: hidden;
    }

    .simapt-header {
        position: sticky;
        top: 0;
        z-index: 100000;
    }

    .simapt-header .header-container,
    .simapt-logos {
        position: relative;
        z-index: 100001;
    }

    .togglemenu,
    .togglemenualogin,
    .student-name,
    .simapt-searchbox,
    .simapt-logo-left {
        position: relative;
        z-index: 100003;
        pointer-events: auto;
    }

    .simapt-menubar ul.simapt-menus,
    .commonmenusnewlisting,
    .student-menus,
    .coursesdropdown-here {
        top: 72px !important;
        height: calc(100vh - 72px) !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .simapt-menubar ul.simapt-menus {
        width: 85vw;
        max-width: 360px;
        left: -85vw;
        z-index: 100004;
        pointer-events: none;
    }

    .simapt-menubar ul.simapt-menus.simaptshowmenus {
        left: 0;
        pointer-events: auto;
    }

    .commonmenusnewlisting {
        width: 85vw !important;
        max-width: 360px;
        left: -85vw !important;
        z-index: 100004;
    }

    .commonmenusnewlisting.commonmenusnewlistingslidethis {
        left: 0 !important;
    }

    .simapt-menus li a,
    .commonmenusnewlisting ul.simapt-menus li a,
    .student-menusul li a {
        white-space: normal !important;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: anywhere;
        line-height: 1.35;
    }

    body#homepages a.readmore.newreadsos.honeban {
        display: none !important;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    p,
    li,
    span,
    a,
    label,
    td,
    th,
    button {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    img,
    video,
    iframe,
    svg,
    canvas,
    table {
        max-width: 100%;
    }

    .row [class*="col-"] {
        min-width: 0;
    }

    body#homepages .simapt-header,
    body#homepages .simapt-header .header-container,
    body#homepages .simapt-logos {
        z-index: 100010 !important;
    }

    body#homepages .simaptafter-login,
    body#homepages .notification-icon,
    body#homepages .student-name,
    body#homepages .simapt-searchbox,
    body#homepages .togglemenualogin,
    body#homepages .togglemenu,
    body#homepages .googletranslate {
        position: relative;
        z-index: 100011;
        pointer-events: auto !important;
    }

    body#homepages .togglemenualogin,
    body#homepages .togglemenu,
    body#homepages .simapt-searchbox,
    body#homepages .student-name h2,
    body#homepages .notification-icon a {
        touch-action: manipulation;
    }

    .course-batch-patch {
        height: auto !important;
        padding: 14px;
    }

    .course-batch-patch h2,
    .course-batch-patch h4,
    .course-batch-patch p,
    .course-details-block h3,
    .course-details-block p,
    .information-block h3,
    .information-block p {
        white-space: normal !important;
        word-break: break-word;
    }

    .coursebook-content-main {
        padding: 12px;
        margin-top: 16px;
    }

    .coursebook-content-inner {
        width: 100%;
        min-width: 0;
        margin-bottom: 12px;
    }

    .curriculumandreview-navsection ul,
    .entroll-buttons,
    .groupbuttonhere {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .curriculumandreview-navsection li,
    .entroll-buttons a,
    .groupbuttonhere a {
        float: none !important;
        width: auto;
        max-width: 100%;
    }

    .curriculumandreview-navsection li a,
    .entroll-buttons a,
    .groupbuttonhere a,
    .book-chapter-list .sublessons li a,
    .booknewclick {
        white-space: normal !important;
        line-height: 1.35;
    }

    .book-chapter-list,
    .book-chapter-acc,
    .panel-group.book-chapter-acc,
    .panel-body,
    .sublessons {
        overflow: visible;
    }
}

@media (max-width: 480px) {
    .simapt-menubar ul.simapt-menus,
    .commonmenusnewlisting {
        width: 90vw !important;
        max-width: none;
        left: -90vw !important;
    }

    .simapt-menubar ul.simapt-menus.simaptshowmenus,
    .commonmenusnewlisting.commonmenusnewlistingslidethis {
        left: 0 !important;
    }

    .simapt-menubar ul.simapt-menus,
    .commonmenusnewlisting,
    .student-menus,
    .coursesdropdown-here {
        top: 68px !important;
        height: calc(100vh - 68px) !important;
    }

    .course-details-block,
    .information-block,
    .course-batch-patch,
    .coursebook-content-main {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .course-batch-patch h2 {
        font-size: 20px !important;
        line-height: 1.3;
    }

    .curriculumandreview-navsection li,
    .entroll-buttons a,
    .groupbuttonhere a {
        width: 100%;
    }
}
