/* ==========================================================
   🎨 MSNS SCHOOL GALLERY — Responsive Grid
   ========================================================== */

body.gallery-page {
    background: #ffffff;
    background-image: 
        radial-gradient(at 0% 0%, rgba(220, 38, 38, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(234, 179, 8, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    color: #52525b;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px 20px;
    margin: 0;
    overflow-x: clip;
}

/* ==========================================================
   GALLERY GRID
   ========================================================== */
.gallery-grid {
    display: grid;
    /* Mobile: 2 per row */
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
}

/* Tablet: 3 per row */
@media (min-width: 480px) {
    .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}

/* Small desktop: 4 per row */
@media (min-width: 768px) {
    .gallery-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

/* Desktop: 5 per row */
@media (min-width: 1024px) {
    .gallery-grid { grid-template-columns: repeat(5, 1fr); gap: 18px; }
}

/* Large desktop: 6 per row */
@media (min-width: 1400px) {
    .gallery-grid { grid-template-columns: repeat(6, 1fr); gap: 20px; }
}

/* ==========================================================
   GALLERY CARD
   ========================================================== */
.gallery-card {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    background: linear-gradient(135deg, #fef3c7, #fef9c3);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.12);
    transition: 
        transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.35s ease,
        border-color 0.35s ease;
    will-change: transform;
}

.gallery-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    pointer-events: none;
    background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
    opacity: 0.85;
    transition: opacity 0.35s ease;
}

.gallery-card:hover {
    transform: translateY(-6px) scale(1.02);
    border-color: rgba(220, 38, 38, 0.4);
    box-shadow: 
        0 15px 35px -12px rgba(185, 28, 28, 0.35),
        0 0 0 2px rgba(234, 179, 8, 0.35);
}

.gallery-card:hover::after {
    opacity: 1;
}

.gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-user-drag: none;
    user-select: none;
}

.gallery-card:hover img {
    transform: scale(1.08);
}

/* Card Title Overlay */
.gallery-card-title {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 12px 10px;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: 0.2px;
    z-index: 2;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: transform 0.35s ease;
}

.gallery-card:hover .gallery-card-title {
    transform: translateY(-2px);
}

/* No-Image Placeholder */
.gallery-card.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #b45309;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.gallery-card.no-image::after { display: none; }

.gallery-card.no-image i {
    font-size: 1.8rem;
    opacity: 0.65;
}

/* ==========================================================
   LOADING + EMPTY STATES
   ========================================================== */
.gallery-loading-state,
.gallery-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 20px;
}

.gallery-loading-state {
    color: #b91c1c;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.gallery-loading-state i {
    font-size: 2rem;
}

.gallery-empty-state {
    color: #71717a;
    background: rgba(255, 255, 255, 0.6);
    border: 1px dashed rgba(0, 0, 0, 0.12);
}

.gallery-empty-state i {
    font-size: 2.5rem;
    color: #b45309;
    opacity: 0.6;
}

/* ==========================================================
   🖼️ MODAL (Full Screen Lightbox)
   ========================================================== */
.gallery-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.gallery-modal.active {
    display: flex;
    opacity: 1;
}

/* Close Button */
.gallery-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(220, 38, 38, 0.4);
    color: #f87171;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 10001;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.gallery-modal-close:hover {
    background: #dc2626;
    color: #ffffff;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 0 30px rgba(220, 38, 38, 0.6);
}

/* Modal Nav */
.gallery-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(234, 179, 8, 0.4);
    backdrop-filter: blur(12px);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    z-index: 10001;
    transition: all 0.3s ease;
}

.gallery-modal-nav:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border-color: rgba(234, 179, 8, 0.8);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 0 25px rgba(220, 38, 38, 0.5);
}

.gallery-modal-prev { left: 20px; }
.gallery-modal-next { right: 20px; }

/* Modal Inner */
.gallery-modal-inner {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    background: linear-gradient(135deg, rgba(18, 26, 43, 0.98), rgba(15, 23, 42, 0.98));
    border: 1px solid rgba(234, 179, 8, 0.35);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 
        0 30px 80px rgba(0, 0, 0, 0.8),
        0 0 60px rgba(220, 38, 38, 0.15);
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.4s ease;
    position: relative;
    z-index: 10000;
}

.gallery-modal.active .gallery-modal-inner {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Modal Media */
.gallery-modal-media {
    position: relative;
    background: #000;
    min-height: 260px;
    max-height: 55vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-modal-media img {
    width: 100%;
    height: 100%;
    max-height: 55vh;
    object-fit: contain;
    display: block;
    animation: modalImgIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalImgIn {
    from { opacity: 0; transform: scale(1.05); filter: blur(10px); }
    to   { opacity: 1; transform: scale(1); filter: blur(0); }
}

.modal-counter {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(234, 179, 8, 0.4);
    border-radius: 50px;
    color: #f59e0b;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    z-index: 3;
}

/* Modal Content */
.gallery-modal-content {
    padding: 26px 22px 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.4);
    overflow-y: auto;
}

.modal-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.15), rgba(234, 179, 8, 0.15));
    border: 1px solid rgba(234, 179, 8, 0.4);
    border-radius: 50px;
    color: #f59e0b;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    align-self: flex-start;
    width: fit-content;
}

.modal-badge i { font-size: 0.75rem; }

.modal-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.3;
    margin: 0;
}

.modal-line {
    height: 4px;
    width: 70px;
    border-radius: 4px;
    background: linear-gradient(90deg, #dc2626, #f59e0b, #dc2626);
    background-size: 200% 100%;
    animation: modalLineFlow 3s ease infinite;
    box-shadow: 0 2px 10px rgba(220, 38, 38, 0.5);
}

@keyframes modalLineFlow {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

.modal-desc {
    font-size: 0.92rem;
    color: #cbd5e1;
    line-height: 1.7;
    margin: 0;
    font-weight: 500;
}

/* ==========================================================
   📱 MOBILE MODAL
   ========================================================== */
@media (max-width: 767.98px) {
    .gallery-modal {
        padding: 0;
        align-items: flex-end;
    }

    .gallery-modal-inner {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 24px 24px 0 0;
    }

    .gallery-modal-media {
        min-height: 200px;
        max-height: 45vh;
    }

    .gallery-modal-media img {
        max-height: 45vh;
    }

    .gallery-modal-content {
        padding: 22px 20px 30px;
        gap: 10px;
    }

    .modal-title { font-size: 1.15rem; }
    .modal-desc  { font-size: 0.85rem; line-height: 1.6; }

    .gallery-modal-close {
        top: 14px;
        right: 14px;
        width: 40px;
        height: 40px;
    }

    .gallery-modal-nav { display: none; }

    .modal-counter {
        top: 12px;
        right: 12px;
        padding: 5px 12px;
        font-size: 0.68rem;
    }
}

/* ==========================================================
   🖥️ DESKTOP MODAL — Side-by-side
   ========================================================== */
@media (min-width: 768px) {
    .gallery-modal-inner {
        grid-template-columns: 1.35fr 1fr;
    }

    .gallery-modal-media {
        min-height: 500px;
        max-height: 80vh;
        border-right: 1px solid rgba(255, 255, 255, 0.06);
    }

    .gallery-modal-media img {
        max-height: 80vh;
    }

    .gallery-modal-content {
        padding: 40px 36px;
    }

    .modal-title { font-size: 1.6rem; }
    .modal-desc  { font-size: 0.95rem; line-height: 1.75; }
}

@media (min-width: 1200px) {
    .gallery-modal-content { padding: 50px 44px; }
    .modal-title { font-size: 1.75rem; }
}

/* ==========================================================
   ♿ REDUCED MOTION
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
    .gallery-card,
    .gallery-card img,
    .gallery-modal-inner,
    .gallery-modal-media img,
    .modal-line {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
   }
/* ==========================================================
   🆕 GALLERY TABS & ALBUM STYLES
   ========================================================== */

/* Tabs Container */
.gallery-tabs-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    grid-column: 1 / -1;
}

.gallery-tab-btn {
    background: #ffffff;
    border: 2px solid rgba(220, 38, 38, 0.15);
    color: #52525b;
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

.gallery-tab-btn i {
    font-size: 1.1rem;
    color: #dc2626;
    transition: color 0.3s ease;
}

.gallery-tab-btn:hover {
    border-color: rgba(220, 38, 38, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(220, 38, 38, 0.1);
}

.gallery-tab-btn.active {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.25);
}

.gallery-tab-btn.active i {
    color: #fef3c7;
}

/* Album Card Element */
.album-card {
    border: 2px solid rgba(234, 179, 8, 0.2);
}

.album-card::after {
    background: linear-gradient(180deg, rgba(0,0,0,0.1) 40%, rgba(0, 0, 0, 0.8) 100%);
}

.album-card-title {
    font-size: 1.1rem;
    text-align: center;
    bottom: 10px;
}

.album-count-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    color: #fef3c7;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    z-index: 3;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

/* Album View Header */
.album-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    grid-column: 1 / -1;
    padding-bottom: 15px;
    border-bottom: 2px dashed rgba(220, 38, 38, 0.2);
}

.album-back-btn {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #dc2626;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.album-back-btn:hover {
    background: #fef2f2;
    border-color: #dc2626;
    transform: translateX(-4px);
}

.current-album-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    color: #1f2937;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
