/**
 * KS LP Image — Block Styles
 */

.kslp-image-block {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.kslp-image-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

.kslp-align-left .kslp-image-container {
    align-items: flex-start;
}

.kslp-align-center .kslp-image-container {
    align-items: center;
}

.kslp-align-right .kslp-image-container {
    align-items: flex-end;
}

.kslp-image-grid-wrap {
    display: grid;
    width: 100%;
    box-sizing: border-box;
}

.kslp-image-holder {
    margin: 0;
    padding: 0;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.kslp-image-holder img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    box-sizing: border-box;
    transition: filter 0.2s ease, opacity 0.2s ease;
}

.kslp-image-link {
    display: block;
    position: relative;
    text-decoration: none;
    line-height: 0;
    overflow: hidden;
    border-radius: inherit;
}

.kslp-image-lightbox-trigger {
    cursor: zoom-in;
}

.kslp-image-lightbox-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(15, 23, 42, 0.65);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.2s ease;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.kslp-image-lightbox-trigger:hover .kslp-image-lightbox-badge {
    opacity: 1;
    transform: scale(1);
    background: rgba(15, 23, 42, 0.85);
}

.kslp-image-caption {
    font-size: 13.5px;
    line-height: 1.5;
    color: #64748b;
    margin-top: 8px;
    text-align: center;
    font-style: italic;
}

/* Hover Caption Bottom */
.kslp-caption-hover {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    padding: 28px 16px 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.45) 60%, transparent 100%);
    color: #ffffff;
    font-size: 13.5px;
    line-height: 1.4;
    text-align: center;
    font-style: normal;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
    pointer-events: none;
    z-index: 2;
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

.kslp-image-holder:hover .kslp-caption-hover,
.kslp-image-holder:focus-within .kslp-caption-hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Lightbox Modal */
.kslp-lightbox-overlay,
.kslp-image-lightbox-overlay {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 24px;
    box-sizing: border-box;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: zoom-out;
}

.kslp-lightbox-overlay.is-active,
.kslp-image-lightbox-overlay.is-active {
    display: flex;
}

.kslp-lightbox-caption {
    color: #ffffff;
    margin-bottom: 12px;
    margin-top: 0;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    max-width: min(850px, 90vw);
    padding: 6px 18px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 6px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    cursor: default;
    z-index: 1000001;
}

.kslp-lightbox-content {
    max-width: 90vw;
    max-height: 78vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.kslp-lightbox-img-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 78vh;
    line-height: 0;
}

.kslp-lightbox-content img,
.kslp-lightbox-img-wrap img,
.kslp-image-lightbox-overlay img {
    max-width: 90vw;
    max-height: 78vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.7);
    transform: scale(0.96);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.kslp-lightbox-overlay.is-active img,
.kslp-image-lightbox-overlay.is-active img {
    transform: scale(1);
}

.kslp-lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 28px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 1000002;
}

.kslp-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.08);
}

@media (max-width: 767px) {
    .kslp-lightbox-close {
        top: 14px;
        right: 14px;
        width: 38px;
        height: 38px;
        font-size: 24px;
    }
    .kslp-lightbox-caption {
        font-size: 13.5px;
        max-width: calc(100vw - 32px);
        padding: 5px 14px;
        margin-bottom: 10px;
    }
    .kslp-lightbox-content,
    .kslp-lightbox-img-wrap,
    .kslp-lightbox-content img,
    .kslp-lightbox-img-wrap img {
        max-height: 72vh;
        max-width: 94vw;
    }
}

/* Editor Interactive Canvas UI */
.block-editor-page .kslp-caption-hover,
.editor-styles-wrapper .kslp-caption-hover,
.block-editor-block-list__layout .kslp-caption-hover {
    pointer-events: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    cursor: text !important;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.editor-styles-wrapper .kslp-caption-hover [data-rich-text-placeholder]::after,
.editor-styles-wrapper .kslp-caption-hover .block-editor-rich-text__editable:empty::before {
    color: rgba(255, 255, 255, 0.75) !important;
    opacity: 0.85 !important;
}

.kslp-grid-item-actions button,
.kslp-single-image-actions button {
    transition: transform 0.15s ease, background-color 0.15s ease !important;
}

.kslp-grid-item-actions button:hover,
.kslp-single-image-actions button:hover {
    background-color: rgba(255, 255, 255, 0.25) !important;
    transform: scale(1.08) !important;
}

.kslp-image-grid-add-slot:hover {
    border-color: #0284c7 !important;
    background-color: #f0f9ff !important;
}

/* Pagination & Load More */
.kslp-image-pagination {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
    width: 100%;
    box-sizing: border-box;
}

.kslp-image-pagination-center {
    justify-content: center;
}

.kslp-image-pagination-left {
    justify-content: flex-start;
}

.kslp-image-pagination-right {
    justify-content: flex-end;
}

.kslp-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #f1f5f9;
    color: #334155;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    user-select: none;
    box-sizing: border-box;
}

.kslp-page-btn:hover:not(.is-disabled):not(.is-active) {
    background: #e2e8f0;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.kslp-page-btn.is-active {
    background: #0b8e36;
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(11, 142, 54, 0.28);
    cursor: default;
}

.kslp-page-btn.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.kslp-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 26px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #f1f5f9;
    color: #334155;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    box-sizing: border-box;
}

.kslp-load-more-btn:hover:not(.is-disabled) {
    background: #e2e8f0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.kslp-load-more-btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.kslp-page-indicator {
    font-size: 14px;
    color: #64748b;
    margin: 0 10px;
    font-weight: 500;
}

.kslp-current-page-num {
    color: #0f172a;
    font-weight: 700;
}


