/* ==========================================================================
   RESPONSIVE ENHANCEMENTS - Green Car Moz
   Comprehensive responsive design improvements for optimal display
   across desktop, tablet, and mobile devices
   ========================================================================== */

/* ==========================================================================
   1. BASE RESPONSIVE SETTINGS
   ========================================================================== */
html {
    font-size: 16px;
}

body {
    overflow-x: hidden;
    margin-top: 0 !important; /* Remove any excessive top margin */
}

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

/* Fix excessive top spacing issues */
.wrapper {
    margin-top: 0 !important;
}

.main-content,
.content-area {
    margin-top: 0 !important;
    padding-top: 20px; /* Add small padding instead of large margin */
}

.page-section:first-child {
    margin-top: 0 !important;
    padding-top: 40px; /* Reasonable top spacing */
}

/* Fix header spacing */
.header {
    margin-bottom: 0 !important;
}

.header.fixed {
    position: relative; /* Change from fixed if causing spacing issues */
}

/* Main slider top spacing fix */
.main-slider {
    margin-top: 0 !important;
}

/* Breadcrumbs spacing fix */
.page-section.breadcrumbs {
    margin-top: 0 !important;
    padding-top: 20px;
    padding-bottom: 20px;
}

/* ==========================================================================
   2. HEADER & NAVIGATION RESPONSIVE
   ========================================================================== */

/* Force header actions to the right on all screen sizes */
.header-actions {
    display: flex;
    justify-content: flex-end !important;
    align-items: center;
    gap: 10px;
    margin: 0 !important; /* Remove any default margins */
    padding: 0 !important; /* Remove any default padding */
    height: 100%; /* Match the height of the navbar row */
}

.main-navbar .row {
    align-items: center; /* Ensure vertical centering */
    min-height: 70px; /* Set consistent height for the navbar */
}

.main-navbar .col-6:last-child,
.main-navbar .col-sm-6:last-child,
.main-navbar .col-md-6:last-child {
    display: flex;
    justify-content: flex-end;
    align-items: center; /* Vertical alignment */
    padding: 0; /* Remove Bootstrap column padding */
    margin: 0; /* Remove any margins */
    height: 100%; /* Full height to match logo */
}

/* Logo alignment - Remove all margins */
.logo-main {
    display: flex;
    align-items: center;
    height: 100%;
    margin: 0 !important; /* Force remove any logo margins */
    padding: 0 !important; /* Force remove any logo padding */
}

.logo-main a {
    display: flex;
    align-items: center;
    margin: 0 !important; /* Remove link margins */
    padding: 0 !important; /* Remove link padding */
}

.logo-main img {
    margin: 0 !important; /* Force remove image margins */
    padding: 0 !important; /* Force remove image padding */
    vertical-align: middle; /* Ensure proper vertical alignment */
}

/* Menu toggle button alignment */
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    margin: 0 !important; /* Force remove margins */
    padding: 10px;
}

/* Mobile specific header fixes */
@media (max-width: 991.98px) {
    .main-navbar {
        min-height: 60px; /* Consistent mobile header height */
    }

    .main-navbar .row {
        justify-content: space-between;
        align-items: center;
        margin: 0; /* Remove row margin */
        min-height: 60px; /* Match main navbar height */
    }

    .main-navbar .col-6:first-child {
        flex: 0 0 auto;
        max-width: none;
        padding: 0; /* Remove padding */
        display: flex;
        align-items: center;
        height: 100%;
        margin: 0 !important; /* Force remove margins */
    }

    .main-navbar .col-6:last-child {
        flex: 0 0 auto;
        max-width: none;
        margin-left: auto;
        padding: 0; /* Remove padding */
        display: flex;
        align-items: center;
        height: 100%;
    }

    .header-actions {
        margin: 0 !important; /* Force no margin on mobile */
        padding: 0 !important; /* Force no padding on mobile */
        height: 100%; /* Full height alignment */
        display: flex;
        align-items: center;
    }

    .logo-main {
        height: 100%;
        display: flex;
        align-items: center;
        margin: 0 !important; /* Force remove mobile logo margins */
        padding: 0 !important; /* Force remove mobile logo padding */
    }

    .logo-main img {
        max-height: 40px;
        width: auto;
        margin: 0 !important; /* Force remove mobile image margins */
        padding: 0 !important; /* Force remove mobile image padding */
    }
}

/* Top bar responsive */
@media (max-width: 991.98px) {
    .header-top-bar {
        display: none !important;
    }
}

/* Logo responsive */
@media (max-width: 767.98px) {
    .logo-main img {
        max-height: 40px;
        width: auto;
    }

    .main-navbar .container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .main-navbar .row {
        width: 100%;
        margin: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .main-navbar .col-6 {
        padding: 0;
        flex: none;
    }

    .main-navbar .col-6:first-child {
        margin-right: auto;
    }
}

@media (max-width: 575.98px) {
    .logo-main img {
        max-height: 35px;
    }

    .header-actions .btn {
        padding: 8px 12px;
        font-size: 14px;
    }

    .menu-toggle {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Main navigation responsive */
@media (max-width: 991.98px) {
    .main-navigation {
        display: none;
    }

    .header-actions .btn {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* Mobile navigation improvements - REMOVE OVERLAY Z-INDEX */
.mobile-navigation {
    position: fixed !important;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: #fff;
    z-index: 2147483647 !important; /* Maximum possible z-index - Navigation on top */
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

.mobile-navigation.active {
    left: 0 !important;
    z-index: 2147483647 !important; /* Ensure active state maintains highest z-index */
}

.mobile-overlay {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    /* REMOVED Z-INDEX - Let navigation handle layering */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: auto; /* Allow clicks to pass through when needed */
}

.mobile-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
    /* REMOVED Z-INDEX - No interference with navigation */
}

/* Mobile menu */
.mobile-menu {
    padding: 20px 0;
    list-style: none;
    margin: 0;
}

.mobile-menu li {
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.mobile-menu li a {
    display: block;
    padding: 15px 20px;
    color: #333;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

.mobile-menu li a:hover {
    background: #f8f9fa;
    color: #28a745;
}

/* Mobile submenu styles - FIXED ARROW POSITION DURING EXPANSION */
.mobile-menu .has-submenu {
    position: relative;
}

.mobile-menu .has-submenu > a {
    position: relative;
    padding-right: 50px; /* Make room for toggle arrow */
    cursor: pointer;
    min-height: 50px;
    display: flex;
    align-items: center;
    /* Create isolated positioning context for arrow */
    z-index: 2;
}

.mobile-menu .submenu-toggle {
    position: absolute;
    right: 15px;
    top: 25px;
    height: 0px; /* Fixed height matching parent menu item */
    background: none;
    border: none;
    color: #27ae60;
    font-size: 18px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 3; /* Higher than parent menu item */
    /* Anchor arrow to parent item only, not expanding container */
}

.mobile-menu .submenu-toggle.active {
    /* No transform - stays in exact same position */
    color: #229954; /* Slightly darker green when active */
    z-index: 3;
}

/* Submenu displays underneath but doesn't affect arrow positioning */
.mobile-menu .submenu {
    display: none;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    margin: 0;
    padding: 0;
    border-radius: 8px;
    margin-top: 0; /* No top margin to prevent pushing arrow */
    margin-left: 15px;
    margin-right: 15px;
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 8px rgba(39, 174, 96, 0.1);
    border: 1px solid rgba(39, 174, 96, 0.2);
    /* Position submenu to not interfere with arrow */
    position: relative;
    z-index: 1; /* Lower than arrow */
}

.mobile-menu .submenu.active {
    display: block;
    animation: slideDownFade 0.4s ease;
}

@keyframes slideDownFade {
    from {
        opacity: 0;
        transform: translateY(-15px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 300px;
    }
}

.mobile-menu .submenu li {
    border-bottom: 1px solid rgba(39, 174, 96, 0.1);
    list-style: none;
}

.mobile-menu .submenu li:last-child {
    border-bottom: none;
}

.mobile-menu .submenu li a {
    padding: 15px 25px;
    font-size: 14px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    text-decoration: none;
    border: none;
    background: transparent;
    position: relative;
}

.mobile-menu .submenu li a::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(135deg, #27ae60, #229954);
    transition: width 0.3s ease;
}

.mobile-menu .submenu li a:hover {
    background: rgba(39, 174, 96, 0.05);
    color: #27ae60;
    padding-left: 30px;
}

.mobile-menu .submenu li a:hover::before {
    width: 3px;
}

.mobile-menu .submenu li a i {
    margin-right: 12px;
    width: 18px;
    font-size: 14px;
    color: #27ae60;
    transition: transform 0.3s ease;
}

.mobile-menu .submenu li a:hover i {
    transform: scale(1.1);
}

/* Remove all the side-sliding styles that are no longer needed */
/* Navigation bar should stay normal width */
.mobile-navigation {
    width: 85% !important;
    max-width: 320px !important;
}

/* Mobile submenu styles */
.mobile-menu .submenu {
    display: none;
    background: #f8f9fa;
    padding-left: 0;
    margin: 0;
    list-style: none;
}

.mobile-menu .submenu li {
    border-bottom: 1px solid #e9ecef;
}

.mobile-menu .submenu li a {
    padding: 12px 20px 12px 40px;
    font-size: 14px;
    color: #666;
}

.mobile-menu .submenu li a:hover {
    background: #e9ecef;
    color: #28a745;
}

/* Submenu toggle button */
.submenu-toggle {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.3s ease;
}

.submenu-toggle.active {
    transform: translateY(-50%) rotate(90deg);
}

/* Mobile menu header with close button */
.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    background: #f8f9fa;
}

.mobile-logo img {
    max-height: 35px;
    width: auto;
}

.menu-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.menu-close:hover {
    background: #e9ecef;
    color: #333;
}

/* Mobile menu footer */
.mobile-menu-footer {
    padding: 20px;
    border-top: 1px solid #f0f0f0;
    background: #f8f9fa;
    margin-top: auto;
}

.mobile-contact p {
    margin: 5px 0;
    font-size: 14px;
    color: #666;
}

.mobile-social {
    margin: 15px 0;
    display: flex;
    gap: 10px;
}

.mobile-social .social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #28a745;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.mobile-social .social-link:hover {
    background: #218838;
    transform: translateY(-2px);
}

.mobile-auth {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.mobile-cta {
    border-top: 1px solid #e9ecef;
    padding-top: 15px;
    margin-top: 15px;
}

/* ==========================================================================
   3. HERO SECTION & SLIDER RESPONSIVE
   ========================================================================== */

/* Main slider responsive */
@media (max-width: 1199.98px) {
    .main-slider .caption-title {
        font-size: 2.5rem;
    }

    .main-slider .caption-subtitle {
        font-size: 1.2rem;
    }
}

@media (max-width: 991.98px) {
    .main-slider .caption-title {
        font-size: 2rem;
        line-height: 1.2;
    }

    .main-slider .caption-subtitle {
        font-size: 1.1rem;
    }

    .main-slider .caption-text {
        font-size: 0.95rem;
    }
}

@media (max-width: 767.98px) {
    .main-slider {
        min-height: 70vh;
    }

    .main-slider .caption-title {
        font-size: 1.8rem;
        margin-bottom: 15px;
    }

    .main-slider .caption-subtitle {
        font-size: 1rem;
        margin-bottom: 15px;
    }

    .main-slider .caption-text {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }

    .main-slider .btn-theme {
        padding: 12px 25px;
        font-size: 14px;
    }
}

@media (max-width: 575.98px) {
    .main-slider {
        min-height: 60vh;
    }

    .main-slider .caption-title {
        font-size: 1.5rem;
    }

    .main-slider .caption-content {
        padding: 20px;
        text-align: center;
    }
}

/* ==========================================================================
   4. FORMS & SEARCH RESPONSIVE
   ========================================================================== */

/* Form search responsive */
@media (max-width: 991.98px) {
    .form-search .form-group {
        margin-bottom: 15px;
    }

    .form-search .btn-submit {
        width: 100%;
        margin-top: 10px;
    }
}

@media (max-width: 767.98px) {
    .form-search {
        padding: 20px;
        margin: 20px 0;
    }

    .form-search .form-title h2 {
        font-size: 1.5rem;
    }
}

/* Contact form responsive */
@media (max-width: 767.98px) {
    .contact-section .row > div {
        margin-bottom: 30px;
    }

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

    .contact-details {
        margin-top: 0 !important;
    }
}

/* ==========================================================================
   5. CONTENT SECTIONS RESPONSIVE
   ========================================================================== */

/* Section titles responsive */
@media (max-width: 767.98px) {
    .section-title {
        font-size: 1.8rem;
        text-align: center;
        margin-bottom: 30px;
    }

    .section-title small {
        font-size: 1rem;
    }
}

@media (max-width: 575.98px) {
    .section-title {
        font-size: 1.5rem;
        margin-bottom: 25px;
    }
}

/* Page sections responsive */
@media (max-width: 991.98px) {
    .page-section {
        padding: 60px 0;
    }
}

@media (max-width: 767.98px) {
    .page-section {
        padding: 40px 0;
    }
}

@media (max-width: 575.98px) {
    .page-section {
        padding: 30px 0;
    }
}

/* ==========================================================================
   6. CAR LISTINGS & CARDS RESPONSIVE
   ========================================================================== */

/* Car cards responsive */
@media (max-width: 991.98px) {
    .thumbnail-car-card {
        margin-bottom: 30px;
    }

    .thumbnail-car-card .table td {
        padding: 12px 8px;
        font-size: 14px;
    }

    .thumbnail-car-card .btn-theme {
        padding: 8px 15px;
        font-size: 13px;
    }
}

@media (max-width: 767.98px) {
    .car-listing .thumbnail-car-card .table {
        font-size: 13px;
    }

    .car-listing .thumbnail-car-card .caption-title {
        font-size: 1.1rem;
    }

    .car-listing .thumbnail-car-card .table td.buttons .btn-theme {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Car big card responsive */
@media (max-width: 991.98px) {
    .car-big-card .row {
        flex-direction: column;
    }

    .car-big-card .car-details {
        margin-top: 20px;
    }
}

@media (max-width: 767.98px) {
    .car-big-card .car-details .title h2 {
        font-size: 1.5rem;
    }

    .car-big-card .car-details .price {
        font-size: 1.2rem;
    }

    .car-big-card .car-details ul li {
        font-size: 14px;
        margin-bottom: 8px;
    }
}

/* ==========================================================================
   7. FOOTER RESPONSIVE
   ========================================================================== */

@media (max-width: 767.98px) {
    .footer-widgets {
        text-align: center;
    }

    .footer-widgets .widget {
        margin-bottom: 40px;
    }

    .footer-meta {
        text-align: center;
        padding: 20px 0;
    }

    .footer-meta .btn-row {
        margin-bottom: 20px;
    }

    .footer-meta .btn {
        margin: 5px;
        font-size: 12px;
        padding: 8px 15px;
    }
}

@media (max-width: 575.98px) {
    .footer-meta .btn {
        display: block;
        width: 100%;
        margin: 5px 0;
    }

    .copyright {
        font-size: 13px;
        line-height: 1.5;
    }
}

/* ==========================================================================
   8. CAROUSEL & SLIDER RESPONSIVE
   ========================================================================== */

/* Owl carousel responsive */
@media (max-width: 767.98px) {
    .owl-carousel .owl-nav {
        display: none !important;
    }

    .owl-carousel .owl-dots {
        text-align: center;
        margin-top: 20px;
    }
}

/* Swiper responsive */
@media (max-width: 991.98px) {
    .swiper .swiper-button-prev,
    .swiper .swiper-button-next {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .swiper-pagination {
        bottom: 10px;
    }
}

/* ==========================================================================
   9. BUTTONS & INTERACTIVE ELEMENTS RESPONSIVE
   ========================================================================== */

/* Buttons responsive */
@media (max-width: 767.98px) {
    .btn-theme {
        padding: 12px 20px;
        font-size: 14px;
    }

    .btn-theme-sm {
        padding: 8px 15px;
        font-size: 13px;
    }

    .btn-theme-lg {
        padding: 15px 30px;
        font-size: 16px;
    }
}

@media (max-width: 575.98px) {
    .btn-block-mobile {
        display: block;
        width: 100%;
        margin-bottom: 10px;
    }
}

/* ==========================================================================
   10. TABLES RESPONSIVE
   ========================================================================== */

@media (max-width: 767.98px) {
    .table-responsive-mobile {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive-mobile .table {
        margin-bottom: 0;
        min-width: 600px;
    }
}

/* ==========================================================================
   11. UTILITIES & HELPERS RESPONSIVE
   ========================================================================== */

/* Text responsive */
@media (max-width: 767.98px) {
    .text-lg {
        font-size: 1.1rem;
    }

    .text-xl {
        font-size: 1.3rem;
    }
}

/* Spacing responsive */
@media (max-width: 767.98px) {
    .mt-mobile-0 {
        margin-top: 0 !important;
    }
    .mb-mobile-0 {
        margin-bottom: 0 !important;
    }
    .mt-mobile-20 {
        margin-top: 20px !important;
    }
    .mb-mobile-20 {
        margin-bottom: 20px !important;
    }
    .mt-mobile-30 {
        margin-top: 30px !important;
    }
    .mb-mobile-30 {
        margin-bottom: 30px !important;
    }
}

/* Display responsive */
@media (max-width: 767.98px) {
    .d-mobile-none {
        display: none !important;
    }
    .d-mobile-block {
        display: block !important;
    }
    .d-mobile-inline {
        display: inline !important;
    }
    .d-mobile-inline-block {
        display: inline-block !important;
    }
    .d-mobile-flex {
        display: flex !important;
    }
}

/* Text alignment responsive */
@media (max-width: 767.98px) {
    .text-mobile-center {
        text-align: center !important;
    }
    .text-mobile-left {
        text-align: left !important;
    }
    .text-mobile-right {
        text-align: right !important;
    }
}

/* ==========================================================================
   12. PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* Reduce animations on mobile for better performance */
@media (max-width: 767.98px) {
    .wow {
        animation-duration: 0.5s !important;
    }

    * {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-link,
    .dropdown-toggle {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ==========================================================================
   13. ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/* Focus improvements */
.btn:focus,
.form-control:focus,
.nav-link:focus {
    outline: 2px solid #28a745;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-theme {
        border: 2px solid #000;
    }

    .text-light {
        color: #000 !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   14. PRINT STYLES
   ========================================================================== */

@media print {
    .header,
    .footer,
    .mobile-navigation,
    .mobile-overlay,
    .btn,
    .owl-carousel .owl-nav,
    .owl-carousel .owl-dots {
        display: none !important;
    }

    .main-content {
        margin-top: 0;
    }

    .page-section {
        break-inside: avoid;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* ==========================================================================
   15. CUSTOM BREAKPOINTS FOR SPECIFIC ELEMENTS
   ========================================================================== */

/* Extra large devices (large desktops, 1400px and up) */
@media (min-width: 1400px) {
    .container-xl {
        max-width: 1320px;
    }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
    .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }
}

/* Landscape phones */
@media (max-width: 767.98px) and (orientation: landscape) {
    .main-slider {
        min-height: 50vh;
    }

    .main-slider .caption-title {
        font-size: 1.3rem;
    }
}

/* Tablet portrait */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .main-slider .caption-title {
        font-size: 2.2rem;
    }

    .car-listing .row .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}
