.wrapper {
    width: 100%;
    /*height: 40px;*/
    height: auto;
    position: relative;
}

.pattern {
    position: absolute;
    left: 5%;
    width: 20%;
    height: 100vh;
    background-image: url(/img/collegeicons/linebg2.png);
    background-size: cover;
    opacity: 0.2;
    z-index: -1;
    background-position: center;
}

@media (max-width: 768px) {
    .box, .pattern {
        display: none;
    }
}

.card-wrapper {
    max-width: 95%;
    margin: 0 auto;
    /*margin-top: 10px;*/
    margin-top: 50px;
}

    .card-wrapper img {
        width: 100%;
        display: block;
    }

.img-display {
    overflow: hidden;
}

.img-showcase {
    display: flex;
    width: 100%;
    transition: all 0.5s ease;
}

    .img-showcase img {
        min-width: 100%;
    }

.img-select {
    display: flex;
    gap: 0; /* Remove gap to allows 25% width */
    /* justify-content: center; Removed to eliminate side gaps */
    justify-content: flex-start; /* Align images to the start (Right in RTL) */
    margin-top: 1rem;
}

.img-item {
    margin: 0.3rem;
    /* Remove older margin logic */
    /* margin: 0.3rem; */
    border: 1px solid #ddd; /* Add subtle border for definition */
    /* border-radius: 4px; Remove radius for flush fit? Keep for style */
    /* width: 80px; Remove fixed size */
    /* height: 80px; */
    width: 24%; /* Set exact 24% width */
    aspect-ratio: 16 / 9; /* Changed from 1/1 to landscape (rectangle) */
    flex-shrink: 0;
    overflow: hidden; /* Ensure image fits rounded corners */
    padding: 0; /* Remove padding causing gap */
    display: flex; /* Remove inline-block vertical alignment issues */
    box-sizing: border-box; /* Ensure padding/border included in width */
    position: relative; /* Anchor for absolute image */
}

    /* Deleted: .img-item:nth-child... margin hacks */

    .img-item:hover {
        opacity: 0.8;
        border-color: #245d55;
    }

    .img-item img {
        position: absolute; /* Force fill container */
        top: 0; left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover; /* Zoom/Crop to fill completely */
        display: block; /* Remove bottom whitespace */
    }

.product-content {
    padding: 2rem 1rem;
    padding-top: 0px;
}

    .product-content li {
        cursor: pointer;
    }

.product-title {
    font-size: 1.2rem;
    text-transform: capitalize;
    font-weight: 700;
    position: relative;
    color: #12263a;
    margin: 1rem 0;
    line-height: 30px;
    text-align: justify;

    direction: rtl;
}

    .product-title::after {
        content: "";
        position: absolute;
        left: 0;
        bottom: -10px;
        height: 4px;
        /*width: 85px;*/
        width: 100%;
        /*background: #212529;*/
        background: #6bddcd;
    }

.product-link {
    text-decoration: none;
    text-transform: uppercase;
    font-weight: 400;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 0.5rem;
    background: #245d55;
    color: #fff;
    padding: 0 0.3rem;
    transition: all 0.5s ease;
}

    .product-link:hover {
        opacity: 0.9;
    }

.product-rating {
    color: #ffc107;
}

    .product-rating span {
        font-weight: 600;
        color: #252525;
    }

.product-price {
    margin: 1rem 0;
    font-size: 1rem;
    font-weight: 700;
}

    .product-price span {
        font-weight: 400;
    }

.last-price span {
    color: #f64749;
    text-decoration: line-through;
}

.new-price span {
    color: #256eff;
}

.product-detail h2 {
    text-transform: capitalize;
    color: #12263a;
    padding-bottom: 0.6rem;

    direction:rtl;
}

.product-detail p {
    /*font-size: 1rem;*/
    font-size: 1.2rem;
    padding: 0.3rem;
    opacity: 0.8;
    text-align: justify;
    color: #212529;

    direction: rtl;
}

.purchase-info {
    margin: 1.5rem 0;
}

    .purchase-info input,
    .purchase-info .btn {
        border: 1.5px solid #ddd;
        border-radius: 25px;
        text-align: center;
        padding: 0.45rem 0.8rem;
        outline: 0;
        margin-right: 0.2rem;
        margin-bottom: 1rem;
    }

    .purchase-info input {
        width: 60px;
    }

    .purchase-info .btn {
        cursor: pointer;
        color: #fff;
    }

        .purchase-info .btn:first-of-type {
            background: #256eff;
        }

        .purchase-info .btn:last-of-type {
            background: #f64749;
        }

        .purchase-info .btn:hover {
            opacity: 0.9;
        }

.social-links {
    display: flex;
    align-items: center;
}

    .social-links a {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        color: #000;
        border: 1px solid #000;
        margin: 0 0.2rem;
        border-radius: 50%;
        text-decoration: none;
        font-size: 0.8rem;
        transition: all 0.5s ease;
    }

        .social-links a:hover {
            background: #000;
            border-color: transparent;
            color: #fff;
        }

@media screen and (min-width: 992px) {
    .card {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-gap: 1.5rem;
    }

    .card-wrapper {
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 50px;
    }

    .product-imgs {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .product-content {
        padding-top: 0;
    }
}

.img-select a {
    display: block; /* Ensure anchor fills the item */
    width: 100%;
    height: 100%;
    position: relative; /* Context for ::after */
    border: 2px solid transparent;
    border-radius: 5px;
    transition: border 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box; /* Include border in size */
}

@keyframes march {
    to {
        background-position: 100% 100%;
    }
}

.img-select a.active {
    /* Move border effect to pseudo-element to sit ABOVE the image */
    border: none; 
    background: none;
    animation: none;
}

.img-select a.active::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    border: 4px solid transparent; /* Thicker border space */
    border-radius: 5px;
    background: repeating-linear-gradient(white, white) padding-box, 
                repeating-linear-gradient(-45deg, black 0, black 25%, white 0, white 50%) 0 / .6em .6em;
    animation: march 12s linear infinite;
    /* Simulate border via background clip */
    /* Note: "border-image" is simpler but rounded corners support is poor. 
       The original trick used padding-box background clipping. 
       To overlay, we need this element to have transparent center. */
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    /* Actually, simplest way to show just border is borders on pseudo? 
       But gradient border needs specific tricks.
       Let's stick to the user's original exact CSS trick but applied on top.
    */
}

/* Wait, rewriting the ::after logic to replicate exact original behavior ON TOP */
.img-select a.active::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 2;
    border: 4px solid transparent;
    border-radius: 5px;
    background: repeating-linear-gradient(transparent, transparent) padding-box, 
                repeating-linear-gradient(-45deg, black 0, black 25%, transparent 0, transparent 50%) 0 / .6em .6em;
    animation: march 12s linear infinite;
}
/* Revert to simpler: Just border is visible? 
   No, the original was opaque white + dashed black gradient. 
   If I put it on top, the opaque white covers the image?
   Yes.
   The user said "Dotted border". 
   Let's just use a standard dashed border on top for now to guarantee visibility, or fix the z-index to put IMG behind A?
*/

/* Better Strategy: Make IMG the background of A? No, img tag is semantic. */
/* Strategy: ::after has transparent background, only Border is painted. */
.img-select a.active::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 5;
    border: 2px dashed #000; /* Simple fallback if gradient fails overlay */
    border-radius: 5px;
    /* Try to execute the marching ants effect as outline/border-image? */
    /* Restoring original logic simply: */
    border: 2px solid transparent;
    background: linear-gradient(transparent, transparent) padding-box, 
                repeating-linear-gradient(-45deg, black 0, black 25%, transparent 0, transparent 50%) 0 / .6em .6em border-box;
    animation: march 12s linear infinite;
}
