/**
 * 移动端首页优化样式 - 简化版
 * 重要：所有样式只在首页生效，不影响P图界面
 */

@media (max-width: 768px) {
  
  /* ===================================
     1. 首页左侧菜单球样式（只在首页显示）
     =================================== */
  
  /* 首页菜单球容器 - 只在没有main-context时显示 */
  .homepage-menu-ball-container {
    position: fixed !important;
    left: 15px !important;
    bottom: 80px !important;
    z-index: 99999 !important;
    pointer-events: auto !important;
    display: none !important;
  }
  
  /* 只在首页显示首页菜单球 */
  body:not(:has(.main-context)) .homepage-menu-ball-container {
    display: block !important;
  }
  
  /* 首页菜单球按钮 */
  .homepage-menu-ball {
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%) !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    cursor: grab !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: box-shadow 0.3s ease !important;
    touch-action: none !important;
    pointer-events: auto !important;
    z-index: 99999 !important;
  }
  
  .homepage-menu-ball:active {
    cursor: grabbing !important;
  }
  
  .homepage-menu-ball span {
    font-size: 20px !important;
    pointer-events: none !important;
  }
  
  /* 首页菜单面板 */
  .homepage-menu-panel {
    position: absolute !important;
    bottom: 60px !important;
    left: 0 !important;
    width: 200px !important;
    max-height: 70vh !important;
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
    overflow: hidden !important;
    display: none !important;
    z-index: 99998 !important;
    pointer-events: auto !important;
    padding: 10px !important;
  }
  
  .homepage-menu-panel.show {
    display: block !important;
  }
  
  /* 菜单面板内的滚动容器 */
  .homepage-menu-panel .scroll-container {
    max-height: 60vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .homepage-menu-panel .scroll-container::-webkit-scrollbar {
    width: 4px !important;
  }
  
  .homepage-menu-panel .scroll-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2) !important;
    border-radius: 2px !important;
  }
  
  /* 确保菜单内所有元素可交互 */
  .homepage-menu-panel * {
    pointer-events: auto !important;
  }
  
  /* 菜单按钮样式 */
  .homepage-menu-panel button {
    width: 100% !important;
    text-align: center !important;
  }
  
  /* ===================================
     2. 只在首页隐藏左侧菜单
     =================================== */
  
  /* 只在首页隐藏左侧菜单列 */
  body:not(:has(.main-context)) #app > div > div:nth-child(2) > div > div:nth-child(2) > div:nth-child(1) {
    display: none !important;
  }
  
  /* ===================================
     3. 隐藏时间信息，优化顶部菜单
     =================================== */
  
  /* 隐藏安装到桌面按钮 - 移动端全局隐藏 */
  #install-button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
  
  /* 隐藏时间信息（360天等） - 完全隐藏第一个div */
  body:not(:has(.main-context)) #app > div > div:nth-child(2) > div > div:nth-child(1) > div > div.flex > div:first-child {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    opacity: 0 !important;
  }
  
  /* 顶部整体容器 */
  body:not(:has(.main-context)) #app > div > div:nth-child(2) > div > div:nth-child(1) {
    display: block !important;
    padding: 8px 10px !important;
    width: 100% !important;
  }
  
  /* 顶部flex容器 */
  body:not(:has(.main-context)) #app > div > div:nth-child(2) > div > div:nth-child(1) > div > div.flex {
    display: flex !important;
    width: 100% !important;
    justify-content: center !important;
    align-items: flex-start !important;
    flex-wrap: wrap !important;
    margin-top: -42px !important;
  }
  
  /* 顶部菜单栏 - 右侧那个50%宽度的div，改为100%宽度 */
  body:not(:has(.main-context)) #app > div > div:nth-child(2) > div > div:nth-child(1) > div > div.flex > div[style*="width: 50%"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 10px 8px !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08) !important;
    border: 1px solid #e8e8e8 !important;
    box-sizing: border-box !important;
  }
  
  /* 菜单项的flex容器 - 网格布局，确保整齐 */
  body:not(:has(.main-context)) div[style*="width: 50%"] > .flex {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 8px 4px !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* 菜单项样式 - 固定宽度确保整齐排列 */
  body:not(:has(.main-context)) div[style*="width: 50%"] .flexList.itmeTop {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    white-space: nowrap !important;
    padding: 4px 8px !important;
    margin: 0 !important;
    color: rgb(22, 118, 253) !important;
    background: rgba(22, 118, 253, 0.05) !important;
    border-radius: 4px !important;
    min-width: 65px !important;
    flex: 0 0 auto !important;
    text-align: center !important;
    font-weight: 400 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
  }
  
  /* 菜单项hover效果 */
  body:not(:has(.main-context)) div[style*="width: 50%"] .flexList.itmeTop:active {
    background: rgba(22, 118, 253, 0.15) !important;
    transform: scale(0.98) !important;
  }
  
  /* 确保emoji正常显示 */
  body:not(:has(.main-context)) div[style*="width: 50%"] .flexList.itmeTop span {
    display: inline !important;
    font-size: 12px !important;
  }
  
  /* ===================================
     4. 主内容区域
     =================================== */
  
  /* 首页：主容器使用flex布局 */
  body:not(:has(.main-context)) #app > div > div:nth-child(2) > div > div:nth-child(2) {
    display: flex !important;
    width: 100% !important;
  }
  
  /* 首页：卡片区域占满全屏 */
  body:not(:has(.main-context)) #app > div > div:nth-child(2) > div > div:nth-child(2) > div:nth-child(2) {
    flex: 1 !important;
    width: 100% !important;
  }
  
  /* ===================================
     6. 底部区域优化（首页和P图界面都适用）
     =================================== */
  
  /* 底部容器 */
  div[style*="position: fixed"][style*="bottom"] {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 50px !important;
    max-height: 70px !important;
    background: white !important;
    border-top: 1px solid #e8e8e8 !important;
    padding: 8px 10px !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05) !important;
    z-index: 1000 !important;
    box-sizing: border-box !important;
  }
  
  /* 底部内容横向布局 */
  div[style*="position: fixed"][style*="bottom"] > div {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 100% !important;
  }
  
  /* 按钮区域 */
  div[style*="position: fixed"][style*="bottom"] > div > div:first-child {
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
    flex-shrink: 0 !important;
  }
  
  /* 按钮样式 */
  div[style*="position: fixed"][style*="bottom"] button {
    font-size: 12px !important;
    padding: 5px 10px !important;
    min-height: 32px !important;
    white-space: nowrap !important;
  }
  
  /* 免责声明 */
  div[style*="position: fixed"][style*="bottom"] > div > div:nth-child(2) {
    font-size: 9px !important;
    line-height: 1.3 !important;
    color: #999 !important;
    text-align: right !important;
    flex: 1 !important;
    overflow: hidden !important;
    max-height: 40px !important;
    margin-left: 10px !important;
  }
  
  /* 主内容底部padding - 只在首页 */
  body:not(:has(.main-context)) #app {
    padding-bottom: 70px !important;
  }
}

/* 桌面端 */
@media (min-width: 769px) {
  .homepage-menu-ball-container {
    display: none !important;
  }
}
