/* ============================================
   Header Section - Bogura Bazar Theme
   Version: 2.1.0 (Mobile Sidebar Fixed)
============================================ */

/* ========== বডি প্যাডিং ========== */
body {
    padding-top: 0;
}

/* ========== হেডার সেকশন ========== */
.main-header {
    background: var(--white);
    position: relative;
    z-index: 1020;
}

/* ========== টপবার ========== */
.topbar {
    background: var(--primary);
    color: var(--white);
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    width: 100%;
    z-index: 1001;
}

.topbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 30px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

.topbar-left {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.topbar-left span {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.topbar-left i {
    font-size: 12px;
}

.topbar-right {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.topbar-right a {
    color: var(--white);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    transition: all 0.2s ease;
}

.topbar-right a i {
    font-size: 12px;
    opacity: 0.9;
}

.topbar-right a:hover {
    color: #f18484;
}

/* ========== হেডার মিডেল (স্টিকি) ========== */
.header-middle {
    background: var(--white);
    position: relative;
    width: 100%;
    z-index: 1021;
    box-shadow: var(--shadow);
}

body.scrolled .header-middle {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    box-shadow: var(--shadow-md);
    animation: headerSlideDown 0.3s ease-out forwards;
}

@keyframes headerSlideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

body.scrolled .topbar {
    visibility: hidden;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.header-middle .container-custom {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
    height: 65px;
    display: grid;
    grid-template-columns: 200px 1fr 200px;
    gap: 20px;
    align-items: center;
}

/* ========== লোগো ========== */
.logo {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-light);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-self: start;
}

.logo i {
    font-size: 28px;
}

.logo span {
    font-size: 22px;
    font-weight: 700;
}

.header-logo-img {
    max-height: 65px;
    max-width: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
    display: block;
    transition: all 0.3s ease;
}

.mobile-logo-img {
    max-height: 45px;
    max-width: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
    display: block;
    transition: all 0.3s ease;
}

@media (max-width: 991px) {
    .header-logo-img {
        max-height: 45px;
    }
    .mobile-logo-img {
        max-height: 30px;
    }
}

@media (max-width: 767px) {
    .header-logo-img {
        max-height: 45px;
    }
}

@media (max-width: 480px) {
    .header-logo-img {
        max-height: 45px;
    }
    .mobile-logo-img {
        max-height: 28px;
    }
}

/* ========== সার্চ বক্স ========== */
.search-wrapper {
    display: flex;
    height: 42px;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    border: 2px solid var(--primary-light);
    border-radius: 8px;
    overflow: visible; /* ফিক্স: সাজেশন ড্রপডাউন দেখানোর জন্য */
    background: var(--white);
    position: relative;
}

.search-wrapper .input-group {
    height: 100%;
    width: 100%;
    flex-wrap: nowrap;
    border-radius: 6px;
    overflow: hidden; /* ইনার কনটেন্ট কোণ ক্লিপ করার জন্য */
}

.search-wrapper input {
    flex: 1;
    border: none !important;
    outline: none !important;
    padding: 0 16px;
    font-size: 14px;
    box-shadow: none !important;
}

.search-wrapper input::placeholder {
    color: #999;
}

.search-wrapper button {
    width: 80px;
    border: none !important;
    background: var(--primary-light);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
    transition: background 0.2s ease;
    flex-shrink: 0;
    box-shadow: none !important;
}

.search-wrapper button:hover {
    background: var(--primary-dark);
}

/* ডেস্কটপ সার্চ সাজেশন */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: none;
    overflow: hidden;
    margin-top: 4px;
}

.suggestions-list {
    max-height: 400px;
    overflow-y: auto;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.suggestion-item:hover {
    background: var(--bg-light);
}

.suggestion-item img {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.suggestion-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestion-info strong {
    font-size: 14px;
}

.suggestion-info .price {
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
}

.view-all {
    padding: 12px;
    text-align: center;
    background: var(--bg-light);
}

.view-all a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.no-suggestions {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

/* ========== হেডার অ্যাকশন ========== */
.header-actions {
    display        : flex;
    justify-content: flex-end;
    gap            : 20px;
    justify-self   : end;
}

.header-actions a {
    text-decoration: none;
    color          : var(--text-dark);
    display        : flex;
    flex-direction : column;
    align-items    : center;
    position       : relative;
    transition     : color 0.2s ease;
}

.header-actions a i {
    font-size: 22px;
}

.header-actions a span {
    font-size: 11px;
    margin-top: 4px;
}

.header-actions a:hover {
    color: var(--primary-light);
}

.cart-btn b,
.wishlist-btn b {
    position       : absolute;
    top            : -8px;
    right          : -12px;
    background     : var(--danger);
    color          : var(--white);
    width          : 18px;
    height         : 18px;
    border-radius  : 50%;
    font-size      : 10px;
    font-weight    : 600;
    display        : flex;
    align-items    : center;
    justify-content: center;
}

/* ========== ডেস্কটপ নেভিগেশন ========== */
.desktop-nav {
    background: var(--white);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 65px;
    z-index: 998;
    height: 50px;
}

.desktop-nav .container-custom {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
}

.desktop-nav ul {
    display: flex;
    list-style: none;
    gap: 28px;
    height: 100%;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.desktop-nav a {
    text-decoration: none;
    color: var(--primary-light);
    font-weight: 600;
    font-size: 14px;
    transition: color 0.2s ease;
    padding: 12px 0;
    display: inline-block;
    position: relative;
}

.desktop-nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-light);
    transition: width 0.3s ease;
}

.desktop-nav a:hover::after,
.desktop-nav a.active::after {
    width: 100%;
}

.desktop-nav a:hover,
.desktop-nav a.active {
    color: var(--primary-dark);
}

/* ========== মোবাইল মেনু বাটন ========== */
.mobile-menu-btn {
    display: none;
    border: none;
    background: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    transition: background 0.2s ease;
    color: var(--primary-light);
}

.mobile-menu-btn:hover {
    background: rgba(0, 166, 90, 0.1);
}

/* ============================================
   মোবাইল সাইডবার - ফিক্সড
============================================ */
.mobile-sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: 320px;
    max-width: 85%;
    height: 100%;
    background: var(--white);
    z-index: 2000;
    transition: left 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden; /* ✅ অনুভূমিক স্ক্রল বন্ধ */
    box-shadow: var(--shadow-md);
    -webkit-overflow-scrolling: touch;
}

/* ✅ সব কন্টেন্ট র‍্যাপ করুন */
.mobile-sidebar * {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

.mobile-sidebar.active {
    left: 0;
}

.mobile-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--white);
    position: sticky;
    top: 0;
    z-index: 10;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-light);
}

.mobile-logo i {
    font-size: 22px;
}

.mobile-logo span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    display: inline-block;
}

.close-menu {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.close-menu:hover {
    background: #f0f0f0;
}

.mobile-sidebar-body {
    padding: 0 0 20px 0;
}

/* ✅ মোবাইল সার্চ - প্রস্থ ঠিক */
.mobile-search-wrapper {
    position: relative;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.mobile-search {
    display: grid;
    grid-template-columns: 1fr auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
    background: var(--white);
}

.mobile-search input {
    padding: 10px 14px;
    border: none;
    outline: none;
    font-size: 14px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    background: transparent;
}

.mobile-search input::placeholder {
    color: #999;
}

.mobile-search input:focus {
    border-color: var(--primary-light);
}

.mobile-search button {
    background: var(--primary-light);
    border: none;
    padding: 0 16px;
    color: var(--white);
    cursor: pointer;
    min-width: 44px;
    flex-shrink: 0;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-search button:hover {
    background: var(--primary-dark);
}

.mobile-search button i {
    font-size: 16px;
}

.mobile-search-suggestions {
    position: absolute;
    top: 100%;
    left: 16px;
    right: 16px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 1002;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

/* ✅ লং টেক্সট র‍্যাপ */
.mobile-nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-nav-links li {
    border-bottom: 1px solid var(--border);
}

.mobile-nav-links li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: normal;
    word-break: break-word;
}

.mobile-nav-links li a:hover {
    background: rgba(0, 166, 90, 0.05);
    color: var(--primary-light);
    padding-left: 24px;
}

.mobile-nav-links li a i {
    width: 22px;
    color: var(--primary-light);
    font-size: 16px;
    flex-shrink: 0;
}

.mobile-actions {
    padding: 20px;
    border-top: 1px solid var(--border);
    margin-top: 10px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.mobile-actions a {
    flex: 1;
    min-width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 8px;
    background: #f8f9fa;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.mobile-actions a:hover {
    background: rgba(0, 166, 90, 0.08);
    color: var(--primary-light);
}

.mobile-actions a i {
    font-size: 20px;
}

.mobile-actions a b {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(6px); /* ফিক্স: আইকনের সাপেক্ষে ব্যাজের পজিশন সঠিক করার জন্য */
    background: var(--danger);
    color: var(--white);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* ✅ ইমেজ সঙ্কুচিত করুন */
.mobile-sidebar img {
    max-width: 100%;
    height: auto;
    max-height: 70px;
}

.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 1999;
    backdrop-filter: blur(2px);
}

.mobile-overlay.active {
    display: block;
}

/* ========== স্ক্রল টু টপ বাটন ========== */
.scroll-to-top {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 45px;
    height: 45px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.scroll-to-top:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
}

.scroll-to-top.show {
    display: flex;
}

/* ============================================
   ফুল রেসপন্সিভ - সব ব্রেকপয়েন্ট
============================================ */

/* ========== লার্জ ডেস্কটপ (1200px+) ========== */
@media (min-width: 1200px) {
    .header-middle .container-custom {
        grid-template-columns: 200px 1fr 200px;
    }
}

/* ========== ডেস্কটপ (992px - 1199px) ========== */
@media (min-width: 992px) and (max-width: 1199px) {
    .header-middle .container-custom {
        grid-template-columns: 170px 1fr 170px;
        gap: 15px;
    }

    .search-wrapper {
        max-width: 380px;
    }

    .search-wrapper button {
        width: 60px;
        font-size: 13px;
    }

    .logo {
        font-size: 24px;
    }

    .logo span {
        font-size: 18px;
    }

    .header-actions {
        margin-right: 14px;
    }

    .desktop-nav ul {
        gap: 20px;
    }
}

/* ========== ট্যাবলেট (768px - 991px) ========== */
@media (max-width: 991px) {
    .topbar {
        display: none;
    }

    .header-middle {
        position: relative;
        top: 0;
        border-bottom: 1px solid var(--primary-light);
    }

    .header-middle .container-custom {
        grid-template-columns: 44px 1fr 44px;
        height: 60px;
        gap: 10px;
        padding: 0 12px;
    }

    .desktop-nav {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        font-size: 22px;
    }

    .search-wrapper {
        display: none;
    }

    .header-actions {
        gap: 8px;
        justify-self: end;
        margin-right: 14px;
    }

    .header-actions a:not(.cart-btn):not(.wishlist-btn) {
        display: none;
    }

    .header-actions a i {
        font-size: 20px;
    }

    .header-actions a span {
        display: none;
    }

    .cart-btn b,
    .wishlist-btn b {
        top: -6px;
        right: -10px;
        width: 16px;
        height: 16px;
        font-size: 9px;
    }

    .logo {
        font-size: 20px;
        justify-self: center;
    }

    .logo i {
        font-size: 20px;
    }

    .logo span {
        font-size: 16px;
    }

    body.scrolled .header-middle {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
    }
}

/* ========== ছোট ট্যাবলেট ও বড় মোবাইল (576px - 767px) ========== */
@media (max-width: 767px) {
    .header-middle .container-custom {
        height: 55px;
        grid-template-columns: 40px 1fr 40px;
        gap: 8px;
        padding: 0 10px;
    }

    .mobile-menu-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .logo {
        font-size: 18px;
    }

    .logo i {
        font-size: 18px;
    }

    .logo span {
        font-size: 20px;
    }

    .header-actions a i {
        font-size: 20px;
    }

    .cart-btn b,
    .wishlist-btn b {
        width: 14px;
        height: 14px;
        font-size: 8px;
        top: -5px;
        right: -8px;
    }

    .mobile-sidebar {
        width: 300px;
        max-width: 85%;
    }
}

/* ========== মোবাইল (480px পর্যন্ত) - সাইডবার ফিক্স ========== */
@media (max-width: 480px) {
    .header-middle .container-custom {
        height               : 50px;
        grid-template-columns: 36px 1fr 36px;
        gap                  : 6px;
        padding              : 0 8px;
    }

    .mobile-menu-btn {
        width    : 40px;
        height   : 40px;
        font-size: 18px;
    }

    .logo {
        font-size: 16px;
    }

    .logo i {
        font-size: 16px;
    }

    .logo span {
        font-size: 20px;
    }

    .header-actions {

        margin-right: 14px;
    }

    .header-actions a i {
        font-size: 20px;
    }

    .cart-btn b,
    .wishlist-btn b {
        width: 12px;
        height: 12px;
        font-size: 7px;
        top: -4px;
        right: -6px;
    }

    /* ✅ মোবাইল সাইডবার - প্রস্থ ঠিক */
    .mobile-sidebar {
        width     : 280px;
        max-width : 90%;
        overflow-x: hidden;
    }

    .mobile-sidebar * {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }

    .mobile-search-wrapper {
        padding: 10px 12px;
    }

    .mobile-search {
        border-radius: 6px;
    }

    .mobile-search input {
        padding: 8px 12px;
        font-size: 13px;
        min-width: 0;
        width: 100%;
    }

    .mobile-search button {
        padding: 0 12px;
        min-width: 38px;
    }

    .mobile-search button i {
        font-size: 14px;
    }

    .mobile-nav-links li a {
        padding: 12px 16px;
        font-size: 13px;
        white-space: normal;
        word-break: break-word;
    }

    .mobile-actions {
        padding: 12px 16px;
        gap: 8px;
    }

    .mobile-actions a {
        padding: 8px 6px;
        font-size: 11px;
        min-width: 60px;
    }

    .mobile-actions a i {
        font-size: 18px;
    }

    .mobile-actions a b {
        top: 3px;
        left: 50%;
        right: auto;
        transform: translateX(5px); /* ছোট স্ক্রিনের আইকন অনুযায়ী শিফট */
        width: 15px;
        height: 15px;
        font-size: 8px;
    }

    .scroll-to-top {
        bottom: 70px;
        right: 12px;
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

/* ========== অতি ছোট মোবাইল (380px পর্যন্ত) ========== */
@media (max-width: 380px) {
    .header-middle .container-custom {
        height               : 48px;
        grid-template-columns: 32px 1fr 32px;
        gap                  : 4px;
        padding              : 0 6px;
    }

    .mobile-menu-btn {
        width    : 40px;
        height   : 40px;
        font-size: 16px;
    }

    .logo {
        font-size: 14px;
    }

    .logo i {
        font-size: 14px;
    }

    .logo span {
        font-size: 20px;
    }

    .header-actions a i {
        font-size: 20px;
    }

    .cart-btn b,
    .wishlist-btn b {
        width: 11px;
        height: 11px;
        font-size: 6px;
        top: -3px;
        right: -5px;
    }

    .mobile-sidebar {
        width: 260px;
        max-width: 92%;
        overflow-x: hidden;
    }

    .mobile-sidebar * {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }

    .mobile-search-wrapper {
        padding: 8px 10px;
    }

    .mobile-search input {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 0;
        width: 100%;
    }

    .mobile-search button {
        padding: 0 10px;
        min-width: 34px;
    }

    .mobile-search button i {
        font-size: 12px;
    }

    .mobile-nav-links li a {
        padding: 10px 14px;
        font-size: 12px;
        white-space: normal;
        word-break: break-word;
    }

    .mobile-actions {
        padding: 10px 12px;
        gap: 6px;
    }

    .mobile-actions a {
        padding: 6px 4px;
        font-size: 10px;
        min-width: 50px;
    }

    .mobile-actions a i {
        font-size: 16px;
    }

    .mobile-actions a b {
        top: 2px;
        left: 50%;
        right: auto;
        transform: translateX(4px); /* অতি ছোট স্ক্রিনের আইকন অনুযায়ী শিফট */
        width: 13px;
        height: 13px;
        font-size: 7px;
    }
}

/* ============================================
   টাচ ডিভাইস অপটিমাইজেশন
============================================ */
@media (hover: none) and (pointer: coarse) {
    .desktop-nav a::after {
        display: none;
    }

    .desktop-nav a:hover {
        color: var(--primary-light);
    }

    .header-actions a:hover {
        color: var(--text-dark);
    }

    .search-wrapper button:hover {
        background: var(--primary-light);
    }

    .mobile-nav-links li a:hover {
        background: transparent;
        padding-left: 20px;
    }

    .mobile-actions a:hover {
        background: #f8f9fa;
        color: var(--text-dark);
    }
}

/* ============================================
   স্ক্রিন রিডার অ্যাক্সেসিবিলিটি
============================================ */
.mobile-menu-btn:focus-visible,
.close-menu:focus-visible,
.header-actions a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
