/* Dynamic Media Gallery Styles - Scoped to prevent conflicts */
.dmg-gallery-wrapper {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    background: #f8fafc;
    color: #1e293b;
    line-height: 1.6;
}

/* Header Styles */
.dmg-gallery-header {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.dmg-gallery-header button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 32px;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    background: #e2e8f0;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    min-width: 160px;
}

.dmg-gallery-header button.dmg-active {
    background: #ff4c00;
    color: #ffffff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.dmg-gallery-header button:hover {
    background: #e04300;
    color: #ffffff;
    transform: translateY(-1px);
}

/* Gallery Grid */
.dmg-gallery-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 32px;
    max-width: 1440px;
    margin: 0 auto;
}

@media (max-width: 1024px) {
    .dmg-gallery-container {
        grid-template-columns: repeat(2, 1fr);
        padding: 24px;
    }
}

@media (max-width: 640px) {
    .dmg-gallery-container {
        grid-template-columns: 1fr;
        padding: 16px;
    }
}

.dmg-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    opacity: 0;
    transform: translateY(20px);
    animation: dmg-fadeInUp 0.5s ease forwards;
    cursor: pointer;
    background: #f0f0f0;
    height: 300px; /* Fixed height for uniformity */
}

.dmg-gallery-item img, 
.dmg-gallery-item video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Perfect crop without distortion */
    transition: transform 0.4s ease;
}

.dmg-gallery-item:hover img, 
.dmg-gallery-item:hover video {
    transform: scale(1.03);
}

.dmg-video-item::after {
    content: '\f144';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 48px;
    opacity: 0.7;
    z-index: 2;
    pointer-events: none;
}

.dmg-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.1) url('data:image/svg+xml;utf8,<svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient x1="8.042%" y1="0%" x2="65.682%" y2="23.865%" id="a"><stop stop-color="%23fff" stop-opacity="0" offset="0%"/><stop stop-color="%23fff" stop-opacity=".631" offset="63.146%"/><stop stop-color="%23fff" offset="100%"/></linearGradient></defs><g fill="none" fill-rule="evenodd"><g transform="translate(1 1)"><path d="M36 18c0-9.94-8.06-18-18-18" stroke="url(%23a)" stroke-width="2"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.9s" repeatCount="indefinite"/></path><circle fill="%23fff" cx="36" cy="18" r="1"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.9s" repeatCount="indefinite"/></circle></g></g></svg>') no-repeat center;
    background-size: 40px;
    z-index: 3;
}

/* Load More Button */
.dmg-load-more {
    text-align: center;
    padding: 32px 0;
}

.dmg-load-more button {
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #ff4c00;
    color: #ffffff;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    min-width: 180px;
}

.dmg-load-more button:hover {
    background: #e04300;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Lightbox Styles */
.dmg-lightbox {
    display: none;
    position: fixed;
    z-index: 99999; /* ensure it's always on top */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
    padding: 32px;
}

.dmg-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    width: auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.dmg-lightbox-content img,
.dmg-lightbox-content video {
    width: 100%;
    height: auto;
    max-height: 80vh;
    border-radius: 12px;
    object-fit: contain;
    background: transparent;
    display: block;
}

/* Close button (moved inside top-right of content) */
.dmg-lightbox-close {
    position: absolute;
    top: 12px;   /* instead of -40px */
    right: 12px; /* keep inside */
    font-size: 28px;
    color: #ffffff;
    background: rgba(0,0,0,0.7);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    text-align: center;
    line-height: 40px;
    cursor: pointer;
    transition: background 0.3s ease;
    z-index: 100000; /* above video/image */
}

.dmg-lightbox-close:hover {
    background: rgba(0,0,0,0.9);
}


.dmg-lightbox-controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    gap: 12px;
}

.dmg-lightbox-controls button {
    background: rgba(0,0,0,0.7);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.3s ease;
}

.dmg-lightbox-controls button:hover {
    background: rgba(0,0,0,0.9);
}

/* Animation */
@keyframes dmg-fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}