/* ============================================================
   Star Cars London - Comprehensive Responsive Layer
   Loaded AFTER style.css. Covers desktop / tablet / mobile.
   ============================================================ */

/* ---- Global iOS no-zoom on input focus ---- */
@media (max-width: 991.98px) {
    input.form-control,
    select.form-select,
    textarea.form-control,
    .search-bar-wrap .form-control,
    .search-bar-wrap .form-select,
    .filter-group .form-control,
    .filter-group .form-select {
        font-size: 16px !important;
    }
}

/* ---- Global container padding tweaks ---- */
@media (max-width: 575.98px) {
    .container, .container-fluid, .container-sm, .container-md, .container-lg, .container-xl, .container-xxl {
        padding-left: 14px;
        padding-right: 14px;
    }
}

/* ---- Improve touch targets ---- */
@media (max-width: 991.98px) {
    .btn { min-height: 42px; }
    .btn-sm { min-height: 36px; }
    .nav-link, .footer-links a, .top-bar a { min-height: 36px; display: inline-flex; align-items: center; }
}

/* ============================================================
   LARGE DESKTOP / DESKTOP
   ============================================================ */
@media (max-width: 1399.98px) {
    .hero-title { font-size: clamp(28px, 4.5vw, 50px) !important; }
    .section-pad { padding: 80px 0; }
}

@media (max-width: 1199.98px) {
    /* Stocklist: filter sidebar narrower */
    .filter-sidebar { top: 90px; }
    .filter-body { padding: 18px; }

    /* Car cards a bit tighter */
    .car-card-body { padding: 18px; }
    .car-card-title { font-size: 17px; }

    /* Hero */
    .hero-swiper { height: 560px; }
    .hero-stats { gap: 22px; }
    .hero-stat .number { font-size: 28px; }

    /* Page header */
    .page-header { padding: 60px 0; }

    /* Finance banner */
    .finance-banner { padding: 50px 36px; }

    /* About / find-us */
    .map-wrap iframe { height: 380px; }
}

/* ============================================================
   TABLET (lg breakpoint)
   ============================================================ */
@media (max-width: 991.98px) {

    /* ---- Top bar: compact ---- */
    .top-bar { font-size: 12px; padding: 6px 0; }
    .top-bar .top-bar-left { gap: 14px !important; flex-wrap: wrap; }
    .top-bar .top-bar-left a { font-size: 12px; }

    /* ---- Navbar: mobile dropdown polished ---- */
    .main-navbar { padding: 10px 0; }
    .navbar-collapse {
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
    .navbar-nav { padding: 4px 8px; }
    .nav-link { font-size: 15px; }
    .nav-link::after { display: none !important; }
    .nav-item.ms-lg-2 .btn { width: 100%; }

    /* ---- Hero ---- */
    .hero-swiper { height: 500px; }
    .hero-text { max-width: 100%; }
    .hero-stats {
        gap: 18px;
        margin-top: 28px;
        padding-top: 22px;
    }
    .hero-stat .number { font-size: 26px; }
    .hero-stat .label { font-size: 12px; }

    /* ---- Sections ---- */
    .section-pad { padding: 64px 0; }
    .section-pad-sm { padding: 48px 0; }
    .section-title { font-size: clamp(24px, 3.6vw, 36px); }

    /* ---- Page header ---- */
    .page-header { padding: 50px 0; }
    .page-header h1 { font-size: clamp(24px, 4vw, 36px); }
    .page-header .col-lg-4 .btn { margin-top: 4px; }

    /* ---- Stocklist: filter becomes collapsible ---- */
    .filter-sidebar { position: static; top: auto; margin-bottom: 24px; }
    .filter-toggle-btn {
        display: flex !important;
        width: 100%;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 12px;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: var(--radius-sm);
        font-weight: 700;
        margin-bottom: 14px;
        cursor: pointer;
        font-family: var(--font);
        font-size: 15px;
    }
    .filter-toggle-btn:hover { background: var(--primary-light); }
    .filter-toggle-btn i { transition: transform 0.3s; }
    .filter-toggle-btn[aria-expanded="true"] i { transform: rotate(180deg); }
    .filter-sidebar.is-collapsed-on-mobile { display: none; }
    .filter-sidebar.is-open { display: block; }

    /* ---- Stat banner ---- */
    .stats-banner { padding: 40px 0; }
    .stat-item .stat-number { font-size: 36px; }
    .stat-divider { display: none; }

    /* ---- Car detail ---- */
    .enquiry-form-card { position: static; margin-top: 24px; }
    .car-detail-price { font-size: 32px; }

    /* ---- Finance banner ---- */
    .finance-banner { padding: 40px 28px; }

    /* ---- Footer ---- */
    .footer-top { padding: 56px 0 40px; }
    .footer-heading { margin-top: 24px; }
}

/* ============================================================
   FILTER TOGGLE BUTTON - hidden on desktop, shown above
   ============================================================ */
.filter-toggle-btn { display: none; }

/* ============================================================
   MOBILE (md breakpoint)
   ============================================================ */
@media (max-width: 767.98px) {

    body { font-size: 15px; }

    /* ---- Top bar: hide hours, compact icons ---- */
    .top-bar { padding: 5px 0; font-size: 11.5px; }
    .top-bar .top-bar-left { gap: 10px !important; }
    .top-bar .top-bar-right { gap: 12px !important; }
    .top-bar .top-bar-right a:not(:last-child) i {
        font-size: 14px;
    }
    /* Hide phone OR email if both don't fit; keep phone visible */
    .top-bar .top-bar-left a:nth-child(2) {
        display: none !important;
    }
    .top-bar .top-bar-right span,
    .top-bar .top-bar-right a span {
        display: none;
    }
    .top-bar .top-bar-right a.whatsapp-text-link { display: inline-flex; }
    /* Show "WhatsApp" text label compact */
    .top-bar .top-bar-right a[href*="wa.me"] {
        font-size: 0;
    }
    .top-bar .top-bar-right a[href*="wa.me"] i {
        font-size: 16px;
    }

    /* ---- Navbar logo ---- */
    .site-logo { height: 42px; }

    /* ---- Hero ---- */
    .hero-swiper { height: auto; min-height: 440px; }
    .hero-content { padding: 32px 0; }
    .hero-text .d-flex { gap: 10px !important; flex-wrap: wrap; }
    .hero-text .btn { flex: 1 1 auto; min-width: 140px; }

    /* ---- Search bar ---- */
    .search-bar-section { padding: 18px 0; }
    .search-bar-wrap { padding: 16px 14px; }
    .search-bar-wrap label { font-size: 11px; margin-bottom: 4px; }
    .search-bar-wrap .row { --bs-gutter-x: 0.75rem; }

    /* ---- Sections ---- */
    .section-pad { padding: 48px 0; }
    .section-pad-sm { padding: 36px 0; }
    .section-title { font-size: clamp(22px, 5.5vw, 30px); margin-bottom: 12px; }
    .section-subtitle { font-size: 15px; }

    /* ---- Page header ---- */
    .page-header { padding: 36px 0; }
    .page-header h1 { font-size: clamp(22px, 5vw, 32px); margin-bottom: 6px; }
    .page-header h1 i { font-size: 0.8em; }
    .page-header .breadcrumb { font-size: 13px; }
    .page-header .col-lg-4 { text-align: left !important; }
    .page-header .col-lg-4 .btn {
        padding: 8px 14px;
        font-size: 13px;
        margin: 4px 4px 0 0;
    }
    /* Decorative circles smaller */
    .page-header::before { width: 240px; height: 240px; right: -80px; top: -80px; }
    .page-header::after { width: 200px; height: 200px; right: 50px; bottom: -120px; }

    /* ---- Stocklist ---- */
    .stocklist-bar { padding: 12px 14px; }
    .stocklist-count { font-size: 14px; }
    .sort-select { font-size: 13px; padding: 7px 12px; }

    /* ---- Car cards ---- */
    .car-card-img { aspect-ratio: 16/11; }
    .car-card-body { padding: 16px; }
    .car-card-title { font-size: 16px; }
    .car-card-price { font-size: 17px; padding: 6px 14px; }
    .car-card-brand-top { min-height: 42px; padding: 6px 10px; }
    .car-card-brand-name { font-size: 11px; }
    .car-card-brand-copy span { font-size: 9px; }
    .car-card-badges { top: 48px; left: 10px; }
    .badge-fuel, .badge-featured { font-size: 10px; padding: 3px 8px; }
    .car-card-brand-bottom { display: none; }
    .car-card-footer .btn { padding: 8px 6px; font-size: 12px; }

    /* ---- Make grid ---- */
    .make-card { padding: 16px 10px; }
    .make-card i { font-size: 26px; }
    .make-card .make-name { font-size: 12px; }
    .make-card .make-count { font-size: 10px; }

    /* ---- Features ---- */
    .feature-card { padding: 26px 20px; }
    .feature-icon { width: 56px; height: 56px; font-size: 22px; }
    .feature-card h4 { font-size: 16px; }
    .feature-card p { font-size: 13px; }

    /* ---- Testimonials ---- */
    .testimonial-card { padding: 24px 20px; }
    .testimonial-text { font-size: 14px; line-height: 1.65; }
    .testimonial-card::before { font-size: 60px; top: 12px; left: 16px; }

    /* ---- Finance banner ---- */
    .finance-banner { padding: 32px 20px; }
    .finance-banner h2 { font-size: 22px; }
    .finance-step h5 { font-size: 15px; }
    .finance-step p { font-size: 13px; }

    /* ---- About ---- */
    .about-img-overlay { padding: 12px 16px; bottom: 14px; right: 14px; }
    .about-img-overlay .big-num { font-size: 28px; }
    .about-img-overlay .big-label { font-size: 12px; }
    .value-item { padding: 12px 0; gap: 12px; }
    .value-icon { width: 38px; height: 38px; font-size: 16px; }
    .value-item h5 { font-size: 15px; }

    /* ---- Warranty ---- */
    .warranty-header { padding: 22px 18px 18px; }
    .warranty-header h3 { font-size: 18px; }
    .warranty-price { font-size: 30px; }
    .warranty-features { padding: 20px 18px; }
    .warranty-features li { font-size: 13px; padding: 6px 0; }

    /* ---- Halal Finance ---- */
    .halal-highlight { padding: 32px 22px; }
    .halal-highlight h2 { font-size: 22px !important; }
    .finance-table { font-size: 13px; }
    .finance-table thead th { padding: 10px 12px; font-size: 12px; }
    .finance-table tbody td { padding: 10px 12px; font-size: 12.5px; }

    /* ---- Sell car ---- */
    .sell-hero { padding: 50px 0; }
    .sell-step { padding: 22px 14px; }
    .sell-step-num { width: 48px !important; height: 48px !important; font-size: 18px !important; }

    /* ---- Jobs ---- */
    .job-header { padding: 18px 20px; gap: 10px; }
    .job-header h3 { font-size: 17px; }
    .job-body { padding: 18px 20px; }

    /* ---- Find Us ---- */
    .map-wrap iframe { height: 280px; }
    .contact-info-card { padding: 22px 20px; }

    /* ---- Car detail ---- */
    .car-detail-price { font-size: 28px; }
    .detail-spec { padding: 12px 10px; gap: 10px; }
    .detail-spec-label { font-size: 9.5px; }
    .detail-spec-value { font-size: 13px; }

    /* Gallery */
    .car-detail-gallery { margin-bottom: 16px; }
    .car-detail-thumbs { gap: 6px; }

    /* Enquiry form */
    .enquiry-form-header { padding: 18px 20px; }
    .enquiry-form-header h4 { font-size: 16px; }
    .enquiry-form-body { padding: 20px; }

    /* ---- Footer ---- */
    .footer-top { padding: 44px 0 28px; }
    .footer-brand .footer-logo { height: 50px; }
    .footer-desc { font-size: 14px; }
    .footer-heading { font-size: 16px; margin-top: 18px; margin-bottom: 14px; }
    .footer-links li { padding: 3px 0; }
    .footer-links a { font-size: 13.5px; }
    .footer-contact li { gap: 12px; padding: 8px 0; }
    .footer-contact span, .footer-contact a { font-size: 13.5px; }
    .footer-badges { gap: 6px; }
    .badge-item { font-size: 11px; padding: 4px 10px; }
    .footer-bottom { padding: 16px 0; font-size: 12px; }
    .footer-bottom-meta { font-size: 11.5px; }
    .apk-store-btn { padding: 10px 12px; gap: 10px; }
    .apk-store-app-name { font-size: 14px; }
    .apk-store-app-sub { font-size: 11px; }

    /* ---- Page sections with row alignment ---- */
    .row.align-items-center .text-lg-end,
    .row.align-items-center .text-md-end { text-align: left !important; margin-top: 12px; }

    /* ---- Modals / video popup ---- */
    #carVideoModal > div[role="dialog"] {
        max-width: calc(100vw - 20px) !important;
        margin: 5vh auto 0 !important;
    }

    /* ---- Finance calculator (codeweavers) ---- */
    #PLUGIN_DIV_ID, #codeweavers-plugin { font-size: 14px; }

    /* ---- Spacing in alert/flash ---- */
    .alert { padding: 12px 16px; font-size: 14px; }

    /* ---- WhatsApp / back to top ---- */
    .whatsapp-float { width: 52px; height: 52px; font-size: 26px; bottom: 18px; right: 16px; }
}

/* ============================================================
   SMALL MOBILE
   ============================================================ */
@media (max-width: 575.98px) {

    /* ---- Hero ---- */
    .hero-swiper { min-height: 380px; }
    .hero-content { padding: 28px 0; }
    .hero-text .d-flex { flex-direction: column; align-items: stretch !important; }
    .hero-text .btn { width: 100%; padding: 12px 18px; font-size: 14px; }

    /* ---- Page header full-width buttons ---- */
    .page-header .col-lg-4 .btn {
        display: inline-block;
        padding: 8px 12px;
        font-size: 12.5px;
        margin: 4px 4px 0 0;
    }

    /* ---- Section gutters ---- */
    .row.g-5 { --bs-gutter-y: 1.6rem; --bs-gutter-x: 0.9rem; }
    .row.g-4 { --bs-gutter-y: 1.2rem; --bs-gutter-x: 0.75rem; }

    /* ---- Search bar ---- */
    .search-bar-wrap { padding: 14px 10px; }
    .search-bar-wrap .row > [class*="col-"] { margin-bottom: 8px; }

    /* ---- Stocklist ---- */
    .stocklist-bar { flex-direction: column; align-items: stretch; gap: 10px; }
    .stocklist-bar .stocklist-count { text-align: center; }
    .stocklist-bar .sort-select { width: 100%; }

    /* ---- Car cards two col turns to one col by Bootstrap default ---- */
    .car-card-specs { grid-template-columns: 1fr 1fr; gap: 6px; }
    .car-spec-item { font-size: 12px; }

    /* ---- Make grid: 3 columns on phones ---- */
    .make-card { padding: 12px 8px; }

    /* ---- Page header decorations off ---- */
    .page-header::before, .page-header::after { display: none; }

    /* ---- About overlay ---- */
    .about-img-overlay { padding: 10px 12px; bottom: 10px; right: 10px; }
    .about-img-overlay .big-num { font-size: 22px; }
    .about-img-overlay .big-label { font-size: 10px; }

    /* ---- Sell car steps ---- */
    .sell-step { padding: 18px 10px; }

    /* ---- Halal highlight ---- */
    .halal-highlight { padding: 26px 16px; }
    .halal-highlight .d-flex.gap-3 { flex-wrap: wrap; gap: 10px !important; }

    /* ---- Finance table: tighter ---- */
    .finance-table { font-size: 12px; }
    .finance-table thead th { padding: 8px 8px; font-size: 11px; }
    .finance-table tbody td { padding: 8px 8px; font-size: 12px; }

    /* ---- Map ---- */
    .map-wrap iframe { height: 240px; }

    /* ---- Car detail ---- */
    .detail-spec-grid { grid-template-columns: 1fr 1fr; }
    .detail-spec { padding: 10px 8px; gap: 8px; }
    .detail-spec-icon { width: 38px; height: 38px; min-width: 38px; }
    .detail-spec-icon svg { width: 18px; height: 18px; }
    .detail-spec-icon-fa i { font-size: 18px; }
    .car-features-list { gap: 5px; }
    .car-feature-tag { font-size: 11.5px; padding: 4px 10px; }

    /* Enquiry form */
    .enquiry-form-header { padding: 16px; }
    .enquiry-form-body { padding: 16px; }

    /* ---- Footer ---- */
    .footer-top { padding: 36px 0 24px; }
    .footer-heading { font-size: 15px; }
    .footer-social-row { flex-wrap: wrap; gap: 8px; }
    .ftr-social-link { width: 38px; height: 38px; font-size: 16px; }
    .apk-store-btn { padding: 9px 11px; gap: 8px; }
    .apk-store-left { display: none !important; }
    .footer-bottom-inner { gap: 6px; }
    .footer-bottom p { font-size: 11.5px; line-height: 1.5; }
    .footer-disclosure { margin-top: 12px; padding-top: 12px; text-align: center; }
    .footer-disclosure-title { font-size: 11.5px; line-height: 1.6; }
    .footer-disclosure-text { font-size: 10.5px !important; line-height: 1.65; }

    /* ---- WhatsApp ---- */
    .whatsapp-float { width: 48px; height: 48px; font-size: 22px; bottom: 14px; right: 12px; }

    /* ---- Card row reduce gap ---- */
    .row.g-4 > [class*="col-"] { padding-left: 8px; padding-right: 8px; }
}

/* ============================================================
   EXTRA SMALL (< 380px)
   ============================================================ */
@media (max-width: 379.98px) {
    .container, .container-fluid { padding-left: 12px; padding-right: 12px; }
    .site-logo { height: 36px; }
    .hero-title { font-size: clamp(20px, 7vw, 26px); }
    .hero-subtitle { font-size: 13px; }
    .section-title { font-size: 22px; }
    .car-card-title { font-size: 15px; }
    .car-card-price { font-size: 15px; padding: 6px 12px; }
    .stat-item .stat-number { font-size: 26px; }
    .filter-toggle-btn { font-size: 14px; padding: 10px; }
}

/* ============================================================
   LANDSCAPE PHONE
   ============================================================ */
@media (max-height: 480px) and (orientation: landscape) {
    .hero-swiper { min-height: 320px; }
    .hero-content { padding: 16px 0; }
    .section-pad { padding: 36px 0; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .top-bar, .main-navbar, .site-footer, .whatsapp-float, .back-to-top,
    .filter-sidebar, .stocklist-bar, .enquiry-form-card,
    .navbar-toggler, .filter-toggle-btn {
        display: none !important;
    }
    body { background: white !important; color: black !important; }
    .car-card, .feature-card, .testimonial-card, .warranty-card {
        page-break-inside: avoid;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
    }
    .page-header { background: #f0f0f0 !important; color: #000 !important; padding: 24px 0 !important; }
    .page-header h1, .page-header .breadcrumb-item, .page-header .breadcrumb-item a { color: #000 !important; }
    a { text-decoration: none !important; color: #000 !important; }
}

/* ============================================================
   ACCESSIBILITY: reduce motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
