/* 通用弹窗组件样式 */
#universalPopupContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2000;
}

.popup-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2000;
}

.popup-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease-out, visibility 0s linear 0.15s;
}

.popup-wrapper.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.15s ease-out, visibility 0s linear;
}

/* hover模式下的特殊处理 */
.popup-wrapper[data-relative="true"] {
    transition: opacity 0.15s ease-out, visibility 0s linear;
    pointer-events: none;
}

/* 相对定位弹窗下，仅弹窗本身可交互，避免空白区域拦截事件 */
.popup-wrapper[data-relative="true"] .popup-panel {
    pointer-events: auto;
}

.popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.popup-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 86vh;
    overflow-y: auto;
    pointer-events: auto;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 中心弹窗初始状态 */
.popup-wrapper .popup-panel[data-position="center"],
.popup-wrapper .popup-panel:not([data-position]):not([position]) {
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0;
}

/* 中心弹窗动画 */
.popup-wrapper.show .popup-panel[data-position="center"],
.popup-wrapper.show .popup-panel:not([data-position]):not([position]) {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* 底部弹窗初始状态 */
.popup-wrapper .popup-panel[position="bottom"] {
    transform: translateY(100%);
    opacity: 0;
}

/* 底部弹窗动画 */
.popup-wrapper.show .popup-panel[position="bottom"] {
    transform: translateY(0);
    opacity: 1;
}

/* 相对定位弹窗样式 */
.popup-panel[data-position="relative"] {
    position: fixed !important;
    max-width: 800px;
    transition: opacity 0.15s ease-out;
    will-change: transform, opacity;
    overflow-y: visible; /* 仅相对定位弹窗不显示滚动条 */
}

/* 相对定位弹窗不需要全屏遮罩 */
.popup-wrapper[data-relative="true"] .popup-overlay {
    background: transparent;
    pointer-events: none;
}

/* 确保弹窗和触发元素之间的连接区域也能响应hover */
.popup-panel[data-position="relative"]::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 10px;
    background: transparent;
    pointer-events: auto;
}

/* 上方定位时的连接区域 */
.popup-panel[data-position="relative"].position-top::before {
    top: 100%;
    bottom: auto;
}

/* 下方定位时的连接区域 */
.popup-panel[data-position="relative"].position-bottom::before {
    bottom: 100%;
    top: auto;
}

/* 减少hover闪烁的过渡效果 */
.popup-panel[data-position="relative"] {
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}

/* 相对定位弹窗动画 */
.popup-wrapper.show .popup-panel[data-position="relative"] {
    animation: popupSlideIn 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation-fill-mode: both;
}

/* 上方定位弹窗动画 */
.popup-wrapper.show .popup-panel[data-position="relative"].position-top {
    animation: popupSlideInTop 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation-fill-mode: both;
}

/* 显式触发重播的动画类（用于目标切换时复用面板） */
.popup-panel[data-position="relative"].animating {
    animation: popupSlideIn 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation-fill-mode: both;
}
.popup-panel[data-position="relative"].position-top.animating {
    animation: popupSlideInTop 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation-fill-mode: both;
}

/* 上方定位样式 */
.popup-panel[data-position="relative"].position-top {
}

.popup-panel[data-position="relative"].position-top::before {
    top: 100%;
    bottom: auto;
}

/* 下方定位样式 */
.popup-panel[data-position="relative"].position-bottom {
}

.popup-panel[data-position="relative"].position-bottom::before {
    bottom: 100%;
    top: auto;
}

/* hover模式专用样式 */
.popup-panel[data-position="relative"] {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* 更好看的滚动条 */
/* 相对定位面板默认不显示滚动条；若内容过多，推荐分列布局避免溢出 */

/* ===================== 弹窗内容 UI 增强（不改原DOM，仅样式优化） ===================== */
/* 通用内容容器与标题 */
.popup-panel[data-position="relative"] .popup-content {
    padding: 14px 16px;
}
.popup-panel[data-position="relative"] .popup-content h6 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

/* 网格布局（图片编辑：模板/类型/比例/数量） */
.popup-panel[data-position="relative"] .popup-content .template-options,
.popup-panel[data-position="relative"] .popup-content .image-style-options,
.popup-panel[data-position="relative"] .popup-content .ratio-options,
.popup-panel[data-position="relative"] .popup-content .num-images-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

/* 选项按钮（图片编辑） */
.popup-panel[data-position="relative"] .popup-content .template-option,
.popup-panel[data-position="relative"] .popup-content .image-style-option,
.popup-panel[data-position="relative"] .popup-content .ratio-option,
.popup-panel[data-position="relative"] .popup-content .num-images-option {
    padding: 10px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    color: #2c3e50;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}
.popup-panel[data-position="relative"] .popup-content .template-option:hover,
.popup-panel[data-position="relative"] .popup-content .image-style-option:hover,
.popup-panel[data-position="relative"] .popup-content .ratio-option:hover,
.popup-panel[data-position="relative"] .popup-content .num-images-option:hover {
    border-color: #1890ff;
    background: #f0f9ff;
    color: #1890ff;
}
.popup-panel[data-position="relative"] .popup-content .image-style-option.active,
.popup-panel[data-position="relative"] .popup-content .ratio-option.active,
.popup-panel[data-position="relative"] .popup-content .num-images-option.active {
    border-color: #1890ff;
    background: #1890ff;
    color: #fff;
}

/* 语音克隆：音色列表布局与卡片样式 */
.popup-panel[data-position="relative"] .popup-content .voice-template-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.popup-panel[data-position="relative"] .popup-content .voice-skeleton-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.popup-panel[data-position="relative"] .popup-content .voice-skeleton {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border: 1px solid #f0f2f5;
    border-radius: 10px;
    background: #fff;
}
.popup-panel[data-position="relative"] .popup-content .voice-skeleton .vs-text {
    flex: 1;
}
.popup-panel[data-position="relative"] .popup-content .voice-skeleton .vs-line {
    height: 10px;
    background: linear-gradient(90deg, #f3f4f6 25%, #e9ecef 37%, #f3f4f6 63%);
    background-size: 400% 100%;
    border-radius: 6px;
    animation: vsShimmer 1.2s ease-in-out infinite;
}
.popup-panel[data-position="relative"] .popup-content .voice-skeleton .vs-line-1 { width: 70%; margin-bottom: 8px; }
.popup-panel[data-position="relative"] .popup-content .voice-skeleton .vs-line-2 { width: 50%; }
.popup-panel[data-position="relative"] .popup-content .voice-skeleton .vs-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(90deg, #f3f4f6 25%, #e9ecef 37%, #f3f4f6 63%);
    background-size: 400% 100%;
    animation: vsShimmer 1.2s ease-in-out infinite;
    margin-left: 12px;
}

@keyframes vsShimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}
.popup-panel[data-position="relative"] .popup-content .voice-template-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border: 1px solid #e1e5e9;
    border-radius: 10px;
    background: #fff;
    transition: all 0.2s ease;
    cursor: pointer;
}
.popup-panel[data-position="relative"] .popup-content .voice-template-option:hover {
    border-color: #1890ff;
    background: #f0f9ff;
    box-shadow: 0 4px 16px rgba(24, 144, 255, 0.1);
}
.popup-panel[data-position="relative"] .popup-content .voice-template-option .voice-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.popup-panel[data-position="relative"] .popup-content .voice-template-option .voice-name {
    font-size: 13px;
    font-weight: 600;
    color: #1f2d3d;
}
.popup-panel[data-position="relative"] .popup-content .voice-template-option .voice-description {
    font-size: 12px;
    color: #6c757d;
}
.popup-panel[data-position="relative"] .popup-content .voice-template-option .voice-preview i {
    font-size: 20px;
    color: #1890ff;
}

/* 小屏适配 */
@media (max-width: 768px) {
    .popup-panel[data-position="relative"] .popup-content .template-options,
    .popup-panel[data-position="relative"] .popup-content .image-style-options,
    .popup-panel[data-position="relative"] .popup-content .ratio-options,
    .popup-panel[data-position="relative"] .popup-content .num-images-options,
    .popup-panel[data-position="relative"] .popup-content .voice-template-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
/* hover模式下减少延迟，提升响应性 */
.popup-wrapper[data-relative="true"] {
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes popupSlideInTop {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* hover触发按钮的视觉反馈 */
.param-btn:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

/* 弹窗内容样式 */
.param-content {
    padding: 0;
}

.param-content h6 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

/* 模板网格 */
.template-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.template-btn {
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-btn:hover {
    border-color: #1890ff;
    color: #1890ff;
}

/* 模型列表 */
.model-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-list label {
    display: flex;
    align-items: center;
    padding: 8px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.model-list label:hover {
    border-color: #1890ff;
    background-color: #f0f9ff;
}

.model-list input {
    margin-right: 8px;
}

/* 比例网格 */
.ratio-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.ratio-btn {
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ratio-btn:hover,
.ratio-btn.active {
    border-color: #1890ff;
    background-color: #1890ff;
    color: white;
}

/* 数量选择器 */
.number-selector {
    display: flex;
    gap: 6px;
}

.num-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.num-btn:hover,
.num-btn.active {
    border-color: #1890ff;
    background-color: #1890ff;
    color: white;
}

/* 质量选项 */
.quality-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quality-options label {
    display: flex;
    align-items: center;
    padding: 8px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.quality-options label:hover {
    border-color: #1890ff;
    background-color: #f0f9ff;
}

.quality-options input {
    margin-right: 8px;
}

/* 时长滑块 */
.duration-slider {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #e1e5e9;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #1890ff;
    cursor: pointer;
}

.duration-display {
    text-align: center;
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

/* FPS选项 */
.fps-options {
    display: flex;
    gap: 6px;
}

.fps-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fps-btn:hover,
.fps-btn.active {
    border-color: #1890ff;
    background-color: #1890ff;
    color: white;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
}

.popup-header h6 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.popup-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.popup-close:hover {
    background: #f8f9fa;
    color: #000;
}

.popup-content {
    padding: 20px;
}

/* 图片选择选项样式 */
.image-select-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.image-select-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #495057;
}

.image-select-option:hover {
    background: #e9ecef;
    border-color: #1890ff;
    color: #1890ff;
}

.image-select-option:active {
    background: #dee2e6;
}

.image-select-option i {
    width: 16px;
    text-align: center;
    font-size: 14px;
}

.image-select-option span {
    flex: 1;
    font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .popup-panel {
        margin: 10px;
        width: calc(100% - 20px) !important;
        max-height: 90vh;
    }
    
    .popup-header {
        padding: 12px 16px;
    }
    
    .popup-content {
        padding: 16px;
    }
}