/**
 * Mobile responsiveness fixes — Pemba Islamic College
 * Load after theme CSS on every page.
 */

/* ---------- Global ---------- */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
}

img,
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* ---------- Homepage header / nav ---------- */
@media (max-width: 991px) {
    .top-navbar .navbar .container-fluid {
        flex-wrap: wrap !important;
        align-items: center !important;
        row-gap: 6px;
    }

    .top-navbar .navbar-collapse {
        width: 100% !important;
        flex-basis: 100% !important;
        max-height: min(75vh, 560px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: 8px;
    }

    .top-navbar .navbar-nav {
        width: 100% !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        padding: 8px 0 16px !important;
        gap: 0 !important;
    }

    .top-navbar .navbar-nav > .nav-item {
        width: 100% !important;
        margin: 0 !important;
        text-align: left !important;
    }

    .top-navbar .navbar-nav > .nav-item > .nav-link {
        display: block !important;
        width: 100% !important;
        padding: 14px 16px !important;
        font-size: 15px !important;
        line-height: 1.35 !important;
        white-space: normal !important;
        min-height: 48px;
    }

    .top-navbar .navbar-nav > .nav-item.dropdown > .dropdown-menu {
        position: static !important;
        float: none !important;
        width: 100% !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: rgba(0, 0, 0, 0.12) !important;
    }

    .top-navbar .navbar-nav > .nav-item.dropdown > .dropdown-menu .dropdown-item {
        padding: 12px 20px !important;
        white-space: normal !important;
        min-height: 44px;
    }

    .nav-item.lang-switcher-item {
        width: 100% !important;
        justify-content: center !important;
        order: 950 !important;
        margin: 10px 0 6px !important;
        padding: 10px 0 !important;
    }

    .nav-item.flag-nav-item {
        width: 100% !important;
        justify-content: center !important;
        margin: 4px 0 12px !important;
        order: 960 !important;
    }

    .lang-switcher .lang-btn {
        min-width: 44px !important;
        height: 36px !important;
        font-size: 13px !important;
    }

    .navbar-toggler {
        min-width: 42px !important;
        min-height: 38px !important;
        width: 42px !important;
        height: 38px !important;
        padding: 7px 8px !important;
        background: transparent !important;
        border: 2px solid #ffffff !important;
        color: #ffffff !important;
        display: inline-flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 5px !important;
    }

    .top-navbar .navbar-toggler .icon-bar,
    .navbar-toggler .icon-bar {
        display: block !important;
        width: 22px !important;
        height: 3px !important;
        min-height: 3px !important;
        background: #ffffff !important;
        background-color: #ffffff !important;
        opacity: 1 !important;
        visibility: visible !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
    }
}

@media (max-width: 576px) {
    .top-navbar .navbar-brand {
        max-width: calc(100% - 48px) !important;
        flex: 1 1 auto !important;
        margin-right: 4px !important;
    }

    .top-navbar .navbar-brand .logo-text h2 {
        font-size: clamp(13px, 4.8vw, 16px) !important;
        white-space: nowrap !important;
        line-height: 1.15 !important;
        max-width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        width: 100% !important;
    }

    .top-navbar .navbar-brand .logo-img,
    .top-navbar .navbar-brand .logo-container {
        width: 34px !important;
        height: 34px !important;
    }

    .znz-flag-top-right {
        height: 24px !important;
    }
}

/* ---------- Homepage carousel / hero ---------- */
@media (max-width: 991px) {
    #carouselExampleControls .carousel-item,
    #carouselExampleControls .first-section,
    #carouselExampleControls .carousel-item .dtab {
        min-height: 520px !important;
    }

    .big-tagline {
        max-width: 92% !important;
        padding: 0 12px !important;
    }

    .big-tagline h2 {
        font-size: 28px !important;
        line-height: 1.25 !important;
        padding: 0 8px !important;
    }

    .big-tagline .lead {
        font-size: 15px !important;
        line-height: 1.5 !important;
        margin: 14px auto !important;
        max-width: 100% !important;
        padding: 0 4px !important;
    }

    .big-tagline .slide-actions {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 8px !important;
        margin-top: 14px !important;
    }

    .big-tagline .slide-actions .hover-btn-new {
        margin: 0 !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        padding: 6px 12px !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
    }

    #carouselExampleControls .carousel-control-prev,
    #carouselExampleControls .carousel-control-next {
        width: 42px !important;
        height: 42px !important;
    }

    #carouselExampleControls .carousel-nav-arrow {
        font-size: 24px !important;
    }

    #carouselExampleControls .carousel-indicators {
        bottom: 12px !important;
        margin-bottom: 0 !important;
    }
}

@media (max-width: 768px) {
    #carouselExampleControls .carousel-item,
    #carouselExampleControls .first-section,
    #carouselExampleControls .carousel-item .dtab {
        min-height: 460px !important;
    }

    .big-tagline h2 {
        font-size: 24px !important;
    }

    .big-tagline .lead {
        font-size: 14px !important;
    }

    .big-tagline .slide-actions {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
    }

    .big-tagline .slide-actions .hover-btn-new {
        width: auto !important;
        min-width: 0 !important;
        padding: 5px 11px !important;
        font-size: 10px !important;
        white-space: nowrap !important;
    }

    #carouselExampleControls .carousel-control-prev {
        left: 6px !important;
    }

    #carouselExampleControls .carousel-control-next {
        right: 6px !important;
    }

    #overviews .message-box h2 {
        font-size: 26px !important;
        line-height: 1.3 !important;
    }

    #overviews .message-box p {
        font-size: 15px !important;
    }

    .footer .row > [class*="col-"] {
        margin-bottom: 28px;
    }
}

@media (max-width: 480px) {
    #carouselExampleControls .carousel-item,
    #carouselExampleControls .first-section,
    #carouselExampleControls .carousel-item .dtab {
        min-height: 420px !important;
    }

    .big-tagline h2 {
        font-size: 20px !important;
        letter-spacing: 0 !important;
    }

    .big-tagline .lead {
        font-size: 13px !important;
        line-height: 1.45 !important;
    }

    #carouselExampleControls .carousel-control-prev,
    #carouselExampleControls .carousel-control-next {
        width: 38px !important;
        height: 38px !important;
        opacity: 0.95 !important;
    }
}

/* ---------- Subpage top bar ---------- */
@media (max-width: 768px) {
    .pic-subpage-topbar {
        padding: 10px 12px !important;
        padding-top: max(10px, env(safe-area-inset-top)) !important;
        padding-left: max(12px, env(safe-area-inset-left)) !important;
        padding-right: max(12px, env(safe-area-inset-right)) !important;
    }

    .pic-subpage-back {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }

    .pic-subpage-lang .lang-btn {
        min-width: 40px !important;
        height: 32px !important;
    }
}

/* ---------- Common subpage layouts ---------- */
@media (max-width: 768px) {
    .content-wrapper,
    .grid,
    .activities-grid,
    .vision-mission-container,
    .footer-content {
        grid-template-columns: 1fr !important;
        flex-direction: column !important;
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .section,
    .section-card,
    .card,
    .contact-info,
    .contact-form {
        max-width: 100%;
    }

    header h1,
    .page-title h2,
    .college-name h1 {
        word-wrap: break-word;
        overflow-wrap: anywhere;
    }
}

/* Results / admin toolbars */
@media (max-width: 768px) {
    .filters-row,
    .filter-bar,
    .toolbar,
    .results-toolbar,
    .search-filters {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .filters-row > *,
    .filter-bar > *,
    .toolbar > *,
    .results-toolbar > *,
    .search-filters > * {
        width: 100% !important;
        max-width: 100% !important;
    }

    .modal-dialog {
        margin: 0.75rem !important;
        max-width: calc(100% - 1.5rem) !important;
    }
}
