/**
 * Fundraiser Media Gallery
 * Upload UI, public gallery display, and lightbox
 */

/* ============================================
   Upload UI (Create/Edit Form)
   ============================================ */

.ssb-gallery-upload {
    margin-top: 0.5em;
}

.ssb-gallery-upload__label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.ssb-gallery-upload__dropzone {
    border: 2px dashed #d4c2e3;
    border-radius: 8px;
    padding: 2em;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    background: #faf7fc;
}

.ssb-gallery-upload__dropzone:hover,
.ssb-gallery-upload__dropzone.ssb-dragover {
    border-color: #9f76be;
    background: #f3ecf8;
}

.ssb-gallery-upload__dropzone-icon {
    font-size: 2em;
    color: #9f76be;
    margin-bottom: 0.5em;
}

.ssb-gallery-upload__dropzone-text {
    font-size: 0.9em;
    color: #666;
    line-height: 1.6;
}

.ssb-gallery-upload__dropzone-text strong {
    color: #9f76be;
}

.ssb-gallery-upload__input {
    display: none;
}

/* Preview grid in form */
.ssb-gallery-upload__preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 1em;
}

.ssb-gallery-upload__item {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    aspect-ratio: 1;
    background: #f0f0f0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.ssb-gallery-upload__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ssb-gallery-upload__item--video {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #23152e;
    color: #fff;
    font-size: 0.75em;
    text-align: center;
    padding: 0.5em;
}

.ssb-gallery-upload__item--video span {
    opacity: 0.8;
    word-break: break-all;
}

button.ssb-gallery-upload__remove,
.ssb-gallery-upload__item button.ssb-gallery-upload__remove,
.ssb-fundraiser-form button.ssb-gallery-upload__remove,
.ssb-fundraiser-form-container button.ssb-gallery-upload__remove {
    all: unset !important;
    position: absolute !important;
    top: 5px !important;
    right: 5px !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 20px !important;
    max-height: 20px !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.7) !important;
    color: transparent !important;
    font-size: 0 !important;
    overflow: hidden !important;
    cursor: pointer !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4) !important;
    box-sizing: border-box !important;
    z-index: 2 !important;
}

button.ssb-gallery-upload__remove::before,
.ssb-gallery-upload__item button.ssb-gallery-upload__remove::before {
    content: '\00D7' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 20px !important;
    height: 20px !important;
    line-height: 20px !important;
    text-align: center !important;
    color: #fff !important;
    font-size: 14px !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-weight: bold !important;
}

button.ssb-gallery-upload__remove:hover,
.ssb-gallery-upload__item button.ssb-gallery-upload__remove:hover {
    background: #c0392b !important;
}

/* Video URL input */
.ssb-gallery-video-input {
    display: flex;
    gap: 8px;
    margin-top: 1em;
}

.ssb-gallery-video-input input {
    flex: 1;
}

.ssb-gallery-video-input button {
    flex-shrink: 0;
}

/* ============================================
   Public Gallery Display
   ============================================ */

.ssb-gallery {
    margin: 2em 0;
}

.ssb-gallery__title {
    font-size: 1.25em;
    font-weight: 600;
    color: #23152e;
    margin-bottom: 1em;
    padding-bottom: 0.5em;
    border-bottom: 2px solid #e3d2ef;
}

.ssb-gallery__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.ssb-gallery__item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 4/3;
    cursor: pointer;
    background: #f0f0f0;
    box-shadow: 0 2px 8px rgba(35, 21, 46, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ssb-gallery__item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(35, 21, 46, 0.14);
}

.ssb-gallery__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.ssb-gallery__item:hover img {
    transform: scale(1.03);
}

/* Video items in gallery */
.ssb-gallery__item--video {
    background: #1a0e23;
}

.ssb-gallery__item--video img {
    opacity: 0.85;
}

.ssb-gallery__video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    background: rgba(159, 118, 190, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.ssb-gallery__item--video:hover .ssb-gallery__video-play {
    background: rgba(159, 118, 190, 1);
    transform: translate(-50%, -50%) scale(1.08);
}

.ssb-gallery__video-play::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 0 10px 18px;
    border-color: transparent transparent transparent #fff;
    margin-left: 3px;
}

/* First item spans wider on desktop */
.ssb-gallery__grid .ssb-gallery__item:first-child {
    grid-column: span 2;
    grid-row: span 2;
}

@media (max-width: 600px) {
    .ssb-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .ssb-gallery__grid .ssb-gallery__item:first-child {
        grid-column: span 2;
        grid-row: span 1;
        aspect-ratio: 16/9;
    }

    .ssb-gallery__item {
        aspect-ratio: 1;
    }

    .ssb-gallery-upload__preview {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
}

/* ============================================
   Lightbox
   ============================================ */

.ssb-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(10, 5, 15, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.ssb-lightbox.ssb-lightbox--open {
    display: flex;
    opacity: 1;
}

.ssb-lightbox__content {
    max-width: 90vw;
    max-height: 85vh;
    position: relative;
}

.ssb-lightbox__content img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}

.ssb-lightbox__content iframe {
    width: 80vw;
    height: 45vw;
    max-width: 960px;
    max-height: 540px;
    border: none;
    border-radius: 4px;
}

.ssb-lightbox__close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    z-index: 100001;
}

.ssb-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ssb-lightbox__nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    z-index: 100001;
}

.ssb-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ssb-lightbox__nav--prev {
    left: 16px;
}

.ssb-lightbox__nav--next {
    right: 16px;
}

.ssb-lightbox__counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85em;
    font-family: inherit;
    z-index: 100001;
}

@media (max-width: 600px) {
    .ssb-lightbox__content iframe {
        width: 92vw;
        height: 52vw;
    }

    .ssb-lightbox__nav {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}
