/* ========================================
   zibll预选头像和背景预设插件 - 样式文件
   ======================================== */

/* ========================================
   头像选择样式
   ======================================== */

.zibll-avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px 0;
}

.zibll-avatar-item {
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 50%;
    overflow: hidden;
    transition: all 0.3s ease;
    aspect-ratio: 1;
    transform: scale(1);
    opacity: 1;
}

.zibll-avatar-item:hover {
    border-color: #007cba;
    transform: scale(1.05);
}

.zibll-avatar-item.selected {
    border-color: #00a0d2;
    box-shadow: 0 0 10px rgba(0, 160, 210, 0.5);
    transform: scale(1.1);
}

/* 头像选中动画效果 */
.zibll-avatar-item.selected-animation {
    animation: selected-pulse 0.5s ease-in-out;
}

/* 头像随机选择动画 */
.zibll-avatar-item.random-selecting {
    animation: random-pulse 0.3s ease-in-out;
}

@keyframes random-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); box-shadow: 0 0 15px rgba(255, 193, 7, 0.7); }
    100% { transform: scale(1); }
}

/* 头像保存中动画 */
.zibll-avatar-item.saving-avatar {
    animation: saving-pulse 1s ease-in-out infinite;
}

@keyframes saving-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

/* 头像保存成功动画 */
.zibll-avatar-item.save-success {
    animation: save-success 0.8s ease-in-out;
    border-color: #28a745;
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.5);
}

.zibll-avatar-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: all 0.3s ease;
}

.zibll-avatar-loading {
    color: #666;
}

.zibll-avatar-loading .fa-spinner {
    color: #007cba;
    animation: spin 1s linear infinite;
}

/* 弹窗样式 */
#zibll-avatar-modal .modal-dialog {
    margin: 30px auto !important;
    max-width: 90%;
    width: 800px;
}

/* 弹窗居中显示 - 只在显示时生效 */
#zibll-avatar-modal.in {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

#zibll-avatar-modal.in .modal-dialog {
    margin: 0 !important;
}

/* 弹窗动画效果 */
#zibll-avatar-modal.fade .modal-dialog {
    transform: translateY(-50px);
    transition: transform 0.3s ease-out;
}

#zibll-avatar-modal.fade.in .modal-dialog {
    transform: translateY(0);
}

/* 按钮加载状态样式 */
.but:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.random-btn-text,
.random-btn-loading,
.save-btn-text,
.save-btn-loading {
    display: inline-block;
    transition: all 0.3s ease;
}

.random-btn-loading i,
.save-btn-loading i {
    margin-right: 5px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================
   背景预设样式
   ======================================== */

/* 背景预设容器 */
.zibll-cover-preset-container {
    padding: 10px 0;
}

/* 背景预设网格布局 */
.zibll-cover-preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

/* 背景预设项 */
.zibll-cover-preset-item {
    position: relative;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    aspect-ratio: 2 / 1;
    background: var(--muted-border-color, #f0f0f0);
    transform: scale(1);
}

.zibll-cover-preset-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--theme-color, #2e7cff);
}

.zibll-cover-preset-item.selected {
    border-color: var(--theme-color, #2e7cff);
    box-shadow: 0 0 0 2px rgba(46, 124, 255, 0.2);
}

/* 选中动画效果 */
.zibll-cover-preset-item.selected-animation {
    animation: selected-pulse 0.5s ease-in-out;
}

@keyframes selected-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 15px rgba(46, 124, 255, 0.5); }
    100% { transform: scale(1); }
}

/* 保存成功动画 */
.zibll-cover-preset-item.save-success {
    animation: save-success 0.8s ease-in-out;
    border-color: #4caf50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
}

@keyframes save-success {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); box-shadow: 0 0 20px rgba(76, 175, 80, 0.7); }
    100% { transform: scale(1); }
}

.zibll-cover-preset-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: all 0.3s ease;
}

.zibll-cover-preset-item:hover img {
    transform: scale(1.05);
}

/* 选中标记 */
.zibll-cover-preset-item .cover-preset-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    background: var(--theme-color, #2e7cff);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: check-fade-in 0.3s ease;
}

@keyframes check-fade-in {
    from { opacity: 0; transform: scale(0); }
    to { opacity: 1; transform: scale(1); }
}

.zibll-cover-preset-item.selected .cover-preset-check {
    display: flex;
}

/* 封面更新动画 */
.cover-updated {
    animation: cover-update 1s ease-in-out;
}

@keyframes cover-update {
    0% { 
        opacity: 0.5; 
        transform: scale(0.95); 
    }
    50% { 
        opacity: 0.8; 
        transform: scale(1.02); 
    }
    100% { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* 保存按钮样式 */
#save-cover-btn {
    position: relative;
    transition: all 0.3s ease;
}

#save-cover-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.save-btn-text,
.save-btn-loading {
    display: inline-block;
    transition: all 0.3s ease;
}

.save-btn-loading i {
    margin-right: 5px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 滚动条样式 */
.zibll-cover-preset-grid::-webkit-scrollbar,
.zibll-avatar-grid::-webkit-scrollbar {
    width: 6px;
}

.zibll-cover-preset-grid::-webkit-scrollbar-track,
.zibll-avatar-grid::-webkit-scrollbar-track {
    background: var(--muted-border-color, #f0f0f0);
    border-radius: 3px;
}

.zibll-cover-preset-grid::-webkit-scrollbar-thumb,
.zibll-avatar-grid::-webkit-scrollbar-thumb {
    background: var(--muted-color, #999);
    border-radius: 3px;
}

.zibll-cover-preset-grid::-webkit-scrollbar-thumb:hover,
.zibll-avatar-grid::-webkit-scrollbar-thumb:hover {
    background: var(--main-color, #666);
}

/* ========================================
   响应式设计
   ======================================== */

@media (max-width: 768px) {
    /* 头像响应式 */
    .zibll-avatar-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }
    
    #zibll-avatar-modal .modal-dialog {
        max-width: 95%;
        width: auto;
    }
    
    /* 背景预设响应式 */
    .zibll-cover-preset-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
        max-height: 350px;
    }
}

@media (max-width: 480px) {
    .zibll-cover-preset-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        max-height: 300px;
    }
}
