/* ================================================================
   ACCOUNTS HUB - PROFESSIONAL MOBILE RESPONSIVE STYLESHEET
   Targets all pages: index, product, checkout, dashboards, forms
   ================================================================ */

/* ----------------------------------------------------------------
   1. RESET OVERLY AGGRESSIVE EXISTING RULES IN style.css
   ---------------------------------------------------------------- */
@media (max-width: 768px) {

    /* style.css set ALL rows to 100% — too broad, reset it */
    .row>* {
        width: auto !important;
        margin-bottom: 0 !important;
    }

    /* style.css stacked ALL d-flex — way too aggressive */
    .d-flex:not(.flex-nowrap) {
        flex-direction: row !important;
    }

    /* style.css made ALL buttons 100% — breaks icon buttons etc */
    .btn {
        width: auto !important;
        min-height: auto !important;
        display: inline-flex !important;
        margin-bottom: 0 !important;
    }
}

/* ----------------------------------------------------------------
   2. GLOBAL MOBILE BASE
   ---------------------------------------------------------------- */
@media (max-width: 768px) {

    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        position: relative;
    }

    body {
        font-size: 15px;
    }

    /* Prevent iOS font size inflation */
    input,
    select,
    textarea,
    button {
        font-size: 16px !important;
    }

    /* Containers — Full width with clean padding */
    .container,
    .container-fluid {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        display: flex;
        flex-wrap: wrap;
    }

    /* Section vertical spacing */
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .py-4 {
        padding-top: 1.25rem !important;
        padding-bottom: 1.25rem !important;
    }

    .mt-5 {
        margin-top: 1.5rem !important;
    }

    .mb-5 {
        margin-bottom: 1.5rem !important;
    }

    /* Typography scale */
    h1 {
        font-size: 1.6rem !important;
    }

    h2 {
        font-size: 1.3rem !important;
    }

    h3 {
        font-size: 1.1rem !important;
    }
}

/* ----------------------------------------------------------------
   26. ANIMATED HAMBURGER → CLOSE BUTTON
   ---------------------------------------------------------------- */
.mob-menu-btn {
    width: 38px;
    height: 38px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0;
    z-index: 1051;
}

.mob-menu-btn .bar {
    display: block;
    width: 24px;
    height: 2.5px;
    background: #fff;
    border-radius: 3px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.mob-menu-btn.is-open .bar:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}

.mob-menu-btn.is-open .bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.mob-menu-btn.is-open .bar:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

/* ----------------------------------------------------------------
   27. OVERFLOW FIX — Stop all horizontal scrolling
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .mega-menu-container {
        display: none !important;
    }

    /* Fix for shifted content */
    #main-viewport,
    .main-content,
    .dashboard-main,
    .container,
    .row {
        transform: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        left: 0 !important;
    }

    [style*="width: 500px"],
    [style*="width: 400px"],
    [style*="min-width: 400px"],
    [style*="min-width: 320px"] {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .cat-block,
    .product-row,
    .card,
    .table-responsive {
        max-width: 100% !important;
        overflow-x: auto !important;
    }

    .dropdown-menu {
        max-width: calc(100vw - 24px) !important;
    }
}

/* ----------------------------------------------------------------
   3. STICKY MOBILE HEADER — Enhance existing mobile nav
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .sticky-top-mobile {
        position: sticky !important;
        top: 0;
        z-index: 1040;
        background: #fff;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    }

    /* Mobile search bar (shown inside mobile collapse menu) */
    #mobileNav .mobile-search-bar {
        margin-bottom: 12px;
    }

    #mobileNav .mobile-search-bar input {
        border-radius: 8px;
        border: 1px solid #ddd;
        padding: 10px 14px;
        width: 100%;
        font-size: 15px;
    }

    /* Mobile nav links */
    #mobileNav .nav-link {
        font-size: 14px;
        font-weight: 600;
        color: #333 !important;
        padding: 11px 4px !important;
    }

    /* Mobile auth buttons in collapse menu */
    .mobile-auth-btns {
        display: flex;
        gap: 8px;
        margin-top: 12px;
    }

    .mobile-auth-btns .btn {
        flex: 1 !important;
        width: 100% !important;
        font-size: 13px !important;
        padding: 10px 8px !important;
        text-align: center !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Hide the heavy desktop top bar */
    .top-bar-classic {
        display: none !important;
    }

    /* Hide desktop navigation row */
    .d-none.d-md-block {
        display: none !important;
    }
}

/* ----------------------------------------------------------------
   4. PRODUCT CARDS GRID — 2 columns on mobile
   ---------------------------------------------------------------- */
@media (max-width: 767px) {

    .row.g-4>.col-lg-3,
    .row.g-4>.col-md-4,
    .row.g-3>.col-lg-3,
    .row.g-3>.col-md-4,
    .row.g-3>.col-lg-4,
    .row.g-4>.col-lg-4 {
        width: 50% !important;
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    /* Product card body compact */
    .product-card .card-body,
    .custom-product-card .card-body {
        padding: 10px !important;
    }

    .product-card .card-title,
    .custom-product-card .card-title {
        font-size: 13px !important;
        line-height: 1.3;
    }

    .product-card .card-text,
    .custom-product-card .card-text {
        font-size: 12px !important;
    }

    /* Product image height */
    .custom-product-card .img-box {
        height: 140px !important;
    }

    .product-img-wrapper {
        padding-top: 70% !important;
    }

    /* Price text */
    .product-card .fw-bold.fs-5,
    .custom-product-card .fw-bold.fs-5 {
        font-size: 15px !important;
    }
}

@media (max-width: 400px) {

    /* Single column on very small screens */
    .row.g-4>.col-lg-3,
    .row.g-4>.col-md-4,
    .row.g-3>.col-lg-3,
    .row.g-3>.col-md-4 {
        width: 100% !important;
    }
}

/* ----------------------------------------------------------------
   5. HERO / HOMEPAGE BANNER
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .hero-section {
        padding: 2.5rem 1rem !important;
        text-align: center;
    }

    .hero-section .row {
        flex-direction: column !important;
    }

    .hero-section .col-lg-6:last-child {
        display: none;
    }

    /* hide decorative illustration */
    .hero-section .btn {
        width: 100% !important;
        margin-bottom: 10px !important;
    }

    .hero-section .d-flex.gap-3 {
        flex-direction: column !important;
    }
}

/* ----------------------------------------------------------------
   6. CATEGORY CARDS — 2 or 3 cols on mobile
   ---------------------------------------------------------------- */
@media (max-width: 767px) {

    .row>.col-lg-2,
    .row>.col-md-3,
    .row>.col-md-4 {
        /* handled by product card rules above; categories stay 3-col */
    }

    .category-box {
        padding: 12px 8px !important;
        text-align: center;
    }

    .category-icon-wrapper {
        width: 52px !important;
        height: 52px !important;
        font-size: 1.4rem !important;
        margin: 0 auto 8px !important;
    }

    .category-box .fw-bold {
        font-size: 12px !important;
    }
}

/* ----------------------------------------------------------------
   7. PRODUCT DETAIL PAGE
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .product-detail-row {
        flex-direction: column !important;
    }

    .product-detail-image {
        width: 100% !important;
        margin-bottom: 1rem;
    }

    .product-detail-info {
        width: 100% !important;
    }

    /* Buy button — full width */
    .btn-buy-now,
    form .btn-primary.btn-lg,
    .add-to-cart.btn-lg {
        width: 100% !important;
        padding: 14px !important;
        font-size: 16px !important;
        margin-bottom: 10px !important;
    }
}

/* ----------------------------------------------------------------
   8. CHECKOUT PAGE
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .checkout-row {
        flex-direction: column !important;
    }

    .checkout-col-main,
    .checkout-col-summary {
        width: 100% !important;
    }

    .checkout-col-summary {
        margin-top: 1.5rem;
    }

    .payment-method-btn {
        width: 100% !important;
        margin-bottom: 8px !important;
    }
}

/* ----------------------------------------------------------------
   9. SEARCH BAR
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .search-form {
        max-width: 100% !important;
    }

    .search-wrapper {
        border-radius: 10px !important;
    }

    .search-btn {
        padding: 0.5rem 1rem !important;
        font-size: 13px !important;
        width: auto !important;
    }
}

/* ----------------------------------------------------------------
   10. FORMS (all pages)
   ---------------------------------------------------------------- */
@media (max-width: 767px) {

    .form-control,
    .form-select,
    textarea {
        font-size: 16px !important;
        padding: 11px 14px !important;
        border-radius: 10px !important;
    }

    /* Full-width form submit buttons */
    form .btn[type="submit"],
    form button[type="submit"] {
        width: 100% !important;
        padding: 13px !important;
        font-size: 15px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Label alignment */
    .d-flex.align-items-center label {
        min-width: 110px;
        font-size: 13px !important;
    }
}

/* ----------------------------------------------------------------
   11. MODALS (login, register, forgot password)
   ---------------------------------------------------------------- */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100vw - 20px) !important;
    }

    .modal-body {
        padding: 1.25rem !important;
    }

    .modal-content {
        border-radius: 16px !important;
    }

    /* Auth modal button */
    #loginForm .btn,
    #registerForm .btn,
    #forgotForm .btn {
        width: 100% !important;
        padding: 12px !important;
        margin-bottom: 8px !important;
    }
}

/* ----------------------------------------------------------------
   12. FORGOT PASSWORD PAGE
   ---------------------------------------------------------------- */
@media (max-width: 576px) {
    .auth-wrapper {
        padding: 2rem 1rem !important;
    }

    .auth-card {
        padding: 2rem 1.25rem !important;
        border-radius: 20px !important;
    }

    .auth-card .btn {
        width: 100% !important;
        padding: 13px !important;
    }
}

/* ----------------------------------------------------------------
   13. ADMIN / SELLER / BUYER DASHBOARDS — Sidebar
   ---------------------------------------------------------------- */
@media (max-width: 991px) {

    /* Sidebar slides in from the left */
    #sidebar {
        position: fixed !important;
        left: -270px;
        top: 0;
        height: 100vh !important;
        z-index: 1050;
        transition: left 0.3s ease !important;
        overflow-y: auto;
    }

    #sidebar.open {
        left: 0 !important;
    }

    /* Overlay when sidebar open */
    #sidebarOverlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1049;
    }

    #sidebarOverlay.show {
        display: block;
    }

    /* Main content takes full width */
    #main-viewport,
    .main-content,
    .dashboard-main {
        margin-left: 0 !important;
        padding: 1rem !important;
        width: 100% !important;
    }

    /* Dashboard stats cards — 2 col grid */
    .stats-row>.col-md-3,
    .stats-row>.col-lg-3 {
        width: 50% !important;
    }

    /* Tables card-mode */
    .admin-table thead {
        display: none;
    }

    .admin-table tr {
        display: block;
        border: 1px solid #eee;
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 12px;
        background: #fff;
    }

    .admin-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border: none;
        font-size: 13px;
    }

    .admin-table td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 11px;
        color: #888;
        text-transform: uppercase;
        flex: 0 0 45%;
    }
}

@media (max-width: 767px) {

    /* Dashboard stats — single col on very small */
    .stats-row>.col-md-3,
    .stats-row>.col-lg-3 {
        width: 100% !important;
    }

    /* Dashboard header row — stack */
    .dashboard-header-row {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: flex-start !important;
    }

    /* Tab navigation — horizontal scroll */
    .nav-tabs,
    .nav-pills {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tabs .nav-link,
    .nav-pills .nav-link {
        white-space: nowrap !important;
        font-size: 13px !important;
        padding: 8px 14px !important;
    }
}

/* ----------------------------------------------------------------
   14. FOOTER — Stack on mobile
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .classic-footer .footer-top-classic .d-flex {
        flex-direction: column !important;
        gap: 16px !important;
        align-items: center !important;
        text-align: center !important;
    }

    .classic-footer .footer-bottom-classic .d-flex {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: center !important;
        text-align: center !important;
    }

    .footer-nav-classic {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .footer-nav-classic a {
        margin: 0 !important;
    }

    .footer-legal-classic a {
        margin: 4px !important;
    }
}

/* ----------------------------------------------------------------
   15. SELLER ONBOARDING / REGISTRATION
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .seller-steps-row {
        flex-direction: column !important;
    }

    .seller-steps-row>div {
        width: 100% !important;
        margin-bottom: 1rem;
    }

    .seller-onboarding-form .row {
        flex-direction: column !important;
    }

    .seller-onboarding-form .col-md-6 {
        width: 100% !important;
    }
}

/* ----------------------------------------------------------------
   16. CHAT WIDGET — Smaller on mobile
   ---------------------------------------------------------------- */
@media (max-width: 576px) {
    .chat-widget-wrapper {
        bottom: 16px !important;
        right: 16px !important;
    }

    .chat-box-container {
        width: calc(100vw - 32px) !important;
        right: -16px !important;
        border-radius: 16px !important;
    }

    .chat-pill-btn {
        padding: 10px 18px !important;
        font-size: 14px !important;
    }
}

/* ----------------------------------------------------------------
   17. PAGINATION
   ---------------------------------------------------------------- */
@media (max-width: 576px) {
    .pagination {
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
    }

    .page-link {
        padding: 6px 10px !important;
        font-size: 13px !important;
    }
}

/* ----------------------------------------------------------------
   18. ALERTS & TOASTS
   ---------------------------------------------------------------- */
@media (max-width: 576px) {
    .alert {
        font-size: 14px !important;
        padding: 12px !important;
    }

    .swal2-popup {
        font-size: 14px !important;
        width: 90vw !important;
    }
}

/* ----------------------------------------------------------------
   19. BADGES & ICON BUTTONS
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .icon-btn {
        width: 36px !important;
        height: 36px !important;
    }

    .badge-count {
        width: 17px !important;
        height: 17px !important;
        font-size: 0.6rem !important;
    }
}

/* ----------------------------------------------------------------
   20. CONTACT & INFO PAGES
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .contact-row {
        flex-direction: column !important;
    }

    .contact-col {
        width: 100% !important;
        margin-bottom: 1.5rem;
    }

    .contact-map {
        height: 200px !important;
        border-radius: 12px;
    }
}

/* ----------------------------------------------------------------
   21. CARDS GENERAL — Better mobile padding
   ---------------------------------------------------------------- */
@media (max-width: 576px) {
    .card {
        border-radius: 12px !important;
    }

    .card-body {
        padding: 1rem !important;
    }

    .card-header {
        padding: 0.75rem 1rem !important;
    }

    .card-footer {
        padding: 0.75rem 1rem !important;
    }
}

/* ----------------------------------------------------------------
   22. WISHLIST PAGE
   ---------------------------------------------------------------- */
@media (max-width: 767px) {

    .wishlist-row>.col-md-3,
    .wishlist-row>.col-lg-3 {
        width: 50% !important;
    }
}

/* ----------------------------------------------------------------
   23. ARTICLE / BLOG PAGES
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .article-row {
        flex-direction: column !important;
    }

    .article-sidebar {
        width: 100% !important;
        margin-top: 1.5rem;
    }

    .article-content {
        width: 100% !important;
    }

    .article-content img {
        border-radius: 10px;
        width: 100% !important;
        height: auto !important;
    }
}

/* ----------------------------------------------------------------
   24. MOBILE BOTTOM NAVIGATION BAR (NEW)
      Appears on all pages for quick navigation
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid #e8e8e8;
        z-index: 1030;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
        height: 60px;
        align-items: stretch;
    }

    .mobile-bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #888;
        text-decoration: none;
        font-size: 10px;
        font-weight: 600;
        gap: 3px;
        transition: color 0.2s;
    }

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

    .mobile-bottom-nav a.active,
    .mobile-bottom-nav a:hover {
        color: #0d6efd;
    }

    .mobile-bottom-nav a.active i {
        color: #0d6efd;
    }

    /* Add padding to body so content isn't hidden under bottom nav */
    body {
        padding-bottom: 65px !important;
    }

    /* Chat widget — lift above bottom nav */
    .chat-widget-wrapper {
        bottom: 75px !important;
    }
}

/* Desktop: hide the bottom nav */
@media (min-width: 768px) {
    .mobile-bottom-nav {
        display: none !important;
    }
}

/* ----------------------------------------------------------------
   25. QUICK UTILITY: Touch-friendly minimum tap target
   ---------------------------------------------------------------- */
a,
button,
[role="button"] {
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 767px) {

    .nav-link,
    .dropdown-item,
    .btn-close {
        min-height: 44px;
        display: flex !important;
        align-items: center;
    }
}

/* ----------------------------------------------------------------
   26. ANIMATED HAMBURGER → CLOSE BUTTON
   ---------------------------------------------------------------- */
.mob-menu-btn {
    width: 36px;
    height: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0;
}

.mob-menu-btn .bar {
    display: block;
    width: 22px;
    height: 2.5px;
    background: #fff;
    border-radius: 3px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.mob-menu-btn.is-open .bar:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}

.mob-menu-btn.is-open .bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.mob-menu-btn.is-open .bar:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

/* ----------------------------------------------------------------
   27. OVERFLOW FIX — Stop all horizontal scrolling
   ---------------------------------------------------------------- */
html,
body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

@media (max-width: 767px) {
    .mega-menu-container {
        display: none !important;
    }

    [style*="width: 500px"],
    [style*="width: 400px"],
    [style*="min-width: 400px"],
    [style*="min-width: 320px"] {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .container,
    .container-fluid,
    .cat-block,
    .product-row,
    .card,
    .table-responsive {
        max-width: 100% !important;
    }

    .dropdown-menu {
        max-width: calc(100vw - 30px) !important;
    }
}

/* ----------------------------------------------------------------
   28. PROFESSIONAL OFF-CANVAS SIDE DRAWER
   ---------------------------------------------------------------- */
.mobile-side-drawer {
    position: fixed;
    top: 0;
    right: -280px;
    /* Hidden by default */
    width: 280px;
    height: 100vh;
    background: #ffffff;
    z-index: 1060;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    visibility: hidden;
}

.mobile-side-drawer.open {
    right: 0;
    visibility: visible;
}

.drawer-header {
    padding: 18px 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
}

.drawer-close-btn {
    background: none;
    border: none;
    font-size: 32px;
    color: #94a3b8;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px 80px;
}

/* Backdrop Overlay */
.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1055;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.drawer-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Drawer Nav Links */
.mobile-side-drawer .nav-link {
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.mobile-side-drawer .nav-link:active {
    background-color: #f8fafc;
    color: #27ae60 !important;
}

/* Ensure bottom nav is below drawer backdrop */
.mobile-bottom-nav {
    z-index: 1050 !important;
}