/* Custom Responsive Styles for MKS Store */

/* UNIVERSAL PRODUCT CARD ACTIONS (Mobile & Desktop) */
/* Placed to the right of the price */
.ul-product-actions {
  position: static !important;
  display: flex !important;
  flex-direction: row !important;
  gap: 5px;
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
  width: auto;
  margin: 0;
  margin-left: auto; /* Push to right */
  background: transparent;
  padding: 0;
}

.ul-product:hover .ul-product-actions {
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
}

.ul-product-action-btn,
.ul-product-actions button,
.ul-product-actions a {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f8f9fa;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #eee;
  margin: 0;
  transition: all 0.3s ease;
  box-shadow: none;
}

.ul-product-actions button:hover,
.ul-product-actions a:hover {
  background: var(--ul-primary);
  color: #fff;
  transform: translateY(-2px);
  border-color: var(--ul-primary);
}

.ul-product-actions i {
  font-size: 14px;
  line-height: 1;
  display: block;
}

/* Ensure price wrapper aligns items correctly */
.ul-product-price-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  flex-wrap: nowrap; /* Prevent wrapping */
  margin-top: auto;
  gap: 10px;
}

/* TARGETED FIX FOR BROWSE PRODUCTS SECTION (High Specificity) */
#products-container .ul-product,
.ul-product {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  background: #fff;
  border: 1px solid #f0f0f0;
  border-radius: 12px;
  padding: 15px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  /* min-height removed to allow content to dictate height */
}

#products-container .ul-product:hover,
.ul-product:hover {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  border-color: var(--ul-primary);
  transform: translateY(-5px);
}

#products-container .ul-product-img,
.ul-product-img {
  position: relative !important; /* Fix for absolute positioned actions */
  aspect-ratio: 1/1 !important;
  width: 100% !important;
  height: auto !important;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 15px;
}

#products-container .ul-product-img img,
.ul-product-img img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  transition: transform 0.4s ease;
}

.ul-product:hover .ul-product-img img {
  transform: scale(1.05); /* Zoom effect on hover */
}

.ul-product-txt {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Mobile Devices (Portrait and Landscape) */
@media only screen and (max-width: 768px) {
  /* Global Container Padding */
  .ul-container,
  .ul-inner-container {
    padding-left: 10px;
    padding-right: 10px;
  }

  /* Product Card Adjustments */
  .ul-product {
    margin-bottom: 15px;
    height: 100% !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  /* Product Image */
  .ul-product-img {
    aspect-ratio: 1/1;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
  }

  .ul-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Product Text */
  .ul-product-txt {
    padding: 5px 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
  }

  .ul-product-title {
    font-size: 13px !important;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
  }

  .ul-product-category {
    font-size: 10px !important;
    margin-bottom: 3px;
    color: #777;
  }

  .ul-product-price {
    font-size: 13px !important;
    font-weight: 700;
    color: var(--ul-primary);
  }

  .ul-product-old-price {
    font-size: 10px !important;
    text-decoration: line-through;
    color: #999;
    margin-left: 4px;
  }

  .ul-product-discount-tag {
    font-size: 9px !important;
    padding: 2px 4px;
    border-radius: 4px;
    margin-left: 5px;
  }

  /* Adjust button size for mobile */
  .ul-product-actions {
    gap: 8px !important; /* Increased gap for easier tapping */
    opacity: 1 !important; /* ALWAYS VISIBLE */
    visibility: visible !important;
    margin-top: 5px;
  }

  .ul-product-actions button,
  .ul-product-actions a {
    width: 30px;
    height: 30px;
    background: #f0f0f0; /* Slight gray background to make them pop if white constraint */
  }

  .ul-product-actions i {
    font-size: 13px;
  }

  /* Swiper Navigation Arrows - GLOBALLY HIDDEN AS REQUESTED */
  [class^="swiper-btn-"],
  .swiper-button-next,
  .swiper-button-prev {
    display: none !important;
  }

  /* Section Headings */
  .ul-section-title {
    font-size: 18px !important;
    margin-bottom: 5px;
    line-height: 1.2;
  }

  .ul-section-sub-title {
    font-size: 10px !important;
    margin-bottom: 5px;
    letter-spacing: 1px;
  }

  .ul-section-heading {
    margin-bottom: 20px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
  }

  .ul-section-heading .right {
    margin-top: 0;
    margin-left: 10px;
    flex-shrink: 0;
  }

  .ul-btn {
    padding: 6px 14px !important;
    font-size: 11px !important;
    white-space: nowrap;
  }

  /* Browse Products Grid (Infinite Scroll) */
  .product-col-5 {
    /* padding removed to let g-1 handle it */
    margin-bottom: 10px !important;
  }
}

/* Extra Small Devices (Phones) */
@media only screen and (max-width: 576px) {
  /* Ensure 2 columns fit perfectly */
  .col-6 {
    width: 50% !important;
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }

  /* Browse Products Grid specifically */
  .ul-bs-row.row-cols-1 {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .product-col-5 {
    width: 50% !important;
    flex: 0 0 50% !important;
    max-width: 50% !important;
    /* Padding removed */
  }

  .ul-product-title {
    font-size: 12px !important;
  }

  .ul-product {
    padding: 0;
    border: none;
    box-shadow: none;
  }

  .ul-product-img {
    border-radius: 8px;
  }
}

/* Ensure images links fill container */
.ul-product-img a {
  display: block;
  width: 100%;
  height: 100%;
}

/* =========================================
   DEDICATED STYLES FOR BROWSE PRODUCTS (Homepage)
   Class: .ul-browse-product
   ========================================= */

.ul-browse-product {
  display: flex !important;
  flex-direction: column !important;
  background: #fff;
  border: 1px solid #f0f0f0;
  border-radius: 8px; /* Slightly smaller radius for small cards */
  padding: 5px; /* Reduced to 5px for ultra-compact look */
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  height: 100% !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
}

.ul-browse-product:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  border-color: var(--ul-primary);
  transform: translateY(-5px);
}

/* Image Container */
.ul-browse-product .ul-product-img {
  aspect-ratio: 1/1 !important;
  width: 100% !important;
  height: auto !important;
  overflow: hidden;
  border-radius: 6px;
  margin-bottom: 6px; /* Reduced from 12px */
  position: relative !important;
  background: #f9f9f9;
}

.ul-browse-product .ul-product-img img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  transition: transform 0.4s ease;
}

.ul-browse-product:hover .ul-product-img img {
  transform: scale(1.08);
}

/* Text & Details */
.ul-browse-product .ul-product-txt {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ul-browse-product .ul-product-title {
  font-size: 14px; /* Slightly smaller font for compact look */
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.3;
  color: #333;
}

.ul-browse-product .ul-product-category {
  font-size: 11px;
  color: #888;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ul-browse-product .ul-product-category a {
  color: inherit;
}

/* Price Wrapper */
.ul-browse-product .ul-product-price-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px solid #f9f9f9;
  gap: 4px; /* Tighter gap */
}

/* Price Styling */
.ul-browse-product .ul-product-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--ul-primary);
}

.ul-browse-product .ul-product-old-price {
  font-size: 12px;
  text-decoration: line-through;
  color: #999;
}

.ul-browse-product .ul-product-discount-tag {
  font-size: 10px;
  padding: 2px 6px;
  background: #ffebeb;
  color: var(--ul-primary);
  border-radius: 4px;
  font-weight: 600;
  margin-left: 5px;
}

/* Actions (Under Pricing) */
.ul-browse-product .ul-product-actions {
  position: static !important;
  display: flex !important;
  flex-direction: row !important;
  justify-content: flex-start; /* Align left */
  gap: 8px;
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
  width: 100%;
  margin: 0;
  background: transparent;
  padding: 0;
}

.ul-browse-product .ul-product-actions button,
.ul-browse-product .ul-product-actions a {
  width: 35px; /* Slightly larger for easier clicking since they are on their own row */
  height: 35px;
  border-radius: 50%;
  background: #fff;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #eee;
  margin: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  flex-grow: 1; /* Make them fill the row evenly for a cool bar effect? Or just fixed? Let's stick to fixed size first. */
  flex-grow: 0;
}

.ul-browse-product .ul-product-actions button:hover,
.ul-browse-product .ul-product-actions a:hover {
  background: var(--ul-primary);
  color: #fff;
  border-color: var(--ul-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.ul-browse-product .ul-product-actions i {
  font-size: 13px;
  line-height: 1;
}

@media only screen and (max-width: 991px) {
  /* FORCE ICONS VISIBLE ON MOBILE/TABLET (No Hover Needed) */
  .ul-product-actions,
  .ul-browse-product .ul-product-actions {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    display: flex !important;
    position: static !important;
    margin-top: 5px !important;
    pointer-events: auto !important;
  }

  .ul-product-txt {
    padding-bottom: 5px !important;
  }
}

@media only screen and (max-width: 576px) {
  .ul-product-txt {
    padding-bottom: 2px !important;
  }

  /* Ensure action buttons are easy to tap */
  .ul-browse-product .ul-product-actions button,
  .ul-browse-product .ul-product-actions a {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important; /* Prevent shrinking */
  }
}

/* Mobile Search Toggle Logic */
@media (max-width: 1400px) {
  /* Adjust breakpoint as needed based on d-xxl-none */
  .ul-header-search-form-wrapper {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100%;
    height: auto !important; /* Changed from 100vh to auto */
    min-height: 80px; /* Ensure enough touch space */
    background: #ffffff;
    z-index: 99999 !important; /* Extremely high z-index */
    display: flex !important; /* Force flex */
    flex-direction: row; /* Row layout for bar */
    align-items: center;
    justify-content: center;
    padding: 15px 60px 15px 20px; /* Right padding for close button */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); /* Shadow for depth */

    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(-100%); /* Slide down from top */
    pointer-events: none; /* Prevent clicking when hidden */
  }

  .ul-header-search-form-wrapper.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important; /* Enable clicking when active */
  }

  /* SEARCH FORM INTERNALS FOR MOBILE */
  .ul-header-search-form {
    display: flex !important;
    width: 100% !important;
    max-width: 800px !important;
    margin: 0 auto;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    height: 50px !important; /* Fixed height for input */
  }

  /* Hide the "Way too big" category dropdown on mobile */
  .ul-header-search-form .dropdown-wrapper {
    display: none !important;
  }

  /* Make search input full width and nice */
  .ul-header-search-form-right {
    width: 100% !important;
    height: 100% !important;
    border: 2px solid #eee !important; /* Slight border */
    border-radius: 50px !important;
    overflow: hidden;
    display: flex;
    align-items: center;
    background: #f9f9f9; /* Light background for input */
    padding: 0 5px;
    transition: all 0.3s ease;
  }

  .ul-header-search-form-right:focus-within {
    border-color: var(--ul-primary) !important;
    background: #fff;
  }

  .ul-header-search-form input {
    height: 100% !important;
    border: none !important;
    padding: 0 20px !important;
    font-size: 16px !important;
    background: transparent !important;
    width: 100% !important;
  }

  .ul-header-search-form button {
    background: transparent !important; /* Remove background if it has one */
    color: var(--ul-primary);
    padding-right: 15px;
    font-size: 20px;
  }

  .ul-header-mobile-search-closer {
    position: absolute;
    top: 50%;
    transform: translateY(-50%); /* Center vertically */
    right: 15px;
    display: block !important; /* Force show closer on mobile */
    background: #f0f0f0;
    border: none;
    font-size: 16px;
    cursor: pointer;
    z-index: 100000;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: all 0.2s ease;
  }

  .ul-header-mobile-search-closer:hover {
    background: var(--ul-primary);
    color: #fff;
  }
}

/* Hide Footer on Small Devices (Infinite Scroll Optimization) */
@media (max-width: 800px) {
  footer,
  .simple-footer,
  .ul-footer {
    display: none !important;
  }

  /* Ensure extra padding at bottom so content isn't cut off */
  body {
    padding-bottom: 50px;
  }
}
