/* ============================================
   Image Viewer 独立组件样式
   ============================================ */

.img-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.img-viewer-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* ── 浮窗主体 ── */
.img-viewer-modal {
    position: relative;
    border-radius: 28px;
    max-width: 85vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(128, 128, 128, 0.3);
    transform: none;
    opacity: 1;
    overflow: hidden;
    transform-origin: top left;
    will-change: transform, opacity;
    transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1),
                opacity 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
    cursor: default;
}

/* ── 控件隐藏状态 ── */
.img-viewer-modal.controls-hidden .img-viewer-title,
.img-viewer-modal.controls-hidden .img-viewer-toolbar {
    opacity: 0;
    pointer-events: none;
}

.img-viewer-modal.controls-hidden {
    cursor: none;
}

.img-viewer-modal.is-hidden {
    opacity: 0 !important;
}

/* ── 标题栏容器 ── */
.img-viewer-title {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    margin: 0;
    padding: 24px 30px 48px;
    pointer-events: none;
    border-radius: 28px 28px 0 0;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    opacity: 1;
    transition: opacity 0.3s ease;
    will-change: opacity;
    transform: translateZ(0);
}

/* 标题栏渐进模糊层 */
.img-viewer-title::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    mask-image: linear-gradient(to bottom,
        rgba(0,0,0,0.8) 0%,
        rgba(0,0,0,0.5) 40%,
        rgba(0,0,0,0.2) 70%,
        rgba(0,0,0,0) 100%
    );
    -webkit-mask-image: linear-gradient(to bottom,
        rgba(0,0,0,0.8) 0%,
        rgba(0,0,0,0.5) 40%,
        rgba(0,0,0,0.2) 70%,
        rgba(0,0,0,0) 100%
    );
    border-radius: inherit;
    z-index: -1;
}

/* 标题栏暗色渐变层 */
.img-viewer-title::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom,
        rgba(0, 0, 0, 0.35) 0%,
        rgba(0, 0, 0, 0.15) 50%,
        transparent 100%
    );
    border-radius: inherit;
    z-index: -2;
}

/* ── 图片容器 ── */
.img-viewer-image-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.img-viewer-image-wrap.loading {
    min-height: 200px;
    min-width: 200px;
}

/* ── 图片本体 ── */
.img-viewer-img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
    opacity: 0;
    transform: translate(0px, 0px) scale(1);
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
    transition: opacity 0.3s ease, transform 0.18s ease;
}

.img-viewer-img.loaded {
    opacity: 1;
}

/* ── 转圈动画 ── */
.img-viewer-spinner {
    position: absolute;
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: img-viewer-spin 0.75s linear infinite;
    pointer-events: none;
}

.img-viewer-spinner.hidden {
    display: none;
}

/* ── 工具栏容器 ── */
.img-viewer-toolbar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 48px 30px 24px;
    pointer-events: auto;
    border-radius: 0 0 28px 28px;
    opacity: 1;
    transition: opacity 0.3s ease;
    will-change: opacity;
    transform: translateZ(0);
}

/* 工具栏渐进模糊层 */
.img-viewer-toolbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    mask-image: linear-gradient(to top,
        rgba(0,0,0,0.8) 0%,
        rgba(0,0,0,0.5) 40%,
        rgba(0,0,0,0.2) 70%,
        rgba(0,0,0,0) 100%
    );
    -webkit-mask-image: linear-gradient(to top,
        rgba(0,0,0,0.8) 0%,
        rgba(0,0,0,0.5) 40%,
        rgba(0,0,0,0.2) 70%,
        rgba(0,0,0,0) 100%
    );
    border-radius: inherit;
    z-index: -1;
}

/* 工具栏暗色渐变层 */
.img-viewer-toolbar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top,
        rgba(0, 0, 0, 0.35) 0%,
        rgba(0, 0, 0, 0.15) 50%,
        transparent 100%
    );
    border-radius: inherit;
    z-index: -2;
}

.img-viewer-zoom-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.img-viewer-tool-btn {
    min-width: 48px;
    height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background-color 0.2s ease;
    position: relative;
}

.img-viewer-tool-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
}

.img-viewer-tool-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.img-viewer-image-wrap.is-pan-enabled {
    cursor: grab;
    touch-action: none;
}

.img-viewer-image-wrap.is-panning {
    cursor: grabbing;
}

@keyframes img-viewer-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── 关闭按钮 ── */
.img-viewer-close-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 12px 24px;
    border-radius: 100px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    width: auto;
    min-width: 96px;
    margin: 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.img-viewer-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ── 可点击图片 ── */
img.img-zoomable {
    cursor: zoom-in;
}

.img-viewer-fly {
    position: fixed;
    z-index: 9100;
    object-fit: cover;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    transition: top 0.38s cubic-bezier(0.2, 0.8, 0.2, 1),
                left 0.38s cubic-bezier(0.2, 0.8, 0.2, 1),
                width 0.38s cubic-bezier(0.2, 0.8, 0.2, 1),
                height 0.38s cubic-bezier(0.2, 0.8, 0.2, 1),
                border-radius 0.38s cubic-bezier(0.2, 0.8, 0.2, 1),
                opacity 0.22s ease;
}
