.lightbox-overlay,
.appointment-modal-overlay {
    position: fixed;
    top: 0; /* Ensure it starts at the top */
    left: 0;
    width: 100%;
    height: 100vh; /* Cover the full viewport height */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    overflow-y: auto; /* Allow scrolling within the modal if content is too tall */
}

.lightbox-overlay {
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.appointment-modal-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.lightbox-overlay.visible,
.appointment-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* This class is added via JS to prevent background scrolling */
body.modal-open {
    overflow: hidden;
}


/* --- The rest of the styling --- */

.lightbox-content {
    position: relative;
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-content img, .lightbox-content iframe {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: zoom-in;
    transition: transform 0.3s;
}
.lightbox-content iframe {
    width: 100%;
    height: 100%;
    background-color: #555;
    border: none;
}
.lightbox-content img.zoomed {
    transform: scale(1.5);
    cursor: zoom-out;
}
.lightbox-close, .lightbox-nav {
    position: absolute;
    background: rgba(30,30,30,0.6);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    z-index: 10;
}
.lightbox-close:hover, .lightbox-nav:hover {
    background: rgba(0,0,0,0.8);
}
.lightbox-close { top: 1rem; right: 1rem; width: 40px; height: 40px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.appointment-modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s;
}
.appointment-modal-overlay.visible .appointment-modal-content {
    transform: scale(1);
}

.share-button-container {
    position: relative;
}
.share-options {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column; /* vertical list for new options */
    min-width: 150px;
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s;
    z-index: 10;
}
.share-options.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.share-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: #374151;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.2s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.share-option:hover {
    background-color: #f3f4f6;
    color: #111827;
}

#wishlist-btn.active {
    background-color: #202328;
    border-color: #202328;
}
#wishlist-btn.active svg {
    fill: #ffffff;
    stroke: #ffffff;
}

/* --- Upgraded gallery / lightbox --- */
.lightbox-content video {
    max-width: 100%;
    max-height: 100%;
    outline: none;
}
.mg-lightbox-counter {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.65);
    color: #fff;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    padding: 4px 14px;
    border-radius: 999px;
    pointer-events: none;
}
.mg-fade-in {
    animation: mgFadeIn 0.35s ease;
}
@keyframes mgFadeIn {
    from { opacity: 0; transform: scale(1.015); }
    to   { opacity: 1; transform: scale(1); }
}
/* Mobile gallery position indicator: thin lines, current one dark and slightly longer */
.mg-dots { display: flex; justify-content: center; align-items: center; gap: 6px; padding: 12px 0 0; margin-bottom: 1.25rem; }
.mg-dots span { display: block; width: 18px; height: 2px; border-radius: 1px; background: #d9d9d9; transition: background 0.25s ease, width 0.25s ease; }
.mg-dots span.is-active { width: 28px; background: #202328; }

/* Hide scrollbar on the thumbnail strip / mobile gallery without losing scroll */
.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* --- Add to Cart button animation --- */
.mg-cart-btn {
    position: relative;
    overflow: hidden;
    transition: background-color 0.35s ease, transform 0.15s ease;
}
.mg-cart-btn:hover:not(:disabled) { background-color: rgba(32, 35, 40, 0.9); }
.mg-cart-btn:active:not(:disabled) { transform: scale(0.975); }
.mg-cart-label { transition: opacity 0.25s ease, transform 0.25s ease; display: inline-block; }
.mg-cart-success {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.22, 1.2, 0.36, 1);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}
.mg-cart-success svg { width: 18px; height: 18px; }
.mg-check-path {
    stroke-dasharray: 30;
    stroke-dashoffset: 30;
}
/* Adding: soft shimmer sweep while the request is in flight */
.mg-cart-btn.mg-adding::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.25) 50%, transparent 70%);
    transform: translateX(-100%);
    animation: mgShimmer 0.9s ease infinite;
}
@keyframes mgShimmer { to { transform: translateX(100%); } }
/* Added: turn gold, slide the label away, slide the check in and draw it */
.mg-cart-btn.mg-added {
    background-color: #C09B48;
}
.mg-cart-btn.mg-added .mg-cart-label { opacity: 0; transform: translateY(-120%); }
.mg-cart-btn.mg-added .mg-cart-success { opacity: 1; transform: translateY(0); }
.mg-cart-btn.mg-added .mg-check-path {
    animation: mgDrawCheck 0.45s 0.15s ease forwards;
}
@keyframes mgDrawCheck { to { stroke-dashoffset: 0; } }
/* Error: quick head-shake */
.mg-cart-btn.mg-shake { animation: mgShake 0.4s ease; }
@keyframes mgShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-3px); }
}