/**
 * 壁纸管理样式
 */

/* 引入独立配色系统 */
@import url('./settings-colors.css');

.wallpaper-subsection {
    margin-bottom: 14px;
}

.wallpaper-subsection-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 8px;
}

.wallpaper-type-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 8px 0 6px 0;
}

.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.wallpaper-item {
    position: relative;
    cursor: pointer;
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: all var(--transition-fast);
    border: 2px solid var(--bg-border);
}

.wallpaper-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--link-color);
}

.wallpaper-item.active {
    border-color: var(--link-color);
    box-shadow: 0 0 0 2px var(--link-color);
}

.wallpaper-preview {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 比例 */
    background-size: cover;
    background-position: center;
    background-color: var(--bg-secondary);
}

/* iframe内容绝对定位，完全填充preview容器 */
.wallpaper-preview iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none;
}

/* 视频预览 */
.preview-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--bg-secondary);
}

/* 加载状态 */
.preview-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* 错误状态 */
.preview-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
}

.error-icon {
    font-size: 16px;
    margin-bottom: 4px;
}

.error-text {
    font-size: 9px;
    margin-bottom: 2px;
}

.error-url {
    font-size: 8px;
    color: var(--text-tertiary);
    word-break: break-all;
    max-width: 80px;
    margin: 0 auto;
}

/* 类型标识徽章 */
.wallpaper-type-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 8px;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 5;
    backdrop-filter: blur(2px);
}

.badge-image {
    background: rgba(76, 175, 80, 0.9);
    color: white;
}

.badge-video {
    background: rgba(220, 53, 69, 0.9);
    color: white;
}

.badge-code {
    background: rgba(91, 192, 222, 0.9);
    color: white;
}

.badge-unknown {
    background: rgba(107, 114, 128, 0.9);
    color: white;
}

/* 加载完成的类 */
.video-loaded .preview-loading,
.code-loaded .preview-loading {
    display: none;
}

.wallpaper-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 0, 0, 0.8);
    color: var(--active-text-color);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    transition: all var(--transition-fast);
}

.wallpaper-item:hover .wallpaper-delete {
    display: flex;
}

.wallpaper-delete:hover {
    background: rgba(255, 0, 0, 1);
    transform: scale(1.1);
}

.wallpaper-name {
    padding: 4px;
    font-size: 10px;
    color: var(--text-color);
    text-align: center;
    background: var(--bg-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* URL输入容器 */
.url-input-container {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    align-items: stretch;
}

.wallpaper-url-input {
    flex: 1;
    padding: 6px 8px;
    font-size: 11px;
    color: var(--text-color);
    background: var(--bg-primary);
    border: 1px solid var(--bg-border);
    border-radius: var(--border-radius);
    outline: none;
    transition: all var(--transition-fast);
}

.wallpaper-url-input:focus {
    border-color: var(--link-color);
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}

.wallpaper-url-input::placeholder {
    color: var(--text-tertiary);
}

.wallpaper-add-btn {
    padding: 6px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-color);
    background: var(--bg-primary);
    border: 1px solid var(--link-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.wallpaper-add-btn:hover {
    background: var(--link-color);
    color: var(--active-text-color);
    transform: scale(1.02);
}

.wallpaper-upload-btn,
.wallpaper-color-btn,
.wallpaper-none-btn {
    width: 100%;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-color);
    background: var(--bg-primary);
    border: 2px dashed var(--bg-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 8px;
}

.wallpaper-upload-btn:hover,
.wallpaper-color-btn:hover,
.wallpaper-none-btn:hover {
    border-color: var(--link-color);
    background: var(--hover-bg);
}

.wallpaper-none-btn.active {
    border-style: solid;
    border-color: var(--link-color);
    background: var(--link-color);
    color: var(--active-text-color);
}

.wallpaper-tip {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
}

/* 随机API样式 */
.random-api-container {
    margin-bottom: 12px;
}

.api-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
}

.api-title::before {
    content: '🎲';
    margin-right: 4px;
    font-size: 10px;
}

/* 紧凑布局 - 一行5个 */
.api-buttons-compact {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.api-button-compact {
    padding: 6px 4px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    text-align: center;
    min-height: 32px;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.api-button-compact:hover {
    border-color: var(--link-color);
    background: var(--hover-bg);
    transform: translateY(-1px);
    z-index: 1;
}

.api-name-compact {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 9px;
    line-height: 1.2;
}

/* 为紧凑布局添加tooltip */
.api-button-compact::after {
    content: attr(title);
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 8px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.api-button-compact:hover::after {
    opacity: 1;
}

/* API壁纸项特殊样式 */
.wallpaper-item[data-type="random-api"],
.wallpaper-item[data-type="bing-image"] {
    position: relative;
}

.wallpaper-item[data-type="random-api"]::after,
.wallpaper-item[data-type="bing-image"]::after {
    content: '🔄';
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.wallpaper-item[data-type="random-api"]:hover::after,
.wallpaper-item[data-type="bing-image"]:hover::after {
    opacity: 1;
}

.wallpaper-item[data-type="random-api"]:active::after,
.wallpaper-item[data-type="bing-image"]:active::after {
    transform: rotate(180deg);
}

/* API状态指示器 */
.api-status {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: var(--success-color);
    color: white;
    border-radius: 2px;
    padding: 1px 3px;
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
}

.api-status.loading {
    background: var(--warning-color);
    animation: pulse 1.5s infinite;
}

.api-status.error {
    background: var(--error-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* 当前随机壁纸区域 */
.current-random-section {
    border: 2px solid var(--link-color);
    background: rgba(64, 158, 255, 0.05);
}

.current-random-section .wallpaper-subsection-title::before {
    content: '✨ ';
}

.current-random-container {
    display: flex;
    justify-content: center;
}

.current-random-container .wallpaper-item {
    width: 200px;
    border: 2px solid var(--link-color);
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}

.refresh-button {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    font-size: 12px;
}

.refresh-button:hover {
    background: rgba(64, 158, 255, 0.9);
    transform: scale(1.1);
}

.refresh-button:active {
    transform: scale(0.95) rotate(180deg);
}

/* 响应式 */
@media (max-width: 768px) {
    .wallpaper-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* 小屏幕下紧凑布局调整为3列 */
    .api-buttons-compact {
        grid-template-columns: repeat(3, 1fr);
        gap: 3px;
    }
    
    .api-button-compact {
        padding: 5px 2px;
        min-height: 28px;
        font-size: 8px;
    }
    
    .api-name-compact {
        font-size: 8px;
    }
    
    /* 更小屏幕调整 */
    @media (max-width: 480px) {
        .api-buttons-compact {
            grid-template-columns: repeat(2, 1fr);
        }
    }
    
    .current-random-container .wallpaper-item {
        width: 160px;
    }
}

/* 超小屏幕特殊处理 */
@media (max-width: 400px) {
    .api-buttons-compact {
        grid-template-columns: repeat(2, 1fr);
        gap: 2px;
    }
    
    .api-button-compact {
        padding: 4px 1px;
        min-height: 26px;
        font-size: 7px;
    }
    
    .api-name-compact {
        font-size: 7px;
    }
}
