/* ==========================================================================
   Mobile / app-style layer — loaded after every other stylesheet.
   Desktop (>= 992px) keeps the original design; only the bottom-nav and
   offcanvas markup is hidden there.
   ========================================================================== */

/* Prevent any element (AOS animations, wide tables, long words) from creating
   horizontal scroll that shrinks the whole page on phones */
html, body {
    max-width: 100%;
    overflow-x: clip;
}

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

/* App chrome is mobile only */
.bottom-nav,
.mobile-menu {
    display: none;
}

@media (max-width: 991.98px) {
    :root {
        --app-primary: #1b3a5c;
        --app-accent: #f39c12;
        --app-bg: #f4f6f9;
        --nav-h: 62px;
        --safe-bottom: env(safe-area-inset-bottom, 0px);
    }

    html {
        -webkit-tap-highlight-color: transparent;
        scroll-padding-top: 70px;
    }

    body {
        background: var(--app-bg);
        font-size: 15px;
        line-height: 1.75;
        padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
        -webkit-text-size-adjust: 100%;
    }

    /* Animations: no sideways movement on phones (it caused the page to widen) */
    [data-aos]:not(.aos-animate) {
        transform: translate3d(0, 22px, 0) !important;
    }

    /* ---------- Top bar & navbar ---------- */
    .top-bar {
        display: none;
    }

    .navbar {
        padding: 0;
        min-height: 56px;
        background: var(--app-primary) !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, .18) !important;
        padding-top: env(safe-area-inset-top, 0px);
    }

    .navbar > .container {
        flex-wrap: nowrap;
        min-height: 56px;
    }

    .navbar-brand {
        color: #fff !important;
        font-size: 16px;
        font-weight: 800;
        margin: 0;
        padding: 0;
        white-space: normal;
        line-height: 1.3;
        max-width: calc(100% - 60px);
    }

    .navbar-brand img {
        height: 38px !important;
        width: auto;
    }

    .navbar-toggler {
        border: 0;
        padding: 8px 10px;
        box-shadow: none !important;
        filter: invert(1) brightness(2);
    }

    #navbarNav {
        display: none !important;
    }

    /* ---------- Bottom navigation ---------- */
    .bottom-nav {
        display: flex;
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1040;
        height: calc(var(--nav-h) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        background: #fff;
        border-top: 1px solid #e3e7ec;
        box-shadow: 0 -4px 18px rgba(0, 0, 0, .08);
    }

    .bottom-nav a,
    .bottom-nav button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        background: none;
        border: 0;
        color: #7b8794;
        font-family: inherit;
        font-size: 11px;
        font-weight: 600;
        text-decoration: none;
        position: relative;
        transition: color .15s, transform .1s;
    }

    .bottom-nav i {
        font-size: 19px;
    }

    .bottom-nav a:active,
    .bottom-nav button:active {
        transform: scale(.92);
    }

    .bottom-nav a.active {
        color: var(--app-primary);
    }

    .bottom-nav a.active::before {
        content: '';
        position: absolute;
        top: 0;
        width: 34px;
        height: 3px;
        border-radius: 0 0 4px 4px;
        background: var(--app-accent);
    }

    /* Floating buttons sit above the bottom bar */
    .whatsapp-btn {
        width: 50px;
        height: 50px;
        font-size: 26px;
        bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px);
        left: 14px;
    }

    .back-to-top {
        width: 42px;
        height: 42px;
        bottom: calc(var(--nav-h) + var(--safe-bottom) + 76px);
        left: 18px;
    }

    /* ---------- Slide-in menu ---------- */
    .mobile-menu {
        display: flex;
        width: min(86vw, 340px) !important;
        background: #fff;
        z-index: 1060;
    }

    .mobile-menu .offcanvas-header {
        background: linear-gradient(135deg, #1b3a5c, #2f6190);
        color: #fff;
        align-items: flex-start;
        padding: 20px 18px 18px;
    }

    .mobile-menu .offcanvas-title {
        font-size: 17px;
        font-weight: 800;
        margin-bottom: 2px;
    }

    .mobile-menu .offcanvas-header small {
        opacity: .8;
        font-size: 12px;
    }

    .mobile-menu-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        margin-bottom: 16px;
    }

    .mobile-menu-actions a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 12px 6px;
        border-radius: 14px;
        background: #f0f4f9;
        color: var(--app-primary);
        text-decoration: none;
        font-size: 12px;
        font-weight: 700;
    }

    .mobile-menu-actions a i {
        font-size: 20px;
    }

    .mobile-menu-actions a:nth-child(2) i {
        color: #25d366;
    }

    .mobile-menu-links {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .mobile-menu-links a {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 13px 12px;
        border-radius: 12px;
        color: #243447;
        text-decoration: none;
        font-weight: 600;
    }

    .mobile-menu-links a i {
        width: 24px;
        text-align: center;
        color: #7b8794;
    }

    .mobile-menu-links a.active {
        background: #e8eef5;
        color: var(--app-primary);
    }

    .mobile-menu-links a.active i {
        color: var(--app-accent);
    }

    .mobile-menu-address {
        margin-top: 16px;
        padding: 12px;
        border-radius: 12px;
        background: #f7f9fc;
        color: #5b6775;
        font-size: 13px;
    }

    /* ---------- Layout rhythm ---------- */
    .container {
        padding-right: 16px;
        padding-left: 16px;
    }

    .section-padding {
        padding: 34px 0;
    }

    .section-title {
        margin-bottom: 22px;
        text-align: center;
    }

    .section-title h2 {
        font-size: 22px;
        font-weight: 800;
    }

    .section-title p {
        font-size: 14px;
        color: #6c757d;
    }

    h1 { font-size: 26px; }
    h2 { font-size: 22px; }
    h3 { font-size: 19px; }
    h4 { font-size: 17px; }
    h5 { font-size: 15px; }

    /* ---------- Hero ---------- */
    .hero-section {
        height: auto !important;
        min-height: 62vh;
        padding: 56px 0 64px;
        display: flex;
        align-items: center;
        background-attachment: scroll !important;
        border-radius: 0 0 26px 26px;
    }

    .hero-section .hero-content {
        padding: 0 4px;
    }

    .hero-content h1 {
        font-size: 26px !important;
        line-height: 1.5;
        font-weight: 800;
    }

    .hero-content p {
        font-size: 14.5px !important;
        line-height: 1.8;
    }

    .hero-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 18px;
    }

    .hero-buttons .btn,
    .hero-btn {
        width: 100%;
        margin: 0 !important;
        padding: 13px 18px !important;
        border-radius: 14px;
        font-size: 15px !important;
        font-weight: 700;
    }

    .hero-scroll-down {
        display: none;
    }

    /* Inner-page banners */
    .hero-section[style*="height: 400px"],
    .hero-section[style*="height:400px"] {
        min-height: 0;
        padding: 36px 0 40px;
    }

    .breadcrumb {
        font-size: 13px;
        margin-bottom: 0;
        justify-content: center;
    }

    /* ---------- Cards & boxes ---------- */
    .card,
    .service-box,
    .job-box,
    .offer-box,
    .project-box,
    .project-card,
    .counter-box,
    .contact-info,
    .contact-form,
    .application-form,
    .gallery-item,
    .team-box {
        border-radius: 16px !important;
        border: 0;
        box-shadow: 0 2px 14px rgba(20, 40, 70, .08) !important;
    }

    .service-box,
    .job-box,
    .contact-info,
    .contact-form,
    .application-form {
        padding: 20px 18px !important;
        margin-bottom: 14px;
    }

    .job-box h3 {
        font-size: 18px;
    }

    .job-box .btn {
        width: 100%;
        margin-top: 8px;
    }

    .job-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 14px;
        font-size: 13px;
        color: #6c757d;
    }

    .counter-box {
        padding: 16px 8px;
        margin-bottom: 14px;
    }

    .counter-box h3 {
        font-size: 24px !important;
    }

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

    img.img-fluid,
    .about-img img {
        border-radius: 16px;
    }


    /* ---------- Compact service / feature cards ---------- */
    .service-box {
        display: grid;
        grid-template-columns: 56px 1fr;
        column-gap: 14px;
        align-items: center;
        text-align: right !important;
        padding: 16px !important;
        margin-bottom: 0 !important;
    }

    .service-box > i {
        grid-row: 1 / span 2;
        width: 56px;
        height: 56px;
        margin: 0 !important;
        border-radius: 16px;
        background: #fff4e0;
        color: var(--app-accent);
        font-size: 26px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .service-box h3,
    .service-box h4 {
        font-size: 16px !important;
        margin: 0 0 2px !important;
    }

    .service-box h3::after,
    .service-box h4::after {
        display: none !important;
    }

    .service-box p {
        font-size: 13px;
        margin: 0;
        color: #6c757d;
        line-height: 1.7;
    }

    /* Stats row stays three across, like app widgets */
    .counter-section .row > [class*="col-"] {
        width: 33.3333%;
        flex: 0 0 auto;
        margin-bottom: 0 !important;
        padding-right: 5px;
        padding-left: 5px;
    }

    .counter-section {
        padding: 22px 0 !important;
    }

    .counter-box {
        padding: 14px 4px !important;
        margin-bottom: 0 !important;
    }

    .counter-box i {
        font-size: 22px !important;
        margin-bottom: 6px !important;
    }

    .counter-box h3 {
        font-size: 20px !important;
        margin-bottom: 2px !important;
    }

    .counter-box p {
        font-size: 11.5px;
        margin: 0;
    }

    /* Tighter gaps between stacked columns */
    .row > [class*="col-"].mb-4 {
        margin-bottom: 14px !important;
    }


    /* ---------- Projects & gallery ---------- */
    .projects-filter,
    .gallery-filters {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        padding: 2px 2px 10px;
        scrollbar-width: none;
        justify-content: flex-start !important;
    }

    .projects-filter::-webkit-scrollbar { display: none; }

    .filter-btn,
    .projects-filter .btn,
    .projects-filter button {
        flex: 0 0 auto;
        white-space: nowrap;
        border-radius: 999px !important;
        padding: 8px 18px !important;
        margin: 0 !important;
        font-size: 14px;
    }

    .project-box,
    .gallery-box {
        overflow: hidden;
        background: #fff;
    }

    .project-img,
    .gallery-img {
        aspect-ratio: 16 / 10;
        overflow: hidden;
    }

    .project-img img,
    .gallery-img img,
    .gallery-img video {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .project-overlay,
    .gallery-overlay {
        display: none !important;
    }

    .project-content,
    .gallery-content {
        padding: 14px 16px !important;
    }

    .project-content h3,
    .gallery-content h4,
    .gallery-content h3 {
        font-size: 16px !important;
    }

    .project-content p,
    .gallery-content p {
        font-size: 13px;
        color: #6c757d;
    }

    /* Gallery as a two-column photo grid */
    .gallery-item {
        width: 50%;
        padding-right: 6px;
        padding-left: 6px;
        margin-bottom: 12px !important;
    }

    .gallery-item .gallery-img {
        aspect-ratio: 1 / 1;
    }

    .gallery-item .gallery-content {
        padding: 10px 12px !important;
    }

    .gallery-item .gallery-content p {
        display: none;
    }

    .contact-info h3,
    .contact-form h3,
    .contact-info h2,
    .contact-form h2 {
        font-size: 19px !important;
    }

    /* ---------- Buttons & forms ---------- */
    .btn {
        border-radius: 12px;
        padding: 11px 18px;
        font-weight: 600;
    }

    .btn:active {
        transform: scale(.97);
    }

    .form-control,
    .form-select {
        min-height: 48px;
        font-size: 16px; /* stops iOS from zooming into inputs */
        border-radius: 12px;
    }

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

    .form-label {
        font-weight: 700;
        font-size: 14px;
    }

    form .btn[type="submit"] {
        width: 100%;
        padding: 14px;
        font-size: 16px;
    }

    /* ---------- Tables become scrollable cards ---------- */
    .table-responsive {
        border-radius: 14px;
        -webkit-overflow-scrolling: touch;
    }


    /* ---------- Data tables turn into stacked cards ---------- */
    table.cards-on-mobile,
    table.cards-on-mobile tbody,
    table.cards-on-mobile tr,
    table.cards-on-mobile td {
        display: block;
        width: 100%;
    }

    table.cards-on-mobile thead {
        display: none;
    }

    table.cards-on-mobile tr {
        background: #fff;
        border: 1px solid #e8ecf1;
        border-radius: 14px;
        margin-bottom: 12px;
        padding: 10px 14px;
        box-shadow: 0 2px 10px rgba(20, 40, 70, .06);
    }

    table.cards-on-mobile > tbody > tr > * {
        background: transparent !important;
        box-shadow: none !important;
    }

    table.cards-on-mobile td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        padding: 7px 0 !important;
        border: 0 !important;
        text-align: left !important;
        font-size: 14px;
    }

    table.cards-on-mobile td + td {
        border-top: 1px dashed #edf0f4 !important;
    }

    table.cards-on-mobile td::before {
        content: attr(data-label);
        flex: 0 0 38%;
        text-align: right;
        font-size: 12px;
        font-weight: 700;
        color: #7b8794;
    }

    table.cards-on-mobile td[colspan] {
        display: block;
        text-align: center !important;
    }

    table.cards-on-mobile td[colspan]::before {
        display: none;
    }

    .table-responsive:has(.cards-on-mobile) {
        overflow: visible;
    }

    .card:has(.cards-on-mobile) > .card-body {
        padding: 12px !important;
    }

    .card:has(.cards-on-mobile) {
        background: transparent;
        box-shadow: none !important;
    }

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

    .pagination .page-link {
        border-radius: 10px !important;
        min-width: 40px;
        text-align: center;
    }

    /* ---------- Footer ---------- */
    footer {
        padding-top: 30px !important;
        border-radius: 26px 26px 0 0;
        margin-top: 10px;
    }

    footer h4 {
        font-size: 17px;
        margin-bottom: 12px !important;
    }

    footer .col-md-4 {
        margin-bottom: 18px !important;
    }

    footer hr {
        margin: 8px 0 14px !important;
    }

    /* ---------- Modals as bottom sheets ---------- */
    .modal-dialog {
        margin: 12px;
    }

    .modal-content {
        border-radius: 18px;
        border: 0;
    }

    .offcanvas {
        border: 0;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .hero-content h1 {
        font-size: 23px !important;
    }

    .navbar-brand {
        font-size: 14px;
    }

    .bottom-nav a,
    .bottom-nav button {
        font-size: 10px;
    }
}

/* Installed app mode (home-screen icon): no browser chrome, respect the notch */
@media (display-mode: standalone) {
    body {
        overscroll-behavior-y: contain;
    }
}
