/* The shared file preview side panel (js/assets/ui/file-preview-panel.js), loaded on every route of both stacks:
   dark header with details and actions, charcoal viewing area, previous/next */

/* -- Frame: the same values as Bootstrap 5's offcanvas, so it also works on Bootstrap 4 pages -- */
.file-preview-offcanvas {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    width: min(820px, 92vw);
    max-width: 100%;
    margin-right: calc(-1 * var(--file-preview-gutter, 0px));
    visibility: hidden;
    outline: 0;
    border-left: 0;
    background: #1f2226;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
}

.file-preview-offcanvas.show {
    transform: none;
}

.file-preview-offcanvas .d-none {
    display: none !important;
}

/* Its own backdrop where Bootstrap 5 doesn't provide one */
.file-preview-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: #000;
    opacity: 0;
    transition: opacity 0.15s linear;
}

.file-preview-backdrop.show {
    opacity: 0.5;
}

/* -- Header -- */
.file-preview-offcanvas__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #1f2226;
    border-bottom: 1px solid rgb(255 255 255 / 6%);
}

.file-preview-offcanvas__chip {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgb(255 255 255 / 8%);
    color: var(--theme-color-1);
    font-size: 1rem;
}

.file-preview-offcanvas__titles {
    flex: 1 1 auto;
    min-width: 0;
}

.file-preview-offcanvas__name {
    margin: 0;
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 15px;
    line-height: 20px;
    color: #f1f3f5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-preview-offcanvas__meta {
    margin-top: 2px;
    font-size: 12px;
    line-height: 16px;
    color: #aab0b7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-preview-offcanvas__meta:empty {
    display: none;
}

.file-preview-offcanvas__actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.file-preview-offcanvas__action {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #aab0b7;
    font-size: 15px;
    text-decoration: none;
    cursor: pointer;
}

.file-preview-offcanvas__action:hover,
.file-preview-offcanvas__action:focus-visible {
    background: rgb(255 255 255 / 10%);
    color: var(--theme-color-1);
}

/* -- Viewing area -- */
.file-preview-offcanvas__stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    background: #1f2226;
}

.file-preview-offcanvas .file-preview-offcanvas__body {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 56px 24px;
    overflow: hidden;
    background: #1f2226;
    scrollbar-width: thin;
    scrollbar-color: rgb(255 255 255 / 22%) transparent;
}

.file-preview-offcanvas .file-preview-offcanvas__body.is-pdf {
    padding: 0;
}

.file-preview-offcanvas__body::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.file-preview-offcanvas__body::-webkit-scrollbar-track,
.file-preview-offcanvas__body::-webkit-scrollbar-corner {
    background: transparent;
}

.file-preview-offcanvas__body::-webkit-scrollbar-thumb {
    background-color: rgb(255 255 255 / 22%);
    border-radius: 999px;
}

.file-preview-offcanvas__body::-webkit-scrollbar-thumb:hover {
    background-color: rgb(255 255 255 / 34%);
}

.file-preview-offcanvas__media {
    border: 0;
}

.file-preview-offcanvas__media--image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    cursor: pointer;
}

.file-preview-offcanvas .file-preview-offcanvas__body.is-zoomed {
    align-items: flex-start;
    justify-content: flex-start;
    overflow: auto;
}

.file-preview-offcanvas__body.is-zoomed .file-preview-offcanvas__media--image {
    max-width: none;
    max-height: none;
}

.file-preview-offcanvas__media--pdf {
    width: 100%;
    height: 100%;
    background: var(--theme-color-white);
}

.file-preview-offcanvas__nav {
    position: absolute;
    top: calc(50% + 20px);
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgb(255 255 255 / 12%);
    color: #e6e8eb;
    cursor: pointer;
}

.file-preview-offcanvas__nav:hover,
.file-preview-offcanvas__nav:focus-visible {
    background: rgb(255 255 255 / 22%);
}

.file-preview-offcanvas__nav--prev {
    left: 12px;
}

.file-preview-offcanvas__nav--next {
    right: 12px;
}

/* -- Footer: the file count and a hint -- */
.file-preview-offcanvas__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 40px;
    padding: 0 16px;
    background: #1f2226;
    font-size: 12px;
    color: #aab0b7;
}

/* -- Loading and problem states -- */
.file-preview-offcanvas__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #aab0b7;
}

.file-preview-offcanvas__loading::before {
    content: "";
    width: 24px;
    height: 24px;
    border: 2px solid rgb(255 255 255 / 18%);
    border-top-color: #e6e8eb;
    border-radius: 50%;
    animation: file-preview-spin 0.8s linear infinite;
}

@keyframes file-preview-spin {
    to {
        transform: rotate(360deg);
    }
}

.file-preview-offcanvas__problem {
    max-width: 320px;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: #d6d9dd;
}

.file-preview-offcanvas__problem a {
    display: inline-block;
    margin-top: 8px;
    color: #f0b48a;
}

/* The page's reserved scrollbar strip takes the panel's colour while a preview is open */
html:has(#filePreviewOffcanvas:is(.show, [style*="visibility: visible"])) {
    background-color: #1f2226;
}

/* A file tile that opens the preview */
.is-previewable {
    cursor: pointer;
}

/* A preview link that covers its whole card; the card is the positioned box */
.file-preview-stretch::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Card controls that stay clickable above a stretched preview link */
.file-preview-above {
    position: relative;
    z-index: 2;
}
