/* 主页特定样式 */

/* 页面跳转动画遮罩 */
#pageTransitionOverlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease-out;
    backdrop-filter: blur(4px);
}

#pageTransitionOverlay.show {
    opacity: 1;
}

#pageTransitionOverlay .transition-content {
    background: var(--card-bg, #ffffff);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#pageTransitionOverlay .transition-spinner {
    position: relative;
    width: 64px;
    height: 64px;
}

#pageTransitionOverlay .transition-ring-bg {
    width: 64px;
    height: 64px;
    border: 4px solid var(--border-color, #e0f2fe);
    border-radius: 50%;
}

#pageTransitionOverlay .transition-ring-spin {
    position: absolute;
    top: 0;
    left: 0;
    width: 64px;
    height: 64px;
    border: 4px solid transparent;
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#pageTransitionOverlay .transition-ring-inner {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 48px;
    height: 48px;
    border: 4px solid transparent;
    border-bottom-color: var(--accent-secondary, #67e8f9);
    border-radius: 50%;
    animation: spin-reverse 1s linear infinite;
}

#pageTransitionOverlay .transition-title {
    color: var(--accent-primary);
    font-weight: 500;
    font-size: 1.125rem;
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#pageTransitionOverlay .transition-sub {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* 反向旋转动画 */
@keyframes spin-reverse {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

.animate-spin-reverse {
    animation: spin-reverse 1s linear infinite;
}

/* 加载动画 */
@keyframes spin-reverse {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

@keyframes pulse-scale {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.animate-spin-reverse {
    animation: spin-reverse 1.2s linear infinite;
}

.animate-pulse-scale {
    animation: pulse-scale 2s ease-in-out infinite;
}

/* 历史记录和设置按钮定位样式 */
.top-corner-button {
    position: fixed;
    z-index: 10;
    background: #222;
    border: 1px solid #333;
    border-radius: 0.5rem;
    padding: 0.375rem 0.75rem;
    transition: all 0.2s ease;
}

.top-corner-button:hover {
    background: #333;
    border-color: white;
}

/* 搜索区域样式 */
.search-box {
    height: 3.5rem;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
    overflow: hidden;
    display: flex;
    align-items: stretch;
}

.search-button {
    width: 5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: black;
    font-weight: 500;
    transition: background-color 0.2s;
}

.search-button:hover {
    background: #f0f0f0;
}

.search-input {
    flex: 1;
    background: #111;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
    color: white;
    padding: 0 1.5rem;
    font-size: 1rem;
    outline: none;
    transition: background-color 0.2s;
}

.search-input:focus {
    background: #191919;
}

/* 最近搜索记录样式 */
.recent-search-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    margin: 0.25rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 0.5rem;
    color: #e5e7eb;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.recent-search-tag:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
}

/* 豆瓣区域样式 */
.douban-container {
    margin: 2rem auto;
    max-width: 1280px;
    padding: 0 0.5rem;
}

.douban-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.douban-toggle {
    display: flex;
    align-items: center;
    background: #222;
    border-radius: 9999px;
    padding: 0.25rem;
}

.douban-toggle-button {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 9999px;
}

.douban-toggle-button.active {
    background: #db2777;
    color: white;
}

.douban-toggle-button:not(.active) {
    color: #9ca3af;
}

.douban-toggle-button:not(.active):hover {
    color: white;
}

.douban-refresh-button {
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
    background: #db2777;
    color: white;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.douban-refresh-button:hover {
    background: #be185d;
}

.douban-tags-container {
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.douban-tags {
    display: flex;
    gap: 0.5rem;
    min-width: max-content;
}

.douban-tag {
    padding: 0.25rem 0.75rem;
    background: rgba(219, 39, 119, 0.1);
    border: 1px solid rgba(219, 39, 119, 0.2);
    border-radius: 0.5rem;
    color: #f9a8d4;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.douban-tag:hover {
    background: rgba(219, 39, 119, 0.2);
    border-color: rgba(219, 39, 119, 0.4);
}

.douban-tag.active {
    background: #db2777;
    border-color: #db2777;
    color: white;
}

/* 搜索结果样式 */
.search-results-container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 0.5rem;
}

.search-result-stats {
    text-align: right;
    font-size: 0.875rem;
    color: #9ca3af;
    margin-bottom: 1rem;
}

/* 响应式网格布局 */
.search-results-grid {
    display: grid;
    gap: 1rem;
}

@media (max-width: 640px) {
    .search-results-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .search-results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .search-results-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1025px) {
    .search-results-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 视频卡片样式 */
.video-card {
    position: relative;
    background: var(--card-bg);
    border-radius: 1rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--card-shadow);
}

.video-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px var(--card-hover-shadow), 0 8px 16px rgba(0, 0, 0, 0.08);
    border-color: var(--border-hover);
}

.video-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-card:hover::before {
    opacity: 1;
}

.video-card .poster-container {
    position: relative;
    aspect-ratio: 2/3;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.video-card .poster-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.video-card:hover .poster-container img {
    transform: scale(1.1);
}

.video-card .poster-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--accent-secondary);
    background: var(--bg-tertiary);
}

/* 封面加载失败占位图 */
.video-card .poster-error {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.video-card .poster-error:hover {
    background: var(--bg-tertiary);
}

.video-card .poster-error .error-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}

.video-card .poster-error .error-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.video-card .poster-error .error-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
}

.video-card .poster-error .retry-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.video-card .poster-error .retry-hint svg {
    width: 12px;
    height: 12px;
    animation: spin 2s linear infinite;
    animation-play-state: paused;
}

.video-card .poster-error:hover .retry-hint svg {
    animation-play-state: running;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.video-card .badge-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2.5rem 0.75rem 0.5rem;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}

.video-card .badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--btn-primary-bg);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 0.375rem;
    backdrop-filter: blur(4px);
    min-width: 2.5rem;
    text-align: center;
}

/* 角标加载动画 */
.video-card .badge.badge-loading {
    background: linear-gradient(135deg, rgba(100, 116, 139, 0.8), rgba(71, 85, 105, 0.8));
}

.video-card .badge .loading-dots {
    display: inline-flex;
    gap: 2px;
}

.video-card .badge .loading-dots span {
    animation: dotPulse 1.2s infinite;
    opacity: 0.3;
}

.video-card .badge .loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.video-card .badge .loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

.video-card .card-info {
    padding: 0.75rem;
    background: var(--card-bg);
}

.video-card .card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.video-card:hover .card-title {
    color: var(--accent-primary);
}

/* 播放图标覆盖层 */
.video-card .play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-card:hover .play-overlay {
    opacity: 1;
}

.video-card .play-icon {
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.video-card:hover .play-icon {
    transform: scale(1);
}

.video-card .play-icon svg {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--accent-primary);
    margin-left: 3px;
}

/* 分类筛选按钮样式 */
.filter-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 0.75rem;
    background: var(--bg-primary);
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
    box-shadow: 0 1px 3px var(--card-shadow);
}

.filter-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--card-hover-shadow);
}

.filter-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px var(--card-shadow);
}

.filter-btn.active {
    background: var(--btn-primary-bg);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px var(--accent-glow);
    font-weight: 600;
}

/* 搜索输入框聚焦效果 */
#searchInput:focus::placeholder {
    opacity: 0.5;
}

/* 内联加载指示器样式 */
#recentLoadingMore > div {
    animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 视频卡片入场动画 */
.video-card {
    animation: card-fade-in 0.4s ease-out backwards;
}

@keyframes card-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 为每个卡片添加延迟动画 */
.video-card:nth-child(1) { animation-delay: 0.02s; }
.video-card:nth-child(2) { animation-delay: 0.04s; }
.video-card:nth-child(3) { animation-delay: 0.06s; }
.video-card:nth-child(4) { animation-delay: 0.08s; }
.video-card:nth-child(5) { animation-delay: 0.10s; }
.video-card:nth-child(6) { animation-delay: 0.12s; }
.video-card:nth-child(7) { animation-delay: 0.14s; }
.video-card:nth-child(8) { animation-delay: 0.16s; }

/* 页面区域标题美化 */
#recentUpdatesArea h2,
#resultsArea h2 {
    letter-spacing: 0.025em;
}

/* 分类侧边栏滚动条美化 */
#categoryFilters::-webkit-scrollbar {
    width: 4px;
}

#categoryFilters::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 2px;
}

#categoryFilters::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

#categoryFilters::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========== 分类面板基础样式 ========== */

/* 分类列表 */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 分类组 */
.category-group {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* 分类标题栏 */
.category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.category-header:hover {
    background: var(--bg-secondary);
}

/* 分类图标 */
.category-icon {
    font-size: 20px;
}

/* 分类名称 */
.category-name {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

/* 分类数量徽章 */
.category-count {
    background: var(--btn-primary-bg);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

/* 展开箭头 */
.category-arrow {
    color: var(--text-muted);
    font-size: 12px;
    transition: transform 0.2s ease;
    padding: 4px;
}

.category-arrow:hover {
    color: var(--accent-primary);
}

/* 子分类容器 */
.category-subs {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

/* 子分类标签 */
.category-sub-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-sub-tag:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* 子分类数量 */
.category-sub-count {
    color: var(--text-muted);
    font-size: 12px;
}

.category-sub-tag:hover .category-sub-count {
    color: var(--accent-primary);
}
