/* Shared Film Force expanded-picture viewer. Toolbar is never transformed with the image. */

.gts-image-viewer {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    z-index: 2147483500;
    box-sizing: border-box;
    overflow: hidden;
    overscroll-behavior: none;
}

.gts-image-viewer[aria-hidden="false"] {
    display: block;
    touch-action: none;
}

.gts-image-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 27, 45, 0.92);
}

.gts-image-viewer-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    padding: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    box-sizing: border-box;
    pointer-events: none;
}

.gts-image-viewer-shell > * {
    pointer-events: auto;
}

.gts-image-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    flex: 0 0 auto;
    z-index: 2;
    padding: 4px 0 10px;
    transform: none !important;
}

.gts-image-viewer-btn {
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border-radius: 8px;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.gts-image-viewer-btn:hover,
.gts-image-viewer-btn:focus-visible {
    background: rgba(255, 255, 255, 0.26);
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.gts-image-viewer-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.gts-image-viewer-pct {
    color: rgba(255, 255, 255, 0.95);
    font-size: 14px;
    min-width: 52px;
    text-align: center;
    user-select: none;
}

.gts-image-viewer-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.gts-image-viewer-viewport {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.gts-image-viewer-viewport.is-pannable {
    cursor: grab;
}

.gts-image-viewer-viewport.is-panning {
    cursor: grabbing;
}

.gts-image-viewer-name,
.gts-image-viewer-pos {
    color: #fff;
    font-size: 14px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gts-image-viewer-name {
    margin-right: auto;
    max-width: 40%;
}

.gts-image-viewer-btn[data-gts-iv-fit] {
    width: auto;
    min-width: 44px;
    padding: 0 10px;
    font-size: 14px;
}

.gts-image-viewer-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.gts-image-viewer-img.is-hidden {
    display: none;
}

.gts-image-viewer-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transform-origin: center center;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
    -webkit-user-drag: none;
    user-select: none;
}

html.gts-image-viewer-open,
body.gts-image-viewer-open {
    overflow: hidden;
}

html.gts-image-viewer-open .ff-header-actions,
html.gts-image-viewer-open #ffNotificationBell,
html.gts-image-viewer-open .top_navbar {
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .gts-image-viewer-img {
        transition: none !important;
    }

    #crmTextModal .crm-text-attachment-layer,
    #chatMessages .crm-text-attachment-layer, #inboxNewHistory .crm-text-attachment-layer,
    #crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"]) > .timeline-image,
    #crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"]) > .timeline-media-file {
        transform: none;
    }
}

/* Same-message attachment stack. One compact pile; the shared viewer opens the set. */
#crmTextModal .crm-text-attachment-stack,
#chatMessages .crm-text-attachment-stack, #inboxNewHistory .crm-text-attachment-stack,
#crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"]) {
    position: relative;
    display: block;
    width: 108px;
    height: 88px;
    max-width: 100%;
    margin: 6px 0 2px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font: inherit;
    line-height: 1;
    cursor: pointer;
    overflow: visible;
    pointer-events: auto;
}

#crmTextModal .crm-text-attachment-stack:focus-visible,
#chatMessages .crm-text-attachment-stack:focus-visible , #inboxNewHistory .crm-text-attachment-stack:focus-visible {
    outline: none;
    box-shadow: var(--ds-btn-focus-ring);
}

#crmTextModal .crm-text-attachment-stack .crm-text-attachment-layer,
#chatMessages .crm-text-attachment-stack .crm-text-attachment-layer, #inboxNewHistory .crm-text-attachment-stack .crm-text-attachment-layer,
#crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"]) > .timeline-image,
#crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"]) > .timeline-media-file {
    position: absolute;
    box-sizing: border-box;
    width: 72px;
    height: 72px;
    max-width: 72px;
    max-height: 72px;
    margin: 0;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--card-bg, var(--content-panel-bg, #fff));
    background: var(--card-bg, #fff);
    color: var(--card-text, var(--content-panel-text, #1f2937));
    box-shadow: 0 1px 4px color-mix(in srgb, var(--content-panel-text, #1f2937) 28%, transparent);
    pointer-events: auto;
}

#crmTextModal .crm-text-attachment-stack a.crm-text-attachment-file,
#chatMessages .crm-text-attachment-stack a.crm-text-attachment-file , #inboxNewHistory .crm-text-attachment-stack a.crm-text-attachment-file {
    pointer-events: auto;
}

#crmTextModal .crm-text-attachment-stack .crm-text-attachment-layer:nth-child(1),
#chatMessages .crm-text-attachment-stack .crm-text-attachment-layer:nth-child(1), #inboxNewHistory .crm-text-attachment-stack .crm-text-attachment-layer:nth-child(1),
#crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"]) > :nth-child(1) {
    left: 0;
    top: 12px;
    z-index: 1;
    transform: rotate(-8deg);
}

#crmTextModal .crm-text-attachment-stack .crm-text-attachment-layer:nth-child(2),
#chatMessages .crm-text-attachment-stack .crm-text-attachment-layer:nth-child(2), #inboxNewHistory .crm-text-attachment-stack .crm-text-attachment-layer:nth-child(2),
#crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"]) > :nth-child(2) {
    left: 16px;
    top: 6px;
    z-index: 2;
    transform: rotate(2deg);
}

#crmTextModal .crm-text-attachment-stack .crm-text-attachment-layer:nth-child(3),
#chatMessages .crm-text-attachment-stack .crm-text-attachment-layer:nth-child(3), #inboxNewHistory .crm-text-attachment-stack .crm-text-attachment-layer:nth-child(3),
#crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"]) > :nth-child(3) {
    left: 30px;
    top: 2px;
    z-index: 3;
    transform: rotate(8deg);
}

#crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"]) > :nth-child(n+4) {
    left: 30px;
    top: 2px;
    z-index: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

#crmTextModal .crm-text-attachment-file,
#chatMessages .crm-text-attachment-file, #inboxNewHistory .crm-text-attachment-file,
#crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"]) > .timeline-media-file {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}

#crmTextModal .crm-text-attachment-count,
#chatMessages .crm-text-attachment-count, #inboxNewHistory .crm-text-attachment-count,
#crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"])::after {
    position: absolute;
    z-index: 4;
    right: 0;
    bottom: 0;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    box-sizing: border-box;
    border-radius: 999px;
    border: 2px solid var(--content-panel-bg, #fff);
    background: var(--button-bg, #0F4C81);
    color: var(--button-text, #fff);
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    pointer-events: none;
}

#crmTextModal .crm-text-attachment-count,
#chatMessages .crm-text-attachment-count , #inboxNewHistory .crm-text-attachment-count {
    display: flex;
    align-items: center;
    justify-content: center;
}

#crmTextModal .timeline-card:not(.crm-text-chat) .timeline-media[data-attachment-count]:not([data-attachment-count="1"])::after {
    content: attr(data-attachment-count);
}

#crmTextModal .crm-text-attachment-video,
#chatMessages .crm-text-attachment-video , #inboxNewHistory .crm-text-attachment-video {
    display: block;
    width: min(220px, 100%);
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}
