/* CSS 重置与设计系统
 * ==========================================
 * 这是项目的主样式表，涵盖了全局重置、变量定义、布局组件和通用样式。
 */

/* --- 1. 全局重置 (Reset) --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    /* 确保 padding 和 border 不会增加元素宽度 */
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    /*字体平滑渲染*/
    color: var(--text-main);
    background-color: var(--bg-body);
    transition: background-color 0.3s ease, color 0.3s ease;
    /* 主题切换时的平滑过渡 */
    display: flex;
    /* Flex 布局用于侧边栏结构 */
    height: 100vh;
    /* 占满全屏高度 */
    overflow: hidden;
    /* 防止 Body 滚动，使用内部滚动 */
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
    /*移除列表默认样式*/
}

img {
    max-width: 100%;
    display: block;
    /* 消除图片下方的默认空白 */
}

/* --- 2. 变量定义 (Design System Variables) --- */
:root {
    /* ☀️ 明亮模式 (Light Mode) - 参考 Bilibili 风格 */
    --primary-color: #FB7299;
    /* 主题粉色 */
    --hover-color: #ff85ad;
    /* 悬停粉色 */

    --text-main: #18191C;
    /* 主要文字颜色 */
    --text-secondary: #9499A0;
    /* 次要文字颜色 */

    --bg-body: #F4F5F7;
    /* 页面背景色 (浅灰) */
    --bg-sidebar: #FFFFFF;
    /* 侧边栏背景 */
    --bg-header: #FFFFFF;
    /* 顶部导航背景 */
    --bg-card: #FFFFFF;
    /* 卡片背景 */

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.1);

    --border-radius: 8px;
    --sidebar-width: 240px;
    --header-height: 64px;

    --input-bg: #F1F2F3;
    /* 搜索框背景 */
    --input-text: #18191C;
    --border-color: #E3E5E7;

    --bg-modal: rgba(255, 255, 255, 0.85);
    /* 模态框半透明背景 */
}

[data-theme="dark"] {
    /* 🌙 暗黑模式 (Dark Mode) - 参考 Anime Republic 风格 */
    --primary-color: #FFA500;
    /* 主题橙金色 */
    --hover-color: #ffb833;

    --text-main: #E0E0E0;
    /* 浅灰白文字 */
    --text-secondary: #A0A0A0;
    /* 深灰文字 */

    --bg-body: #0F0F0F;
    /* 深黑背景 */
    --bg-sidebar: #1A1A1A;
    /* 侧边栏深灰 */
    --bg-header: #1F1F1F;
    /* 头部深灰 */
    --bg-card: #2D2D2D;
    /* 卡片深灰 */

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.5);

    --input-bg: #2D2D2D;
    --input-text: #EEEEEE;
    --border-color: #444444;

    --bg-modal: rgba(30, 30, 30, 0.85);
    /* 暗黑模态框背景 */
}

/* --- 3. 布局工具 (Layout Utilities) --- */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* --- 4. 侧边栏样式 (Sidebar) --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    white-space: nowrap;
}

/* Logo 区域 */
.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2rem;
    padding-left: 0.5rem;
    position: relative;
    height: 40px;
}

.logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    transition: opacity 0.2s;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    transition: opacity 0.2s;
}

/* 导航菜单 */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    transition: all 0.2s;
    font-weight: 500;
    justify-content: flex-start;
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(var(--primary-color), 0.1);
    /* 浅色半透明背景 */
    color: var(--primary-color);
    background-color: var(--bg-body);
    /* 在明亮模式下增加对比 */
}

[data-theme="dark"] .nav-item:hover,
[data-theme="dark"] .nav-item.active {
    background-color: rgba(255, 255, 255, 0.05);
    /* 暗黑模式下的悬停背景 */
    color: var(--primary-color);
}

.nav-item .icon {
    font-size: 1.2rem;
    margin-right: 12px;
}

/* 分割线 */
.nav-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 8px 0;
}

/* --- 5. 主内容区样式 (Main Body) --- */
.main-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body);
    position: relative;
    min-width: 0;
    /* 防止 Flex 子元素溢出 */
}

/* 顶部 Header */
.top-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    background-color: var(--bg-header);
    z-index: 10;
    transition: background-color 0.3s;
}

/* 搜索栏 */
.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--input-bg);
    border-radius: 20px;
    padding: 0 16px;
    height: 40px;
    width: 300px;
    transition: width 0.3s;
    /* 聚焦时宽度伸展动画 */
    position: relative;
    /* 为下拉菜单定位 */
}

.search-bar:focus-within {
    width: 400px;
}

.search-input {
    border: none;
    background: transparent;
    flex: 1;
    color: var(--input-text);
    outline: none;
    font-size: 0.9rem;
}

.search-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
}

/* 搜索下拉菜单 */
.search-dropdown {
    position: absolute;
    top: 100%;
    /* 正下方 */
    left: 0;
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin-top: 8px;
    padding: 12px 0;
    z-index: 100;
    display: none;
    /* 默认隐藏 */
}

.search-section {
    margin-bottom: 12px;
}

.search-section-title {
    padding: 8px 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.search-tag {
    margin-right: 8px;
    padding: 4px 10px;
    background: var(--bg-body);
    border-radius: 12px;
    font-size: 0.85rem;
    display: inline-block;
    margin-bottom: 8px;
    cursor: pointer;
}

.history-list {
    padding: 0 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.clear-history {
    cursor: pointer;
    font-size: 0.8rem;
}

.clear-history:hover {
    color: var(--primary-color);
}

.search-item {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.95rem;
    color: var(--text-main);
    /* 修复文字颜色 */
}

.search-item:hover {
    background-color: var(--hover-color);
}

/* 搜索排名徽章 */
.rank-badge {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background-color: #ccc;
    color: white;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-weight: bold;
}

.rank-1 {
    background-color: #ff4757;
}

/* 红色 */
.rank-2 {
    background-color: #ffa502;
}

/* 橙色 */
.rank-3 {
    background-color: #eccc68;
}

/* 金色 */
.rank-other {
    background-color: #747d8c;
    opacity: 0.5;
}

/* 用户操作区域 (Theme Toggle, Notify, History, Avatar) */
.user-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.action-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: color 0.2s;
    position: relative;
    /* 历史记录下拉菜单的定位基准 */
}

.action-btn:hover {
    color: var(--primary-color);
}

.avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
}

/* 修复：暗黑模式下图标反色 (变白) */
[data-theme="dark"] .action-btn img,
[data-theme="dark"] .search-btn img {
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

/* --- 6. 观看历史下拉菜单 (Watch History Dropdown) --- */
.history-dropdown {
    position: absolute;
    top: 100%;
    right: -10px;
    width: 320px;
    background-color: #1F1F1F;
    /* 固定深色背景 */
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    z-index: 200;
    text-align: left;
    max-height: 500px;
    overflow-y: auto;
    cursor: default;

    /* 隐藏滚动条 */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.history-dropdown::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Opera */
}

.history-group-title {
    font-size: 1rem;
    color: #fff;
    margin: 10px 0 10px 0;
    font-weight: 500;
}

.history-group-title:first-child {
    margin-top: 0;
}

.history-item {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    cursor: pointer;
    /* 可点击 */
    padding: 0;
    border-radius: 6px;
    transition: opacity 0.2s;
}

.history-item:hover {
    opacity: 0.8;
}

.history-cover {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 6px;
    filter: none !important;
    /* 防止被全局暗黑模式反色影响 */
}

.history-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.history-name {
    font-size: 0.95rem;
    color: #fff;
    font-weight: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-meta {
    font-size: 0.8rem;
    color: #999;
}

/* --- 7. 可滚动内容区域 (Content Scroll) --- */
.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 2rem 3rem;
}

/* --- 8. 主页推荐轮播 (Featured Hero) --- */
.featured-hero {
    position: relative;
    height: 450px;
    width: 100%;
    margin-bottom: 3rem;
    border-radius: var(--border-radius);
    overflow: hidden;
    color: white;
    /* 始终白色文字 */
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center top;
    transition: background-image 0.5s ease-in-out;
    z-index: 0;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    /* 降低亮度以凸显文字 */
    z-index: 1;
}

.hero-container {
    position: relative;
    z-index: 2;
    display: flex;
    height: 100%;
    padding: 3rem;
    gap: 2rem;
    align-items: center;
}

/* Hero 左侧信息 */
.hero-info {
    flex: 1;
    max-width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* 内容沉底 */
    align-items: flex-start;
    padding-bottom: 2rem;
    height: 100%;
}

/* 文本淡入动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.anim-text {
    animation: fadeIn 0.8s ease-out;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.hero-desc {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    /* 最多显示3行 */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.play-btn {
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 12px 32px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.play-btn:hover {
    transform: scale(1.05);
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(var(--primary-color), 0.4);
}

/* Hero 右侧列表缩略图 */
.hero-list {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 35%;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    z-index: 10;
}

.hero-item {
    flex: 1;
    height: 195px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    background: #000;
    display: flex;
    flex-direction: column;
}

.hero-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.6);
    /* 默认变暗 */
    transition: filter 0.3s;
}

.hero-item:hover img,
.hero-item.active img {
    filter: brightness(1);
    /* 激活或悬停亮起 */
}

.hero-item.active {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(var(--primary-color), 0.6);
}

.hero-item-title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 6px 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.85rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* --- 9. 视频网格与分区 (Video Grid & Sections) --- */
.video-section {
    padding: 30px 40px;
    max-width: 1600px;
    margin: 0 auto 3rem;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
}

.section-title h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
}

.more-link {
    font-size: 0.9rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 16px;
    transition: all 0.2s;
}

.more-link:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.video-grid {
    display: grid;
    /* 强制4列布局 */
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.video-card {
    width: 100%;
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.video-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
}

.card-cover {
    width: 100%;
    aspect-ratio: 3/4;
    /* 封面比例 */
    position: relative;
    overflow: hidden;
}

.card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.video-card:hover .card-cover img {
    transform: scale(1.05);
    /* 封面轻微缩放 */
}

/* 卡片统计数据 (位于封面左下角) */
.card-stats {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 2.5rem 0.5rem 0.5rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: white;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    opacity: 1;
}

.play-btn img,
.card-stats img {
    filter: brightness(0) invert(1);
    /* 确保 SVG 图标为白色 */
}

.card-info {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    /* 限制标题一行显示 */
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

/* --- 10. 页脚 (Footer) --- */
.main-footer {
    text-align: center;
    color: var(--text-secondary);
    padding-bottom: 2rem;
    font-size: 0.9rem;
}

/* --- 11. 通知模态框 (Modal) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    /* 遮罩层 */
    align-items: flex-start;
    justify-content: center;
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: var(--bg-modal);
    backdrop-filter: blur(12px);
    /* 毛玻璃效果 */
    padding: 30px;
    border-radius: 12px;
    width: 400px;
    text-align: center;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    margin-top: 80px;
    /* 距离顶部偏移 */
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.close-modal:hover {
    color: var(--primary-color);
}