/**
 * 改进的预设和风格选择样式
 * 支持选中项优先排列和高亮显示
 */

/* 快速选择项的激活状态 - 增强版 */
.quick-style-item.active,
.quick-preset-item.active,
#quick-presets-container .quick-preset-item.active,
#quick-styles-container .quick-style-item.active {
    /* 统一为蓝色描边+阴影，去除渐变背景与缩放动画 */
    background: #ffffff !important;
    border: none !important;
    transform: none !important;
    box-shadow: 0 0 0 2px #3b82f6, 0 8px 15px rgba(59, 130, 246, 0.15) !important;
    position: relative;
    z-index: 5;
    animation: none !important;
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 12px 30px rgba(76, 99, 210, 0.4);
    }
    100% {
        box-shadow: 0 15px 35px rgba(76, 99, 210, 0.6);
    }
}

.quick-style-item.active::before,
.quick-preset-item.active::before,
#quick-presets-container .quick-preset-item.active::before,
#quick-styles-container .quick-style-item.active::before {
    /* 移除发光边框动画，保持与文生图一致 */
    content: none !important;
}

@keyframes borderGlow {
    0% { 
        background-position: 0% 50%; 
        filter: hue-rotate(0deg);
    }
    25% { 
        background-position: 100% 50%; 
        filter: hue-rotate(90deg);
    }
    50% { 
        background-position: 100% 100%; 
        filter: hue-rotate(180deg);
    }
    75% { 
        background-position: 0% 100%; 
        filter: hue-rotate(270deg);
    }
    100% { 
        background-position: 0% 50%; 
        filter: hue-rotate(360deg);
    }
}

.quick-style-item.active .quick-style-name,
.quick-preset-item.active .quick-preset-name,
#quick-presets-container .quick-preset-item.active .quick-preset-name,
#quick-styles-container .quick-style-item.active .quick-style-name {
    color: #1f2937 !important;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.8);
    font-size: 0.95em;
}

.quick-style-item.active .quick-style-image img,
.quick-preset-item.active .quick-preset-image img,
#quick-presets-container .quick-preset-item.active .quick-preset-image img,
#quick-styles-container .quick-style-item.active .quick-style-image img {
    filter: brightness(1.15) contrast(1.15) saturate(1.2);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

/* 选中标记 - 参考文生图风格实现 */
.quick-style-item.active::after,
.quick-preset-item.active::after {
    /* 使用右上角矩形角标 */
    content: '✓' !important;
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    width: 20px !important;
    height: 20px !important;
    background-color: #3b82f6 !important;
    color: white !important;
    border-radius: 0 0 0 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 12px !important;
    font-weight: bold !important;
    z-index: 20 !important;
}

/* 调试用CSS - 强制显示勾选标记 */
.quick-preset-item.active {
    position: relative !important;
}

/* 统一勾选标记效果：已在通用选择器中定义 */

@keyframes checkmarkPop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(-90deg);
        opacity: 0.7;
    }
    80% {
        transform: scale(1.1) rotate(10deg);
        opacity: 0.9;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* 未激活状态的hover效果 */
.quick-style-item:not(.active):hover,
.quick-preset-item:not(.active):hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border-color: #8b5cf6;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-style-item:not(.active):hover::before,
.quick-preset-item:not(.active):hover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(124, 58, 237, 0.1));
    border-radius: inherit;
    z-index: -1;
}

/* 基础样式改进 - 确保勾选标记显示，图生图更大气 */
.quick-style-item,
.quick-preset-item {
    position: relative !important;
    cursor: pointer;
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    overflow: visible !important; /* 确保勾选标记不被裁剪 */
    padding: 1rem;
    min-height: 180px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 统一卡片尺寸（预设与风格一致） */
#quick-presets-container .quick-preset-item {
    min-height: 180px;
    padding: 1rem;
    border-radius: 16px;
}

/* 图片容器样式增强 */
.quick-preset-image,
.quick-style-image {
    width: 100%;
    height: 120px;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 0.75rem;
}

/* 统一缩略图尺寸（与风格一致） */
#quick-presets-container .quick-preset-image {
    height: 120px;
    border-radius: 12px;
    margin-bottom: 0.75rem;
}

.quick-preset-image img,
.quick-style-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* 文字样式增强 */
.quick-preset-name,
.quick-style-name {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
    line-height: 1.3;
}

/* 图生图预设文字更大 */
#quick-presets-container .quick-preset-name {
    font-size: 1rem;
    font-weight: 700;
}

/* Modal中隐藏的选项 */
.style-card[style*="display: none"],
.preset-card[style*="display: none"] {
    display: none !important;
}

/* Modal中选项的淡出效果 */
.style-card.fade-out,
.preset-card.fade-out {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* 快速选择容器的改进样式 */
.quick-select-container {
    position: relative;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    padding: 1.2rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.quick-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.quick-select-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

/* 隐藏原来的查看更多按钮 */
.view-more-btn {
    display: none !important;
}

/* 统一网格布局（PC 3列×2行） */
.quick-styles-grid,
.quick-presets-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, auto);
    gap: 10px;
    margin-top: 12px;
    max-width: 100%;
    overflow: hidden;
}

/* 预设与风格统一布局，不区分容器 */
#quick-presets-container .quick-presets-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, auto);
    gap: 10px;
    padding: 0;
}

/* 移动端强制覆盖 - 最高优先级 */
@media (max-width: 768px) {
    #quick-presets-container .quick-presets-grid,
    .i2i-horizontal-layout .quick-presets-grid,
    .quick-presets-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
        grid-template-rows: auto !important;
        gap: 4px !important;
    }
}

/* 更多按钮样式 - 调整为5列布局 */
.more-presets-item,
.more-styles-item {
    border: 2px dashed #d1d5db !important;
    background: #f9fafb !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    min-height: 180px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}

/* 图生图更多按钮特殊样式 */
#quick-presets-container .more-presets-item {
    min-height: 220px !important;
    border-radius: 20px !important;
}

.more-presets-item:hover,
.more-styles-item:hover {
    border-color: #8b5cf6 !important;
    background: #faf5ff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15) !important;
}

.more-presets-icon,
.more-styles-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 48px !important;
    color: #9ca3af !important;
    font-size: 1.6rem !important;
}

.more-presets-item:hover .more-presets-icon,
.more-styles-item:hover .more-styles-icon {
    color: #8b5cf6 !important;
}

.more-presets-item .quick-preset-name,
.more-styles-item .quick-style-name {
    color: #6b7280 !important;
    font-weight: 500 !important;
}

.more-presets-item:hover .quick-preset-name,
.more-styles-item:hover .quick-style-name {
    color: #8b5cf6 !important;
}

/* 确保更多按钮不会被选中效果影响 */
.more-presets-item::after,
.more-styles-item::after {
    display: none !important;
}

@media (max-width: 768px) {
    /* 移动端：两行布局，第一行3个，第二行2个选项+1个更多按钮 */
    .quick-styles-grid,
    .quick-presets-grid {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        grid-template-rows: repeat(2, auto) !important;
        gap: 12px !important;
        padding-bottom: 0 !important;
        overflow: visible !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    
    /* 移动端快速选择项样式（与mobile-styles.css完全统一） */
    .quick-style-item,
    .quick-preset-item {
        width: 100% !important;
        max-width: 100% !important;
        aspect-ratio: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        border: 1px solid #e5e7eb !important;
        background-color: #ffffff !important;
        border-radius: 8px !important;
        overflow: hidden !important;
        min-height: 0 !important;
        position: relative !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .quick-preset-image,
    .quick-style-image {
        width: 100% !important;
        height: 70% !important;
        margin: 0 !important;
        border-radius: 6px !important;
        overflow: hidden !important;
        aspect-ratio: 1 !important;
    }
    
    .quick-preset-image img,
    .quick-style-image img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    .quick-style-name,
    .quick-preset-name {
        height: 30% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
        overflow: hidden !important;
        font-size: 10px !important;
        padding: 2px 1px 0 !important;
        width: 100% !important;
    }
    
    /* 移动端"更多"按钮统一样式（第6个卡片） */
    .more-styles-item,
    .more-presets-item {
        width: 100% !important;
        max-width: 100% !important;
        aspect-ratio: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        border: 1px dashed #cbd5e1 !important;
        background: #f8fafc !important;
        border-radius: 8px !important;
        overflow: hidden !important;
        min-height: 0 !important;
        position: relative !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        visibility: visible !important;
        opacity: 1 !important;
        color: #64748b !important;
    }
    
    .more-presets-icon,
    .more-styles-icon {
        font-size: 14px !important;
        color: #9ca3af !important;
        margin-bottom: 2px !important;
        height: auto !important;
    }
    
    .more-styles-item .quick-style-name,
    .more-presets-item .quick-preset-name {
        font-size: 10px !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: center !important;
        color: #64748b !important;
    }
    
    /* 移动端交互效果（与mobile-styles.css完全统一） */
    .quick-style-item:active,
    .quick-preset-item:active {
        transform: scale(0.95) !important;
    }
    
    .quick-style-item:hover,
    .quick-preset-item:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* 移动端选中效果（与mobile-styles.css完全统一） */
    .quick-style-item.active,
    .quick-preset-item.active {
        border-color: #3b82f6 !important;
        box-shadow: 0 0 8px rgba(59, 130, 246, 0.3) !important;
    }
    
    .quick-style-item.active::after,
    .quick-preset-item.active::after {
        content: '✓' !important;
        position: absolute !important;
        top: 6px !important;
        right: 6px !important;
        width: 18px !important;
        height: 18px !important;
        background: #22c55e !important;
        color: white !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 10px !important;
        font-weight: bold !important;
        z-index: 10 !important;
    }
    
    /* 移动端角标样式（与mobile-styles.css保持一致） */
    .quick-style-badge,
    .quick-preset-badge {
        position: absolute !important;
        top: 0 !important;
        right: 0 !important;
        background: linear-gradient(135deg, #f97316, #ea580c) !important;
        color: white !important;
        font-size: 10px !important;
        font-weight: 500 !important;
        padding: 2px 6px !important;
        border-radius: 0 6px 0 6px !important;
        z-index: 5 !important;
        line-height: 1 !important;
    }
    
    .quick-style-badge.new,
    .quick-preset-badge.new {
        background: linear-gradient(135deg, #10b981, #059669) !important;
    }
    
    .quick-style-name,
    .quick-preset-name {
        white-space: nowrap;
        word-break: normal;
        line-height: 1.2;
    }
    
    .quick-select-container {
        padding: 1rem;
    }
}

/* 移动端模态框样式已移至 mobile-modal-fix.css */

/* 加载状态 */
.quick-style-item.loading,
.quick-preset-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.quick-style-item.loading::after,
.quick-preset-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f4f6;
    border-top: 2px solid #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}
