/* Mobile Layout Fixes for TawasolMap */
/* Targeting iPhone 14 Pro Max and similar devices (428px - 430px) */

/* Critical Mobile Viewport Fix */
@media (max-width: 430px) {
    * {
        box-sizing: border-box !important;
    }

    html {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* General Mobile Fixes */
@media (max-width: 430px) {
    body {
        overflow-x: hidden !important;
    }

    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
        max-width: 100% !important;
    }

    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

/* Header and Navigation Fixes */
@media (max-width: 430px) {
    #topnav .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    .navigation-menu {
        margin: 0 !important;
    }

    .buy-button {
        margin-bottom: 0 !important;
    }
}

/* Home Slider and Carousel Fixes - Updated for full image display */
@media (max-width: 768px) {
    .home-slider.position-relative {
        margin-top: 0 !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    .home-slider .carousel-inner {
        width: 100% !important;
        overflow: hidden !important;
    }

    .home-slider .carousel-item {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        /* Optimized for 16:9 aspect ratio images (1920x1080) */
        height: calc(100vw * 9 / 16) !important;
        min-height: 240px !important;
        max-height: 432px !important;
        background-size: cover !important;
        background-position: center center !important;
        background-repeat: no-repeat !important;
        background-attachment: scroll !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .home-slider .carousel-indicators {
        bottom: 15px !important;
        margin-bottom: 0 !important;
    }
}

/* Enhanced fixes for very small screens */
@media (max-width: 430px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        /* Perfect 16:9 ratio for small screens */
        height: calc(100vw * 9 / 16) !important;
        min-height: 240px !important;
        max-height: 275px !important;
        background-size: cover !important;
        background-position: center !important;
    }

}

/* Tablet and Medium Screen Fixes */
@media (min-width: 769px) and (max-width: 1024px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        /* Balanced height for tablets - not too tall */
        height: 50vh !important;
        min-height: 400px !important;
        max-height: 576px !important;
        background-size: cover !important;
        background-position: center center !important;
        background-attachment: scroll !important;
    }
}

/* Large Mobile and Small Tablet Fixes */
@media (min-width: 431px) and (max-width: 768px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        /* Perfect 16:9 ratio for tablets */
        height: calc(100vw * 9 / 16) !important;
        min-height: 275px !important;
        max-height: 432px !important;
        background-size: cover !important;
        background-position: center center !important;
        background-attachment: scroll !important;
    }
}

/* Landscape orientation fixes */
@media (max-width: 768px) and (orientation: landscape) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: 80vh !important;
        min-height: 280px !important;
        max-height: 400px !important;
    }
}

/* Section and Content Fixes */
@media (max-width: 430px) {
    .section {
        padding: 40px 0 !important;
    }

    .mt-100 {
        margin-top: 60px !important;
    }

    .mt-60 {
        margin-top: 40px !important;
    }

    .section-title h4 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
        margin-bottom: 15px !important;
    }

    .section-title p {
        font-size: 0.9rem !important;
        line-height: 1.5 !important;
    }
}

/* Features Section Fixes */
@media (max-width: 430px) {
    .features {
        margin-bottom: 30px !important;
        padding: 20px 10px !important;
    }

    .features .image i {
        font-size: 2.5rem !important;
    }

    .features .content h5 {
        font-size: 1.1rem !important;
        margin-top: 15px !important;
    }

    .col-md-3 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 5px !important;
    }

    .col-md-4 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 20px !important;
    }
}

/* Image and Media Fixes */
@media (max-width: 430px) {

    .img-fluid {
        width: 100% !important;
        max-width: 100% !important;
    }

    .avatar {
        margin: 0 auto !important;
    }

    .tiny-slide img {
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
    }
}

/* Map and Contact Section Fixes */
@media (max-width: 430px) {
    .card.map {
        margin: 0 !important;
    }

    .card.map iframe {
        height: 300px !important;
        width: 100% !important;
    }

    .custom-form {
        margin: 20px 10px !important;
        padding: 20px 15px !important;
    }

    .form-control {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

/* Text and Typography Fixes */
@media (max-width: 430px) {
    h1, .h1 {
        font-size: 1.8rem !important;
        line-height: 1.2 !important;
    }

    h2, .h2 {
        font-size: 1.6rem !important;
        line-height: 1.3 !important;
    }

    h3, .h3 {
        font-size: 1.4rem !important;
        line-height: 1.3 !important;
    }

    h4, .h4 {
        font-size: 1.2rem !important;
        line-height: 1.4 !important;
    }

    .display-4 {
        font-size: 2rem !important;
    }

    .display-5 {
        font-size: 1.5rem !important;
    }
}


/* Carousel Content Fixes */
@media (max-width: 430px) {
    .title-heading {
        padding: 20px 15px !important;
        text-align: center !important;
    }

    .title-heading h1 {
        font-size: 1.8rem !important;
        margin-bottom: 15px !important;
    }

    .title-heading p {
        font-size: 1rem !important;
        margin-bottom: 15px !important;
    }
}

/* Grid and Layout Fixes */
@media (max-width: 430px) {
    .row {
        margin-left: -10px !important;
        margin-right: -10px !important;
    }

    .row > * {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .col-lg-7, .col-lg-5, .col-md-6, .col-md-5 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 20px !important;
    }
}

/* WhatsApp Button Fix */
@media (max-width: 430px) {
    .whatsapp {
        bottom: 20px !important;
        right: 15px !important;
        width: 50px !important;
        height: 50px !important;
        font-size: 1.2rem !important;
    }
}

/* Specific iPhone 14 Pro Max Fixes */
@media screen and (max-width: 430px) and (min-width: 428px) {
    .container {
        max-width: 415px !important;
        margin: 0 auto !important;
    }

    .bg-home {
        background-attachment: scroll !important;
    }
}

/* Enhanced Landscape Mode Fixes */
@media screen and (max-height: 932px) and (orientation: landscape) and (max-width: 768px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: 80vh !important;
        min-height: 280px !important;
        max-height: none !important;
    }
}

/* ========================================== */
/* COMPREHENSIVE SCREEN SIZE OPTIMIZATIONS   */
/* ========================================== */

/* Extra Small Devices - Phones (320px - 374px) */
@media (min-width: 320px) and (max-width: 374px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: calc(100vw * 9 / 16) !important;
        min-height: 180px !important;
        max-height: 210px !important;
        background-size: cover !important;
        background-position: center !important;
    }
}

/* Small Phones (375px - 424px) */
@media (min-width: 375px) and (max-width: 424px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: calc(100vw * 9 / 16) !important;
        min-height: 210px !important;
        max-height: 238px !important;
        background-size: cover !important;
        background-position: center !important;
    }
}

/* Standard Mobile Phones (425px - 767px) */
@media (min-width: 425px) and (max-width: 767px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: calc(100vw * 9 / 16) !important;
        min-height: 240px !important;
        max-height: 432px !important;
        background-size: cover !important;
        background-position: center !important;
    }
}

/* Large Tablets Portrait (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: calc(100vw * 9 / 16) !important;
        min-height: 432px !important;
        max-height: 558px !important;
        background-size: cover !important;
        background-position: center !important;
    }
}

/* Small Desktop / Large Tablet Landscape (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: calc(100vw * 9 / 16) !important;
        min-height: 558px !important;
        max-height: 675px !important;
        background-size: cover !important;
        background-position: center !important;
    }
}

/* Medium Desktop (1200px - 1399px) */
@media (min-width: 1200px) and (max-width: 1399px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: calc(100vw * 9 / 16) !important;
        min-height: 675px !important;
        max-height: 787px !important;
        background-size: cover !important;
        background-position: center !important;
    }
}

/* Large Desktop (1400px - 1919px) */
@media (min-width: 1400px) and (max-width: 1919px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: calc(100vw * 9 / 16) !important;
        min-height: 787px !important;
        max-height: 1080px !important;
        background-size: cover !important;
        background-position: center !important;
    }
}

/* Extra Large Desktop (1920px and up) */
@media (min-width: 1920px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: 1080px !important; /* Native image height */
        min-height: 1080px !important;
        background-size: cover !important;
        background-position: center !important;
    }
}

/* Ultra-wide screens (aspect ratio adjustments) */
@media (min-aspect-ratio: 21/9) and (min-width: 1920px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        height: 70vh !important;
        min-height: 800px !important;
        max-height: 1080px !important;
    }
}

/* High-resolution mobile devices */
@media (-webkit-min-device-pixel-ratio: 2) and (max-width: 767px) {
    .home-slider .carousel-item .bg-home.d-flex.align-items-center {
        background-attachment: scroll !important; /* Better performance on high-DPI mobile */
    }
}

/* ========================================== */
/* RESPONSIVE HEADER LOGO OPTIMIZATIONS      */
/* ========================================== */

/* Extra Small Devices - Phones (320px - 374px) */
@media (min-width: 320px) and (max-width: 374px) {
    #topnav .logo img {
        height: 40px !important;
        max-width: 120px !important;
        width: auto !important;
    }

    #topnav .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

/* Small Phones (375px - 424px) */
@media (min-width: 375px) and (max-width: 424px) {
    #topnav .logo img {
        height: 42px !important;
        max-width: 130px !important;
        width: auto !important;
    }
}

/* Standard Mobile Phones (425px - 574px) */
@media (min-width: 425px) and (max-width: 574px) {
    #topnav .logo img {
        height: 45px !important;
        max-width: 140px !important;
        width: auto !important;
    }
}

/* Large Mobile Phones (575px - 767px) */
@media (min-width: 575px) and (max-width: 767px) {
    #topnav .logo img {
        height: 50px !important;
        max-width: 160px !important;
        width: auto !important;
    }
}

/* Tablets Portrait (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    #topnav .logo img {
        height: 55px !important;
        max-width: 180px !important;
        width: auto !important;
    }
}

/* Small Desktop / Large Tablet Landscape (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    #topnav .logo img {
        height: 58px !important;
        max-width: 190px !important;
        width: auto !important;
    }
}

/* Medium Desktop (1200px - 1399px) */
@media (min-width: 1200px) and (max-width: 1399px) {
    #topnav .logo img {
        height: 60px !important;
        max-width: 200px !important;
        width: auto !important;
    }
}

/* Large Desktop (1400px - 1599px) */
@media (min-width: 1400px) and (max-width: 1599px) {
    #topnav .logo img {
        height: 65px !important;
        max-width: 220px !important;
        width: auto !important;
    }
}

/* Extra Large Desktop (1600px - 1919px) */
@media (min-width: 1600px) and (max-width: 1919px) {
    #topnav .logo img {
        height: 70px !important;
        max-width: 240px !important;
        width: auto !important;
    }
}

/* Ultra Large Desktop (1920px and up) */
@media (min-width: 1920px) {
    #topnav .logo img {
        height: 75px !important;
        max-width: 260px !important;
        width: auto !important;
    }
}

/* ========================================== */
/* LOGO POSITIONING AND SPACING FIXES        */
/* ========================================== */

/* General logo container improvements */
@media (max-width: 767px) {
    .logo {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }

    .logo img {
        object-fit: contain !important;
        transition: all 0.3s ease !important;
    }
}

/* Header spacing adjustments for mobile */
@media (max-width: 574px) {
    #topnav {
        min-height: 60px !important;
        padding: 8px 0 !important;
    }
}

/* Navigation menu spacing with logo */
@media (max-width: 991px) {
    .menu-extras {
        margin-left: auto !important;
    }

    .buy-button {
        margin-left: 10px !important;
    }
}

/* Landscape orientation fixes for mobile logo */
@media (max-width: 767px) and (orientation: landscape) {
    #topnav .logo img {
        height: 38px !important;
        max-width: 140px !important;
    }

    #topnav {
        min-height: 50px !important;
        padding: 5px 0 !important;
    }
}

/* RTL Support for Mobile */
@media (max-width: 430px) {
    [dir="rtl"] .navigation-menu {
        text-align: right !important;
    }

    [dir="rtl"] .title-heading {
        text-align: right !important;
    }

    [dir="rtl"] .features {
        text-align: center !important;
    }
}
