/* ==========================================
   V2 Attachment Preview / Lightbox Component
   Reusable full-screen preview for attachments.
   Supports single item or multi-item with bottom thumbnail slider.

   Usage:
     window.v2AttachmentPreview.open({ url, type, fileName, onDelete })
     window.v2AttachmentPreview.open({ items, startIndex, onDelete })
     window.v2AttachmentPreview.close()

   Types: 'image', 'video', 'doc'
   ========================================== */

/* Overlay */
.v2-ap-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Content area */
.v2-ap-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90%;
    max-height: calc(100% - 80px);
    padding: 40px 0;
    overflow: hidden;
    min-height: 0;
}
/* When bottom strip is visible, shrink content to prevent overflow */
.v2-ap-overlay.v2-ap-has-strip .v2-ap-content {
    max-height: calc(100% - 168px);
}

/* Image */
.v2-ap-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* Video */
.v2-ap-video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    outline: none;
}

/* PDF / Office iframe — wrapped so the spinner can sit underneath the
   iframe while it loads. The iframe fades in once `load` fires. */
.v2-ap-pdf-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    overflow: hidden;
    background: #1a1a1a;
}
.v2-ap-pdf {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 4px;
    background: #fff;
    transition: opacity 0.25s ease;
    position: relative;
    z-index: 1;
}
.v2-ap-pdf.v2-ap-pdf-loading {
    opacity: 0;
}

/* Loading state: dark surface with a small spinner so the user gets
   instant feedback. Sits behind the iframe (which is opacity:0 while
   loading) and disappears together with the .v2-ap-pdf-loading class. */
.v2-ap-loading {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    background: #1a1a1a;
    pointer-events: none;
}
.v2-ap-spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #fff;
    animation: v2ApSpin 0.8s linear infinite;
}
@keyframes v2ApSpin {
    to { transform: rotate(360deg); }
}
.v2-ap-loading-text {
    letter-spacing: 0.4px;
}

/* Expand content area for document previews. Reserve a strip at the top so
   the close/download buttons don't sit on top of the iframe's white body
   (they have translucent backgrounds and would otherwise disappear). */
.v2-ap-content.v2-ap-doc-mode {
    max-width: 95%;
    width: 95%;
    min-width: 800px;
    padding-top: 72px;
}

/* Doc placeholder */
.v2-ap-doc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.v2-ap-doc svg {
    opacity: 0.9;
}
.v2-ap-doc-name {
    color: #fff;
    font-size: 14px;
    font-family: 'Lato', sans-serif;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Top-right action buttons. High z-index so iframe stacking contexts can't
   sit on top of them in document preview mode. */
.v2-ap-actions {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
}
.v2-ap-delete-btn,
.v2-ap-download-btn {
    height: 40px;
    padding: 0 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    outline: none;
    transition: background 0.15s;
}
.v2-ap-delete-btn:hover,
.v2-ap-download-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}
.v2-ap-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    transition: background 0.15s;
}
.v2-ap-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ---- Bottom Thumbnail Slider Strip ---- */
.v2-ap-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 24px;
    flex-shrink: 0;
    overflow: hidden;
    width: 100%;
}
/* Add button (optional, matches question attachment flow) */
.v2-ap-add-btn {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px dashed rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.v2-ap-add-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}
/* PS-2206 max-disable */
.v2-ap-add-btn.v2-ap-add-disabled {
    opacity: .4;
    pointer-events: none;
    cursor: not-allowed;
}
.v2-ap-thumbs-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    overflow: hidden;
    min-width: 0;
    max-width: calc(100% - 80px);
}
.v2-ap-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}
.v2-ap-thumbs::-webkit-scrollbar {
    display: none;
}

/* Image thumbnail */
.v2-ap-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    flex-shrink: 0;
    border: 2px solid transparent;
    opacity: 0.6;
    transition: opacity 0.15s, border-color 0.15s;
}
.v2-ap-thumb:hover {
    opacity: 0.85;
}
.v2-ap-thumb.v2-ap-thumb-active {
    border-color: #fff;
    opacity: 1;
}

/* File/video thumbnail */
.v2-ap-file-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    border: 2px solid transparent;
    opacity: 0.6;
    transition: opacity 0.15s, border-color 0.15s;
    position: relative;
    overflow: hidden;
}
.v2-ap-file-thumb:hover {
    opacity: 0.85;
}
.v2-ap-file-thumb.v2-ap-thumb-active {
    border-color: #fff;
    opacity: 1;
}

/* Video thumbnail variant — first-frame poster + translucent play badge */
.v2-ap-file-thumb-video {
    background: #000;
}
.v2-ap-thumb-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.v2-ap-thumb-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.v2-ap-thumb-play svg {
    display: block;
}

/* Scroll (prev/next) buttons */
.v2-ap-scroll-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    color: #fff;
    transition: background 0.15s;
}
.v2-ap-scroll-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}
.v2-ap-count {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    margin-right: 12px;
    align-self: center;
    letter-spacing: 0.3px;
}
.v2-ap-doc-note { color: rgba(255,255,255,0.7); font-size: 13px; margin-top: 8px; }
