/* MMSN Gallery Plugin Frontend Styles */

.mmsn-gallery-wrapper {
    width: 100%;
    margin: 20px 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.mmsn-gallery-wrapper * {
    box-sizing: border-box;
}

.mmsn-gallery-empty {
    padding: 40px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-align: center;
    color: #64748b;
    font-size: 15px;
}

/* 1. CATEGORY CARD GRID DISPLAY */
.mmsn-gallery-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    width: 100%;
}

.mmsn-gallery-cat-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    height: 240px;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mmsn-gallery-cat-card:hover {
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15), 0 8px 10px -6px rgba(0,0,0,0.15);
}

.mmsn-gallery-cat-cover {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.5s ease;
}

.mmsn-gallery-cat-card:hover .mmsn-gallery-cat-cover {
    transform: scale(1.05);
}

.mmsn-gallery-cat-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 24px;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0.4) 60%, rgba(15, 23, 42, 0.1) 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
}

.mmsn-gallery-cat-name {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    line-height: 1.3;
}

.mmsn-gallery-cat-count {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #004E66;
    color: #ffffff;
    padding: 3px 10px;
    border-radius: 9999px;
    margin-bottom: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 2. MASONRY GALLERY IMAGES DISPLAY */
.mmsn-gallery-images-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 16px;
}

.mmsn-gallery-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    color: #334155;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}

.mmsn-gallery-back-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
    transform: translateX(-2px);
}

.mmsn-gallery-category-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
}

/* Masonry Columns config */
.mmsn-gallery-masonry {
    display: flex;
    gap: 16px;
    width: 100%;
}

.mmsn-gallery-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mmsn-gallery-item {
    display: block;
    width: 100%;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.1);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    background: #f1f5f9;
}

.mmsn-gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

.mmsn-gallery-item img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.mmsn-gallery-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    color: #ffffff;
    text-align: center;
    padding: 16px;
}

.mmsn-gallery-item:hover .mmsn-gallery-item-overlay {
    opacity: 1;
}

.mmsn-enlarge-icon {
    font-size: 20px;
    color: #ffffff;
    background: #004E66;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    transform: translateY(10px);
    transition: transform 0.25s ease;
}

.mmsn-gallery-item:hover .mmsn-enlarge-icon {
    transform: translateY(0);
}

.mmsn-gallery-item-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff !important;
    max-width: 90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
}

/* Spinner Loading */
.mmsn-gallery-loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px 0;
    width: 100%;
}

.mmsn-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(99, 102, 241, 0.1);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: mmsn-spin 1s linear infinite;
}

@keyframes mmsn-spin {
    to { transform: rotate(360deg); }
}

/* 3. LIGHTBOX MODULE (Fullscreen) */
.mmsn-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #004e6667;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    user-select: none;
}

.mmsn-lightbox-content {
    position: relative;
    max-width: 85%;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.mmsn-lightbox-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    display: block;
}

.mmsn-lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    font-size: 36px;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
    z-index: 1000000;
}

.mmsn-lightbox-close:hover {
    color: #ffffff;
    transform: scale(1.1);
}

.mmsn-lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    color: #94a3b8;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 1000000;
}

.mmsn-lightbox-arrow:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.mmsn-lightbox-prev {
    left: 24px;
}

.mmsn-lightbox-next {
    right: 24px;
}

.mmsn-lightbox-caption {
    text-align: center;
    margin-top: 20px;
    max-width: 700px;
    color: #ffffff;
}

.mmsn-lightbox-title {
    margin: 0 0 6px 0;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff !important;
    display: none;
}

.mmsn-lightbox-desc {
    margin: 0;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.4;
}

/* RESPONSIVE LAYOUTS */

/* 2 Columns on Tablet */
@media (max-width: 1024px) {
    .mmsn-gallery-masonry {
        flex-wrap: wrap;
    }
    .mmsn-gallery-column {
        flex: 0 0 calc(50% - 8px);
    }
    .mmsn-lightbox-arrow {
        width: 44px;
        height: 44px;
        font-size: 24px;
    }
    .mmsn-lightbox-prev {
        left: 12px;
    }
    .mmsn-lightbox-next {
        right: 12px;
    }
}

/* 1 Column on Mobile */
@media (max-width: 600px) {
    .mmsn-gallery-masonry {
        flex-wrap: wrap;
    }
    .mmsn-gallery-column {
        flex: 0 0 100%;
    }
    .mmsn-lightbox {
        padding: 16px;
    }
    .mmsn-lightbox-content {
        max-width: 95%;
    }
    .mmsn-lightbox-arrow {
        display: none !important; /* Hide arrows on small screens, rely on swipe or simple close */
    }
    .mmsn-lightbox-close {
        top: 16px;
        right: 16px;
    }
}
