/**
 * Professional Lightweight Image Gallery Styles
 * Consistent with Tailwind design system
 */

/* Gallery Container */
.gallery-container {
    position: relative;
}

/* Gallery Grid */
.school-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 768px) {
    .school-gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* Collapsible Gallery State */
.gallery-collapsible .school-gallery-grid {
    max-height: 450px; /* Exactly 2 rows on desktop (3 items per row) */
    overflow: hidden;
}

@media (max-width: 767px) {
    .gallery-collapsible .school-gallery-grid {
        max-height: 360px; /* Exactly 2 rows on mobile (1 item per row) */
    }
}

.gallery-collapsible.expanded .school-gallery-grid {
    max-height: 10000px; /* Large enough to show all images */
}

/* Expand Overlay */
.gallery-expand-overlay {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 1.5rem;
    margin-top: -120px;
    height: 120px;
    background: linear-gradient(to top, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.95) 40%, transparent 100%);
    pointer-events: none;
    transition: all 0.3s ease;
}

.gallery-collapsible.expanded .gallery-expand-overlay {
    margin-top: 0;
    background: transparent;
    height: auto;
    padding-top: 1.5rem;
    padding-bottom: 0;
}

/* Expand Button */
.gallery-expand-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border: none;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.gallery-expand-btn:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.gallery-expand-btn:active {
    transform: translateY(0);
}

.gallery-expand-btn:focus {
    outline: 2px solid #f59e0b;
    outline-offset: 2px;
}

.expand-icon {
    transition: transform 0.3s ease;
}

.gallery-collapsible.expanded .expand-icon {
    transform: rotate(180deg);
}

.gallery-collapsible.expanded .gallery-expand-btn .expand-text {
    display: none;
}

.gallery-collapsible.expanded .gallery-expand-btn::before {
    content: 'Ver menos imágenes';
}

/* Smooth transition for gallery items */
.gallery-item {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Gallery Item */
.gallery-item {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

/* Video Thumbnail Wrapper */
.video-thumbnail-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Video Placeholder (when no thumbnail available) */
.video-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Video Play Overlay */
.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.gallery-item-video:hover .video-play-overlay {
    background: rgba(0, 0, 0, 0.5);
}

/* Video Play Button */
.video-play-button {
    width: 80px;
    height: 80px;
    background: rgba(245, 158, 11, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.gallery-item-video:hover .video-play-button {
    background: rgba(217, 119, 6, 1);
    transform: scale(1.1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.video-play-button i {
    margin-left: 4px; /* Slight offset for visual centering */
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* Gallery Item Overlay */
.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.gallery-item-caption {
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Featured Badge */
.gallery-item-featured {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

/* Modal */
.gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

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

.gallery-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.3s ease;
}

.gallery-modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    z-index: 10;
    animation: scaleIn 0.3s ease;
}

/* Modal Controls */
.gallery-modal-close,
.gallery-modal-prev,
.gallery-modal-next {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 20;
}

.gallery-modal-next {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    z-index: 1001;
    pointer-events: auto;
}

.gallery-modal-close:hover,
.gallery-modal-prev:hover,
.gallery-modal-next:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.gallery-modal-close:active,
.gallery-modal-prev:active,
.gallery-modal-next:active {
    transform: scale(0.95);
}

.gallery-modal-close {
    top: 1rem;
    right: 1rem;
}

.gallery-modal-prev {
    left: -60px;
    top: 50%;
    transform: translateY(-50%);
}

.gallery-modal-next {
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
}

@media (max-width: 768px) {
    .gallery-modal-prev {
        left: 0.5rem;
        bottom: 1rem;
        top: auto;
        transform: none;
    }
    
    .gallery-modal-next {
        right: 0.5rem;
        bottom: 1rem;
        top: auto;
        transform: none;
    }
}

/* Modal Media Container */
.gallery-modal-media {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.gallery-modal-media > * {
    pointer-events: auto;
}

/* Modal Image */
.gallery-modal-img {
    max-width: 90vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Modal Video */
.gallery-modal-video {
    width: 90vw;
    height: 50.625vw; /* 16:9 aspect ratio */
    max-width: 1280px;
    max-height: 720px;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

@media (max-width: 768px) {
    .gallery-modal-video {
        width: 95vw;
        height: 53.4375vw; /* 16:9 aspect ratio */
    }
}

.gallery-modal-image {
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    display: block;
}

/* Modal Caption */
.gallery-modal-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 2rem 1.5rem 1.5rem;
    font-size: 1rem;
    text-align: center;
}

/* Modal Counter */
.gallery-modal-counter {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loading State */
.gallery-item.loading {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Empty State */
.gallery-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    background-color: #f9fafb;
    border-radius: 0.75rem;
    border: 2px dashed #d1d5db;
}

.gallery-empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: #9ca3af;
}

.gallery-empty-text {
    color: #6b7280;
    font-size: 1rem;
}

/* Accessibility */
.gallery-modal-close:focus,
.gallery-modal-prev:focus,
.gallery-modal-next:focus,
.gallery-item:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .gallery-modal {
        display: none !important;
    }
}

/* ===================================
   Description Expand/Collapse Styles
   =================================== */

/* Description Container */
.description-container {
    position: relative;
}

/* Description Content */
.description-content {
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Collapsible State */
.description-collapsible .description-content {
    max-height: 300px; /* Show approximately 10-12 lines of text */
}

.description-collapsible.expanded .description-content {
    max-height: 10000px; /* Large enough to show all content */
}

/* Description Expand Overlay */
.description-expand-overlay {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 1.5rem;
    margin-top: -120px;
    height: 120px;
    background: linear-gradient(to top, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.95) 40%, transparent 100%);
    pointer-events: none;
    transition: all 0.3s ease;
}

.description-collapsible.expanded .description-expand-overlay {
    margin-top: 0;
    background: transparent;
    height: auto;
    padding-top: 1.5rem;
    padding-bottom: 0;
}

/* Description Expand Button */
.description-expand-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border: none;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.description-expand-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.description-expand-btn:active {
    transform: translateY(0);
}

.description-expand-btn:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.description-expand-btn .expand-icon {
    transition: transform 0.3s ease;
}

.description-collapsible.expanded .description-expand-btn .expand-icon {
    transform: rotate(180deg);
}

.description-collapsible.expanded .description-expand-btn .expand-text {
    display: none;
}

.description-collapsible.expanded .description-expand-btn::before {
    content: 'Ver menos';
}
