/* 设置面板样式 - 精确控制动画触发版本 */

/* 禁用默认的transform transition，避免与动画冲突 */
body.settings-open.settings-animated header,
body.settings-open.settings-animated .container,
body.settings-open.settings-animated .video-player,
body.settings-open.settings-animated .mode-switcher,
body.settings-open.settings-animated .breadcrumb,
body.settings-open.settings-animated .category-grid,
body.settings-open.settings-animated .video-items,
body.settings-open.settings-animated .announcement,
body.settings-open.settings-animated .search-box,
body.settings-open.settings-animated .video-item,
body.settings-open.settings-animated .category-card {
    transition: none !important;
}

/* 排除标题文字，不参与躲避动画 */
body.settings-open.settings-animated header h1 {
    animation: none !important;
    transform: none !important;
}

/* 设置面板打开时的全局动画状态 - 只在有settings-animated类时触发 */
body.settings-open.settings-animated header {
    animation: avoidanceElastic 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

body.settings-open.settings-animated .container {
    animation: avoidanceElastic 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.05s forwards;
}

body.settings-open.settings-animated .video-player {
    animation: avoidanceElasticVideo 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s forwards;
    filter: brightness(0.9);
}

body.settings-open.settings-animated .mode-switcher {
    animation: avoidanceElastic 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.08s forwards;
}

body.settings-open.settings-animated .breadcrumb {
    animation: avoidanceElastic 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.06s forwards;
}

body.settings-open.settings-animated .category-grid {
    animation: avoidanceElastic 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.12s forwards;
}

body.settings-open.settings-animated .video-items {
    animation: avoidanceElastic 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.12s forwards;
}

body.settings-open.settings-animated .announcement {
    animation: avoidanceElasticSmall 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.02s forwards;
}

body.settings-open.settings-animated .search-box {
    animation: avoidanceElastic 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.04s forwards;
}

/* 设置面板关闭时的返回动画 - 只在有settings-animated类时触发 */
body:not(.settings-open).settings-animated header,
body:not(.settings-open).settings-animated .container,
body:not(.settings-open).settings-animated .mode-switcher,
body:not(.settings-open).settings-animated .breadcrumb,
body:not(.settings-open).settings-animated .category-grid,
body:not(.settings-open).settings-animated .video-items,
body:not(.settings-open).settings-animated .search-box {
    animation: returnElastic 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

body:not(.settings-open).settings-animated header h1 {
    animation: none !important;
    transform: none !important;
}

body:not(.settings-open).settings-animated .video-player {
    animation: returnElasticVideo 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    filter: brightness(1);
}

body:not(.settings-open).settings-animated .announcement {
    animation: returnElasticSmall 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

body:not(.settings-open).settings-animated .video-item,
body:not(.settings-open).settings-animated .category-card {
    animation: returnElastic 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* 视频卡片的个别动画效果 - 只在有settings-animated类时触发 */
body.settings-open.settings-animated .video-item:nth-child(odd) {
    animation: avoidanceElasticItem 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.15s forwards;
}

body.settings-open.settings-animated .video-item:nth-child(even) {
    animation: avoidanceElasticItemSmall 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.18s forwards;
}

/* 分类卡片的个别动画效果 */
body.settings-open .category-card:nth-child(1) {
    animation: avoidanceElasticCard1 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s forwards;
}

body.settings-open .category-card:nth-child(2) {
    animation: avoidanceElasticCard2 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.12s forwards;
}

body.settings-open .category-card:nth-child(3) {
    animation: avoidanceElasticCard3 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.14s forwards;
}

body.settings-open .category-card:nth-child(n+4) {
    animation: avoidanceElasticItemSmall 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.16s forwards;
}

/* 为背景添加遮罩效果 */
body.settings-open::before {
    opacity: 0.7;
    transition: opacity 0.4s ease;
}

/* 设置按钮 */
.settings-button {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(73, 73, 73, 0.503);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    text-decoration: none;
    color: white;
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.settings-button:hover {
    background-color: rgba(54, 54, 54, 0.4);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.settings-button:active {
    transform: scale(0.95) rotate(180deg);
    transition: all 0.2s ease;
}

.settings-button.active {
    transform: rotate(180deg) scale(1.1);
    background-color: rgba(0, 150, 136, 0.8);
    box-shadow: 0 6px 20px rgba(0, 150, 136, 0.4);
}

/* 设置侧边栏 */
.settings-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background-color: rgba(106, 106, 106, 0.363);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 999;
    transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    padding: 20px;
    overflow-y: auto;
    /* 隐藏滚动条 */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE 和 Edge */
}

.settings-sidebar::-webkit-scrollbar {
    display: none; /* Chrome, Safari 和 Opera */
}

.settings-sidebar.active {
    right: 0;
    box-shadow: -15px 0 30px rgba(0, 0, 0, 0.3);
}

/* 设置项进入动画 */
.settings-sidebar.active .setting-item {
    animation: settingsItemSlide 0.4s ease-out forwards;
}

.settings-sidebar.active .setting-item:nth-child(1) {
    animation-delay: 0.1s;
}

.settings-sidebar.active .setting-item:nth-child(2) {
    animation-delay: 0.15s;
}

.settings-sidebar.active .setting-item:nth-child(3) {
    animation-delay: 0.2s;
}

.settings-sidebar.active .setting-item:nth-child(4) {
    animation-delay: 0.25s;
}

.settings-sidebar.active .setting-item:nth-child(5) {
    animation-delay: 0.3s;
}

.settings-sidebar.active .setting-item:nth-child(6) {
    animation-delay: 0.35s;
}

/* 移动端响应式调整 */
@media (max-width: 768px) {
    .settings-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .settings-sidebar.active {
        right: 0;
    }
    
    /* 移动端的躲避动画幅度减小 */
    body.settings-open header,
    body.settings-open .container,
    body.settings-open .video-player,
    body.settings-open .mode-switcher,
    body.settings-open .breadcrumb,
    body.settings-open .category-grid,
    body.settings-open .video-items,
    body.settings-open .announcement,
    body.settings-open .search-box {
        animation: none;
        transform: none;
    }
}

@media (max-width: 480px) {
    .settings-sidebar {
        padding: 15px;
    }
    
    .settings-button {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

/* 设置头部 */
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.settings-header h2 {
    margin: 0;
    color: white;
}

/* 设置项目 */
.setting-item {
    margin-bottom: 25px;
    border-radius: 12px;
    background-color: rgba(40, 40, 40, 0.3);
    padding: 15px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateX(30px);
}

/* 设置项目头部 */
.setting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.setting-header h3 {
    margin: 0;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    display: flex;
    align-items: center;
}

/* 设置内容区域 */
.setting-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 1;
    margin-top: 10px;
}

.setting-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    overflow: hidden;
}

/* 折叠图标 */
.toggle-icon {
    transition: transform 0.3s ease;
    font-size: 18px;
    margin-left: 8px;
    color: rgba(177, 177, 177, 0.95);
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

/* 设置表单元素 */
.setting-item label {
    display: block;
    margin-bottom: 8px;
    color: white;
    font-weight: bold;
}

.setting-item select,
.setting-item input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
}

/* 背景预览 */
.background-preview {
    width: 100%;
    height: 150px;
    object-fit: cover;
    margin-top: 10px;
    border-radius: 8px;
}

/* 保存设置按钮 */
.save-settings {
    background-color: #4CAF50;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    font-size: 16px;
    margin-top: 20px;
    transition: background-color 0.3s;
}

.save-settings:hover {
    background-color: #45a049;
}
