/* Phase 8: focused responsive fixes */
html,
body {
    max-width: 100%;
    overflow-x: clip;
}

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

.mobile-menu-toggle,
.mobile-menu-close {
    display: none;
}

.mobile-menu-backdrop,
.mobile-menu-panel {
    display: none;
}

.header-container {
    gap: 1rem;
}

.auth-links {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.listing-horizontal-card,
.premium-biz-card,
.section-card,
.sidebar-card {
    min-width: 0;
}

.listing-horizontal-card .lh-actions .btn,
.listing-horizontal-card .lh-actions button,
.sidebar-cta-stack a,
.mobile-cta-bar a {
    min-height: 44px;
}

.biz-title,
.biz-title a,
.listing-horizontal-card h3,
.detail-hero h1 {
    overflow-wrap: anywhere;
}

.rich-text-content,
.detail-meta-line,
.sidebar-info-table,
.footer-links {
    overflow-wrap: anywhere;
}

@media (max-width: 980px) {
    .header {
        position: sticky;
    }

    .header-container {
        min-height: 68px;
        padding: 0.75rem 0;
    }

    .logo a {
        font-size: 1.45rem;
        letter-spacing: 0;
        white-space: nowrap;
    }

    .header .nav-links,
    .header .auth-links {
        display: none !important;
    }

    .mobile-menu-toggle {
        width: 44px;
        height: 44px;
        border-radius: 8px;
        border: 1px solid var(--border);
        background: #fff;
        color: var(--text-primary);
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        cursor: pointer;
        box-shadow: var(--shadow-sm);
    }

    .mobile-menu-toggle span {
        width: 20px;
        height: 2px;
        border-radius: 999px;
        background: #0f172a;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    body.mobile-menu-open .mobile-menu-toggle span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    body.mobile-menu-open .mobile-menu-toggle span:nth-child(2) {
        opacity: 0;
    }

    body.mobile-menu-open .mobile-menu-toggle span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .mobile-menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1100;
        background: rgba(15, 23, 42, 0.42);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        display: block;
    }

    .mobile-menu-panel {
        position: fixed;
        top: 0;
        right: 0;
        z-index: 1110;
        width: min(88vw, 360px);
        height: 100vh;
        padding: 1rem;
        background: #fff;
        border-left: 1px solid var(--border);
        box-shadow: -24px 0 60px rgba(15, 23, 42, 0.2);
        transform: translateX(102%);
        transition: transform 0.24s ease;
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
        overflow-y: auto;
    }

    body.mobile-menu-open .mobile-menu-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    body.mobile-menu-open .mobile-menu-panel {
        transform: translateX(0);
    }

    body.mobile-menu-open {
        overflow: hidden;
    }

    .mobile-menu-panel__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.25rem 0.15rem 0.85rem;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid var(--border-light);
    }

    .mobile-menu-logo {
        font-size: 1.35rem;
        font-weight: 900;
        color: var(--text-primary);
    }

    .mobile-menu-logo span {
        color: var(--primary);
    }

    .mobile-menu-close {
        width: 42px;
        height: 42px;
        border-radius: 8px;
        border: 1px solid var(--border);
        background: #f8fafc;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 1.1rem;
        color: #0f172a;
    }

    .mobile-menu-panel > a {
        min-height: 48px;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.8rem 0.85rem;
        border-radius: 8px;
        color: #0f172a;
        font-weight: 750;
        border: 1px solid transparent;
    }

    .mobile-menu-panel > a:hover,
    .mobile-menu-panel > a:focus {
        background: #f8fafc;
        border-color: var(--border-light);
        color: var(--primary);
    }

    .mobile-menu-panel > a i {
        width: 20px;
        color: var(--primary);
    }

    .search-box-jd {
        width: 100%;
    }

    .search-box-jd input {
        width: 100%;
    }

    .listing-layout {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .hero-search-container {
        margin-bottom: 0;
    }

    .search-box-jd {
        border-width: 1px;
        box-shadow: 0 16px 34px rgba(15, 23, 42, 0.12);
    }

    .search-box-jd select,
    .search-box-jd input,
    .search-box-jd button {
        font-size: 1rem !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    #search_suggest {
        top: calc(100% + 8px) !important;
        max-height: 280px !important;
    }

    .section-header {
        display: block !important;
    }

    .section-header .btn {
        margin-top: 1rem;
        width: 100%;
    }

    .cat-section-premium {
        padding: 3.25rem 0;
    }

    .listing-page-wrap {
        padding: 1.5rem 0 3rem;
    }

    .listing-filters-sidebar {
        padding: 1rem;
        border-radius: 8px;
    }

    .listing-horizontal-card {
        border-radius: 8px;
    }

    .listing-horizontal-card .lh-body {
        padding: 1rem;
    }

    .listing-horizontal-card .lh-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }

    .listing-horizontal-card .lh-actions .btn,
    .listing-horizontal-card .lh-actions button {
        width: 100%;
        padding: 0.75rem 0.7rem !important;
        white-space: normal;
    }

    .premium-btn-icon {
        min-width: 44px;
    }

    .detail-hero {
        min-height: 320px;
    }

    .detail-hero-inner {
        min-height: 320px;
        padding-top: 2rem;
    }

    .detail-badges-row,
    .detail-meta-line {
        gap: 0.5rem;
    }

    .detail-meta-line span {
        max-width: 100%;
    }

    .section-card {
        padding: 1rem;
        border-radius: 8px;
    }

    .highlights-grid,
    .services-grid-premium {
        grid-template-columns: 1fr;
    }

    .similar-slider {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
        overflow: visible;
    }

    .sidebar-card {
        border-radius: 8px;
    }

    .footer-wrap {
        margin-top: 3rem;
        padding: 3rem 0 1.5rem;
    }

    .footer-grid {
        gap: 1.75rem;
        margin-bottom: 2rem;
        padding-bottom: 2rem;
    }

    .footer-title {
        margin-bottom: 0.85rem;
    }
}

@media (max-width: 430px) {
    .listing-horizontal-card .lh-actions {
        grid-template-columns: 1fr;
    }

    .premium-biz-footer,
    .biz-card-pro__actions {
        display: grid !important;
        grid-template-columns: 1fr;
    }

    .biz-card-pro__quick {
        justify-content: stretch;
    }

    .biz-card-pro__icon-btn {
        flex: 1;
    }

    .footer-bottom > div:last-child {
        flex-direction: column;
        gap: 0.6rem !important;
    }
}
