﻿/* ===== GLOBAL MOBILE RESPONSIVE FIXES ===== */

/* Force proper mobile rendering - prevent desktop site mode */
@media only screen and (max-width: 767px) {
    * {
        -webkit-text-size-adjust: none !important;
        -ms-text-size-adjust: none !important;
    }
}

/* Mobile devices - phones */
@media (max-width: 767px) {
    /* Fix viewport and overall width - force mobile mode */
    html {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        font-size: 16px !important;
    }

    body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        -webkit-text-size-adjust: 100% !important;
        -ms-text-size-adjust: 100% !important;
        text-size-adjust: 100% !important;
    }

    /* Force mobile viewport behavior */
    @supports (-webkit-touch-callout: none) {
        body {
            min-height: -webkit-fill-available;
        }
    }

    /* Container width fixes */
    .container, .container-xl, .container-fluid {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Remove padding from containers with carousel */
    .container:has(.carousel),
    .container:has(.owl-carousel),
    .container-fluid:has(.carousel),
    .container-fluid:has(.owl-carousel) {
        padding: 0 !important;
    }

    /* Row fixes to prevent overflow */
    .row {
        margin-left: -10px !important;
        margin-right: -10px !important;
    }

    [class*="col-"] {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Header improvements */
    .header_main {
        padding: 10px 0 !important;
        text-align: center !important;
    }

    .header_main h1 {
        font-size: 18px !important;
        line-height: 1.3 !important;
        margin-bottom: 5px !important;
        text-align: center !important;
    }

    .header_main span {
        font-size: 12px !important;
        display: block !important;
        text-align: center !important;
    }

    /* Center align the department name column */
    .header_main .col-md-10 {
        text-align: center !important;
    }

    /* Logo sizing - controlled size on mobile */
    .emblemb img {
        max-width: 50px !important;
        max-height: 50px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }

    .emblemb2 img {
        max-width: 70px !important;
        max-height: 50px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }

    /* Navigation improvements */
    .navbar {
        padding: 10px 15px !important;
    }

    /* Hamburger menu button - position on right */
    .navbar-toggler {
        border: none !important;
        padding: 8px 10px !important;
        background: transparent !important;
        margin-left: auto !important;
        order: 2 !important;
    }

    .navbar-toggler:focus {
        box-shadow: none !important;
        outline: none !important;
    }

    .navbar-toggler .fa-bars {
        color: #fff !important;
        font-size: 28px !important;
    }

    /* Ensure navbar uses flexbox for proper alignment */
    .navbar {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .navbar-collapse {
        max-height: 400px;
        overflow-y: auto;
        order: 3 !important;
        flex-basis: 100% !important;
    }

    /* Force navbar menu to stack vertically on mobile */
    .navbar-nav {
        flex-direction: column !important;
        width: 100% !important;
    }

    .navbar-nav .nav-item {
        width: 100% !important;
    }

    .nav-link {
        font-size: 16px !important;
        padding: 12px 20px !important;
        width: 100% !important;
        text-align: left !important;
    }

    /* Banner and hero sections */
    .innerBanner {
        min-height: 150px !important;
        padding: 20px 0 !important;
    }

    .innerBanner .innerHeader h2 {
        font-size: 22px !important;
        line-height: 1.3 !important;
    }

    .breadcrumb {
        font-size: 12px !important;
    }

    /* Typography improvements */
    body {
        font-size: 15px !important;
        line-height: 1.6 !important;
    }

    h1 {
        font-size: 24px !important;
        line-height: 1.3 !important;
    }

    h2 {
        font-size: 22px !important;
        line-height: 1.3 !important;
    }

    h3 {
        font-size: 20px !important;
        line-height: 1.4 !important;
    }

    h4 {
        font-size: 18px !important;
        line-height: 1.4 !important;
    }

    h5 {
        font-size: 16px !important;
    }

    p {
        font-size: 15px !important;
        line-height: 1.6 !important;
        margin-bottom: 15px !important;
    }

    /* Images responsive */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Director image - prevent shrinking on mobile */
    .director-image-fixed {
        width: 100% !important;
        height: auto !important;
        min-width: 150px !important;
        object-fit: contain !important;
    }

    /* Specific image containers - full width */
    .owl-carousel img,
    .carousel img,
    .carousel-inner img,
    .photo-gallery img,
    .gallery img,
    .banner img {
        width: 100% !important;
        height: auto !important;
        display: block !important;
    }

    /* Cards and sections */
    .card, .section, [class*="section"] {
        margin-bottom: 20px !important;
    }

    .card-body {
        padding: 15px !important;
    }

    /* Spacing improvements */
    section, .section {
        padding: 30px 0 !important;
    }

    .py-5 {
        padding-top: 30px !important;
        padding-bottom: 30px !important;
    }

    .my-5 {
        margin-top: 30px !important;
        margin-bottom: 30px !important;
    }

    /* Tables scrollable */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        font-size: 14px !important;
    }

    table th, table td {
        padding: 8px !important;
        font-size: 14px !important;
    }

    /* Grid layouts single column */
    .form-grid,
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Buttons touch-friendly */
    button, .btn, .upload-btn, .btn-modern {
        min-height: 44px !important;
        padding: 12px 20px !important;
        font-size: 15px !important;
        width: 100%;
        margin-bottom: 10px;
    }

    .btn-group {
        flex-direction: column !important;
    }

    .btn-group .btn {
        width: 100% !important;
        margin-bottom: 10px !important;
    }

    /* Stack action buttons vertically */
    .action-buttons {
        flex-direction: column !important;
        width: 100%;
    }

    .action-buttons button,
    .action-buttons .btn-modern {
        width: 100%;
        margin-bottom: 10px;
    }

    /* Forms */
    input, select, textarea {
        font-size: 16px !important;
        padding: 12px !important;
        width: 100% !important;
    }

    .form-control {
        font-size: 16px !important;
    }

    /* Footer adjustments - compact version */
    .footer,
    .container-fluid.footer {
        padding: 15px 0 10px 0 !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .footer .container {
        padding: 0 !important;
    }

    .footer .py-5 {
        padding-top: 15px !important;
        padding-bottom: 15px !important;
    }

    /* Footer logo section - compact */
    .logo-footer {
        padding: 10px 0 !important;
    }

    .logo-footer .py-5 {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    .logo-footer .row {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        margin: 0 !important;
    }

    .logo-footer .col-md-4,
    .logo-footer .col-lg-4,
    .logo-footer .col-xl-2 {
        width: 33.33% !important;
        max-width: 33.33% !important;
        flex: 0 0 33.33% !important;
        padding: 5px !important;
        text-align: center !important;
    }

    .logo-footer img {
        max-width: 60px !important;
        max-height: 45px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }

    /* Footer menu section - compact single column */
    .footer .container .row.g-5.fo {
        display: block !important;
        margin: 0 !important;
        padding: 0 15px !important;
    }

    .footer .row.g-5 {
        row-gap: 0 !important;
    }

    .footer .col-md-6,
    .footer .col-lg-6,
    .footer .col-xl-2 {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        display: block !important;
        margin-bottom: 15px !important;
        padding: 10px 15px !important;
        float: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    .footer .col-md-6:last-child,
    .footer .col-lg-6:last-child,
    .footer .col-xl-2:last-child {
        border-bottom: none !important;
        margin-bottom: 5px !important;
    }

    /* Footer headings - compact */
    .footer h4,
    .footer h5, 
    .footer h6,
    .footer h3,
    .footer-item h4 {
        font-size: 16px !important;
        margin-bottom: 8px !important;
        font-weight: 600 !important;
        color: #fff !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        padding-bottom: 5px !important;
        text-align: left !important;
    }

    /* Footer links - compact */
    .footer-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .footer-link,
    .footer a,
    .footer-item a {
        font-size: 13px !important;
        line-height: 1.8 !important;
        margin-bottom: 4px !important;
        color: rgba(255, 255, 255, 0.85) !important;
        text-decoration: none !important;
        display: block !important;
        padding: 3px 0 !important;
    }

    .footer-link:hover,
    .footer a:hover,
    .footer-item a:hover {
        color: #fff !important;
        padding-left: 5px !important;
        transition: all 0.3s ease !important;
    }

    .footer p {
        font-size: 13px !important;
        line-height: 1.6 !important;
        color: rgba(255, 255, 255, 0.9) !important;
        margin-bottom: 5px !important;
    }

    /* Copyright section - compact */
    .container-fluid.copyright {
        padding: 15px 10px 10px 10px !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .copyright .container {
        padding: 0 10px !important;
    }

    .copyright .py-4 {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    .copyright .row {
        display: block !important;
        margin: 0 !important;
    }

    .copyright .col-md-4,
    .copyright .col-md-6,
    .copyright .col-md-2 {
        width: 100% !important;
        max-width: 100% !important;
        text-align: center !important;
        margin-bottom: 12px !important;
        padding: 5px !important;
    }

    .copyright .text-md-start,
    .copyright .text-md-end {
        text-align: center !important;
    }

    .copyright span,
    .copyright a {
        font-size: 11px !important;
        line-height: 1.6 !important;
        display: block !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        color: rgba(255, 255, 255, 0.9) !important;
        margin: 3px 0 !important;
    }

    .copyright .fas.fa-copyright {
        font-size: 12px !important;
        margin-right: 3px !important;
    }

    /* Visitor counter - compact */
    .copyright .visitor {
        display: block !important;
        margin: 5px 0 !important;
        font-size: 11px !important;
    }

    /* Connect with us - compact */
    .copyright img[alt*="Twitter"],
    .copyright img[alt*="X"] {
        width: 22px !important;
        height: 22px !important;
        max-width: 22px !important;
        max-height: 22px !important;
        vertical-align: middle !important;
        margin-left: 5px !important;
    }

    /* Visitor counter and last updated */
    footer .visitor-counter,
    footer [class*="visitor"],
    footer [class*="counter"] {
        text-align: center !important;
        font-size: 14px !important;
        margin: 10px 0 !important;
    }

    /* Footer bottom links - compact */
    .copyright .footer-item.footer-link {
        text-align: center !important;
        display: block !important;
        width: 100% !important;
        padding: 8px 5px !important;
        margin: 5px 0 !important;
    }

    .copyright .footer-link {
        display: inline-block !important;
        margin: 4px 3px !important;
        font-size: 11px !important;
        line-height: 1.6 !important;
        padding: 3px 5px !important;
        color: rgba(255, 255, 255, 0.85) !important;
    }

    /* Separate links with dividers */
    .copyright .footer-link:not(:last-child)::after {
        content: "|" !important;
        margin-left: 8px !important;
        color: rgba(255, 255, 255, 0.4) !important;
    }

    /* Social media icons */
    footer .social-media,
    footer [class*="social"] {
        text-align: center !important;
        margin: 15px 0 !important;
    }

    footer .social-media a,
    footer [class*="social"] a {
        display: inline-block !important;
        margin: 0 8px !important;
    }

    footer .social-media img,
    footer [class*="social"] img {
        width: 35px !important;
        height: 35px !important;
        max-width: 35px !important;
        max-height: 35px !important;
    }

    /* Connect with us section */
    footer [class*="connect"] {
        text-align: center !important;
    }

    /* Back to top button in footer area */
    footer .back-to-top {
        position: fixed !important;
        right: 15px !important;
        bottom: 15px !important;
    }

    /* Back to top button */
    .back-to-top {
        right: 15px !important;
        bottom: 15px !important;
        width: 45px !important;
        height: 45px !important;
    }

    /* Carousel/Banner section - remove white space */
    .carousel, 
    .owl-carousel,
    [class*="carousel"],
    [class*="banner"],
    [class*="slider"] {
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Owl carousel adjustments - fix small images with white space */
    .owl-carousel .owl-stage-outer,
    .owl-carousel .owl-stage {
        height: auto !important;
    }

    .owl-carousel .owl-item {
        height: auto !important;
    }

    .owl-carousel .owl-item img {
        width: 100% !important;
        height: auto !important;
        object-fit: cover !important;
        display: block !important;
        margin: 0 !important;
    }

    /* Carousel navigation arrows - fix positioning */
    .owl-carousel .owl-nav,
    .carousel-control-prev,
    .carousel-control-next {
        z-index: 10 !important;
    }

    .owl-carousel .owl-nav button,
    .owl-carousel .owl-prev,
    .owl-carousel .owl-next {
        position: absolute !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 10 !important;
        background: rgba(0, 0, 0, 0.5) !important;
        color: #fff !important;
        padding: 10px 15px !important;
        font-size: 20px !important;
    }

    .owl-carousel .owl-prev {
        left: 10px !important;
    }

    .owl-carousel .owl-next {
        right: 10px !important;
    }

    /* Bootstrap carousel controls */
    .carousel-control-prev,
    .carousel-control-next {
        width: 40px !important;
        height: 40px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        opacity: 0.8 !important;
    }

    .carousel-control-prev {
        left: 10px !important;
    }

    .carousel-control-next {
        right: 10px !important;
    }

    /* Carousel dots/indicators */
    .owl-carousel .owl-dots,
    .carousel-indicators {
        position: absolute !important;
        bottom: 10px !important;
        z-index: 10 !important;
    }

    /* Bootstrap Carousel container */
    .carousel-inner {
        width: 100% !important;
        height: auto !important;
    }

    .carousel-item {
        width: 100% !important;
        height: auto !important;
    }

    .carousel-item img {
        width: 100% !important;
        height: auto !important;
        object-fit: cover !important;
        display: block !important;
        margin: 0 !important;
    }

    /* Remove any section padding around carousel */
    section:has(.carousel),
    section:has(.owl-carousel),
    div:has(.carousel),
    div:has(.owl-carousel) {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Photo gallery */
    .photo-gallery img {
        width: 100% !important;
        height: auto !important;
        margin-bottom: 15px !important;
        object-fit: cover !important;
    }

    /* Content images should scale properly */
    .content img,
    article img,
    .body-content img {
        max-width: 100% !important;
        height: auto !important;
        width: auto !important;
        display: block;
    }

    /* Listing pages */
    .listing-item {
        padding: 15px !important;
        margin-bottom: 15px !important;
    }

    /* Modal adjustments */
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }

    .modal-content {
        padding: 15px !important;
    }

    /* Prevent text overflow */
    * {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
}

/* Mobile menu fixes for all mobile/tablet sizes */
@media (max-width: 991px) {
    /* Ensure dropdown menu is visible on mobile */
    .navbar .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        margin-top: 0;
        background-color: #f5f5f5 !important;
        border: none;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
        padding: 10px 0 !important;
    }

    .navbar .dropdown-menu .dropdown-item {
        padding: 12px 20px 12px 30px !important;
        color: #333 !important;
        background-color: transparent !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        font-size: 16px;
        font-weight: 400;
    }

    .navbar .dropdown-menu .dropdown-item:last-child {
        border-bottom: none;
    }

    .navbar .dropdown-menu .dropdown-item:hover,
    .navbar .dropdown-menu .dropdown-item:focus,
    .navbar .dropdown-menu .dropdown-item:active {
        background-color: #95241e !important;
        color: #ffffff !important;
    }

    /* Dropdown toggle arrow */
    .navbar .dropdown-toggle::after {
        float: right;
        margin-top: 8px;
    }

    /* Show dropdown when active */
    .navbar .dropdown.show .dropdown-menu {
        display: block;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991px) {
    /* Container adjustments for tablets */
    .container, .container-xl {
        max-width: 100% !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    /* Typography for tablets */
    body {
        font-size: 15px;
    }

    h1 {
        font-size: 28px !important;
    }

    h2 {
        font-size: 24px !important;
    }

    h3 {
        font-size: 22px !important;
    }

    /* Grid adjustments */
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    /* Buttons */
    .btn {
        padding: 12px 20px !important;
    }

    /* Header */
    .header_main h1 {
        font-size: 22px !important;
    }

    /* Navigation */
    .nav-link {
        font-size: 15px !important;
    }
}

/* Small tablets and large phones landscape */
@media (min-width: 576px) and (max-width: 767px) {
    .container, .container-xl {
        max-width: 100% !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    h1 {
        font-size: 26px !important;
    }

    h2 {
        font-size: 24px !important;
    }

    .btn {
        width: auto !important;
        display: inline-block !important;
    }
}

/* Desktop and desktop site mode - normal image behavior */
@media (min-width: 768px) {
    /* Reset aggressive mobile image rules */
    img {
        max-width: 100%;
        height: auto;
        width: auto;
    }

    /* Carousel and gallery images should be responsive */
    .owl-carousel img,
    .carousel img,
    .photo-gallery img,
    .gallery img,
    .banner img {
        width: 100%;
        height: auto;
        object-fit: cover;
    }

    /* Logo images - proper desktop size */
    .emblemb img {
        max-width: 80px;
        max-height: 80px;
        width: auto;
        height: auto;
        object-fit: contain;
    }

    .emblemb2 img {
        max-width: 130px;
        max-height: 50px;
        width: auto;
        height: auto;
        object-fit: contain;
    }

    /* Footer images - proper size */
    footer img {
        max-width: 120px;
        max-height: 80px;
        width: auto;
        height: auto;
        object-fit: contain;
    }

    /* Content images maintain aspect ratio */
    .content img,
    article img,
    .body-content img {
        max-width: 100%;
        height: auto;
        width: auto;
    }

    /* Director image - maintain size on desktop */
    .director-image-fixed {
        width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
        max-width: 100% !important;
    }
}
