/* Global Responsive Overrides (mobile-first) */

:root {
    --tb-mobile-header-height: 60px;
    --tb-mobile-drawer-width: min(90vw, 360px);
    --tb-panel-drawer-width: min(88vw, 340px);
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

*,
*::before,
*::after {
    min-width: 0;
}

img,
picture,
video,
canvas,
svg,
iframe {
    max-width: 100%;
    height: auto;
}

table {
    width: 100%;
}

.table-responsive,
.dataTables_wrapper {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.dropdown-menu {
    max-width: min(92vw, 420px);
    overflow-wrap: anywhere;
}

.modal-dialog {
    max-width: min(95vw, 640px);
}

.tb-main-header,
.tb-nav-bar {
    max-width: 100%;
}

.tb-mobile-menu-btn {
    display: none;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    border-radius: 0.55rem;
    width: 2.35rem;
    height: 2.35rem;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    padding: 0;
}

.tb-mobile-menu-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.tb-mobile-drawer-overlay,
.tb-panel-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1050;
}

.tb-mobile-drawer-overlay.is-open,
.tb-panel-drawer-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.tb-mobile-drawer,
.tb-panel-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--tb-mobile-drawer-width);
    max-width: 100%;
    height: 100dvh;
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.22);
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    z-index: 1060;
    display: grid;
    grid-template-rows: auto 1fr;
}

.tb-panel-drawer {
    width: var(--tb-panel-drawer-width);
}

.tb-mobile-drawer.is-open,
.tb-panel-drawer.is-open {
    transform: translateX(0);
}

.tb-mobile-drawer-head,
.tb-panel-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.85rem 0.95rem;
    background: #f8fafc;
}

.tb-mobile-drawer-title,
.tb-panel-drawer-title {
    font-weight: 700;
    color: #0f172a;
    font-size: 0.95rem;
}

.tb-mobile-drawer-close,
.tb-panel-drawer-close {
    border: 1px solid #d1d5db;
    width: 2rem;
    height: 2rem;
    border-radius: 0.45rem;
    background: #ffffff;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.tb-mobile-drawer-body,
.tb-panel-drawer-body {
    overflow-y: auto;
    padding: 0.8rem 0.9rem 1.15rem;
    display: grid;
    gap: 0.65rem;
}

.tb-panel-drawer aside {
    border: 0 !important;
    min-height: 100%;
    background: transparent !important;
    box-shadow: none !important;
}

.tb-panel-drawer .nav-link {
    font-size: 0.92rem;
}

.tb-mobile-block-title {
    margin: 0;
    font-size: 0.77rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 700;
}

.tb-mobile-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.68rem 0.72rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.62rem;
    background: #ffffff;
    color: #111827;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    gap: 0.55rem;
}

.tb-mobile-link:hover {
    color: #1d4ed8;
    border-color: #cbd5e1;
}

.tb-mobile-acc {
    border: 1px solid #e5e7eb;
    border-radius: 0.62rem;
    background: #ffffff;
    overflow: hidden;
}

.tb-mobile-acc > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.7rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
}

.tb-mobile-acc > summary::-webkit-details-marker {
    display: none;
}

.tb-mobile-acc > summary::after {
    content: "+";
    float: right;
    color: #64748b;
}

.tb-mobile-acc[open] > summary::after {
    content: "-";
}

.tb-mobile-acc-body {
    border-top: 1px solid #eef2f7;
    padding: 0.45rem;
    display: grid;
    gap: 0.35rem;
}

.tb-mobile-lang-grid {
    display: grid;
    gap: 0.45rem;
    grid-template-columns: 1fr 1fr;
}

.tb-mobile-lang-grid .btn {
    width: 100%;
}

.tb-mobile-drawer-open,
.tb-panel-drawer-open {
    overflow: hidden;
}

.tb-panel-menu-btn {
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #0f172a;
    border-radius: 0.52rem;
    width: 2.2rem;
    height: 2.2rem;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.05rem;
}

.market-product-title-link,
.b2b-product-title,
.tb-product-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.market-product-image,
.b2b-product-image,
.tb-deal-img {
    object-fit: cover;
}

.market-product-meta-row {
    flex-wrap: wrap;
}

.tb-product-mobile-cta {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1038;
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -10px 24px rgba(15, 23, 42, 0.09);
    padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
}

.tb-product-mobile-cta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

body.has-mobile-product-cta {
    padding-bottom: 86px;
}

@media (max-width: 1200px) {
    .tb-main-header .container-xxl,
    .tb-nav-bar .container-xxl,
    .container,
    .container-xxl {
        padding-left: 0.9rem;
        padding-right: 0.9rem;
    }
}

@media (max-width: 991.98px) {
    .tb-main-header {
        position: sticky;
        top: 0;
        z-index: 1030;
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }

    .tb-main-header .tb-header-row {
        min-height: var(--tb-mobile-header-height);
        gap: 0.55rem;
        position: relative;
        justify-content: center;
    }

    .tb-main-header .tb-logo {
        margin: 0 auto;
    }

    .tb-main-header .tb-header-actions {
        margin-left: auto;
        gap: 0.45rem;
    }

    .tb-main-header .tb-header-actions .tb-rfq-btn,
    .tb-main-header .tb-header-actions .tb-signin-btn,
    .tb-main-header .tb-header-actions .tb-register-btn {
        padding: 0.45rem 0.62rem;
        font-size: 0.82rem;
    }

    .tb-main-header .tb-header-actions .tb-rfq-btn span,
    .tb-main-header .tb-header-actions .tb-signin-btn span,
    .tb-main-header .tb-header-actions .tb-register-btn span {
        display: none;
    }

    .tb-main-header .tb-user-trigger {
        padding: 0.42rem 0.58rem;
    }

    .tb-main-header .tb-user-trigger span {
        display: none;
    }

    .tb-mobile-menu-btn {
        display: inline-flex;
    }

    .tb-nav-bar {
        display: none;
    }

    .tb-hero-cta-row a,
    .tb-btn-primary-hero,
    .tb-btn-outline-hero,
    .b2b-product-cta,
    .tb-quick-quote-btn,
    .market-product-cta {
        width: 100%;
        justify-content: center;
    }

    .tb-sponsor-product-grid {
        grid-template-columns: 1fr !important;
    }

    .tb-seller-grid {
        grid-template-columns: 1fr !important;
    }

    .b2b-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .tb-category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .market-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: min(92vw, 360px) !important;
        height: 100dvh !important;
        z-index: 1060 !important;
        transform: translateX(-100%);
        transition: transform 0.24s ease;
        background: #ffffff;
        overflow-y: auto !important;
        padding: 0 !important;
    }

    .market-sidebar.is-open {
        transform: translateX(0);
    }

    .market-sidebar .market-sidebar-panel {
        border-radius: 0;
        border: 0;
        min-height: 100%;
        padding: 0.95rem;
    }

    .market-sidebar-close {
        display: inline-flex !important;
    }

    .market-sidebar-mobile-toggle {
        display: none !important;
    }

    .market-sidebar-overlay {
        z-index: 1050;
    }

    .market-toolbar {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.85rem;
    }

    .market-toolbar-right {
        justify-content: space-between;
        width: 100%;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #marketGrid .market-grid-col {
        padding-left: 0.35rem;
        padding-right: 0.35rem;
    }

    #productGalleryThumbs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 0.45rem;
        margin-left: 0;
        margin-right: 0;
    }

    #productGalleryThumbs > [class*="col-"] {
        flex: 0 0 86px;
        max-width: 86px;
        padding-left: 0;
        padding-right: 0;
    }

    .tb-product-mobile-cta {
        display: block;
    }
}

@media (max-width: 767.98px) {
    .tb-main-header .tb-logo-text {
        display: none;
    }

    .admin-layout-row,
    .row.min-vh-100 {
        min-height: auto !important;
    }

    .tb-panel-menu-btn {
        display: inline-flex;
    }

    main.p-3,
    main.p-lg-4 {
        padding: 0.9rem !important;
    }

    .card-body {
        padding: 0.9rem;
    }

    .b2b-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.65rem !important;
    }

    #dropZone {
        padding: 1.15rem !important;
    }

    #dropZone .bi-file-earmark-spreadsheet {
        display: none;
    }

    .tb-counter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .tb-counter-item {
        min-height: 96px;
    }

    .b2b-home-hero .col-lg-6 {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    .modal-dialog {
        max-width: 95vw;
        margin: 0.75rem auto;
    }

    .b2b-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .market-product-card .card-body {
        padding: 0.7rem;
    }

    .tb-mobile-drawer {
        width: 92vw;
    }

    .tb-panel-drawer {
        width: 90vw;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .tb-sponsor-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .tb-seller-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .b2b-product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    .tb-category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}
