
/* ==================================================
   NightTube - 全站样式
   PC：左侧固定导航 + 4列影片
   平板：3列影片
   手机：右侧滑出导航 + 2列影片
================================================== */


/* ==============================
   1. 全局变量
================================ */

:root {
    --bg: #0f0f0f;
    --panel: #181818;
    --panel-hover: #272727;
    --border: #303030;

    --text: #f1f1f1;
    --text-secondary: #aaaaaa;

    --accent: #3ea6ff;

    --topbar-height: 64px;
    --sidebar-width: 240px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, "Microsoft YaHei", sans-serif;
    font-size: 14px;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}


/* ==============================
   2. 顶部导航栏
================================ */

.topbar {
    position: fixed;
    z-index: 3000;
    top: 0;
    left: 0;
    right: 0;

    height: var(--topbar-height);

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 28px;

    background: rgba(15, 15, 15, 0.98);
    border-bottom: 1px solid #222;
}

.topbar-left {
    width: 240px;
    min-width: 240px;

    display: flex;
    align-items: center;
    gap: 22px;
}


/* 菜单按钮 */

.menu-toggle {
    width: 38px;
    height: 38px;

    padding: 10px 8px;

    display: flex;
    flex-direction: column;
    justify-content: space-around;

    border: 0;
    border-radius: 50%;

    background: transparent;
}

.menu-toggle:hover {
    background: var(--panel-hover);
}

.menu-toggle span {
    width: 22px;
    height: 2px;

    display: block;

    background: #eee;
    border-radius: 2px;
}


/* Logo */

.site-logo {
    display: flex;
    align-items: center;
    gap: 9px;
    white-space: nowrap;
}

.logo-icon {
    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 9px;

    background: #e62117;
    color: #fff;

    font-size: 19px;
    font-weight: 800;
}

.logo-text {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.5px;
}


/* 搜索栏 */

.topbar-search {
    width: min(600px, 55%);
    margin: 0 auto;
}

.search-box {
    width: 100%;
    height: 42px;

    display: flex;
    overflow: hidden;

    border: 1px solid #333;
    border-radius: 24px;

    background: #121212;
}

.search-box:focus-within {
    border-color: #3d6b91;
}

.search-box input {
    flex: 1;
    min-width: 0;

    padding: 0 20px;

    border: 0;
    outline: 0;

    background: transparent;
    color: #fff;

    font-size: 15px;
}

.search-box input::placeholder {
    color: #888;
}

.search-box button {
    width: 62px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-left: 1px solid #333;

    background: #252525;
}

.search-box button:hover {
    background: #333;
}

.search-box svg {
    width: 21px;
    height: 21px;

    fill: none;
    stroke: #eee;
    stroke-width: 2;
    stroke-linecap: round;
}


/* 用户入口 */

.topbar-right {
    width: 240px;
    min-width: 80px;

    display: flex;
    justify-content: flex-end;
}

.user-avatar {
    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #285b8f;
    color: #fff;

    font-weight: 700;
}


/* ==============================
   3. 页面主体布局
================================ */

.page-shell {
    min-height: 100vh;
    padding-top: var(--topbar-height);
}


/* ==============================
   4. 左侧导航栏（PC）
================================ */

.sidebar {
    position: fixed;
    z-index: 2000;

    top: var(--topbar-height);
    bottom: 0;
    left: 0;

    width: var(--sidebar-width);

    display: flex;
    flex-direction: column;

    padding: 14px 12px;

    overflow-x: hidden;
    overflow-y: auto;

    background: var(--bg);

    transition: transform 0.25s ease;
}

.sidebar-nav {
    flex: 1;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-item {
    width: 100%;
    min-height: 44px;

    display: flex;
    align-items: center;
    gap: 20px;

    padding: 0 13px;

    border: 0;
    border-radius: 10px;

    background: transparent;
    color: #e5e5e5;

    text-align: left;

    transition: background 0.15s ease;
}

.nav-item:hover {
    background: var(--panel-hover);
}

.nav-icon {
    width: 22px;
    flex-shrink: 0;

    color: #ddd;

    font-size: 20px;
    text-align: center;
}

.nav-text {
    min-width: 0;
    overflow: hidden;

    color: #e5e5e5;

    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-divider {
    height: 1px;

    margin: 13px 0;

    background: var(--border);
}

.nav-heading {
    padding: 8px 13px 12px;

    color: #aaa;

    font-size: 14px;
    font-weight: 600;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 7px;

    padding: 18px 13px 8px;

    color: #777;
    font-size: 12px;
}


/* ==============================
   5. 右侧主内容区域
================================ */

.main-area {
    min-height: calc(100vh - var(--topbar-height));

    margin-left: var(--sidebar-width);

    padding: 24px 30px 50px;

    transition: margin-left 0.25s ease;
}

.page-content {
    width: 100%;
    max-width: 1800px;

    margin: 0 auto;
}


/* ==============================
   6. PC端侧栏收起
================================ */

body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .main-area {
    margin-left: 0;
}


/* ==============================
   7. 页面标题
================================ */

.home-heading {
    margin-bottom: 24px;
}

.home-heading .page-title {
    margin-bottom: 8px;
}

.home-subtitle {
    margin: 0;
    color: #999;
    font-size: 14px;
}

.page-title {
    margin: 0 0 22px;

    color: #f5f5f5;

    font-size: 23px;
    font-weight: 700;
}

.section-title {
    margin: 28px 0 18px;

    color: #f5f5f5;

    font-size: 19px;
    font-weight: 700;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 16px;
}

.section-header .section-title {
    margin: 0;
}

.more-link {
    color: #aaa;
    font-size: 13px;
}

.more-link:hover {
    color: #fff;
}


/* ==============================
   8. 视频网格
================================ */

.video-section {
    width: 100%;
}

.video-grid {
    display: grid;

    grid-template-columns: repeat(4, minmax(0, 1fr));

    column-gap: 18px;
    row-gap: 30px;
}

.video-card {
    min-width: 0;
    overflow: hidden;
}

.video-card-link {
    display: block;
}


/* 视频封面 */

.video-cover {
    position: relative;

    width: 100%;
    aspect-ratio: 16 / 9;

    overflow: hidden;

    border-radius: 12px;

    background: #252525;
}

.video-cover img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: cover;

    transition: transform 0.25s ease;
}

.video-card:hover .video-cover img {
    transform: scale(1.04);
}


/* 视频备注 */

.video-remarks {
    position: absolute;

    right: 8px;
    bottom: 8px;

    max-width: 85%;

    overflow: hidden;

    padding: 4px 7px;

    border-radius: 4px;

    background: rgba(0, 0, 0, 0.78);
    color: #fff;

    font-size: 11px;

    text-overflow: ellipsis;
    white-space: nowrap;
}


/* 视频信息 */

.video-info {
    display: flex;
    gap: 12px;

    padding-top: 12px;
}

.video-avatar {
    width: 36px;
    height: 36px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #333;
    color: #ccc;
}

.video-detail {
    min-width: 0;
    flex: 1;
}


/* 视频标题 */

.video-title {
    display: -webkit-box;

    overflow: hidden;

    color: #f1f1f1;

    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;

    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.video-card:hover .video-title {
    color: var(--accent);
}


/* 播放次数和添加日期 */

.video-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;

    gap: 3px 12px;

    margin-top: 7px;

    color: #aaa;

    font-size: 12px;
    line-height: 1.7;
}

.video-meta span {
    display: inline-block;
    white-space: nowrap;
}

/* 影片日期：亮蓝色 */
.video-date {
    color: #3ea6ff !important;
    font-weight: 600;
}


/* ==============================
   9. 通用状态
================================ */

.empty-state {
    padding: 70px 20px;

    color: #888;
    text-align: center;
}


/* ==============================
   10. 平板布局
================================ */

@media (max-width: 1200px) {

    .video-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .main-area {
        padding-right: 22px;
        padding-left: 22px;
    }

}


/* ==============================
   11. 分类折叠菜单
================================ */

.category-nav {
    width: 100%;
}

.category-group {
    width: 100%;
}


/* 一级分类按钮 */

.category-toggle {
    width: 100%;
    min-height: 44px;

    display: flex;
    align-items: center;

    border: 0;
    text-align: left;

    background: transparent;
    color: #e5e5e5;

    cursor: pointer;
}

.category-toggle:hover {
    background: #272727;
}

.category-toggle .nav-text {
    flex: 1;
}


/* 展开箭头 */

.category-arrow {
    margin-left: auto;

    color: #888;
    font-size: 21px;

    transition: transform 0.2s ease;
}

.category-toggle.active .category-arrow {
    transform: rotate(90deg);
}

.category-toggle.active {
    background: #222;
}


/* 二级分类 */

.category-submenu {
    display: none;

    padding: 4px 0 7px 34px;
}

.category-submenu.open {
    display: block;
}

.category-subitem {
    min-height: 38px;

    display: flex;
    align-items: center;
    gap: 10px;

    padding: 0 12px;

    border-radius: 8px;

    color: #aaa;
    font-size: 13px;

    transition: background 0.15s ease, color 0.15s ease;
}

.category-subitem:hover {
    background: #272727;
    color: #fff;
}

.subitem-dot {
    color: #666;
    font-size: 18px;
    flex-shrink: 0;
}


/* ==============================
   12. 手机布局
================================ */

@media screen and (max-width: 768px) {

    :root {
        --topbar-height: 56px;
    }


    /* 顶部导航 */

    .topbar {
        position: fixed !important;
        z-index: 3000 !important;

        top: 0;
        left: 0;
        right: 0;

        width: 100%;
        height: 56px !important;

        padding: 0 12px !important;

        display: flex;
        align-items: center;
        justify-content: flex-start;
    }


    /* Logo区域 */

    .topbar-left {
        position: static !important;

        width: auto !important;
        min-width: 0 !important;
        height: 100%;

        display: flex;
        align-items: center;

        gap: 0;
        padding: 0 !important;

        flex: 0 0 auto;
    }

    .logo-icon {
        width: 29px;
        height: 29px;
        font-size: 17px;
    }

    .logo-text {
        font-size: 16px;
    }


    /* 三横线按钮：固定在右上角 */

    .menu-toggle {
        position: absolute !important;

        top: 50% !important;
        right: 8px !important;
        left: auto !important;

        width: 36px !important;
        height: 36px !important;

        margin: 0 !important;
        padding: 8px !important;

        display: flex !important;
        align-items: center;
        justify-content: space-around;

        transform: translateY(-50%) !important;

        z-index: 3001 !important;
    }


    /* 搜索栏 */

    .topbar-search {
        position: relative;

        height: 100%;

        width: auto !important;
        min-width: 0 !important;

        flex: 1 1 auto;

        margin: 0 44px 0 12px !important;

        display: flex;
        align-items: center;
    }

    .topbar-search form {
        width: 100%;
        min-width: 0;
        margin: 0;
    }

    .search-box {
        width: 100%;
        min-width: 0;
        height: 36px;
    }

    .search-box input {
        width: 100%;
        height: 36px;

        min-width: 0;

        padding: 0 12px;

        font-size: 13px;
    }

    .search-box button {
        width: 42px;
        height: 36px;
        flex-shrink: 0;
    }

    .topbar-right {
        display: none !important;
    }


    /* ==============================
       手机侧栏：从右侧滑出
    ============================== */

    #sidebar.sidebar {
        position: fixed !important;

        top: 56px !important;
        right: 0 !important;
        left: auto !important;
        bottom: 0 !important;

        width: 150px !important;
        min-width: 150px !important;
        max-width: 150px !important;

        height: calc(100vh - 56px) !important;
        height: calc(100dvh - 56px) !important;

        display: flex !important;
        flex-direction: column;

        padding: 12px 6px !important;

        box-sizing: border-box !important;

        background: #181818 !important;

        z-index: 2000 !important;

        /* 默认隐藏在右侧屏幕外 */
        transform: translateX(105%) !important;

        visibility: hidden;
        pointer-events: none;

        transition:
            transform 0.25s ease,
            visibility 0.25s ease;

        overflow-y: auto !important;
        overflow-x: hidden !important;

        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }


    /* 点击三横线后从右侧滑出 */

    body.mobile-menu-open #sidebar.sidebar {
        transform: translateX(0) !important;

        visibility: visible;
        pointer-events: auto;
    }


    /* 侧栏内部 */

    #sidebar .sidebar-nav {
        width: 100%;
        flex: 1;
        padding: 0 !important;
    }

    #sidebar .nav-group,
    #sidebar .category-group {
        width: 100%;
    }


    /* 普通菜单和一级分类 */

    #sidebar .nav-item,
    #sidebar .category-toggle {
        width: 100% !important;
        min-height: 40px !important;

        display: flex;
        align-items: center;

        padding: 6px 5px !important;
        gap: 5px !important;

        font-size: 15px !important;
    }


    /* 菜单图标 */

    #sidebar .nav-icon {
        width: 17px !important;
        min-width: 17px !important;

        font-size: 13px !important;
    }


    /* 一级菜单文字 */

    #sidebar .nav-text {
        min-width: 0;
        flex: 1;

        font-size: 15px !important;

        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }


    /* 分类标题 */

    #sidebar .nav-heading {
        padding: 8px 5px !important;
        font-size: 12px !important;
    }


    /* 分类箭头 */

    #sidebar .category-arrow {
        font-size: 16px !important;
    }


    /* 二级分类 */

    #sidebar .category-submenu {
        padding: 3px 0 5px 15px !important;
    }

    #sidebar .category-subitem {
        min-height: 34px !important;

        padding: 5px 3px !important;
        gap: 5px !important;

        font-size: 13px !important;
    }

    #sidebar .subitem-dot {
        font-size: 13px;
    }


    /* 侧栏底部 */

    #sidebar .sidebar-footer {
        padding: 10px 5px !important;
        font-size: 10px !important;
    }


    /* 手机遮罩 */

    body.mobile-menu-open::after {
        position: fixed;

        content: "";

        top: 56px;
        right: 0;
        bottom: 0;
        left: 0;

        background: rgba(0, 0, 0, 0.6);

        z-index: 1500;

        pointer-events: auto;
    }


    /* 手机内容区域 */

    .main-area {
        width: 100% !important;

        margin-left: 0 !important;

        padding: 18px 12px 35px;
    }

    body.sidebar-collapsed .main-area {
        margin-left: 0 !important;
    }


    /* 手机视频两列 */

    .video-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));

        column-gap: 12px;
        row-gap: 22px;
    }

    .video-cover {
        border-radius: 8px;
    }

    .video-info {
        gap: 8px;
        padding-top: 8px;
    }

    .video-avatar {
        display: none;
    }

    .video-title {
        font-size: 13px;
    }


    /* 手机播放次数和添加日期 */

    .video-meta {
        display: flex;
        flex-wrap: wrap;
        align-items: center;

        gap: 2px 8px;

        margin-top: 4px;

        font-size: 11px;
        line-height: 1.6;
    }


    /* 手机标题 */

    .home-heading {
        margin-bottom: 18px;
    }

    .home-subtitle {
        font-size: 12px;
    }

    .section-header {
        margin-bottom: 13px;
    }

}


/* ==============================
   13. 小屏手机
================================ */

@media screen and (max-width: 380px) {

    .logo-text {
        display: none;
    }

    .topbar-search {
        margin-left: 8px !important;
        margin-right: 44px !important;
    }

    .main-area {
        padding-right: 9px;
        padding-left: 9px;
    }

    .video-grid {
        column-gap: 9px;
    }

}


/* ==============================
   14. PC端搜索框垂直居中
================================ */

@media screen and (min-width: 769px) {

    .topbar-search {
        align-self: center !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        transform: translateY(8px);
    }

}


/* ==============================
   15. 首页栏目今日更新数量
================================ */

/* 栏目今日更新文字 */
.today-count {
    display: inline-block;
    margin-left: 10px;
    font-size: 13px;
    font-weight: normal;
    color: #999;
    vertical-align: middle;
}

/* 栏目今日更新数字：亮蓝色 */
.today-number {
    color: #3ea6ff !important;
    font-size: 15px;
    font-weight: 700;
}

/* 首页影片日期：亮蓝色 */
.video-meta .video-date,
.video-meta .today-video-date,
.today-video-date {
    color: #3ea6ff !important;
    font-weight: 600;
}
