/* ============================================================================
   MOBILE RESPONSIVENESS FIX - HOME SCREEN
   Purpose: Fix mobile display issues on home page
   ============================================================================ */

/* ============================================================================
   BANNER / CAROUSEL MOBILE FIXES
   ============================================================================ */

@media (max-width: 576px) {
  /* Extra small devices (phones, less than 576px) */

  /* Banner content adjustments */
  .ab-carousel .content {
    padding: 1.5rem 1rem !important;
  }

  .ab-carousel .content .col-lg-7 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  /* Banner text sizing */
  .ab-carousel h1 {
    font-size: 1.5rem !important;
    line-height: 1.2 !important;
    margin-top: 0.5rem !important;
  }

  .ab-carousel h2 {
    font-size: 1.25rem !important;
    line-height: 1.2 !important;
    margin-top: 0.5rem !important;
  }

  .ab-carousel .display-5,
  .ab-carousel .display-6 {
    font-size: 1.25rem !important;
  }

  .ab-carousel p,
  .ab-carousel .lead {
    font-size: 0.85rem !important;
    line-height: 1.4 !important;
    margin-bottom: 0.75rem !important;
  }

  .ab-carousel .pill {
    font-size: 0.65rem !important;
    padding: 0.2rem 0.5rem !important;
  }

  /* Banner buttons */
  .ab-carousel .btn {
    font-size: 0.85rem !important;
    padding: 0.5rem 1.5rem !important;
  }

  .ab-carousel .btn-lg {
    font-size: 0.875rem !important;
    padding: 0.6rem 1.75rem !important;
  }

  .ab-carousel .btn i {
    font-size: 0.75rem !important;
  }

  /* Banner height for small phones */
  .ab-carousel .carousel-item {
    min-height: 300px !important;
    max-height: 400px !important;
  }

  /* Carousel controls smaller */
  .carousel-control-prev-icon,
  .carousel-control-next-icon {
    width: 1.5rem !important;
    height: 1.5rem !important;
  }

  .carousel-control-prev,
  .carousel-control-next {
    width: 12% !important;
  }

  /* Carousel indicators smaller */
  .carousel-indicators [data-bs-target] {
    width: 8px !important;
    height: 8px !important;
    margin: 0 3px !important;
  }

  .carousel-indicators .active {
    width: 10px !important;
    height: 10px !important;
  }

  .carousel-indicators {
    margin-bottom: 1rem !important;
  }
}

/* ============================================================================
   CATEGORIES SECTION MOBILE FIXES
   ============================================================================ */

@media (max-width: 768px) {
  /* Popular Categories Section */
  .popular-categories-section {
    padding: 2rem 0 !important;
  }

  .popular-categories-section .text-center.mb-5 {
    margin-bottom: 2rem !important;
  }

  .popular-categories-section h2 {
    font-size: 1.5rem !important;
  }

  .popular-categories-section .lead-subtitle {
    font-size: 0.9rem !important;
  }

  /* Category cards */
  .category-card-enhanced {
    padding: 1rem !important;
  }

  .category-icon-enhanced {
    font-size: 2rem !important;
  }

  .category-title {
    font-size: 1rem !important;
  }

  .category-description {
    font-size: 0.85rem !important;
    margin-bottom: 0.75rem !important;
  }

  .btn-category-explore {
    font-size: 0.85rem !important;
    padding: 0.5rem 1rem !important;
  }

  /* Category carousel controls */
  .carousel-control-custom {
    display: none !important; /* Hide arrow controls on mobile */
  }

  .carousel-indicators-custom {
    margin-top: 1rem !important;
  }

  .carousel-indicators-custom button {
    width: 8px !important;
    height: 8px !important;
  }
}

@media (max-width: 576px) {
  /* Stack categories vertically on small phones */
  .category-card-enhanced {
    margin-bottom: 1rem;
  }

  /* Make single column on very small screens */
  #categoriesCarousel .col-sm-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
}

/* ============================================================================
   FEATURED PRODUCTS SECTION MOBILE FIXES
   ============================================================================ */

@media (max-width: 768px) {
  .featured-products {
    padding: 2rem 0 !important;
  }

  .featured-products h2 {
    font-size: 1.5rem !important;
  }

  .featured-products .section-title {
    font-size: 1.5rem !important;
  }

  .featured-products .small-muted {
    font-size: 0.85rem !important;
  }

  /* Product cards */
  .product-card {
    margin-bottom: 1rem;
  }

  .product-card-img {
    height: 200px !important;
  }

  .product-card-title {
    font-size: 0.95rem !important;
  }

  .product-card-price {
    font-size: 1rem !important;
  }

  .btn-add-cart {
    font-size: 0.85rem !important;
    padding: 0.5rem 1rem !important;
  }
}

/* ============================================================================
   GENERAL MOBILE IMPROVEMENTS
   ============================================================================ */

@media (max-width: 768px) {
  /* Section spacing */
  .py-5 {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
  }

  /* Container padding */
  .container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Section titles */
  .section-title-large {
    font-size: 1.75rem !important;
  }

  .section-title {
    font-size: 1.5rem !important;
  }

  /* Small titles */
  .small-title {
    font-size: 0.75rem !important;
  }

  /* Buttons */
  .btn-lg {
    font-size: 0.95rem !important;
    padding: 0.65rem 1.5rem !important;
  }

  .btn {
    font-size: 0.875rem !important;
  }

  /* Gaps and spacing */
  .gap-3 {
    gap: 0.75rem !important;
  }

  .gap-4 {
    gap: 1rem !important;
  }

  /* Margins */
  .mb-4 {
    margin-bottom: 1.5rem !important;
  }

  .mb-5 {
    margin-bottom: 2rem !important;
  }

  .mt-4 {
    margin-top: 1.5rem !important;
  }

  .mt-5 {
    margin-top: 2rem !important;
  }
}

@media (max-width: 576px) {
  /* Extra small devices - more aggressive sizing */

  /* Even smaller section spacing */
  .py-5 {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }

  /* Tighter container */
  .container {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  /* Smaller titles */
  .section-title-large {
    font-size: 1.5rem !important;
  }

  .section-title {
    font-size: 1.25rem !important;
  }

  /* View all buttons */
  .btn-ab-outline.btn-lg,
  .btn-ab.btn-lg {
    font-size: 0.875rem !important;
    padding: 0.6rem 1.25rem !important;
  }
}

/* ============================================================================
   TOP BAR MOBILE FIXES
   ============================================================================ */

@media (max-width: 768px) {
  .top-bar {
    font-size: 0.75rem !important;
    padding: 0.5rem 0 !important;
  }

  .top-bar small {
    font-size: 0.7rem !important;
  }

  .top-bar .col-12 {
    padding: 0.25rem 0;
  }

  .top-bar .text-nowrap {
    white-space: normal !important;
    word-break: break-word;
  }
}

@media (max-width: 576px) {
  .top-bar {
    font-size: 0.7rem !important;
    padding: 0.4rem 0 !important;
  }

  .top-bar small {
    font-size: 0.65rem !important;
  }

  .top-bar i {
    font-size: 0.65rem !important;
  }
}

/* ============================================================================
   HEADER BAR MOBILE FIXES
   ============================================================================ */

@media (max-width: 768px) {
  .header-bar {
    padding: 0.75rem 0 !important;
  }

  /* Fix header row spacing */
  .header-bar .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .header-bar .row > * {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  /* Logo section - left aligned */
  .header-bar .col-6:first-child {
    padding-left: 0.75rem !important;
  }

  /* Buttons section - right aligned */
  .header-bar .col-6:nth-child(2) {
    padding-right: 0.75rem !important;
  }

  .header-logo {
    max-height: 60px !important;
    height: 60px !important;
  }

  .brand-text {
    font-size: 0.9rem !important;
  }

  .header-bar .btn-sm {
    padding: 0.35rem 0.6rem !important;
    font-size: 0.85rem !important;
  }

  .header-bar .btn-sm i {
    font-size: 0.9rem !important;
  }

  /* Better button spacing on mobile */
  .header-bar .gap-2 {
    gap: 0.4rem !important;
  }

  /* Ensure buttons are properly aligned */
  .header-bar .d-flex.align-items-center {
    height: 100%;
  }
}

@media (max-width: 576px) {
  .header-bar {
    padding: 0.5rem 0 !important;
  }

  .header-bar .row {
    --bs-gutter-x: 0.5rem !important;
  }

  /* Logo section */
  .header-bar .col-6:first-child {
    padding-left: 0.5rem !important;
  }

  /* Buttons section */
  .header-bar .col-6:nth-child(2) {
    padding-right: 0.5rem !important;
  }

  .header-logo {
    max-height: 48px !important;
    height: 48px !important;
  }

  .brand-text {
    font-size: 0.85rem !important;
  }

  .header-bar .btn-sm {
    padding: 0.3rem 0.5rem !important;
    font-size: 0.8rem !important;
  }

  .header-bar .btn-sm i {
    font-size: 0.85rem !important;
  }

  /* Tighter button spacing on small phones */
  .header-bar .gap-2 {
    gap: 0.3rem !important;
  }

  .cart-count,
  .wishlist-count {
    font-size: 0.6rem !important;
    min-width: 16px !important;
    height: 16px !important;
    padding: 0.15rem 0.3rem !important;
  }

  /* Make sure logo and buttons are vertically centered */
  .header-bar .navbar-brand {
    display: flex !important;
    align-items: center !important;
    height: 100%;
    margin: 0;
  }
}

/* ============================================================================
   NAVIGATION MOBILE FIXES
   ============================================================================ */

@media (max-width: 991px) {
  .navbar-toggler {
    padding: 0.5rem !important;
    font-size: 1rem !important;
  }

  .navbar-collapse {
    margin-top: 1rem;
  }

  .nav-link {
    padding: 0.75rem 1rem !important;
    font-size: 0.95rem !important;
  }

  .dropdown-menu {
    margin-top: 0 !important;
  }
}

@media (max-width: 576px) {
  .navbar-toggler {
    padding: 0.4rem !important;
    font-size: 0.9rem !important;
  }

  .nav-link {
    padding: 0.65rem 0.85rem !important;
    font-size: 0.9rem !important;
  }

  .dropdown-item {
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
  }
}

/* Make offcanvas category panel narrower on small screens so it doesn't cover entire viewport */
@media (max-width: 991.98px) {
  /* Prefer Bootstrap variable for offcanvas width to avoid layout shift */
  .offcanvas.offcanvas-start {
    --bs-offcanvas-width: 80% !important;
    max-width: 360px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  }

  /* Ensure offcanvas body scrolls internally and doesn't cause page horizontal scroll */
  .offcanvas-body {
    padding: 1rem !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent any accidental horizontal overflow caused by offcanvas contents */
  .offcanvas, .offcanvas * {
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden !important;
  }
}

/* Prevent sticky sidebar and internal scrollbars from affecting mobile layout */
@media (max-width: 991.98px) {
  /* Disable sticky behavior in small screens (offcanvas or regular flow) */
  .filter-sidebar {
    position: static !important;
    top: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* Hide custom scrollbar for filter-sidebar to avoid visible rail */
  .filter-sidebar::-webkit-scrollbar {
    display: none;
  }

  /* Ensure product area does not get pushed by any offscreen elements */
  .products-section,
  .products-section .container,
  .products-section .row {
    overflow-x: hidden !important;
  }
}

/* Force offcanvas fully off-screen when hidden to avoid a visible scrollbar rail */
@media (max-width: 991.98px) {
  .offcanvas {
    transform: translateX(-150%) !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .offcanvas.show {
    transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  /* Ensure product column occupies full width on small screens */
  .products-section .col-lg-9 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding-right: 0 !important;
  }

  /* Guarantee left sidebar column is gone on mobile */
  .products-section .col-lg-3 {
    display: none !important;
  }
}

/* ============================================================================
   TEXT READABILITY ON MOBILE
   ============================================================================ */

@media (max-width: 768px) {
  /* Ensure text is readable on banner overlay */
  .ab-carousel .overlay {
    background: linear-gradient(90deg, rgba(15,61,46,.9), rgba(15,61,46,.4)) !important;
  }

  /* Better contrast for banner text */
  .ab-carousel h1,
  .ab-carousel h2,
  .ab-carousel p {
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  }

  /* Make buttons more visible */
  .ab-carousel .btn {
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  }
}

/* ============================================================================
   TOUCH TARGETS - Make buttons easier to tap on mobile
   ============================================================================ */

@media (max-width: 768px) {
  /* Minimum touch target size of 44x44px for better UX */
  .btn,
  .btn-sm,
  a.btn {
    min-height: 38px;
    min-width: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Carousel controls */
  .carousel-control-prev,
  .carousel-control-next {
    min-width: 44px;
  }
}

/* ============================================================================
   PREVENT HORIZONTAL SCROLLING
   ============================================================================ */

@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  /* Avoid forcing global max-width which can break Bootstrap grid; only hide horizontal overflow where needed */
  .products-section,
  .products-section .container,
  .products-section .row {
    overflow-x: hidden;
  }

  img {
    max-width: 100%;
    height: auto;
  }
}
