/* ===== Primary Image Styles ===== */
.preview-item.primary-image {
    border: 3px solid #007bff !important;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3);
    position: relative;
}

.preview-item.primary-image::after {
    content: "رئيسية";
    position: absolute;
    top: 5px;
    right: 5px;
    background: #007bff;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    z-index: 10;
}

.primary-btn {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(255, 193, 7, 0.9);
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    z-index: 5;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    background: rgba(255, 193, 7, 1);
    transform: scale(1.1);
}

.preview-item.primary-image .primary-btn {
    background: rgba(0, 123, 255, 0.9);
}

.preview-item.primary-image .primary-btn:hover {
    background: rgba(0, 123, 255, 1);
}

/* ===== Option Images Primary Styles ===== */
.opt-img-thumb-wrap.primary-option-image {
    border: 2px solid #28a745 !important;
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.3);
    position: relative;
}

.opt-img-thumb-wrap.primary-option-image::after {
    content: "رئيسية";
    position: absolute;
    top: 2px;
    right: 2px;
    background: #28a745;
    color: white;
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 8px;
    font-weight: bold;
    z-index: 10;
}

.opt-img-primary {
    position: absolute;
    top: 2px;
    left: 2px;
    background: rgba(255, 193, 7, 0.9);
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    color: #fff;
    cursor: pointer;
    font-size: 10px;
    z-index: 5;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.opt-img-primary:hover {
    background: rgba(255, 193, 7, 1);
    transform: scale(1.1);
}

.opt-img-thumb-wrap.primary-option-image .opt-img-primary {
    background: rgba(40, 167, 69, 0.9);
}

.opt-img-thumb-wrap.primary-option-image .opt-img-primary:hover {
    background: rgba(40, 167, 69, 1);
}

/* ===== Edit Gallery Primary Styles ===== */
.edit-img-thumb.primary-image {
    border: 3px solid #007bff !important;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3);
}

.edit-img-thumb.primary-image .thumb-badge {
    background: #007bff !important;
}

.edit-img-thumb.primary-image::before {
    content: "الصورة الرئيسية";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 123, 255, 0.8));
    color: white;
    padding: 8px 4px 4px;
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    z-index: 5;
}

/* ===== Complete Image Display Styles ===== */
/* Homepage product cards */
.card-product .card-img img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
}

/* Category page product cards */
.container-product .card-product .card-img img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
}

/* Product page main and thumbnail images */
#mainImage {
    width: 100%;
    /*height: 400px;*/
    object-fit: cover;
    object-position: center;
    border-radius: 10px;
}

.select-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    object-position: center;
    border-radius: 6px;
    cursor: pointer;
}

/* Cart and favorites page images */
.item-img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
}

/* Search results images */
.search-results .card-product .card-img img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
}

/* Ensure no image overflow */
.card-img, .item-img-container {
    overflow: hidden;
    border-radius: 8px;
}

/* Mobile responsiveness for images */
@media (max-width: 768px) {
    .card-product .card-img img,
    .container-product .card-product .card-img img {
        height: 180px;
    }

    #mainImage {
        /*height: 300px;*/
    }

    .select-item img {
        width: 60px;
        height: 60px;
    }

    .item-img {
        width: 100px;
        height: 100px;
    }
}

/* ===== Inventory Read-Only Image Styles ===== */
.inv-img-wrap.read-only {
    position: relative;
    cursor: default !important;
}

.inv-img-wrap.read-only:hover .inv-img-readonly-overlay {
    opacity: 1;
}

.inv-img-readonly-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 14px;
    text-align: center;
    pointer-events: none;
}

.inv-img-readonly-overlay i {
    font-size: 20px;
    margin-bottom: 5px;
    color: #f39c12;
}

.inv-img-readonly-overlay span {
    font-size: 12px;
    font-weight: 600;
}

/* Option quantity message styling */
.option-qty-message {
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-5px); }
    20% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-5px); }
}