/* GW Gallery — front-end member gallery */

.gw-gallery-frontend {
    --gw-gallery-radius: 6px;
}

/* ── Grid ────────────────────────────────────────────────────────── */
.gw-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.gw-gallery-item {
    position: relative;
    margin: 0;
    overflow: hidden;
    border-radius: var(--gw-gallery-radius);
    background: #f2f3f5;
}

.gw-gallery-thumb {
    display: block;
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    color: inherit;
    text-decoration: none;
    overflow: hidden;
}

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

/* ── Captions ────────────────────────────────────────────────────── */
.gw-gallery-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: 10px 12px;
    margin: 0;
    color: #fff;
    text-align: left;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0) 60%);
    pointer-events: none;
}

.gw-gallery-caption-below {
    display: block;
    padding: 10px 12px;
    margin: 0;
    font-size: 0.875em;
    background: #fff;
}

/* ── Item actions ────────────────────────────────────────────────── */
.gw-gallery-item-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.gw-gallery-item:hover .gw-gallery-item-actions,
.gw-gallery-item:focus-within .gw-gallery-item-actions {
    opacity: 1;
}

@media (hover: none) {
    .gw-gallery-item-actions {
        opacity: 1;
    }
}

.gw-gallery-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: grab;
    user-select: none;
}

.gw-gallery-drag-handle:active {
    cursor: grabbing;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.gw-gallery-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 0;
    border-radius: 4px;
    background: #1f2933;
    color: #fff;
    font: inherit;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.gw-gallery-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.gw-gallery-item-actions .gw-gallery-btn {
    padding: 6px 10px;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.55);
}

.gw-gallery-delete {
    background: #c81e1e;
}

.gw-gallery-add {
    background: #1f6feb;
    color: #fff;
}

.gw-gallery-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.gw-gallery-upload-status {
    font-size: 0.875em;
    color: #52606d;
}

.gw-gallery-upload-status.is-error {
    color: #c81e1e;
}

/* ── Usage bar ───────────────────────────────────────────────────── */
.gw-gallery-usage {
    margin-bottom: 14px;
}

.gw-gallery-usage-text {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8125em;
    color: #52606d;
}

.gw-gallery-usage-bar {
    display: block;
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: #e4e7eb;
    overflow: hidden;
}

.gw-gallery-usage-fill {
    display: block;
    height: 100%;
    background: #1f6feb;
    transition: width 0.3s ease;
}

/* ── Empty / editor placeholder ──────────────────────────────────── */
.gw-gallery-empty {
    margin: 0;
    padding: 24px 16px;
    text-align: center;
    color: #52606d;
    background: #f7f8fa;
    border-radius: var(--gw-gallery-radius);
}

.gw-gallery-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: repeating-linear-gradient(
        45deg,
        #eef0f3,
        #eef0f3 10px,
        #e5e8ec 10px,
        #e5e8ec 20px
    );
}

.gw-gallery-placeholder-icon {
    font-size: 28px;
    opacity: 0.5;
}

/* ── Sortable states ─────────────────────────────────────────────── */
.gw-gallery-item.gw-dragging {
    opacity: 0.4;
}

.gw-gallery-item.gw-drag-over {
    outline: 2px dashed #1f6feb;
    outline-offset: -2px;
}

/* ── Lightbox ────────────────────────────────────────────────────── */
.gw-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gw-gallery-lightbox[hidden] {
    display: none;
}

.gw-gallery-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
}

.gw-gallery-lightbox-figure {
    position: relative;
    z-index: 2;
    margin: 0;
    max-width: 90vw;
    text-align: center;
}

.gw-gallery-lightbox-img {
    display: block;
    max-width: 90vw;
    max-height: 82vh;
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: 4px;
}

.gw-gallery-lightbox-caption {
    margin-top: 12px;
    color: #fff;
    font-size: 0.9375em;
}

.gw-gallery-lightbox-close,
.gw-gallery-lightbox-prev,
.gw-gallery-lightbox-next {
    position: absolute;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.gw-gallery-lightbox-close {
    top: 16px;
    right: 20px;
    font-size: 40px;
    line-height: 1;
}

.gw-gallery-lightbox-prev,
.gw-gallery-lightbox-next {
    top: 50%;
    transform: translateY(-50%);
    font-size: 48px;
    line-height: 1;
    padding: 0 12px;
}

.gw-gallery-lightbox-prev {
    left: 12px;
}

.gw-gallery-lightbox-next {
    right: 12px;
}

.gw-gallery-lightbox.is-single .gw-gallery-lightbox-prev,
.gw-gallery-lightbox.is-single .gw-gallery-lightbox-next {
    display: none;
}

/* ── Edit modal ──────────────────────────────────────────────────── */
.gw-gallery-edit-modal {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gw-gallery-edit-modal[hidden] {
    display: none;
}

.gw-gallery-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.gw-gallery-edit-form {
    position: relative;
    z-index: 2;
    width: min(440px, 90vw);
    padding: 24px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.gw-gallery-modal-title {
    margin: 0 0 16px;
    font-size: 1.125em;
}

.gw-gallery-field {
    display: block;
    margin-bottom: 14px;
}

.gw-gallery-field > span {
    display: block;
    margin-bottom: 4px;
    font-size: 0.8125em;
    font-weight: 600;
}

.gw-gallery-field input,
.gw-gallery-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd2d9;
    border-radius: 4px;
    font: inherit;
    box-sizing: border-box;
}

.gw-gallery-modal-error {
    margin: 0 0 12px;
    color: #c81e1e;
    font-size: 0.875em;
}

.gw-gallery-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.gw-gallery-btn-primary {
    background: #1f6feb;
}
