/* 
 * GAMX-UI - 主样式表
 * 版本: 1.0.0
 * 描述: 为GAMX管理系统提供统一的样式定义
 */

/* ---------- 1. 变量和重置样式 ---------- */
:root {
    /* 颜色变量 - 系统级颜色定义 */
    --primary-color: #1E88E5;
    --secondary-color: #0D47A1;
    --accent-color: #00C853;
    --background-color: #f0f2f5;
    --sidebar-bg-color: #262626;
    --sidebar-text-color: #FFFFFF;
    --sidebar-text-secondary: #B0B0B0;
    --sidebar-border-color: #333333;
    --card-bg-color: #FFFFFF;
    --text-color: #333333;
    --text-secondary: #666666;
    --border-color: #E0E0E0;
    --success-color: #00C853;
    --danger-color: #FF3D00;
    --warning-color: #FFD600;
    
    /* 布局变量 - 全局尺寸和间距定义 */
    --sidebar-width: 240px;
    --mobile-header-height: 60px;
    --card-border-radius: 8px;
    --submenu-transition: max-height 0.3s ease, opacity 0.2s ease, transform 0.2s ease;
}

/* 全局样式重置和基础设定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow-y: auto;
    font-display: swap; /* 优化字体加载 */
}

.app-container {
    display: flex;
    min-height: 100dvh;
    width: 100%;        /* 显式控制宽度 */
    position: relative;  /* 按需添加，如果需要定位上下文 */
    overflow-x: hidden;  /* 更安全的溢出控制 */
}

/* ---------- 2. 按钮样式 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    border: none;
    text-decoration: none;
    gap: 6px;
    height: 36px;
    line-height: 1;
}

.btn i {
    font-size: 14px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
}

.btn-primary:hover {
    background-color: #0D47A1;
    border-color: #0D47A1;
}

.btn-primary:active {
    background-color: #01579B;
    border-color: #01579B;
}

.btn-outline {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: rgba(30, 136, 229, 0.05);
}

.btn-outline:active {
    background-color: rgba(30, 136, 229, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ---------- 3. 侧边栏样式 ---------- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg-color); 
    border-right: 1px solid var(--sidebar-border-color);
    display: flex;
    flex-direction: column;
    height: 100dvh;
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
    transform: translateZ(0); /* 启用硬件加速 */
    will-change: transform; /* 优化动画性能 */
    
    /* 自定义滚动轴样式 */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) #262626;
}

/* Webkit浏览器的滚动轴样式 (Chrome, Safari, Edge) */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #262626;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    border: 2px solid #262626;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

/* Logo 区域样式 */
.logo {
    padding: 20px;
    text-align: center;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--sidebar-border-color);
}

.logo img {
    height: 40px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
}

/* SVG Logo颜色控制 - 侧边栏和顶部导航的白色Logo */
.sidebar .logo img,
.mobile-header .mobile-logo img {
    filter: brightness(0) invert(1); /* 将SVG转为白色 */
}


/* 主导航栏样式 */
.main-nav {
    flex: 1; /* 占据剩余空间 */
    overflow-y: auto; /* 内容超出时可滚动 */
    padding-bottom: 10px; /* 底部边距 */
}

.main-nav ul {
    list-style: none;
}

.main-nav li {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
}

.main-nav li:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.main-nav li.active {
    border-left: 3px solid var(--primary-color);
    padding-left: 17px;
}

.main-nav li i {
    margin-right: 16px;
    font-size: 16px;
    color: var(--sidebar-text-secondary);
    width: 20px;
    text-align: center;
    height: 18px;
    line-height: 18px;
    flex-shrink: 0;
}

.main-nav li span {
    color: #999999;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.main-nav li.active i,
.main-nav li.active span {
    color: #ffffff;
}

.main-nav li.has-submenu {
    padding-right: 15px;
}

/* 导航分隔线 */
.nav-divider {
    height: 1px !important;
    padding: 0 !important;
    margin: 10px 20px !important;
    background-color: var(--sidebar-border-color) !important;
    cursor: default !important;
}

.nav-divider:hover {
    background-color: var(--sidebar-border-color) !important;
}

/* 子菜单图标样式 */
.submenu-icon {
    margin-left: auto !important;
    margin-right: 0 !important;
    font-size: 11px !important;
    color: var(--sidebar-text-secondary) !important;
    opacity: 0.7;
    width: auto !important;
    height: auto !important;
    line-height: normal !important;
    transition: transform 0.3s ease;
}

.has-submenu.active .submenu-icon {
    color: #ffffff !important;
    opacity: 1;
}



/* ---------- 4. 子菜单样式 ---------- */
/* 子菜单容器基本样式 */
.submenu {
    list-style: none;
    width: 100%;
    padding: 0;
    margin: 0;
    background-color: rgba(0, 0, 0, 0.15);
    transition: var(--submenu-transition);
    overflow: hidden;
    max-height: 0; /* 初始状态下隐藏 */
    opacity: 0;
    transform: translateY(-10px);
    will-change: max-height, opacity, transform; /* 优化动画性能 */
}

/* 子菜单显示状态 */
.submenu.show {
    max-height: 500px; /* 显示时的最大高度 */
    opacity: 1;
    transform: translateY(0);
    padding-left: calc(10% - 21px) !important;
    /* 默认情况下不显示左边框 */
    border-left: none !important;
}

/* 子菜单项被点击后，整个子菜单容器显示边框 */
.has-submenu.active + .submenu.show {
    border-left: 3px solid var(--primary-color) !important;
    padding-left: calc(10% - 24px) !important; /* 调整内边距补偿3px边框 */
    background-color: rgba(0, 0, 0, 0.2);
}

/* 子菜单项样式 */
.submenu-item,
.submenu .submenu-item,
ul.submenu > li {
    display: block;
    padding: 12px 0 12px 53px; /* 包含父菜单左边框的3px偏移 */
    margin: 0;
    font-size: 14px;
    color: var(--sidebar-text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
    text-decoration: none;
    border: none !important;
    background: none;
    text-align: left;
    width: 100%;
    position: static;
}

/* 子菜单项悬停效果 */
.submenu-item:hover,
.submenu .submenu-item:hover {
    color: #ffffff;
}

/* 子菜单项激活样式 */
.submenu-item.active,
.submenu .submenu-item.active,
ul.submenu > li.active {
    color: #ffffff;
    padding-left: 53px !important;
}

/* 子菜单图标旋转动画 */
.has-submenu .submenu-icon {
    transition: transform 0.3s ease;
}

.has-submenu.submenu-open .submenu-icon {
    transform: rotate(180deg);
}

/* ---------- 5. 用户信息样式 ---------- */
.user-section {
    padding: 20px;
    border-top: 1px solid var(--sidebar-border-color);
    margin-top: auto;
    background-color: var(--sidebar-bg-color);
}

.user-profile {
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
}

.user-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.username {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
}

.user-role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    display: inline-block;
}

/* 退出菜单样式 */
.logout-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 200px;
    background-color: #1a1a1a;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 8px 0;
    margin-bottom: 10px;
    display: none;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-menu.show {
    display: block;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.menu-item i {
    margin-right: 12px;
    width: 16px;
    text-align: center;
}

.menu-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

.menu-item.logout {
    color: #ff4d4f;
}

.menu-item.logout:hover {
    background-color: rgba(255, 77, 79, 0.1);
    color: #ff7875;
}

/* ---------- 6. 主内容区域样式 ---------- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: calc(100% - var(--sidebar-width));
    transition: width 0.3s ease, margin-left 0.3s ease;
}

.content-wrapper {
    flex: 1;
    overflow: hidden;
    background-color: var(--background-color);
    position: relative;
}

#content-frame {
    width: 100%;
    height: 100%;
    border: none;
    background-color: var(--background-color);
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* ---------- 7. 移动端样式 ---------- */
/* 移动端头部样式 */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-header-height);
    background-color: var(--sidebar-bg-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.mobile-logo {
    display: flex;
    align-items: center;
    height: var(--mobile-header-height);
}

.mobile-logo img {
    height: 32px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
}

.mobile-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.mobile-menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 移动端用户菜单 */
.mobile-user-menu {
    display: none;
    position: fixed;
    top: var(--mobile-header-height);
    right: 10px;
    width: 240px;
    background: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    border-radius: var(--card-border-radius);
    padding: 12px 0;
    transition: all 0.3s ease;
}

.mobile-user-menu.show {
    display: block;
}

.mobile-user-info {
    display: flex;
    align-items: center;
    padding: 12px 16px;
}

.mobile-user-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
}

.mobile-user-menu .username {
    font-weight: 500;
    font-size: 14px;
    color: #333;
}

.mobile-user-menu .user-role {
    font-size: 12px;
    color: #666;
}

.mobile-user-menu .menu-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: #333;
    transition: background-color 0.2s;
}

.mobile-user-menu .menu-item:hover {
    background-color: #f5f7fa;
}

.mobile-user-menu .menu-item i {
    margin-right: 12px;
    width: 16px;
    color: #666;
}

.mobile-user-menu .menu-divider {
    height: 1px;
    background-color: #e9ecef;
    margin: 8px 0;
}

.mobile-user-menu .menu-item.logout {
    color: #e53935;
}

.mobile-user-menu .menu-item.logout i {
    color: #e53935;
}

.mobile-user-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 12px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    border-top: 1px solid #e9ecef;
    border-left: 1px solid #e9ecef;
}

/* 遮罩层样式 */
.sidebar-overlay, .user-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 998;
}

.sidebar-overlay {
    background: rgba(0, 0, 0, 0.5);
}

.user-menu-overlay {
    background: transparent;
}

.sidebar-overlay.active, .user-menu-overlay.active {
    display: block;
}

/* ---------- 8. 动画和加载状态 ---------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* 加载状态样式 */
.content-wrapper.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.content-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1001;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 页面加载状态 */
html.loading {
    overflow: hidden;
}

html.loading::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--background-color);
    z-index: 9999;
}

html.loading::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10000;
} 
