/* 统一的背景设置面板 — Apple Light Theme */

.background-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 440px;
    max-height: 75vh;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    z-index: 2001;
    display: flex;
    flex-direction: column;
}

.background-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 标签页导航 */
.background-tabs {
    display: flex;
    padding: 12px 16px 0;
    gap: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.background-tab {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(134, 134, 139, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}

.background-tab:hover {
    color: rgba(29, 29, 31, 0.7);
    background: rgba(0, 0, 0, 0.03);
}

.background-tab.active {
    color: #0071e3;
    border-bottom-color: #0071e3;
}

.background-tab svg {
    width: 16px;
    height: 16px;
}

/* 标签页内容 */
.background-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.background-content::-webkit-scrollbar {
    width: 6px;
}

.background-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 3px;
}

.background-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.background-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

.background-tab-content {
    display: none;
}

.background-tab-content.active {
    display: block;
}

/* 纯色网格 */
.color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.color-item {
    aspect-ratio: 1;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.color-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0);
    transition: background 0.2s ease;
}

.color-item:hover::before {
    background: rgba(255, 255, 255, 0.15);
}

.color-item:hover {
    transform: scale(1.1);
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.color-item.active {
    border-color: #0071e3;
    box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.2);
}

.color-item.active::after {
    content: '\2713';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* 上传区域 */
.upload-area {
    border: 2px dashed rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-area:hover {
    border-color: rgba(0, 0, 0, 0.25);
    background: rgba(0, 0, 0, 0.02);
}

.upload-area.dragover {
    border-color: #0071e3;
    background: rgba(0, 113, 227, 0.06);
}

.upload-icon {
    color: rgba(134, 134, 139, 0.6);
    margin-bottom: 12px;
}

.upload-icon svg {
    display: block;
    margin: 0 auto;
}

.upload-text {
    font-size: 14px;
    color: rgba(29, 29, 31, 0.8);
    margin-bottom: 6px;
}

.upload-hint {
    font-size: 12px;
    color: rgba(134, 134, 139, 0.7);
}

/* 随机图片操作按钮 */
.random-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.random-load-btn,
.random-favorite-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.random-load-btn {
    background: #0071e3;
    color: white;
}

.random-load-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.random-load-btn:active {
    transform: translateY(0);
}

.random-load-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.random-load-btn.loading svg {
    animation: rotate 1s linear infinite;
}

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

.random-favorite-btn {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(29, 29, 31, 0.8);
}

.random-favorite-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.08);
    color: rgba(29, 29, 31, 0.95);
}

.random-favorite-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.random-favorite-btn.favorited {
    background: rgba(255, 149, 0, 0.12);
    color: #ff9500;
}

.random-favorite-btn.favorited .favorite-icon-empty {
    display: none;
}

.random-favorite-btn.favorited .favorite-icon-filled {
    display: block !important;
}

.random-favorite-btn:not(.favorited) .favorite-icon-empty {
    display: block;
}

.random-favorite-btn:not(.favorited) .favorite-icon-filled {
    display: none !important;
}

/* 收藏区域 */
.random-favorites-section {
    margin-top: 20px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 13px;
    color: rgba(134, 134, 139, 0.9);
    font-weight: 600;
}

.favorites-count {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.favorites-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: none;
    overflow-y: auto;
}

.favorites-grid::-webkit-scrollbar {
    width: 4px;
}

.favorites-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}

.favorites-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

/* 收藏项 — Flex 横排，宽松布局 */
.favorite-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: background 0.2s ease;
}

.favorite-item:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* 收藏缩略图 — 默认大尺寸 */
.favorite-preview {
    width: 220px;
    height: 124px;
    object-fit: cover;
    object-position: center;
    border-radius: 10px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.06);
    display: block;
}

/* 收藏操作按钮（右侧） */
.favorite-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

/* 收藏操作按钮 */
.favorite-item-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.06);
    color: rgba(29, 29, 31, 0.7);
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.favorite-item-btn:hover {
    background: rgba(0, 113, 227, 0.1);
    color: #0071e3;
}

.favorite-item-btn.delete:hover {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
}

/* 空状态占位符 */
.no-favorites-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.placeholder-text {
    font-size: 13px;
    color: rgba(134, 134, 139, 0.6);
}

/* 通知提示 */
.background-notification {
    position: fixed;
    top: 80px;
    right: 400px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    color: rgba(29, 29, 31, 0.9);
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    font-size: 13px;
    z-index: 10000;
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.background-notification.show {
    opacity: 1;
    transform: translateX(0);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .background-panel {
        width: 400px;
        max-height: 65vh;
    }
    
    .color-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .favorite-preview {
        width: 160px;
        height: 90px;
    }

    .favorite-item {
        padding: 8px 10px;
    }
    
    .background-notification {
        right: 480px;
    }
}

@media (max-width: 480px) {
    .background-panel {
        width: calc(100vw - 24px);
        max-height: 70vh;
        right: 12px;
    }
    
    .background-tabs {
        padding: 8px 12px 0;
    }
    
    .background-tab {
        padding: 8px 10px;
        font-size: 12px;
        gap: 4px;
    }
    
    .background-tab svg {
        width: 14px;
        height: 14px;
    }
    
    .background-content {
        padding: 12px;
    }
    
    .color-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .random-actions {
        flex-direction: column;
    }
    
    .favorites-grid {
        gap: 6px;
    }

    .favorite-preview {
        width: 160px;
        height: 90px;
    }

    .favorite-item {
        padding: 8px 10px;
    }

    .favorite-item-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .background-notification {
        right: auto;
        left: 50%;
        transform: translateX(-50%) translateY(-10px);
        font-size: 12px;
        padding: 10px 16px;
    }
    
    .background-notification.show {
        transform: translateX(-50%) translateY(0);
    }
}

/* 横屏模式 */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    .background-panel {
        width: 300px;
        max-height: 380px;
        top: 50px;
    }
    
    .background-tabs {
        padding: 8px 12px 0;
    }
    
    .background-tab {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .background-content {
        padding: 12px;
    }
    
    .color-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .upload-area {
        padding: 30px 15px;
    }
    
    .random-actions {
        margin-bottom: 12px;
    }
    
    .random-load-btn,
    .random-favorite-btn {
        padding: 8px 12px;
        font-size: 11px;
    }
    
    .favorites-grid {
        max-height: 200px;
    }

    .favorite-preview {
        width: 160px;
        height: 90px;
    }

    .favorite-item {
        padding: 6px 8px;
    }
    
    .background-notification {
        top: 50px;
    }
}
