/* Media Gallery Modal Block Styles */

.sc-media-gallery-block {
    margin: 2rem 0;
}

/* Grid View */
.sc-media-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.sc-media-grid-item {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    cursor: pointer;
}

.sc-media-grid-item .sc-grid-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sc-media-grid-item-title {
    position: absolute;
    bottom: 0;
    left: 0;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    width: 100%;
    box-sizing: border-box;
    z-index: 1;
}

/* View All Media Button */
.sc-view-all-wrapper {
    text-align: center;
    margin-top: 2rem;
}

.sc-view-all-media-btn {
    padding: 12px 32px;
    background-color: #000;
    color: #fff;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.sc-view-all-media-btn:hover {
    background-color: #333;
}

/* Modal */
.sc-media-gallery-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background-color: rgba(0, 0, 0, 0.9);
}

.sc-media-gallery-modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sc-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.sc-modal-container {
    position: relative;
    width: 90%;
    max-width: 1200px;
    height: calc(100vh - 2rem);
    max-height: calc(100vh - 2rem);
    margin: 0 auto;
    z-index: 10000;
    background-color: #CCC;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #CCC;
    border-bottom: 1px solid #999;
    flex-shrink: 0;
}

.sc-modal-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #000;
}

/* Modal Filters */
.sc-modal-filters {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background-color: #CCC;
    border-bottom: 1px solid #999;
    flex-shrink: 0;
}

.sc-filter-label {
    display: inline-block;
    cursor: pointer;
}

.sc-filter-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

.sc-filter-btn {
    display: inline-block;
    background: transparent;
    border: 1px solid #666;
    color: #000;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border-radius: 4px;
    pointer-events: none;
}

.sc-filter-label:hover .sc-filter-btn {
    background-color: #999;
    color: #fff;
}

.sc-filter-radio:focus+.sc-filter-btn {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.sc-filter-radio:focus:not(:focus-visible)+.sc-filter-btn {
    outline: none;
}

.sc-modal-close {
    background: transparent;
    border: none;
    color: #000;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.sc-modal-close:hover {
    transform: scale(1.2);
}

.sc-modal-content {
    position: relative;
    flex: 1 1 0;
    overflow: hidden;
    background-color: #CCC;
    min-height: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    box-sizing: border-box;
}

/* Grid View (Initial View) */
.sc-modal-grid-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

.sc-modal-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    max-width: 100%;
    width: 100%;
}

.sc-modal-grid-item {
    position: relative;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 2px solid transparent;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.sc-modal-grid-item:hover {
    border-color: var(--global-palette1, #990001);
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.sc-modal-grid-item:focus {
    outline: 2px solid var(--global-palette1, #990001);
    outline-offset: 2px;
}

.sc-modal-grid-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    flex: 1;
}

.sc-modal-grid-video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    flex: 1;
}

.sc-modal-grid-video-wrapper .sc-modal-grid-thumbnail {
    opacity: 0.9;
}

.sc-modal-grid-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.sc-modal-grid-item:hover .sc-modal-grid-play-icon {
    transform: translate(-50%, -50%) scale(1.1);
}

/* Slider View (Hidden Initially) */
.sc-modal-slider-view {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

.sc-modal-slider-view[style*="display: flex"] {
    display: flex !important;
}

.sc-slider-content-wrapper {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 60px;
    overflow: hidden;
    min-height: 0;
    max-height: calc(100% - 140px);
}

/* Thumbnail Gallery (Preview) */
.sc-modal-thumbnails {
    background-color: rgba(0, 0, 0, 0.8);
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    height: 140px;
    max-height: 140px;
    min-height: 140px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
    flex-grow: 0;
    box-sizing: border-box;
}

.sc-thumbnails-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.5rem;
    justify-content: flex-start;
    align-items: center;
    padding: 0.25rem 0;
}

.sc-thumbnail-item {
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    transition: all 0.2s ease;
}

.sc-thumbnail-item:hover {
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.sc-thumbnail-item.active {
    border-color: var(--global-palette1, #990001);
    box-shadow: 0 0 0 1px rgba(153, 0, 1, 0.5);
}

.sc-thumbnail-item:focus {
    outline: 2px solid var(--global-palette1, #990001);
    outline-offset: 2px;
}

.sc-thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sc-thumbnail-video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.sc-thumbnail-video-wrapper .sc-thumbnail-image {
    opacity: 0.9;
}

.sc-thumbnail-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 0.6rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.sc-thumbnail-item:hover .sc-thumbnail-play-icon {
    transform: translate(-50%, -50%) scale(1.2);
}


/* Responsive styles */
@media (max-width: 1024px) {
    .sc-modal-grid-container {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.875rem;
    }

    .sc-modal-grid-view {
        padding: 1.25rem;
    }
}

@media (max-width: 767px) {
    .sc-modal-grid-container {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 0.625rem;
    }

    .sc-modal-grid-view {
        padding: 1rem;
    }

    .sc-modal-thumbnails {
        max-height: 110px;
        min-height: 110px;
        height: 110px;
        padding: 0.5rem;
    }

    .sc-thumbnails-container {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 0.375rem;
    }

    .sc-thumbnail-play-icon {
        font-size: 0.5rem;
    }
}

/* Modal media wrapper - basic */
.sc-modal-media-wrapper {
    width: 100%;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
}

/* Basic Image Carousel - following Splide.js tutorial */
.sc-modal-slider-view .splide__slide img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.sc-modal-slider-view .splide__slide iframe {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    aspect-ratio: 16 / 9;
    display: block;
}

/* Video iframe handling */
.sc-media-gallery-modal .splide__slide .video-iframe {
    position: relative;
    z-index: 2;
    max-width: 100%;
    max-height: 100%;
}

/* Empty Message */
.sc-gallery-empty-message {
    padding: 2rem;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .sc-modal-container {
        width: 95%;
        max-width: calc(100% - 20px);
    }

    .sc-media-gallery-modal .splide__arrow--prev {
        left: 5px !important;
    }

    .sc-media-gallery-modal .splide__arrow--next {
        right: 5px !important;
    }
}

@media (max-width: 480px) {
    .sc-media-gallery-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* Basic Splide Carousel Styles */
.sc-media-gallery-modal .splide {
    padding: 0;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
}

.sc-media-gallery-modal .splide__track {
    position: relative;
    width: 100%;
    height: 100%;
}

.sc-media-gallery-modal .splide__list {
    height: 100%;
    display: flex;
    align-items: center;
}

.sc-media-gallery-modal .splide__slide {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* Arrow styles - basic */
.sc-media-gallery-modal .splide .splide__arrow {
    background: rgba(0, 0, 0, 0.7) !important;
    border: none !important;
    color: white !important;
    opacity: 1 !important;
    transition: background 0.3s ease;
    width: 50px !important;
    height: 50px !important;
    z-index: 10001 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    cursor: pointer !important;
    border-radius: 50% !important;
}

.sc-media-gallery-modal .splide .splide__arrow:hover {
    background: rgba(0, 0, 0, 0.9) !important;
}

.sc-media-gallery-modal .splide .splide__arrow svg {
    fill: white !important;
    width: 24px !important;
    height: 24px !important;
}

.sc-media-gallery-modal .splide .splide__arrow--prev {
    left: 10px !important;
}

.sc-media-gallery-modal .splide .splide__arrow--next {
    right: 10px !important;
}

.sc-media-gallery-modal .splide .splide__arrow:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}