/* Global responsive optimizations — all pages */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

/* Prevent flex/grid children from forcing page wider than viewport */
.container,
.container-fluid,
main,
section,
header,
footer {
    max-width: 100%;
}

img,
video,
svg {
    max-width: 100%;
    height: auto;
}

/* ——— Navigation ——— */
@media (max-width: 991px) {
    .navbar-custom {
        padding: 10px 0 !important;
    }
    .navbar-brand img {
        max-width: 160px !important;
        height: auto;
    }
    .navbar-toggler {
        padding: 6px 10px;
    }
    .navbar-collapse {
        margin-top: 10px;
        padding: 10px 12px;
        background: #ffffff;
        border-radius: 10px;
        box-shadow: 0 6px 18px rgba(0, 11, 48, 0.1);
        max-height: calc(100vh - 90px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .navbar-collapse .nav-link-custom {
        color: #1f2937 !important;
    }
    .navbar-custom:not(.navbar-scrolled) .navbar-collapse .nav-link-custom {
        color: #1f2937 !important;
    }
    .navbar-collapse .nav-link-custom:hover,
    .navbar-collapse .nav-link-custom:focus {
        color: #3976be !important;
    }
    .navbar-custom:not(.navbar-scrolled) .navbar-collapse .nav-link-custom:hover,
    .navbar-custom:not(.navbar-scrolled) .navbar-collapse .nav-link-custom:focus {
        color: #3976be !important;
    }
    .navbar-collapse .navbar-nav .nav-item {
        width: 100%;
    }
    .navbar-nav {
        align-items: flex-start !important;
        width: 100%;
    }
    .nav-link-custom {
        margin-right: 0 !important;
        margin-bottom: 6px;
        font-size: 13px !important;
        line-height: 1.4;
        padding: 8px 4px !important;
    }
    #languageSwitcher {
        width: 92px;
        max-width: 100%;
    }
    .navbar-collapse #languageSwitcher {
        margin-top: 6px;
    }
    .simple-dropdown-menu {
        display: none !important;
    }
    .nav-item-dropdown.active-mobile > .simple-dropdown-menu {
        display: block !important;
    }
    .mega-menu {
        display: none !important;
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        opacity: 1 !important;
        visibility: visible !important;
        position: static !important;
        transform: none !important;
    }
    .nav-item-mega.active-mobile > .mega-menu {
        display: block !important;
    }
    .mega-menu .row {
        --bs-gutter-y: 0.5rem;
    }
    .mega-menu-item {
        padding: 10px !important;
    }
    .mega-menu-icon {
        width: 40px !important;
        height: 40px !important;
        flex-shrink: 0;
    }
}

/* ——— Hero / category headers ——— */
@media (max-width: 991px) {
    .hero-section {
        padding-top: 124px !important;
        padding-bottom: 56px !important;
        min-height: auto !important;
    }
    .about-hero,
    .blog-hero,
    .category-hero {
        padding-top: 88px !important;
        padding-bottom: 48px !important;
    }
    .category-hero--catalog {
        padding-top: 96px !important;
        padding-bottom: 52px !important;
    }
    .hero-title,
    .about-hero-title,
    .blog-hero h1,
    .category-hero h1 {
        font-size: clamp(1.45rem, 5.5vw, 2rem) !important;
        line-height: 1.25 !important;
        word-wrap: break-word;
    }
    .hero-desc,
    .blog-hero .lead,
    .category-hero .lead {
        font-size: 0.96rem !important;
        line-height: 1.45 !important;
    }
    .hero-section .hero-title {
        margin-top: 10px !important;
    }
    .hero-section .hero-desc {
        margin-top: 18px !important;
    }
    .hero-section .d-flex.gap-3,
    .hero-section .d-flex.flex-wrap {
        justify-content: center;
    }
}

/* ——— Catalog: toolbar, grid, cards ——— */
@media (max-width: 991px) {
    .catalog-toolbar {
        padding: 12px 0 !important;
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
    }
    .catalog-toolbar .container {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: hidden;
    }
    .catalog-toolbar .container > * {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
    }
    .catalog-filters-scroll {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        gap: 8px !important;
        padding-bottom: 6px !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .catalog-filter-btn {
        white-space: nowrap !important;
        margin-right: 0 !important;
        flex-shrink: 0 !important;
        font-size: 13px !important;
        padding: 8px 10px !important;
    }
    .catalog-toolbar .container > .d-flex.gap-2,
    .catalog-toolbar .container > .d-flex.flex-wrap {
        flex-wrap: wrap !important;
    }
    .catalog-toolbar .container > .d-flex.gap-2 > * {
        flex: 1 1 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
    .catalog-search-wrap {
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        flex: 1 1 100%;
        min-width: 0 !important;
    }
    .catalog-search-wrap input {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 44px;
    }
    .catalog-sort-select {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        min-height: 44px;
    }

    .store-grid-section,
    .ahu-grid-section,
    .panels-grid-section {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }
    .store-card-img-wrap {
        min-height: 160px !important;
        padding: 12px !important;
    }
    .store-card-img-wrap img {
        max-height: 180px !important;
    }
    .store-card-body {
        padding: 16px !important;
    }
    .store-card-title {
        font-size: 1rem !important;
    }
    .store-card-desc {
        font-size: 0.88rem !important;
        -webkit-line-clamp: 4;
    }
    .btn-store-primary,
    .btn-store-outline {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .quiz-section {
        padding: 48px 0 !important;
    }
    .quiz-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    .quiz-check-grid {
        grid-template-columns: 1fr !important;
    }
    .quiz-footer-nav {
        flex-wrap: wrap;
        gap: 10px;
    }
    .quiz-footer-nav .d-flex {
        width: 100%;
        justify-content: flex-end;
    }

    .seo-section {
        padding: 48px 0 !important;
    }
    .aysu-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }
}

/* ——— Product modal ——— */
@media (max-width: 991px) {
    .product-detail-modal .modal-dialog {
        max-width: calc(100% - 1rem) !important;
        margin: 0.5rem auto !important;
    }
    .product-detail-modal .modal-body .row {
        flex-direction: column !important;
    }
    .product-detail-img {
        margin-bottom: 1rem;
        padding: 14px !important;
    }
    .product-detail-img img,
    #productDetailImage {
        max-height: 240px !important;
    }
    .product-detail-title,
    #productDetailTitle {
        font-size: 1.25rem !important;
    }
    .product-detail-html {
        overflow-x: auto;
        word-break: break-word;
    }
    .product-detail-html img {
        max-width: 100% !important;
        height: auto !important;
    }
    .product-detail-relevants .col-lg-3,
    .product-detail-relevants .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ——— Sections: home, about, blog ——— */
@media (max-width: 991px) {
    .product-section,
    .panels-grid-section,
    .about-section,
    .advantages-section,
    .stats-section {
        padding-top: 44px !important;
        padding-bottom: 44px !important;
    }
    .product-card,
    .panels-card {
        border-radius: 10px !important;
    }
    .product-body,
    .panels-card-body {
        padding: 16px !important;
    }
    .product-title,
    .panels-card-title {
        font-size: 1.05rem !important;
    }

    .stats-section .stat-number {
        font-size: 2rem !important;
    }
    .stats-section .stat-label {
        font-size: 0.92rem !important;
        line-height: 1.35 !important;
    }

    .aysu-section {
        margin: 24px auto !important;
        padding: 0 14px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    .aysu-title {
        font-size: clamp(1.25rem, 4.5vw, 1.5rem) !important;
    }
    .aysu-lead {
        font-size: 15px !important;
    }
    .aysu-seo-text {
        margin-top: 24px !important;
        padding-top: 20px !important;
        font-size: 14px !important;
        line-height: 1.65 !important;
    }
    .seo-section .d-flex.gap-3,
    .aysu-footer-action {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .seo-section .d-flex.gap-3 .btn,
    .aysu-footer-action .btn {
        width: 100% !important;
    }

    footer .row {
        text-align: center !important;
    }
    footer .col-md-4 {
        margin-bottom: 1rem;
    }

    .floating-widget {
        right: 14px !important;
        bottom: 14px !important;
        z-index: 1060 !important;
    }
    .widget-btn {
        width: 52px !important;
        height: 52px !important;
        font-size: 20px !important;
    }
    .widget-item {
        width: 44px !important;
        height: 44px !important;
    }

    .modal-dialog {
        margin: 0.5rem !important;
    }
    .modal-body {
        padding: 14px !important;
    }
    .modal-footer {
        padding: 12px 14px !important;
        flex-wrap: wrap;
        gap: 8px;
    }
    .modal-footer .btn {
        flex: 1 1 auto;
        min-width: 120px;
    }
}

/* ——— Small phones ——— */
@media (max-width: 575px) {
    .hero-section {
        padding-top: 132px !important;
        padding-bottom: 48px !important;
    }
    .category-hero h1 {
        font-size: 1.45rem !important;
    }
    .container,
    .container-fluid {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }
    .btn,
    .btn-sm {
        font-size: 0.92rem !important;
    }
    .d-flex.gap-3:not(.flex-row) {
        flex-direction: column;
        align-items: stretch !important;
    }
    .d-flex.gap-3 .btn {
        width: 100%;
    }
    .store-grid-section .row,
    #storeProductGrid.row {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }
    .quiz-container {
        padding: 16px !important;
    }
    .projects-carousel-wrap {
        padding: 0 40px !important;
    }
}

/* ——— Large tablets / small laptops ——— */
@media (min-width: 992px) and (max-width: 1199px) {
    .mega-menu {
        max-width: 960px !important;
        padding: 24px !important;
    }
    .category-hero h1 {
        font-size: 2.2rem;
    }
}

/* ——— Wide screens ——— */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}
