/*****************************************
  HOME PRODUCTS WRAPPER
******************************************/
.mg-home-products-wrapper{
  max-width:1350px;
  margin:50px auto 40px;
  padding:0 16px;
}
.mg-home-products-title{
  font-size:26px;
  font-weight:800;
  color:#0b1a39;
  margin-bottom:22px;
}

/*****************************************
  GRID
******************************************/
.mg-home-products-grid{
  display:grid;
  grid-template-columns:repeat(6,minmax(0,1fr));
  gap:26px;
}

/*****************************************
  PRODUCT CARD
******************************************/
.mg-home-product-card{
  background:linear-gradient(135deg,rgba(205,220,255,0.18),rgba(175,195,255,0.22));
  border-radius:22px;
  border:1px solid rgba(255,255,255,0.22);
  backdrop-filter:blur(18px);
  padding:18px;
  box-shadow:0 12px 26px rgba(0,0,0,0.06);

  display:flex;
  flex-direction:column;
  height:400px; /* stable card height */
}
.mg-home-product-img img{
  width:100%;
  height:160px;
  object-fit:contain;
  border-radius:16px;
  background:#fff;
  padding:8px;
  display:block;
}
.mg-home-product-title{
  font-size:14px;
  font-weight:600;
  color:#0b1a39;
  min-height:48px;
  margin:10px 0 6px;
}
.mg-home-product-title a{
  color:inherit;
  text-decoration:none;
}
.mg-home-product-price .price{
  font-size:15px;
  font-weight:800;
  color:#0b1a39;
  margin-top:6px;
  margin-bottom:10px;
}

/* Button pinned to bottom */
.mg-home-product-btn{
  margin-top:auto;
}
.mg-home-product-btn a{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 16px;
  border-radius:999px;
  background:linear-gradient(135deg,#238CFF,#5b7dff);
  color:#fff;
  font-size:14px;
  font-weight:600;
  text-decoration:none;
  box-shadow:0 4px 14px rgba(35,140,255,0.35);
  transition:.2s ease;
}
.mg-home-product-btn a:hover{
  box-shadow:0 8px 22px rgba(35,140,255,0.5);
  filter:brightness(1.05);
}

/* Hide WooCommerce "View cart" link that appears under the button */
.added_to_cart,
.added_to_cart.wc-forward{
  display:none !important;
}

/*****************************************
  TABLET
******************************************/
@media (max-width:992px){
  .mg-home-products-grid{grid-template-columns:repeat(3,minmax(0,1fr));}
}

/*****************************************
  MOBILE (FIXED GRID)
******************************************/
@media (max-width:600px){

  .mg-home-products-wrapper{
    padding: 0 12px;
    overflow-x: hidden; /* prevents any page sideways push */
  }

  .mg-home-products-grid{
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .mg-home-product-card{
    height: auto;          /* override desktop fixed height */
    min-height: 340px;     /* keeps cards visually consistent */
    padding: 14px;
    border-radius: 18px;
  }

  .mg-home-product-img img{
    height: 140px;
    padding: 6px;
    border-radius: 14px;
  }

  .mg-home-product-title{
    font-size: 13px;
    min-height: 40px;
    margin: 10px 0 6px;

    /* prevents tall cards from long titles */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .mg-home-product-price .price{
    font-size: 14px;
    margin-bottom: 10px;
  }

  .mg-home-product-btn a{
    width: 100%;
    padding: 10px 14px;
    font-size: 13px;
  }

  #mg-load-more{
    width: 100%;
    max-width: 320px;
  }
}
/*****************************************
  MOBILE PATCH – FIX TITLE + KEEP BUTTON INSIDE CARD
******************************************/
@media (max-width: 600px){

  /* Ensure cards always contain their children */
  .mg-home-product-card{
    position: relative;
    overflow: hidden;

    /* force override of desktop fixed height */
    height: auto !important;
    min-height: 360px;

    padding: 14px 14px 16px;
    display: flex;
    flex-direction: column;
  }

  /* Title: clean 2-line clamp + no weird breaks */
  .mg-home-product-title{
    font-size: 13px;
    font-weight: 600;
    color: #0b1a39;

    line-height: 1.25;
    margin: 10px 0 6px;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;

    overflow: hidden;
    word-break: break-word;
    hyphens: auto;

    /* keeps consistent height across cards */
    min-height: calc(1.25em * 2);
  }

  .mg-home-product-title a{
    display: block;
    color: inherit;
    text-decoration: none;
  }

  /* Button: hard reset any Woo/global positioning that pushes it outside */
  .mg-home-product-btn{
    margin-top: auto;
    padding-top: 12px;
  }

  .mg-home-product-btn a,
  .mg-home-product-btn a.button,
  .mg-home-product-btn a.add_to_cart_button,
  .mg-home-product-btn a.ajax_add_to_cart{
    width: 100% !important;

    position: static !important;
    inset: auto !important;
    float: none !important;

    margin: 0 !important;
    transform: none !important;

    box-sizing: border-box !important;
  }
}

/*****************************************
  LOAD MORE BUTTON
******************************************/
#mg-load-more{
  margin:40px auto 0;
  display:block;
  padding:12px 28px;
  background:linear-gradient(135deg,#238CFF,#5b7dff);
  color:#fff;
  border:none;
  border-radius:999px;
  font-size:15px;
  font-weight:600;
  cursor:pointer;
  box-shadow:0 4px 14px rgba(35,140,255,0.35);
}
#mg-load-more:hover{
  box-shadow:0 8px 22px rgba(35,140,255,0.5);
  filter:brightness(1.05);
}
.mg-spinner{
  width:16px;
  height:16px;
  border:3px solid rgba(255,255,255,0.4);
  border-top-color:#fff;
  border-radius:50%;
  display:inline-block;
  margin-right:8px;
  animation:mg-spin .8s linear infinite;
}
@keyframes mg-spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}
/* ==============================
   FORCE MG BUTTON STYLE (SHOP + CATEGORY)
================================ */

/* Reset Woo button */
.mg-home-product-btn a.button,
.mg-home-product-btn a.add_to_cart_button,
.mg-home-product-btn a.ajax_add_to_cart {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;

    padding: 8px 16px !important;
    border-radius: 999px !important;

    background: linear-gradient(135deg, #238CFF, #5b7dff) !important;
    color: #ffffff !important;

    font-size: 14px !important;
    font-weight: 600 !important;
    text-decoration: none !important;

    border: none !important;
    box-shadow: 0 4px 14px rgba(35,140,255,0.35) !important;

    opacity: 1 !important;
    min-height: auto !important;
}

/* Hover */
.mg-home-product-btn a.button:hover {
    box-shadow: 0 8px 22px rgba(35,140,255,0.5) !important;
    filter: brightness(1.05);
}

/* Loading state */
.mg-home-product-btn a.loading {
    opacity: 0.7 !important;
    pointer-events: none;
}

/* Added to cart */
.mg-home-product-btn a.added {
    background: linear-gradient(135deg, #1e7cff, #4f6fff) !important;
}

/* Hide Woo "View cart" text completely */
.mg-home-product-btn a.added::after,
.mg-home-product-btn .added_to_cart {
    display: none !important;
}
.mg-back-row{
  margin-bottom:16px;
}
.mg-back-btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-weight:600;
  color:#0b1a39;
  text-decoration:none;
  opacity:.7;
  transition:.2s ease;
}
.mg-back-btn:hover{
  opacity:1;
}
/*****************************************
  SORT FILTER – MATCH PRODUCT CARD STYLE
******************************************/

.mg-sort-form{
  margin-left:auto;
}

.mg-sort-form select{
  /* Same glass background as cards */
  background: linear-gradient(
    135deg,
    rgba(205,220,255,0.18),
    rgba(175,195,255,0.22)
  );
  backdrop-filter: blur(18px);

  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;

  padding: 10px 44px 10px 18px;

  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #0b1a39;

  box-shadow: 0 12px 26px rgba(0,0,0,0.06);

  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  cursor: pointer;
  transition: .2s ease;
}

/* Hover = same feel as cards */
.mg-sort-form select:hover{
  box-shadow: 0 18px 34px rgba(0,0,0,0.08);
  filter: brightness(1.03);
}

/* Focus (clean, no ugly outline) */
.mg-sort-form select:focus{
  outline: none;
  box-shadow:
    0 0 0 2px rgba(35,140,255,0.25),
    0 12px 26px rgba(0,0,0,0.08);
}

/* Custom dropdown arrow */
.mg-sort-form{
  position: relative;
}

.mg-sort-form::after{
  content: '▾';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: #0b1a39;
  pointer-events: none;
  opacity: .6;
}

/* Dropdown options (browser-limited, but improved) */
.mg-sort-form select option{
  background: #ffffff;
  color: #0b1a39;
  font-weight: 500;
}
/*****************************************
  WOOCOMMERCE PAGINATION – MG STYLE (CLEAN v2)
  (Removes the grey "base" under corners)
******************************************/
.mg-home-products-wrapper .woocommerce-pagination{
  margin-top: 28px;
  display: flex;
  justify-content: center;
  align-items: center;

  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

/* Kill any default segmented styles */
.mg-home-products-wrapper .woocommerce-pagination ul.page-numbers{
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;

  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;

  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;

  line-height: 1 !important;
}

.mg-home-products-wrapper .woocommerce-pagination ul.page-numbers li{
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;

  display: flex !important;
  align-items: center !important;
}

/* Button base */
.mg-home-products-wrapper .woocommerce-pagination .page-numbers{
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  height: 44px !important;
  min-width: 44px !important;
  padding: 0 14px !important;

  border-radius: 16px !important;

  background: linear-gradient(
    135deg,
    rgba(205,220,255,0.18),
    rgba(175,195,255,0.22)
  ) !important;

  border: 1px solid rgba(255,255,255,0.22) !important;
  backdrop-filter: blur(18px);

  /* IMPORTANT: remove default shadow (this was the grey "base") */
  box-shadow: none !important;

  font-size: 15px !important;
  font-weight: 800 !important;
  color: #0b1a39 !important;
  text-decoration: none !important;

  white-space: nowrap !important;
  line-height: 1 !important;

  transition: transform .2s ease, filter .2s ease, box-shadow .2s ease !important;
}

.mg-home-products-wrapper .woocommerce-pagination a.page-numbers:hover{
  transform: translateY(-2px);
  filter: brightness(1.03);
}

/* Active page */
.mg-home-products-wrapper .woocommerce-pagination .page-numbers.current{
  background: linear-gradient(135deg, #238CFF, #5b7dff) !important;
  color: #fff !important;
  border-color: rgba(35,140,255,0.35) !important;
}

/* Prev / Next */
.mg-home-products-wrapper .woocommerce-pagination .page-numbers.prev,
.mg-home-products-wrapper .woocommerce-pagination .page-numbers.next{
  min-width: auto !important;
  padding: 0 18px !important;
  border-radius: 999px !important;
}

/* Dots */
.mg-home-products-wrapper .woocommerce-pagination .page-numbers.dots{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;

  min-width: auto !important;
  padding: 0 6px !important;
  height: auto !important;

  color: rgba(11,26,57,.45) !important;
}

@media (max-width: 600px){
  .mg-home-products-wrapper .woocommerce-pagination{
    margin-top: 20px;
  }

  .mg-home-products-wrapper .woocommerce-pagination ul.page-numbers{
    gap: 8px !important;
  }

  .mg-home-products-wrapper .woocommerce-pagination .page-numbers{
    height: 40px !important;
    min-width: 40px !important;
    padding: 0 12px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
  }

  .mg-home-products-wrapper .woocommerce-pagination .page-numbers.prev,
  .mg-home-products-wrapper .woocommerce-pagination .page-numbers.next{
    padding: 0 14px !important;
  }
}
