/**
 * Zivora Jewels — Global Responsive Overrides
 * Public store + Member portal + Office admin
 */
html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}
body {
    overflow-x: hidden;
}
img, video, iframe, svg {
    max-width: 100%;
    height: auto;
}
.table-responsive,
.ms-scroll-x {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-responsive > .table {
    margin-bottom: 0;
    min-width: 640px;
}

/* ---------- Public store ---------- */
/* Desktop: never clip navbar dropdowns (overflow:auto hid Company / Collections menus) */
.ms-navbar,
.ms-navbar .container,
.ms-navbar .navbar-collapse,
.ms-navbar .navbar-nav,
.ms-navbar .nav-item.dropdown {
    overflow: visible !important;
}
.ms-navbar .navbar-collapse {
    max-height: none;
}
.ms-navbar .dropdown-menu {
    z-index: 1050;
}
@media (max-width: 991.98px) {
    .ms-navbar .navbar-collapse {
        max-height: calc(100vh - 70px);
        overflow-x: hidden !important;
        overflow-y: auto !important;
        background: #fff;
        border: 1px solid rgba(212, 175, 55, 0.25);
        border-radius: 12px;
        margin-top: 0.75rem;
        padding: 0.75rem 1rem 1rem;
        box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
    }
    .ms-navbar .navbar-nav {
        width: 100%;
    }
    .ms-navbar .nav-link {
        padding: 0.65rem 0.25rem !important;
    }
    .ms-navbar .dropdown-menu {
        border: 0;
        box-shadow: none;
        padding-left: 0.5rem;
        position: static !important;
        float: none;
        width: 100%;
        transform: none !important;
        animation: none !important;
    }
    .ms-navbar .d-flex.gap-2 {
        width: 100%;
        margin-top: 0.75rem;
        flex-wrap: wrap;
    }
    .ms-navbar .d-flex.gap-2 .btn {
        flex: 1 1 calc(50% - 0.35rem);
    }
    .top-utility-bar .container {
        justify-content: center !important;
    }
    .display-4 {
        font-size: clamp(1.75rem, 7vw, 2.4rem) !important;
    }
    .display-6 {
        font-size: clamp(1.35rem, 5vw, 1.85rem) !important;
    }
    .lead {
        font-size: 1rem !important;
    }
    .jb-story-item {
        flex: 0 0 72px !important;
        width: 72px !important;
    }
    .jb-story-ring {
        width: 64px !important;
        height: 64px !important;
        min-width: 64px !important;
        min-height: 64px !important;
    }
    .jb-cat-card {
        height: 260px !important;
    }
    .jb-cat-title {
        font-size: 1.35rem !important;
    }
    .auth-card,
    .plan-card,
    .stat-card {
        padding: 1.25rem !important;
    }
    footer .row > [class*="col-"] {
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 575.98px) {
    .container,
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }
    .btn-lg {
        padding: 0.55rem 1rem;
        font-size: 0.95rem;
    }
    .product-card .thumb {
        height: 170px !important;
    }
    .product-card h5,
    .product-card .fw-semibold {
        font-size: 0.85rem !important;
        min-height: 2.4em !important;
    }
    .carousel-item .badge {
        font-size: 0.68rem;
    }
    .min-vh-50 {
        min-height: auto !important;
    }
}

/* ---------- Member + Office shells ---------- */
.member-wrapper {
    width: 100%;
    max-width: 100vw;
}
.member-sidebar {
    flex-shrink: 0;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}
.member-sidebar .flex-grow-1.overflow-y-auto,
.member-sidebar > .flex-grow-1 {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.member-content {
    flex: 1;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    min-width: 0;
}
.member-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: nowrap;
    min-height: 56px;
}
.member-topbar > div {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: nowrap;
    min-width: 0;
}
.stat-box,
.stat-card {
    margin-bottom: 0;
}
.stat-box .fs-4,
.stat-box .fs-5,
.stat-card .fs-4,
.stat-card .fs-5,
.stat-card .display-6 {
    word-break: break-word;
}

/* ============================================================
   MOBILE OFF-CANVAS SIDEBAR (< 992px)
   ============================================================ */
@media (max-width: 991.98px) {
    /* Layout: block stacking, sidebar fixed off-screen */
    .member-wrapper {
        display: block;
        position: relative;
    }
    .member-sidebar {
        width: min(300px, 86vw);
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-105%);
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.32s ease;
        z-index: 1055;
        box-shadow: none;
    }
    .member-sidebar.show {
        transform: translateX(0);
        box-shadow: 16px 0 40px rgba(15, 23, 42, 0.28);
    }
    .member-content {
        width: 100%;
        min-height: 100vh;
        min-width: 0;
    }
    /* Topbar: no-wrap, menu button always on left, actions on right */
    .member-topbar {
        padding: 8px 14px;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }
    .member-topbar > div:first-child {
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
    }
    .member-topbar > div:last-child {
        flex-shrink: 0;
    }
    .member-content > .container-fluid {
        padding: 12px !important;
    }
    /* Backdrop overlay — never intercept clicks while hidden */
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        z-index: 1050;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.25s ease, visibility 0.25s ease;
    }
    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    /* Hamburger must stay above content and receive taps */
    #sidebarToggleBtn {
        position: relative;
        z-index: 1060;
        pointer-events: auto !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    .member-topbar > div:first-child {
        overflow: visible;
    }
    /* Cards */
    .card,
    .plan-card,
    .auth-card {
        border-radius: 12px;
    }
    .row.g-4,
    .row.g-3 {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }
    /* Binary tree nodes */
    .tree-node,
    .tree-node-card {
        min-width: 110px;
        max-width: 100%;
    }
    /* Dashboard metric card amounts */
    .ms-card h4,
    .ms-card h4.fw-bold,
    .ms-card h4.font-monospace {
        font-size: 1.05rem;
        word-break: break-all;
    }
}

/* ============================================================
   SMALL PHONES (< 576px)
   ============================================================ */
@media (max-width: 575.98px) {
    /* Topbar tighter */
    .member-topbar {
        padding: 6px 10px;
        gap: 0.3rem;
    }
    .member-topbar .btn,
    .member-topbar .topbar-btn {
        height: 34px;
        min-height: 34px;
        padding: 0 8px;
        font-size: 0.8rem;
    }
    /* Stat boxes */
    .stat-box,
    .stat-card {
        padding: 14px !important;
    }
    /* Dashboard metric card amounts */
    .ms-card h4,
    .ms-card h4.fw-bold,
    .ms-card h4.font-monospace {
        font-size: 0.9rem;
        word-break: break-all;
        line-height: 1.25;
    }
    /* Referral link inputs: smaller monospace */
    #leftRefLink,
    #rightRefLink {
        font-size: 0.7rem;
    }
    /* Welcome banner on mobile: stack vertically */
    .ms-card .d-flex.flex-wrap.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }
    .ms-card .d-flex.flex-wrap.justify-content-between > div.d-flex.flex-wrap.gap-2 {
        width: 100%;
    }
    .ms-card .d-flex.flex-wrap.justify-content-between .btn {
        flex: 1 1 auto;
        text-align: center;
    }
    .display-6 {
        font-size: 1.6rem !important;
    }
    h1.section-title,
    h1.h3,
    .section-title.h3 {
        font-size: 1.25rem !important;
    }
    .dropdown-menu {
        max-width: calc(100vw - 24px);
    }
}

/* ============================================================
   VERY SMALL PHONES (< 400px)
   ============================================================ */
@media (max-width: 400px) {
    .member-topbar {
        padding: 5px 8px;
        gap: 0.25rem;
    }
    .member-topbar img[alt="Logo"] {
        height: 26px !important;
    }
    .ms-card h4,
    .ms-card h4.fw-bold {
        font-size: 0.82rem;
    }
    .ms-card .small.fw-bold.text-dark {
        font-size: 0.72rem;
    }
}

/* DataTables mobile */
@media (max-width: 767.98px) {
    div.dataTables_wrapper div.dataTables_length,
    div.dataTables_wrapper div.dataTables_filter,
    div.dataTables_wrapper div.dataTables_info,
    div.dataTables_wrapper div.dataTables_paginate {
        float: none !important;
        text-align: left !important;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    div.dataTables_wrapper .dt-buttons {
        float: none !important;
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
        margin-bottom: 0.75rem;
    }
}

/* Prevent horizontal page jump from 100vw scrollbars */
.member-wrapper,
.ms-navbar,
footer {
    max-width: 100%;
}

/* ---------- Total Team Left / Right cards ---------- */
.team-total-banner {
    background: linear-gradient(135deg, #FFFDF5 0%, #FFF8E7 100%);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-left: 4px solid #D4AF37;
    border-radius: 14px;
    padding: 1rem 1.25rem;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}
.team-leg-card {
    background: #FFFDF8;
    border: 1px solid rgba(212, 175, 55, 0.22);
    border-top: 3px solid #D4AF37;
    border-radius: 14px;
    padding: 1.15rem 1.25rem;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}
.team-leg-card--left {
    border-top-color: #0D6EFD;
}
.team-leg-card--right {
    border-top-color: #0DCAF0;
}
.team-leg-label {
    color: #64748B;
    font-size: 0.85rem;
    font-weight: 500;
}
@media (max-width: 575.98px) {
    .team-leg-card h4 {
        font-size: 1.15rem;
    }
}

