/*******************************************************
  MAIN CARD
*******************************************************/
.mg-single-product .mg-product-card {
    max-width: 1250px;
    margin: 40px auto 50px;
    padding: 32px 40px;
    border-radius: 26px;

    background: linear-gradient(
        135deg,
        rgba(205,220,255,0.22),
        rgba(175,195,255,0.26)
    );
    border: 1px solid rgba(255,255,255,0.22);
    backdrop-filter: blur(28px);
    box-shadow: 0 16px 40px rgba(0,0,0,0.07);
    box-sizing: border-box;
}

/*******************************************************
  LAYOUT (MATCH OLD: 1.1fr / 1fr)
*******************************************************/
.mg-product-layout {
    display: grid;
    grid-template-columns: 1.1fr 1fr; /* same proportions as old code */
    gap: 32px;
    align-items: flex-start;
}

/*******************************************************
  LEFT: GALLERY (MATCH OLD)
*******************************************************/
.mg-left-gallery {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);  /* old: thumbs 72px + main image */
    gap: 18px;
}

.mg-thumbs-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mg-thumb {
    border: 2px solid transparent;
    padding: 0;
    border-radius: 14px;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mg-thumb img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;             /* clip the image corners */
}

.mg-thumb:hover {
    box-shadow: 0 6px 14px rgba(0,0,0,0.12);
}
.mg-thumb:focus,
.mg-thumb:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.mg-thumb.active,
.mg-thumb.is-active {
    border: 2px solid #000;          /* black border */
    border-radius: 14px;             /* ensure rounded corners match */
    overflow: hidden;                /* clips border so it stays clean */
    box-shadow: none !important;
}

/*******************************************************
  MAIN IMAGE – EXACT BEHAVIOR FROM OLD CODE
*******************************************************/
.mg-main-image-box {
    border-radius: 20px;
    overflow: hidden;
    background: #f4f6ff;
    /* no flex, no fixed height – image controls the height */
}

.mg-main-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    transition: transform 0.3s ease;
}

/* hover zoom like original */
.mg-main-image-box:hover .mg-main-img {
    transform: scale(1.35);
    cursor: zoom-in;
}

/*******************************************************
  RIGHT: TEXT + BUTTONS
*******************************************************/
.mg-right-info {
    display: flex;
    flex-direction: column;
    gap: 5px; /* tighter spacing */
}

/* back button above title */
.mg-back-btn {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 14px;
    color: #0b1a39;
    opacity: 0.75;
    text-decoration: none;
}
.mg-back-btn:hover {
    opacity: 1;
    text-decoration: underline;
}

.mg-title {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    color: #0b1a39;
}

.mg-sku {
    font-size: 13px;
    color: #7b859c;
}
.mg-sku span { font-weight: 600; }

.mg-copylink-btn {
    align-self: flex-start;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(35,140,255,0.35);
    background: rgba(255,255,255,0.95);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.mg-copylink-btn:hover {
    background: rgba(35,140,255,0.08);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.mg-short-description {
    font-size: 15px;
    color: #253048;
}

.mg-char-btn {
    align-self: flex-start;
    padding: 7px 14px;
    border-radius: 999px;
    border: none;
    background: rgba(35,140,255,0.16);
    color: #0b1a39;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}
.mg-char-btn:hover {
    background: rgba(35,140,255,0.25);
    transform: translateY(-1px);
}

/*******************************************************
  PRICE & STOCK
*******************************************************/
.mg-price-box {
    font-size: 24px;
    font-weight: 800;
    color: #0b1a39;
}
.mg-price-box .price,
.mg-price-box .woocommerce-Price-amount {
    font-size: 24px;
    font-weight: 800;
    color: #0b1a39;
}

.mg-stock-wrapper { 
    margin-top: 2px;
}

.mg-stock-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}
.mg-stock-in {
    background: rgba(60,180,120,0.14);
    color: #1e7c3f;
    border: 1px solid rgba(60,180,120,0.45);
}
.mg-stock-out {
    background: rgba(220,50,60,0.12);
    color: #b42323;
    border: 1px solid rgba(220,50,60,0.45);
}

/*******************************************************
  CART ROW – ADD SPACE BETWEEN BUTTON & QTY
*******************************************************/
.mg-cart-row {
    margin-top: 9px;
    display: flex !important;
    flex-wrap: wrap;
    gap: 50px !important;           /* SPACE BETWEEN Add to cart & qty */
    align-items: center;
}
.mg-cart-btn {
    float: none !important;
}

/* quantity box */
.mg-qty-box {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: rgba(246,248,255,0.98);
    border: 1px solid rgba(175,195,255,0.7);
    overflow: hidden;
}

.mg-qty-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: rgba(220,230,255,0.9);
    font-size: 18px;
    font-weight: 700;
    color: #0b1a39;
    cursor: pointer;
    transition: background 0.15s ease;
}
.mg-qty-btn:hover {
    background: rgba(200,215,255,0.98);
}

.mg-qty-input {
    width: 48px;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    outline: none;
}
.mg-qty-input::-webkit-outer-spin-button,
.mg-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.mg-qty-input[type=number] {
    -moz-appearance: textfield;
}

/* add to cart button */
.mg-cart-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 10px 26px !important;
    border-radius: 999px !important;
    border: none !important;
    background: linear-gradient(135deg,#238CFF,#5b7dff) !important;
    color: #ffffff !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 14px rgba(35,140,255,0.35) !important;
    cursor: pointer !important;
    transition: box-shadow 0.2s ease, filter 0.2s ease;
}
.mg-cart-btn:hover {
    box-shadow: 0 8px 22px rgba(35,140,255,0.5) !important;
    filter: brightness(1.05);
}

/*******************************************************
  CHARACTERISTICS SECTION
*******************************************************/
.mg-characteristics-section {
    max-width: 1250px;
    margin: 0 auto 60px;
    padding: 0 16px;
}
.mg-characteristics-section h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}
.mg-characteristics-section .shop_attributes {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.mg-characteristics-section .shop_attributes th,
.mg-characteristics-section .shop_attributes td {
    padding: 8px 10px;
    text-align: left;
}
.mg-characteristics-section .shop_attributes th {
    width: 32%;
    background: #f3f5ff;
    color: #5d6885;
    font-weight: 600;
}
.mg-characteristics-section .shop_attributes td {
    background: #ffffff;
}
.mg-characteristics-section .shop_attributes tr:nth-child(even) td {
    background: #f8f9ff;
}

/*******************************************************
  MOBILE STICKY ADD-TO-CART
*******************************************************/
.mg-mobile-sticky-cart {
    display: none;
}

@media (max-width: 900px) {

    .mg-product-card {
        padding: 22px 18px;
        margin: 24px 10px 80px;
    }

    .mg-product-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .mg-left-gallery {
        grid-template-columns: 70px minmax(0, 1fr);
    }

    .mg-main-image-box {
        border-radius: 18px;
    }

    .mg-title {
        font-size: 22px;
    }

    .mg-cart-row {
        gap: 16px;
    }

    /* sticky bar */
    .mg-mobile-sticky-cart {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 16px;
        background: rgba(246,248,255,0.96);
        backdrop-filter: blur(16px);
        box-shadow: 0 -6px 18px rgba(0,0,0,0.16);
    }

    .mg-mobile-price .price,
    .mg-mobile-price .woocommerce-Price-amount {
        font-size: 18px;
        font-weight: 700;
        color: #0b1a39;
    }

    .mg-mobile-add-btn {
        border-radius: 999px;
        padding: 8px 18px;
        border: none;
        background: linear-gradient(135deg,#238CFF,#5b7dff);
        color: #fff;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
    }

    body {
        padding-bottom: 70px; /* space so content not hidden behind sticky bar */
    }
}

/*******************************************************
  DESCRIPTION SECTION  (GLASS STYLE)
*******************************************************/
.mg-product-description-section {
    max-width: 1250px;
    margin: 50px auto;
    padding: 0 16px;
}

.mg-product-description-section h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}

/* CHANGED: from plain white box to glass, matching main card */
.mg-description-content {
    font-size: 15px;
    line-height: 1.6;
    color: #253048;

    padding: 24px 26px;
    border-radius: 26px;

    background: linear-gradient(
        135deg,
        rgba(205,220,255,0.22),
        rgba(175,195,255,0.26)
    );
    border: 1px solid rgba(255,255,255,0.22);
    backdrop-filter: blur(24px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.08);
}

/******************************************************
  RELATED PRODUCTS – FINAL FIXED VERSION
*******************************************************/

.mg-related-products-wrapper {
    max-width: 1250px;
    margin: 60px auto;
    padding: 0 16px;
}

.mg-related-products-wrapper h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 18px;
}

/* hide Woo default title */
.mg-related-products-wrapper .related > h2 {
    display: none;
}

.mg-related-products-wrapper .related {
    width: 100%;
}

/* ================= DESKTOP GRID ================= */
.mg-related-products-wrapper ul.products {
    list-style: none;
    margin: 0;
    padding: 0;

    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 28px;

    align-items: stretch; /* IMPORTANT */
}

/* reset Woo defaults */
.mg-related-products-wrapper ul.products li.product {
    float: none !important;
    width: auto !important;
    margin: 0 !important;

    box-sizing: border-box;
}

/* ================= CARD ================= */
.mg-related-products-wrapper ul.products li.product {
    height: 100%;

    display: flex;
    flex-direction: column;

    background: linear-gradient(
        135deg,
        rgba(205,220,255,0.18),
        rgba(175,195,255,0.20)
    );

    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.20);
    backdrop-filter: blur(18px);
    box-shadow: 0 10px 26px rgba(0,0,0,0.06);

    padding: 16px 14px 20px;
}

/* ================= IMAGE (LOCKED HEIGHT) ================= */
.mg-related-products-wrapper ul.products li.product a img {
    width: 100%;
    height: 180px;              /* LOCK HEIGHT */
    object-fit: contain;

    background: #ffffff;
    border-radius: 18px;
    padding: 6px;

    display: block;
    margin-bottom: 10px;
}

/* ================= TITLE (LOCKED HEIGHT – FIX) ================= */
.mg-related-products-wrapper 
ul.products 
li.product 
.woocommerce-loop-product__title {
    font-size: 15px;
    font-weight: 600;
    color: #0b1a39;
    line-height: 1.2;

    margin: 0 0 6px 0;

    min-height: 48px;  /* EXACT 2 LINES */
    max-height: 48px;
    overflow: hidden;
}

/* ================= PRICE (PUSH TO BOTTOM) ================= */
.mg-related-products-wrapper 
ul.products 
li.product 
.price {
    font-size: 15px;
    font-weight: 700;
    color: #0b1a39;

    margin-top: auto;  /* CRITICAL */
    margin-bottom: 10px;
}

/* ================= BUTTON ================= */
.mg-related-products-wrapper 
ul.products 
li.product 
a.button,
.mg-related-products-wrapper 
ul.products 
li.product 
a.add_to_cart_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 8px 18px;
    border-radius: 999px;
    border: none;

    background: linear-gradient(135deg,#238CFF,#5b7dff);
    color: #ffffff;

    font-size: 14px;
    font-weight: 600;
    text-decoration: none;

    box-shadow: 0 4px 14px rgba(35,140,255,0.35);
    transition: box-shadow .2s ease, filter .2s ease;
}

.mg-related-products-wrapper 
ul.products 
li.product 
a.button:hover,
.mg-related-products-wrapper 
ul.products 
li.product 
a.add_to_cart_button:hover {
    box-shadow: 0 8px 22px rgba(35,140,255,0.5);
    filter: brightness(1.05);
}

/* ================= MOBILE – HORIZONTAL SCROLL ================= */
@media (max-width: 900px) {

    .mg-related-products-wrapper {
        margin: 40px 0;
        padding-left: 16px;
        padding-right: 0;
    }

    .mg-related-products-wrapper ul.products {
        display: flex !important;
        flex-wrap: nowrap;

        overflow-x: auto;
        gap: 16px;

        padding-right: 16px;

        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .mg-related-products-wrapper ul.products li.product {
        min-width: 260px;
        scroll-snap-align: start;
    }

    .mg-related-products-wrapper ul.products::-webkit-scrollbar {
        height: 6px;
    }

    .mg-related-products-wrapper ul.products::-webkit-scrollbar-thumb {
        background: rgba(15,60,155,0.25);
        border-radius: 999px;
    }
}

/* ================= MORE PRODUCTS BUTTON ================= */
.mg-related-more-btn-wrapper {
    text-align: center;
    margin-top: 20px;
}

.mg-related-more-btn {
    display: inline-block;
    padding: 10px 26px;
    border-radius: 999px;

    background: linear-gradient(135deg,#238CFF,#5b7dff);
    color: #fff;

    font-size: 15px;
    font-weight: 600;
    text-decoration: none;

    box-shadow: 0 4px 14px rgba(35,140,255,0.35);
    transition: box-shadow .2s ease, filter .2s ease;
}

.mg-related-more-btn:hover {
    box-shadow: 0 8px 22px rgba(35,140,255,0.5);
    filter: brightness(1.05);
}