/* Mobile Responsive Fixes */

/* CRITICAL: Prevent ALL images from overflowing on mobile */
@media (max-width: 991px) {
    /* Global image constraint */
    img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    html {
        overflow-x: hidden !important;
    }
}

/* Fix hamburger menu positioning on mobile */
@media (max-width: 991px) {
    /* Fix navbar container to prevent horizontal scroll */
    .navbar .container {
        max-width: 100%;
        padding-left: 15px;
        padding-right: 15px;
        display: flex;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
    }

    /* Ensure navbar brand doesn't push content */
    .navbar-brand {
        max-width: 60%;
        flex-shrink: 1;
        padding-left: 0;
    }

    .brand-class {
        max-width: 100%;
        height: auto;
        margin-right: 0;
        width: auto;
    }

    .brand-class img {
        max-width: 100%;
        height: auto;
    }

    /* Keep hamburger menu visible and in viewport */
    .navbar-toggler {
        margin-right: 0;
        position: relative;
        right: 0;
        flex-shrink: 0;
    }

    /* Prevent navbar from extending beyond viewport */
    .navbar-collapse {
        max-width: 100%;
    }
}

/* Fix news article images on mobile */
@media (max-width: 767px) {
    /* Make news article columns full width on mobile */
    .outer-events .row > [class*='col-'] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 20px;
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Ensure images are responsive - CRITICAL */
    .card-news-article {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 20px;
        overflow: hidden;
    }

    .card-news-article img.card-img-top,
    .card-img-top,
    .outer-events img,
    article img {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 200px;
        max-height: 300px;
        object-fit: cover;
        display: block;
    }
    
    /* Override fixed height from _card.css */
    .card-news-article .card-img-top {
        height: auto !important;
    }

    /* Force all images in news section to be contained */
    .outer-events .card img,
    .outer-events article img {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }

    /* Ensure card body doesn't overflow */
    .card-news-article .card-body,
    .card-body {
        padding: 15px;
        word-wrap: break-word;
        overflow-wrap: break-word;
        min-height: auto;
        max-width: 100%;
    }

    /* Adjust card title for mobile */
    .card h5 {
        font-size: 18px;
        line-height: 24px;
        margin-bottom: 10px;
        height: auto;
    }

    /* Adjust card paragraph */
    .card-news-para {
        font-size: 14px;
        line-height: 20px;
        margin-bottom: 30px;
    }

    /* Fix container overflow - CRITICAL */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
        overflow-x: hidden !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Fix outer-events container - CRITICAL */
    .outer-events {
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow-x: hidden !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .outer-events .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
    }

    /* Fix upcoming meets table on mobile */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }

    table.table {
        font-size: 14px;
        min-width: 500px;
    }

    table.table th,
    table.table td {
        padding: 8px 5px;
        word-wrap: break-word;
        white-space: nowrap;
    }

    table.table th:first-child,
    table.table td:first-child {
        padding-left: 10px;
    }
}

/* Tablet view adjustments */
@media (min-width: 768px) and (max-width: 991px) {
    /* Two columns on tablets */
    .outer-events .row > [class*='col-md-3'] {
        flex: 0 0 50%;
        max-width: 50%;
        margin-bottom: 20px;
    }

    .card-news-article img.card-img-top,
    .card-img-top {
        width: 100%;
        height: auto;
        min-height: 180px;
        max-height: 250px;
        object-fit: cover;
    }

    .card-body {
        min-height: 180px;
    }

    .navbar-brand {
        max-width: 50%;
    }

    .brand-class {
        width: 280px;
        height: auto;
    }
}

/* Small tablets */
@media (min-width: 576px) and (max-width: 767px) {
    .outer-events .row > [class*='col-'] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 20px;
    }
}

/* Prevent any element from causing horizontal scroll */
@media (max-width: 991px) {
    body {
        overflow-x: hidden;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    .row {
        margin-left: 0;
        margin-right: 0;
    }

    [class*='col-'] {
        padding-left: 15px;
        padding-right: 15px;
    }
}
