:root {
    --pm-active-color: #2563eb;
    --pm-viewer-height: 520px;
}

.pm-gallery {
    display: flex;
    gap: 14px;
    width: 100%;
}

/* ============================================================
   Layout Presets (Left, Bottom, Grid, Slider)
   ============================================================ */

/* 1. Left Vertical Layout (Default) */
.pm-gallery.pm-layout-left {
    flex-direction: row;
}

/* 2. Bottom Horizontal Layout */
.pm-gallery.pm-layout-bottom {
    flex-direction: column;
}

.pm-gallery.pm-layout-bottom .pm-thumb-rail {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    width: 100%;
    max-height: none;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    padding-top: 4px;
    scroll-behavior: smooth;
    justify-content: flex-start;
}

/* 3. Instagram Grid Layout */
.pm-gallery.pm-layout-grid {
    flex-direction: column;
}

.pm-gallery.pm-layout-grid .pm-thumb-rail {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    max-height: none;
    gap: 10px;
}

/* 4. Touch Swipe Slider Layout */
.pm-gallery.pm-layout-slider {
    flex-direction: column;
    position: relative;
    user-select: none;
}

.pm-gallery.pm-layout-slider .pm-thumb-rail {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: 100%;
    max-height: none;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-top: 6px;
    padding-bottom: 6px;
    scroll-behavior: smooth;
}

/* ============================================================
   Thumbnail Rail & Items
   ============================================================ */

.pm-thumb-rail {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 76px;
    max-height: var(--pm-viewer-height, 520px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.pm-thumb-rail::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.pm-thumb-rail::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 4px;
}

.pm-thumb-btn {
    position: relative;
    padding: 0;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    cursor: pointer;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    transition: all 0.2s ease-in-out;
}

.pm-thumb-btn:hover {
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.pm-thumb-btn.is-active {
    border-color: var(--pm-active-color, #2563eb);
    box-shadow: 0 0 0 2px var(--pm-active-color, rgba(37, 99, 235, 0.25));
}

.pm-thumb-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pm-thumb-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 26px;
    height: 26px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.pm-main-viewer {
    flex: 1;
    min-width: 0;
    position: relative;
}

/* ============================================================
   Share Button & Menu Positions
   ============================================================ */
.pm-share-wrap {
    position: absolute;
    z-index: 10;
}

.pm-share-wrap.pm-share-pos-top_right {
    top: 10px;
    right: 10px;
}

.pm-share-wrap.pm-share-pos-top_left {
    top: 10px;
    left: 10px;
}

.pm-share-wrap.pm-share-pos-bottom_right {
    bottom: 10px;
    right: 10px;
}

.pm-share-wrap.pm-share-pos-bottom_left {
    bottom: 10px;
    left: 10px;
}

.pm-share-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.88);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transition: background 0.18s ease, transform 0.15s ease;
    backdrop-filter: blur(6px);
}

.pm-share-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.08);
}

.pm-share-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 210px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 1px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    animation: pm-share-in 0.18s ease;
    transform-origin: top right;
}

.pm-share-wrap.pm-share-pos-top_left .pm-share-menu,
.pm-share-wrap.pm-share-pos-bottom_left .pm-share-menu {
    right: auto;
    left: 0;
    transform-origin: top left;
}

.pm-share-wrap.pm-share-pos-bottom_right .pm-share-menu,
.pm-share-wrap.pm-share-pos-bottom_left .pm-share-menu {
    top: auto;
    bottom: calc(100% + 8px);
}

@keyframes pm-share-in {
    from {
        opacity: 0;
        transform: scale(0.88) translateY(-6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.pm-share-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 10px;
    border-bottom: 1px solid #f1f5f9;
}

.pm-share-menu-title {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.04em;
}

.pm-share-menu-close {
    background: none;
    border: none;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: #94a3b8;
    font-size: 14px;
    transition: background 0.15s ease, color 0.15s ease;
}

.pm-share-menu-close:hover {
    background: #f1f5f9;
    color: #475569;
}

.pm-share-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
}

.pm-share-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 18px;
    text-decoration: none;
    color: #1e293b;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.12s ease;
}

.pm-share-item:hover {
    background: #f8fafc;
    color: #1e293b;
    text-decoration: none;
}

.pm-share-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pm-share-icon--email { background: #64748b; color: #fff; }
.pm-share-icon--line { background: #06C755; }
.pm-share-icon--facebook { background: #1877F2; }
.pm-share-icon--x { background: #000; }
.pm-share-icon--copy { background: #94a3b8; }

.pm-share-icon--email svg { stroke: #fff; }

.pm-share-copy-done {
    color: #16a34a;
    font-weight: 600;
}

/* ============================================================
   Viewer Wrappers & Dynamic Height
   ============================================================ */

.pm-main-image-wrap,
.pm-main-video-wrap,
.pm-main-iframe-wrap {
    width: 100%;
    height: var(--pm-viewer-height, 520px);
    max-height: var(--pm-viewer-height, 520px);
    border-radius: 12px;
    overflow: hidden;
    background-color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.pm-main-image-wrap {
    cursor: zoom-in;
}

.pm-main-image-wrap.is-zooming img {
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

.pm-zoom-lens {
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.25), inset 0 0 20px rgba(0, 0, 0, 0.25), 0 12px 32px rgba(0, 0, 0, 0.5);
    background-repeat: no-repeat;
    background-size: 250% 250%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 20;
    backdrop-filter: blur(1px);
}

.pm-main-iframe-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.pm-thumb-play--yt {
    background: rgba(220, 38, 38, 0.9);
}

.pm-thumb-play--vimeo {
    background: rgba(14, 165, 233, 0.9);
}

.pm-main-image-wrap img,
.pm-main-video-wrap video {
    max-width: 100%;
    max-height: var(--pm-viewer-height, 520px);
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

@media (max-width: 767.98px) {
    .pm-gallery.pm-layout-left {
        flex-direction: column-reverse;
    }

    .pm-gallery.pm-layout-left .pm-thumb-rail {
        flex-direction: row;
        width: 100%;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .pm-thumb-btn {
        width: 64px;
        height: 64px;
    }
}

/* Admin Dropzone & FilePond Card Style */
.pm-drop-area {
    background-color: #f8f9fa;
    border: 2px dashed #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.pm-drop-area:hover,
.pm-drop-area.is-dragover {
    background-color: #eef6ff;
    border-color: #3b82f6;
}

.pm-media-card {
    width: 170px;
    height: 120px;
    border-radius: 10px;
    background-color: #2e7d32;
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pm-media-card:active {
    cursor: grabbing;
}

.pm-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pm-card-video-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 3;
}

.pm-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 6px 10px;
    background: linear-gradient(to bottom, rgba(46, 125, 50, 0.95), rgba(46, 125, 50, 0.65), transparent);
    color: #fff;
    z-index: 2;
}

.pm-card-status {
    font-size: 12px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.pm-card-remove-btn {
    background: rgba(0, 0, 0, 0.35);
    border: none;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

/* ============================================================
   Shared Media Library Cards
   ============================================================ */
.pm-lib-card {
    width: 125px;
    height: 125px;
    position: relative;
    border: 2px solid #cbd5e1;
    transition: all 0.2s ease;
    user-select: none;
    background: #f8fafc;
}

.pm-lib-card:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
}

.pm-lib-card.is-selected {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35) !important;
}

.pm-lib-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pm-lib-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 5;
    transition: background 0.15s ease, transform 0.15s ease;
}

.pm-lib-card.is-selected .pm-lib-check {
    background: #2563eb;
    transform: scale(1.1);
}

.pm-lib-caption-strip {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.85);
    color: #f8fafc;
    font-size: 10px;
    padding: 3px 6px;
    z-index: 4;
}

.pm-card-remove-btn:hover {
    background: rgba(211, 47, 47, 0.9);
}

.pm-card-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 12px;
}

/* ============================================================
   Lightbox Modal
   ============================================================ */
.pm-lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    cursor: zoom-out;
}

.pm-lightbox-overlay.is-open {
    opacity: 1;
}

.pm-lightbox-inner {
    position: relative;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.pm-lb-caption {
    margin-top: 12px;
    padding: 8px 18px;
    background: rgba(15, 23, 42, 0.85);
    color: #f8fafc;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    border-radius: 20px;
    text-align: center;
    max-width: 85vw;
    word-break: break-word;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.pm-lightbox-inner img {
    max-width: 90vw;
    max-height: 78vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    display: block;
    user-select: none;
}

.pm-lightbox-inner video {
    max-width: 90vw;
    max-height: 78vh;
    width: auto;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    display: block;
    background: #000;
}

.pm-lightbox-close {
    position: absolute;
    top: -44px;
    right: 0;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    backdrop-filter: blur(4px);
}

.pm-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Prev / Next navigation */
.pm-lightbox-prev,
.pm-lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
    backdrop-filter: blur(4px);
    z-index: 2;
    user-select: none;
}

.pm-lightbox-prev { left: 20px; }
.pm-lightbox-next { right: 20px; }

.pm-lightbox-prev:hover { background: rgba(255, 255, 255, 0.28); transform: translateY(-50%) scale(1.08); }
.pm-lightbox-next:hover { background: rgba(255, 255, 255, 0.28); transform: translateY(-50%) scale(1.08); }

.pm-lightbox-prev:disabled,
.pm-lightbox-next:disabled {
    opacity: 0.25;
    cursor: default;
}

/* Counter badge */
.pm-lightbox-counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 13px;
    padding: 4px 14px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    letter-spacing: 0.04em;
    pointer-events: none;
}

/* Frontend: cursor zoom-in only on the actual image/video, not the whole viewer area */
.pm-main-image-wrap img,
.pm-main-video-wrap video {
    cursor: zoom-in;
}

/* Admin: cursor pointer hint on card img */
.pm-media-card .pm-card-img {
    cursor: zoom-in;
}