/* 全局样式设置 */
:root {
  /* 苹果典型色系 */
  --primary-color: #007AFF; /* 苹果蓝 */
  --background-color: #F5F5F7; /* 浅灰色背景 */
  --text-color: #1D1D1F; /* 深灰色文本 */
  --accent-red: #FF3B30; /* 红色强调 */
  --accent-blue: #5AC8FA; /* 浅蓝色强调 */
  --accent-green: #4CD964; /* 绿色强调 */
  --sidebar-width: 60px; /* 侧边栏默认宽度，改为更窄 */
  --sidebar-expanded-width: 240px; /* 侧边栏展开宽度 */
  --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* 卡片阴影 */
  --header-height: 60px; /* 顶部标题高度 */
}

/* 基础重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 修改基础布局，去掉侧边栏的外边距，这样内容可以占据全屏 */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  /* 移除左侧边栏的外边距 */
  margin-left: 0;
  transition: margin-left 0.3s ease;
}

/* 响应式图片 */
img {
  max-width: 100%;
  height: auto;
}

/* 链接样式 */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-blue);
}

/* 顶部标题栏调整，让它占据全屏宽度 */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: #FFFFFF;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 900;
  transition: padding-left 0.3s ease;
}

/* 给标题栏添加左侧内边距，避免与侧边栏切换按钮重叠 */
.header .site-title {
  margin-left: 50px;
  transition: margin-left 0.3s ease;
}

/* 侧边栏隐藏时标题栏恢复正常 */
body.sidebar-hidden .header .site-title {
  margin-left: 0;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-color);
}

/* 侧边栏导航改为悬浮样式 */
.sidebar {
  position: fixed;
  left: 0;
  top: var(--header-height); /* 从标题栏下方开始 */
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height)); /* 高度为视口高度减去标题栏高度 */
  background-color: #FFFFFF;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
  padding: 20px 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow: hidden;
  /* 确保初始状态下侧边栏是可见的 */
  transform: translateX(0);
}

/* 侧边栏悬停时展开 */
.sidebar:hover {
  width: var(--sidebar-expanded-width);
}

/* 侧边栏隐藏时的样式 */
body.sidebar-hidden .sidebar {
  transform: translateX(-100%);
}

/* 侧边栏切换按钮调整位置 */
.toggle-sidebar {
  /* 基本定位 */
  position: fixed !important;
  z-index: 2000 !important;
  
  /* 基本尺寸 */
  width: 30px !important;
  height: 30px !important;
  
  /* 视觉样式 */
  background-color: #FFFFFF !important;
  border: 1px solid #EEEEEE !important;
  border-radius: 50% !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
  
  /* 内容布局 */
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  
  /* 交互相关 */
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  
  /* 桌面端位置 - 调整到侧边栏顶部 */
  top: calc(var(--header-height) + 20px) !important;
  left: calc(var(--sidebar-width) - 15px) !important;
}

/* 图标旋转动画 */
.toggle-sidebar i {
  color: var(--text-color);
  transition: transform 0.3s ease;
}

/* 侧边栏隐藏时的按钮位置 */
body.sidebar-hidden .toggle-sidebar {
  left: 15px !important;
}

/* 侧边栏隐藏时的图标旋转 */
body.sidebar-hidden .toggle-sidebar i {
  transform: rotate(180deg);
}

/* 按钮悬停效果 */
.toggle-sidebar:hover {
  box-shadow: 0 0 10px rgba(0, 122, 255, 0.5) !important;
  background-color: #f9f9f9 !important;
}

/* 导航链接样式 */
.nav-links {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  margin-top: 20px;
}

.nav-link {
  padding: 12px 15px;
  color: var(--text-color);
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.nav-link i {
  font-size: 1.2rem;
  width: 30px;
  text-align: center;
}

.nav-link-text {
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  margin-left: 10px;
}

.sidebar:hover .nav-link-text {
  opacity: 1;
  transform: translateX(0);
}

.nav-link:hover, .nav-link.active {
  background-color: rgba(0, 122, 255, 0.1);
  border-left-color: var(--primary-color);
  color: var(--primary-color);
}

.tags-dropdown {
  margin: 5px 10px;
  position: relative;
}

.tags-dropdown-button {
  width: 100%;
  padding: 10px;
  background-color: transparent;
  border: none;
  border-radius: 5px;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  color: var(--text-color);
}

.tags-dropdown-button i:first-child {
  font-size: 1.2rem;
  width: 30px;
  text-align: center;
}

.tags-dropdown-button span {
  margin-left: 10px;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar:hover .tags-dropdown-button span {
  opacity: 1;
  transform: translateX(0);
}

.tags-dropdown-button i.fa-chevron-down {
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar:hover .tags-dropdown-button i.fa-chevron-down {
  opacity: 1;
}

.tags-dropdown-content {
  display: none;
  position: absolute;
  left: 60px;
  top: 0;
  background-color: #fff;
  min-width: 180px;
  box-shadow: var(--card-shadow);
  border-radius: 5px;
  z-index: 1;
  max-height: 300px;
  overflow-y: auto;
}

.sidebar:hover .tags-dropdown-content {
  left: 100%;
}

.tags-dropdown-content a {
  padding: 10px;
  display: block;
}

.tags-dropdown-content a:hover {
  background-color: rgba(0, 122, 255, 0.1);
}

.tags-dropdown:hover .tags-dropdown-content {
  display: block;
}

/* 主内容区域调整，添加左侧内边距避免内容被侧边栏覆盖 */
.main-content {
  padding: 30px;
  min-height: 100vh;
  margin-top: var(--header-height); /* 为顶部标题腾出空间 */
  padding-left: calc(var(--sidebar-width) + 30px); /* 为侧边栏腾出空间 */
  transition: padding-left 0.3s ease;
}

/* 侧边栏隐藏时，主内容左侧内边距恢复正常 */
body.sidebar-hidden .main-content {
  padding-left: 30px;
}

.page-title {
  margin-bottom: 20px;
  font-weight: 600;
  color: var(--text-color);
}

/* 游戏卡片样式 */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.game-card {
  background-color: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.game-thumbnail {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.game-info {
  padding: 15px;
}

.game-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-color);
}

.game-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.game-tag {
  background-color: var(--accent-blue);
  color: white;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.8rem;
}

/* 标签页样式 */
.tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
}

.tag-card {
  background-color: #fff;
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease;
}

.tag-card:hover {
  transform: translateY(-3px);
  background-color: rgba(0, 122, 255, 0.1);
}

.tag-count {
  display: inline-block;
  background-color: var(--primary-color);
  color: white;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 0.8rem;
  margin-top: 5px;
}

/* 游戏详情 */
.game-detail {
  background-color: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  margin-bottom: 30px;
}

.game-iframe-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 宽高比 */
  margin-bottom: 20px;
}

.game-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* 加载动画 */
.loader {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
}

.loader::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 响应式布局 */
@media (max-width: 992px) {
  :root {
    --sidebar-width: 50px;
    --sidebar-expanded-width: 200px;
  }
  
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (min-width: 769px) {
  .mobile-toggle {
    display: none;
  }
}

/* 切换按钮动画 */
@keyframes toggle-shake {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.toggle-animate {
  animation: toggle-shake 0.3s ease;
}

/* 移动设备特殊样式 */
@media (max-width: 768px) {
  /* 在移动设备上，侧边栏从左侧滑入 */
  .sidebar {
    width: 200px;
    transform: translateX(-200px);
    opacity: 0.95;
    overflow-y: auto;
    border-radius: 0 5px 5px 0;
    z-index: 1010;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
  }
  
  /* 当侧边栏显示时 */
  body:not(.sidebar-hidden) .sidebar {
    transform: translateX(0);
  }

  /* 侧边栏覆盖在内容之上时添加半透明背景遮罩 */
  body:not(.sidebar-hidden)::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 1005;
    pointer-events: none; /* 允许点击穿透 */
    transition: opacity 0.3s ease;
  }
  
  /* 侧边栏悬停宽度保持不变 */
  .sidebar:hover {
    width: 200px;
  }
  
  /* 调整移动设备上的按钮位置 */
  .toggle-sidebar {
    top: calc(var(--header-height) + 10px) !important;
    left: 15px !important;
  }
  
  /* 在移动设备上显示导航文本 */
  .nav-link-text {
    opacity: 1;
    transform: translateX(0);
  }
  
  /* 调整标签下拉菜单样式 */
  .tags-dropdown-button span {
    opacity: 1;
    transform: translateX(0);
  }
  
  .tags-dropdown-button i.fa-chevron-down {
    opacity: 1;
  }
  
  .tags-dropdown-content {
    left: 0;
    top: 100%;
    width: 100%;
  }
  
  .tags-dropdown:hover .tags-dropdown-content {
    position: relative;
  }
  
  /* 调整游戏网格和缩略图大小 */
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  
  .game-thumbnail {
    height: 120px;
  }
} 