/* ============================================
   School Gallery Manager – Frontend Styles
   ============================================ */

/* ── Filter Tabs — Base ── */
.sgm-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 25px;
    justify-content: center;
    padding: 0;
    list-style: none;
}

.sgm-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border: none;
    background: none;
    color: #555;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    line-height: 1.4;
    position: relative;
}

.sgm-tab:hover {
    color: #222;
}

.sgm-tab:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.sgm-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 50px;
    background: rgba(0,0,0,0.07);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    transition: all 0.3s ease;
}

/* ──────────────────────────────
   Tab Style: PILLS (default)
   ────────────────────────────── */
.sgm-tabs-pills {
    gap: 10px;
}

.sgm-tabs-pills .sgm-tab {
    padding: 10px 24px;
    border-radius: 50px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #4b5563;
}

.sgm-tabs-pills .sgm-tab:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.sgm-tabs-pills .sgm-tab.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.sgm-tabs-pills .sgm-tab.active .sgm-tab-count {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

/* ──────────────────────────────
   Tab Style: UNDERLINE
   ────────────────────────────── */
.sgm-tabs-underline {
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0;
}

.sgm-tabs-underline .sgm-tab {
    padding: 12px 24px;
    border-radius: 0;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    color: #6b7280;
}

.sgm-tabs-underline .sgm-tab:hover {
    color: #1f2937;
    border-bottom-color: #d1d5db;
}

.sgm-tabs-underline .sgm-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 600;
}

.sgm-tabs-underline .sgm-tab.active .sgm-tab-count {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
}

/* ──────────────────────────────
   Tab Style: BOXED
   ────────────────────────────── */
.sgm-tabs-boxed {
    gap: 0;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 5px;
    display: inline-flex;
    width: auto;
    margin-left: auto;
    margin-right: auto;
}

.sgm-tabs-boxed .sgm-tab {
    padding: 10px 22px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: #6b7280;
}

.sgm-tabs-boxed .sgm-tab:hover {
    color: #1f2937;
}

.sgm-tabs-boxed .sgm-tab.active {
    background: #fff;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    font-weight: 600;
}

.sgm-tabs-boxed .sgm-tab.active .sgm-tab-count {
    background: #2563eb;
    color: #fff;
}

/* ──────────────────────────────
   Tab Style: ROUNDED OUTLINE
   ────────────────────────────── */
.sgm-tabs-rounded {
    gap: 10px;
}

.sgm-tabs-rounded .sgm-tab {
    padding: 10px 24px;
    border-radius: 8px;
    background: transparent;
    border: 2px solid #d1d5db;
    color: #4b5563;
}

.sgm-tabs-rounded .sgm-tab:hover {
    border-color: #9ca3af;
    color: #1f2937;
    background: #f9fafb;
}

.sgm-tabs-rounded .sgm-tab.active {
    border-color: #2563eb;
    color: #2563eb;
    background: rgba(37, 99, 235, 0.04);
    font-weight: 600;
}

.sgm-tabs-rounded .sgm-tab.active .sgm-tab-count {
    background: #2563eb;
    color: #fff;
}

/* ── Responsive Tabs ── */
@media (max-width: 767px) {
    .sgm-tabs {
        gap: 6px;
    }

    .sgm-tab {
        padding: 8px 16px;
        font-size: 13px;
    }

    .sgm-tabs-boxed {
        flex-wrap: wrap;
        width: 100%;
    }

    .sgm-tabs-underline {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .sgm-tabs-underline::-webkit-scrollbar {
        display: none;
    }

    .sgm-tabs-underline .sgm-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ── Grid Layout ── */
.sgm-grid {
    display: grid;
    gap: 10px;
}

.sgm-cols-1 { grid-template-columns: repeat(1, 1fr); }
.sgm-cols-2 { grid-template-columns: repeat(2, 1fr); }
.sgm-cols-3 { grid-template-columns: repeat(3, 1fr); }
.sgm-cols-4 { grid-template-columns: repeat(4, 1fr); }
.sgm-cols-5 { grid-template-columns: repeat(5, 1fr); }
.sgm-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Tablet */
@media (max-width: 1024px) {
    .sgm-cols-tablet-1 { grid-template-columns: repeat(1, 1fr); }
    .sgm-cols-tablet-2 { grid-template-columns: repeat(2, 1fr); }
    .sgm-cols-tablet-3 { grid-template-columns: repeat(3, 1fr); }
    .sgm-cols-tablet-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Mobile */
@media (max-width: 767px) {
    .sgm-cols-mobile-1 { grid-template-columns: repeat(1, 1fr); }
    .sgm-cols-mobile-2 { grid-template-columns: repeat(2, 1fr); }
    .sgm-cols-mobile-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ── Masonry Layout ── */
.sgm-layout-masonry {
    display: grid;
    grid-template-rows: masonry;
}

/* ── Gallery Item ── */
.sgm-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #f0f0f0;
    cursor: pointer;
    text-decoration: none;
    display: block;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.sgm-item.sgm-hidden {
    display: none;
}

.sgm-item.sgm-fade-out {
    opacity: 0;
    transform: scale(0.95);
}

.sgm-item.sgm-fade-in {
    opacity: 1;
    transform: scale(1);
}

/* Aspect ratio container */
.sgm-ratio {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.sgm-ratio .sgm-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Direct image (masonry / auto) */
.sgm-layout-masonry .sgm-img,
.sgm-item > .sgm-img {
    display: block;
    width: 100%;
    height: auto;
}

/* ── Hover Effects ── */
.sgm-img {
    transition: transform 0.4s ease, filter 0.4s ease;
}

.sgm-hover-zoom:hover .sgm-img {
    transform: scale(1.08);
}

.sgm-hover-brighten:hover .sgm-img {
    filter: brightness(1.15);
}

/* Overlay */
.sgm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.sgm-hover-overlay:hover .sgm-overlay {
    opacity: 1;
}

.sgm-overlay svg {
    color: #fff;
}

/* ── Caption ── */
.sgm-caption {
    padding: 8px 10px;
    font-size: 13px;
    color: #333;
    text-align: center;
    line-height: 1.4;
}

/* ── Lazy Load ── */
.sgm-lazy {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.sgm-lazy.sgm-loaded {
    opacity: 1;
}

/* ============================================
   Lightbox
   ============================================ */
.sgm-lightbox-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sgm-lightbox-backdrop.sgm-lb-open {
    opacity: 1;
    visibility: visible;
}

.sgm-lightbox-inner {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sgm-lightbox-inner img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    transition: opacity 0.25s ease;
}

.sgm-lightbox-caption {
    position: absolute;
    bottom: -36px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
}

.sgm-lightbox-close {
    position: fixed;
    top: 20px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.sgm-lightbox-close:hover {
    background: rgba(255,255,255,0.2);
}

.sgm-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.sgm-lightbox-nav:hover {
    background: rgba(255,255,255,0.2);
}

.sgm-lightbox-prev {
    left: 20px;
}

.sgm-lightbox-next {
    right: 20px;
}

.sgm-lightbox-counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    z-index: 10;
}

/* Mobile lightbox */
@media (max-width: 767px) {
    .sgm-lightbox-inner img {
        max-width: 95vw;
        max-height: 80vh;
    }

    .sgm-lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .sgm-lightbox-prev { left: 10px; }
    .sgm-lightbox-next { right: 10px; }
}
