/*
 * Image Gallery plugin shell. Folder browser and resizer widths are CSS-owned
 * layout contracts; scripts should toggle classes/attributes, not inline
 * dimensions.
 */
:root {
    --gallery-accent: #007bff;
    --gallery-muted: #f7f7f7;
    --gallery-border: #ccc;
    --gallery-text: #1f2937;
}

.image-gallery {
    --gallery-thumbnail-size: 240px;

    display: flex;
    min-height: 0;
    flex-direction: column;
    color: var(--gallery-text);
}

.image-gallery[data-gallery-thumb-size="160"],
.image-gallery[data-gallery-thumb-size-active="160"] {
    --gallery-thumbnail-size: 160px;
}

.image-gallery[data-gallery-thumb-size="240"],
.image-gallery[data-gallery-thumb-size-active="240"] {
    --gallery-thumbnail-size: 240px;
}

.image-gallery[data-gallery-thumb-size="320"],
.image-gallery[data-gallery-thumb-size-active="320"] {
    --gallery-thumbnail-size: 320px;
}

.image-gallery[data-gallery-thumb-size="480"],
.image-gallery[data-gallery-thumb-size-active="480"] {
    --gallery-thumbnail-size: 480px;
}

.image-gallery--with-folders {
    flex-direction: row;
}

.image-gallery__folder-browser {
    width: 300px;
    min-width: 180px;
    max-width: 560px;
    padding: 10px;
    overflow: auto;
    border-right: 1px solid var(--gallery-border);
}

.image-gallery__folder-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.image-gallery__folder {
    padding: 6px 10px;
    border: 1px solid var(--gallery-border);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.image-gallery__folder small {
    opacity: 0.72;
}

.image-gallery__folder:hover,
.image-gallery__folder.is-active {
    border-color: var(--gallery-accent);
    background: color-mix(in srgb, var(--gallery-accent) 14%, transparent);
}

.image-gallery__resizer {
    width: 6px;
    flex: 0 0 6px;
    cursor: ew-resize;
    background: color-mix(in srgb, var(--gallery-border) 70%, transparent);
}

.image-gallery__main {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.image-gallery__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    align-items: center;
    padding: 12px 16px;
    background: var(--gallery-muted);
    border-bottom: 1px solid var(--gallery-border);
}

.image-gallery__section {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.image-gallery__button {
    padding: 6px 12px;
    border: 1px solid var(--gallery-accent);
    border-radius: 6px;
    background: #fff;
    color: var(--gallery-accent);
    font-size: 14px;
    cursor: pointer;
}

.image-gallery__button:hover:not(:disabled),
.image-gallery__button.is-active {
    background: var(--gallery-accent);
    color: #fff;
}

.image-gallery__button:disabled {
    border-color: #9ca3af;
    color: #9ca3af;
    cursor: not-allowed;
}

.image-gallery__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--gallery-thumbnail-size)), 1fr));
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    align-content: flex-start;
}

.image-gallery__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.image-gallery__image {
    max-width: min(100%, var(--gallery-thumbnail-size));
    max-height: var(--gallery-thumbnail-size);
    border: 1px solid var(--gallery-border);
    border-radius: 6px;
    object-fit: contain;
    cursor: pointer;
}

.image-gallery__title {
    font-size: 12.5px;
    font-weight: 600;
    text-align: center;
}

.image-gallery__caption {
    color: #6b7280;
    font-size: 11px;
    text-align: center;
}

.image-gallery__lightbox {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
}

.image-gallery__lightbox.is-open {
    display: flex;
}

.image-gallery__lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    border: 2px solid #fff;
    border-radius: 6px;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
}

.image-gallery__nav {
    position: absolute;
    top: 50%;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transform: translateY(-50%);
}

.image-gallery__nav--prev {
    left: 16px;
}

.image-gallery__nav--next {
    right: 16px;
}

.image-gallery__status {
    min-height: 20px;
    padding: 12px 16px;
    color: #4b5563;
    font-size: 14px;
}

@media (max-width: 960px) {
    .image-gallery--with-folders {
        flex-direction: column;
    }

    .image-gallery__folder-browser {
        width: auto;
        max-width: none;
        border-right: 0;
        border-bottom: 1px solid var(--gallery-border);
    }

    .image-gallery__resizer {
        display: none;
    }
}
