@media (max-width: 1200px) {
    /* Banner responsive styles moved to banner-engine.css */
    .product-detail { gap: 32px; }
}

@media (max-width: 1024px) {
    /* Tablet Typography Scale */
    .hero h1, .hero-title { font-size: 3rem; }
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.5rem; }
    body { font-size: 16px; }

    /* Layout & Sidebar Drawer */
    .cart-layout { grid-template-columns: 1fr; }
    .product-detail { grid-template-columns: 1fr; }
    .product-gallery .main-image { height: 350px; }
    .dashboard,
    .dashboard-container { grid-template-columns: 1fr; width: 100%; max-width: 100%; }
    .dashboard-sidebar {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1050;
        width: 280px;
        height: 100vh;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.4);
        background: var(--sidebar-bg);
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
    }
    .dashboard-sidebar.mobile-open {
        transform: translateX(0) !important;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        backdrop-filter: blur(2px);
    }
    .sidebar-overlay.active {
        display: block;
    }
    .sidebar-toggle {
        display: inline-flex !important;
    }
    .settings-grid { grid-template-columns: 1fr; }

    /* ── SEARCH BAR: Tablet responsive fix (769px–1024px) ────────────────
       Ensures the search bar fits cleanly without clipping or overflow.
    ── */
    .home-search-container { max-width: 100%; }
    .home-search-hero-wrap {
        box-sizing: border-box;
        width: 100%;
        min-width: 0;
    }
    .home-search-hero-input {
        min-width: 0;
        flex: 1 1 0;
    }
    .home-search-hero-btn { flex-shrink: 0; }

    /* ── Footer Trust & Benefits: Tablet 3 + 2 Layout (769px–1024px) ── */
    .footer-trust-bar {
        grid-template-columns: repeat(6, 1fr);
        gap: 12px;
    }
    .footer-trust-item:nth-child(1) { grid-column: 1 / span 2; }
    .footer-trust-item:nth-child(2) { grid-column: 3 / span 2; }
    .footer-trust-item:nth-child(3) { grid-column: 5 / span 2; }
    .footer-trust-item:nth-child(4) { grid-column: 2 / span 2; }
    .footer-trust-item:nth-child(5) { grid-column: 4 / span 2; }
    .footer-trust-item {
        padding: 9px 12px;
    }
    .footer-newsletter {
        flex-direction: column;
        align-items: flex-start;
        gap: 18px;
        padding: 20px 24px;
    }
    .footer-newsletter-form {
        max-width: 100%;
        width: 100%;
    }
}


@media (min-width: 1025px) {
    .sidebar-toggle { display: none !important; }
    .sidebar-overlay { display: none !important; }
    .dashboard-sidebar {
        position: static;
        width: auto;
        height: auto;
        box-shadow: none;
        transform: none !important;
        transition: none;
    }
}

@media (max-width: 768px) {
    /* Mobile Typography Scale */
    .hero h1, .hero-title { font-size: 2.125rem; }
    h1 { font-size: 1.875rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    body { font-size: 15px; }

    .nav-toggle { display: inline-flex; }
    .nav-icon-item .nav-label-text { display: none !important; }
    .nav-user-link { padding: 4px 8px !important; }
    .nav-user-link .nav-label { font-size: 0.82rem; font-weight: 600; }
    .nav-icons .nav-btn { height: 32px; min-width: 76px; font-size: 13px; padding: 0 12px; }
    .nav-icons .nav-btn-secondary { height: 32px; min-width: 76px; font-size: 13px; padding: 0 12px; }
    .section-header h2 { font-size: 1.5rem; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
    .store-info-section { margin-top: -60px; }
    .store-info-container { flex-direction: column; align-items: center; text-align: center; }
    .store-info-logo { width: 100px; height: 100px; font-size: 2rem; }
    .store-info-details .store-meta { justify-content: center; flex-wrap: wrap; }
    .store-header { height: 200px; }
    .page-header h1 { font-size: 1.8rem; }
    .auth-box { padding: 24px; }
    .form-row { grid-template-columns: 1fr; }
    .cart-item { grid-template-columns: 80px 1fr; }
    .cart-item-actions { grid-column: span 2; flex-direction: row; justify-content: space-between; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; }

    /* ── Local Store Spotlight Mobile Rules (Phone: max-width: 768px) ── */
    /* Exactly 2 stores per row */
    .hp-store-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
    }

    .hp-store-card {
        max-width: 100% !important;
        padding: 16px 10px 14px !important;
        border-radius: var(--radius-sm, 10px) !important;
    }

    /* Completely hide store banner on mobile */
    .hp-store-banner {
        display: none !important;
    }

    /* Logo sits cleanly at the top of the mobile card */
    .hp-store-logo-wrap {
        margin: 0 auto 10px !important;
        width: 52px !important;
        height: 52px !important;
        padding: 3px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    }

    .hp-store-logo-wrap i {
        width: 26px !important;
        height: 26px !important;
    }

    .hp-store-body {
        padding: 0 !important;
    }

    .hp-store-name {
        font-size: 0.88rem !important;
        margin-bottom: 4px !important;
    }

    .hp-store-name .hp-verified {
        width: 13px !important;
        height: 13px !important;
    }

    .hp-store-desc {
        font-size: 0.74rem !important;
        line-height: 1.35 !important;
        margin-bottom: 12px !important;
        max-width: 100% !important;
        -webkit-line-clamp: 2 !important;
    }

    .hp-store-cta {
        padding: 7px 10px !important;
        font-size: 0.76rem !important;
        min-height: 32px !important;
        gap: 4px !important;
        width: 100% !important;
    }

    .hp-store-cta i {
        width: 13px !important;
        height: 13px !important;
    }
    /* ── Footer Trust & Benefits: Mobile 2 + 2 + 1 Layout (≤ 768px) ── */
    .footer-trust-wrap {
        padding-bottom: 16px;
        margin-bottom: 20px;
    }
    .footer-trust-bar {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px 8px !important;
    }
    .footer-trust-item:nth-child(1) { grid-column: 1 / span 2 !important; }
    .footer-trust-item:nth-child(2) { grid-column: 3 / span 2 !important; }
    .footer-trust-item:nth-child(3) { grid-column: 1 / span 2 !important; }
    .footer-trust-item:nth-child(4) { grid-column: 3 / span 2 !important; }
    .footer-trust-item:nth-child(5) { grid-column: 2 / span 2 !important; }
    .footer-trust-item {
        padding: 8px 10px !important;
        gap: 8px !important;
    }
    .footer-trust-icon {
        width: 32px !important;
        height: 32px !important;
    }
    .footer-trust-icon i {
        width: 16px !important;
        height: 16px !important;
    }
    .footer-trust-label {
        font-size: 0.76rem !important;
        white-space: normal !important;
        line-height: 1.2 !important;
    }
    .footer-trust-sub {
        font-size: 0.66rem !important;
        white-space: normal !important;
        line-height: 1.2 !important;
    }
    .footer-newsletter {
        padding: 20px 16px;
        text-align: center;
        align-items: center;
    }
    .footer-newsletter-form {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    .footer-newsletter-input {
        width: 100%;
    }
    .footer-newsletter-btn {
        width: 100%;
        padding: 12px;
    }
    .dash-card .dash-value { font-size: 1.4rem; }
    .dashboard-main { padding: 20px 16px; }
    .store-tabs { gap: 0; }
    .store-tab { padding: 10px 16px; font-size: 0.85rem; }
    .offer-grid { grid-template-columns: 1fr; }

    /* Table overflow protection on mobile */
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Container breathing room */
    .container { padding: 0 16px; }
    .settings-card { padding: 20px; }

    /* ── SEARCH BAR: Phone/Tablet responsive fix ─────────────────────────
       Prevents horizontal overflow and clipping on small viewports.
       Targets the existing .home-search-hero-* classes from index.php.
    ── */
    .section-search { overflow: visible; }
    .home-search-container { max-width: 100%; padding: 0; }
    .home-search-hero-wrap {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 4px 6px 4px 10px;
        border-radius: 40px;
        flex-wrap: nowrap;
        min-width: 0;
        overflow: visible;
    }
    .home-search-hero-input {
        flex: 1 1 0;
        min-width: 0;
        width: 0; /* forces flex to control width */
        padding: 10px 6px;
        font-size: 0.85rem;
    }
    .home-search-hero-btn {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 0.85rem;
        gap: 4px;
        white-space: nowrap;
    }
    .home-search-hero-icon { display: none; } /* hide store icon on mobile to save space */
}

/* ── SEARCH BAR: Extra narrow phones (≤360px) ─────────────────────────────
   At 320px–360px the button text 'Search' + padding can still cause
   horizontal overflow if default sizes are not reduced further.
── */
@media (max-width: 360px) {
    .section-search { overflow: visible; padding-left: 0; padding-right: 0; }
    .home-search-container { padding: 0; }
    .home-search-hero-wrap {
        padding: 3px 4px 3px 8px;
        gap: 0;
    }
    .home-search-hero-input {
        padding: 8px 4px;
        font-size: 0.80rem;
    }
    .home-search-hero-btn {
        padding: 8px 10px;
        font-size: 0.78rem;
        gap: 3px;
    }
}

@media (max-width: 480px) {
    .nav-icons .nav-btn { height: 30px; min-width: 68px; font-size: 12px; padding: 0 10px; }
    .nav-icons .nav-btn-secondary { height: 30px; min-width: 68px; font-size: 12px; padding: 0 10px; }
    .notif-dropdown {
        right: -120px;
        width: 300px;
    }
}

@media (max-width: 480px) {
    /* Banner responsive styles moved to banner-engine.css */
    .product-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .product-card-image { height: 160px; }
    .product-card-body { padding: 10px; }
    .product-card-body h3 { font-size: 0.85rem; }
    .product-card-body .product-price .current { font-size: 1rem; }
    .section { padding: 32px 0; }
    .footer-grid { grid-template-columns: 1fr; }
    .store-info-logo { width: 80px; height: 80px; }
    .store-header { height: 160px; }
    .auth-box { padding: 20px; }
}

@media (max-width: 425px) {
    /* Banner responsive styles moved to banner-engine.css */
    .store-grid { grid-template-columns: 1fr; gap: 12px; }
    .hp-store-grid { gap: 8px !important; }
    .hp-store-card { padding: 12px 8px 10px !important; }
    .hp-store-logo-wrap { width: 44px !important; height: 44px !important; margin-bottom: 6px !important; }
    .hp-store-name { font-size: 0.82rem !important; }
    .hp-store-desc { font-size: 0.70rem !important; margin-bottom: 8px !important; }
    .hp-store-cta { padding: 5px 8px !important; font-size: 0.72rem !important; min-height: 28px !important; }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .product-card-image { height: 170px; }
    .footer-grid { grid-template-columns: 1fr; }
    .page-header { padding: 60px 0 20px; }
    .page-header h1 { font-size: 1.4rem; }
    .dashboard-main { padding: 16px; }
    .dashboard-cards { grid-template-columns: 1fr; }
    .dash-card { padding: 16px; }
    .dash-card .dash-value { font-size: 1.4rem; }
    .table-wrapper { overflow-x: auto; }
    .table { min-width: 600px; }
    .modal { margin: 10px; }
}

@media (max-width: 380px) {
    /* Banner responsive styles moved to banner-engine.css */
    .nav-container { padding: 0 10px; gap: 8px; }
    .nav-logo { font-size: 1.1rem; }
    .nav-logo i { font-size: 1.3rem; }
    .product-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .product-card-image { height: 130px; }
    .product-card-body { padding: 8px; }
    .product-card-body h3 { font-size: 0.78rem; }

    .section { padding: 24px 0; }
    .container { padding: 0 10px; }
    .store-info-section { margin-top: -32px; }
    .store-info-logo { width: 56px; height: 56px; font-size: 1.3rem; }
    .store-header { height: 120px; }
    .auth-box { padding: 14px; }
    .footer-trust-bar { gap: 6px 6px !important; }
    .footer-trust-item { padding: 6px 6px !important; gap: 6px !important; }
    .footer-trust-icon { width: 28px !important; height: 28px !important; }
    .footer-trust-icon i { width: 14px !important; height: 14px !important; }
    .footer-trust-label { font-size: 0.70rem !important; }
    .footer-trust-sub { font-size: 0.60rem !important; }
}

/* Account page service actions retain readable contrast in both theme modes. */
.account-logout-btn,
.account-logout-btn:visited {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    background: #b91c1c !important;
    border: 1px solid #991b1b !important;
}

.account-logout-btn:hover,
.account-logout-btn:focus-visible,
.account-logout-btn:active {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    background: #991b1b !important;
    opacity: 1;
    outline: 3px solid #fecaca;
    outline-offset: 2px;
}

.account-security-status,
.account-security-status--channel {
    color: #07552f !important;
    -webkit-text-fill-color: #07552f !important;
    background: #eaf7ee !important;
    border: 1px solid #15803d !important;
}

.account-service-action,
.account-service-action:visited {
    color: #07552f !important;
    -webkit-text-fill-color: #07552f !important;
    background: #eaf7ee !important;
    border: 1px solid #15803d !important;
}

.account-service-action--repair,
.account-service-action--repair:visited {
    color: #1d4ed8 !important;
    -webkit-text-fill-color: #1d4ed8 !important;
    background: #eff6ff !important;
    border-color: #2563eb !important;
}

.account-service-action:focus-visible {
    outline: 3px solid var(--focus-ring, #1877f2);
    outline-offset: 2px;
}

.account-service-action svg,
.account-service-action i {
    color: currentColor;
    flex: 0 0 auto;
}

.account-content-grid,
.account-content-grid > *,
.account-personal-column > *,
.account-navigation-panel > * {
    min-width: 0;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .account-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        padding-left: 12px !important;
        padding-right: 12px !important;
        overflow-x: clip;
    }

    .account-container * {
        box-sizing: border-box;
    }

    .account-content-grid {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 20px !important;
        width: 100%;
    }

    .account-personal-column,
    .account-navigation-panel,
    .account-personal-details {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        grid-column: 1 / -1;
    }

    .account-personal-details {
        padding: 20px !important;
    }

    .account-service-actions {
        width: 100%;
    }

    .account-service-action {
        max-width: 100%;
        white-space: normal;
    }
}
