/* 基础样式 - 修复浏览器缩放问题 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px; /* 固定基础字体大小，不受缩放影响 */
    height: 100%;
    scroll-behavior: auto;
}

body {
    font-family: "OPPO Sans 4.0", 'Microsoft YaHei', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: white;
    min-height: 100%;
    overflow-x: hidden;
    position: relative;
    /* 使用rem单位，基于html的font-size */
}

/* 防止锚点影响布局 */
*:target {
    scroll-margin-top: 0;
}

/* 容器基础样式 */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* 导航栏样式 */
.navbar {
    background: #1565C0;
    padding: 0.7rem 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: none;
    margin: 0;
    padding: 0 1rem;
    width: 100%;
}

.navbar-brand {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.navbar-nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.navbar-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.navbar-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-login {
    border: none !important;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}


/* 用户头像和下拉菜单样式 */
.user-menu {
    position: relative;
    display: inline-block;
}

.user-avatar {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-text {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    color: #1565C0;
}

.avatar-image {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.9);
    display: block;
}


.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 120px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 2500;
    overflow: hidden;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu {
    padding: 0;
}

/* 重置下拉菜单项的所有样式，避免继承导航栏样式 */
.user-dropdown .dropdown-item {
    all: unset;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    padding: 0.6rem 0.8rem !important;
    color: #333 !important;
    text-decoration: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-size: 0.9rem !important;
    font-family: 'Microsoft YaHei', Arial, sans-serif !important;
    font-weight: normal !important;
    transition: background-color 0.2s ease !important;
    transform: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    cursor: default !important;
}

/* 下拉菜单图标样式 */
.dropdown-icon {
    width: 16px;
    height: 16px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    flex-shrink: 0;
}

.user-icon {
    background-image: url('/static/icons/user.svg');
}

.logout-icon {
    background-image: url('/static/icons/logout.svg');
}

/* 下拉菜单悬停效果 */
.user-dropdown .dropdown-item:hover {
    background-color: #f0f0f0 !important;
    color: #333 !important;
    text-decoration: none !important;
    transform: none !important;
    font-weight: normal !important;
    cursor: default !important;
}

/* 移除退出登录项的边框和特殊样式 */

/* 主要内容区域 */
.main-content {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 12rem; /* 大幅增加与导航栏的距离 */
    padding-bottom: 2rem;
    overflow-y: auto;
}

/* 搜索容器 */
.search-container {
    width: 100%;
    max-width: 600px;
    padding: 0 2rem;
    margin-bottom: 8rem; /* 大幅增加与分类区域的距离 */
}

.search-box {
    display: flex;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 2px solid #e0e0e0;
    position: relative;
}

.search-input {
    flex: 1;
    border: none;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    outline: none;
    background: transparent;
}

.search-input::placeholder {
    color: #999;
}

.search-btn {
    background: #1565C0;
    color: white;
    border: none;
    padding: 1rem 1.2rem;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    background-image: url('/static/icons/search.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px 20px;
}

.search-btn:hover {
    background-color: #0d47a1;
    background-image: url('/static/icons/search.svg');
}


/* 大屏幕优化 */
@media (min-width: 1200px) {
    .navbar .container {
        padding: 0 1.5rem;
    }
}

/* 超大屏幕进一步优化 */
@media (min-width: 1600px) {
    .navbar .container {
        padding: 0 2rem;
    }
}

/* 汉堡菜单按钮 */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* 侧边菜单 */
.mobile-sidebar {
    position: fixed;
    top: 0;
    right: -50%;
    width: 50%;
    height: 100vh;
    background: white;
    transition: right 0.3s ease;
    z-index: 2000;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

.mobile-sidebar.open {
    right: 0;
}

.mobile-sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}


.mobile-sidebar-link {
    display: block;
    padding: 1.2rem 1.5rem;
    color: #333;
    text-decoration: none;
    font-size: 1.1rem;
    transition: background 0.3s ease;
    text-align: center;
}

.mobile-sidebar-link:hover {
    background: #f8f9fa;
    color: #333;
}

/* 遮罩层 */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1500;
}

.mobile-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .navbar .container {
        flex-direction: row;
        gap: 0;
        padding: 0 1rem;
        justify-content: space-between;
        align-items: center;
    }
    
    .navbar-nav {
        display: none;
    }
    
    /* 手机模式显示用户头像和汉堡菜单 */
    .mobile-nav-right {
        display: flex;
        align-items: center;
        gap: 1rem;
    }
    
    /* 手机模式下保持与桌面版相同的按钮样式 */
    .mobile-nav-right .btn-login {
        border: none !important;
        padding: 0.5rem 1rem;
        border-radius: 6px;
        font-size: 0.9rem;
        font-weight: 500;
        color: white;
        text-decoration: none;
    }
    
    .mobile-nav-right .user-menu {
        position: relative;
    }

    .mobile-nav-right .user-avatar {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-nav-right .avatar-text {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }

    .mobile-nav-right .user-dropdown {
        right: 0;
        width: 120px;
        z-index: 2500 !important;
    }
    
    /* 搜索栏移动端适配 */
    .search-container {
        padding: 0 1rem;
        max-width: 100%;
        margin-bottom: 4rem; /* 移动端增加与分类的间距 */
    }
    
    /* 移动端主内容区域调整 */
    .main-content {
        padding-top: 8rem; /* 移动端增加顶部间距 */
    }
    
    .search-input {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
    
    .search-btn {
        padding: 0.8rem 1rem;
        min-width: 50px;
        background-size: 18px 18px;
    }
}

/* 随机影视推荐区域样式 */
.section-divider {
    width: 100%;
    max-width: 1200px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #e0e0e0, transparent);
    margin: 3rem 0 2rem 0;
}

.random-movies-section {
    width: 100%;
    margin-bottom: 3rem;
    padding: 0 2%;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0;
}

.random-movies-section .section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #1565C0;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.refresh-btn:hover {
    background: #0d47a1;
    transform: translateY(-1px);
}

.refresh-btn svg {
    transition: transform 0.3s ease;
}

.refresh-btn:hover svg {
    transform: rotate(180deg);
}

.random-movies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.5rem;
    padding: 0;
}

.random-movie-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.random-movie-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.movie-poster {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    overflow: hidden;
}

.movie-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.random-movie-card:hover .movie-poster img {
    transform: scale(1.05);
}

.movie-info {
    padding: 1rem;
}

.movie-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: center;
}

/* 加载和错误状态样式 */
.loading-placeholder,
.empty-placeholder,
.error-placeholder {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
    font-size: 0.9rem;
    grid-column: 1 / -1;
}

.loading-placeholder {
    color: #1565C0;
}

.error-placeholder {
    color: #d32f2f;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .random-movies-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 0;
    }
    
    .section-header {
        padding: 0;
    }
    
    .section-title {
        font-size: 1.3rem;
    }
    
    .refresh-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .movie-info {
        padding: 0.8rem;
    }
    
    .movie-title {
        font-size: 0.85rem;
    }
}

/* 桌面模式隐藏手机菜单 */
@media (min-width: 769px) {
    .mobile-nav-right {
        display: none;
    }
}
