/**
 * 移动端个人中心页面统一样式
 * 解决所有移动端个人中心页面的样式问题，包括：
 * 1. 顶部搜索栏遮挡问题
 * 2. 底部导航栏显示问题
 * 3. 内容区域滚动问题
 * 4. 标题栏隐藏但保留占位空间
 */

@media (max-width: 768px) {
  /* ===== 基础样式 ===== */
  /* 个人中心模态框基础样式 */
  .mobile-profile.profile-modal {
    position: fixed !important;
    top: 60px !important; /* 为顶部搜索栏留出空间 */
    left: 0 !important;
    right: 0 !important;
    bottom: 70px !important; /* 保留底部导航栏的空间 */
    height: calc(100vh - 130px) !important; /* 减去顶部搜索栏和底部导航栏的高度 */
    max-height: calc(100vh - 130px) !important;
    background-color: #222 !important;
    color: white !important;
    z-index: 990 !important; /* 确保在搜索框下方，但在大多数其他元素上方 */
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
  }

  /* 添加一个空白占位区域，确保内容不被搜索框遮挡 */
  .mobile-profile.profile-modal::before {
    content: '' !important;
    display: block !important;
    height: 10px !important; /* 额外的顶部空间 */
    width: 100% !important;
  }

  /* ===== 标题栏样式 ===== */
  /* 隐藏个人中心页面的标题栏，但保留其占位空间 */
  .mobile-profile .profile-header {
    position: static !important; /* 改为静态定位，不再固定在顶部 */
    z-index: 5 !important;
    background-color: transparent !important; /* 透明背景 */
    padding: 15px !important;
    border-bottom: 1px solid #444 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    visibility: hidden !important; /* 隐藏但保留空间 */
    height: 56px !important; /* 固定高度，确保占位空间一致 */
    opacity: 0 !important; /* 完全透明 */
    pointer-events: none !important; /* 禁用鼠标事件 */
    margin-bottom: 10px !important; /* 增加底部间距 */
  }

  /* 隐藏标题文字 */
  .mobile-profile .profile-header h2,
  .mobile-profile .profile-header h3 {
    margin: 0 !important;
    font-size: 1.5rem !important;
    color: transparent !important; /* 透明文字颜色 */
    visibility: hidden !important; /* 隐藏文字 */
  }

  /* 隐藏关闭按钮，但保留可点击区域 */
  .mobile-profile .close-btn,
  .mobile-profile .close-profile {
    background: none !important;
    border: none !important;
    color: transparent !important; /* 透明颜色 */
    font-size: 1.5rem !important;
    cursor: pointer !important; /* 保持为指针光标 */
    padding: 5px !important;
    visibility: hidden !important; /* 隐藏按钮 */
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    width: 40px !important;
    height: 40px !important;
    z-index: 10 !important;
    pointer-events: auto !important; /* 确保可点击 */
  }

  /* ===== 内容区域样式 ===== */
  /* 确保个人中心内容区域可滚动且不被遮挡 */
  .mobile-profile .profile-content {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 80px !important; /* 确保底部内容不被遮挡 */
    padding-top: 10px !important; /* 增加顶部内边距 */
    margin-top: 0 !important; /* 移除顶部外边距 */
  }

  /* 确保个人中心页面的标签正确显示 */
  .mobile-profile .profile-tabs {
    display: flex !important;
    flex-direction: column !important;
    padding: 10px 15px !important;
    gap: 10px !important;
    border-bottom: 1px solid #444 !important;
    padding-top: 15px !important; /* 增加顶部内边距 */
  }

  /* 标签样式 */
  .mobile-profile .profile-tab {
    background-color: #333 !important; /* 深色背景 */
    color: white !important; /* 白色文字 */
    border-radius: 5px !important;
    margin-bottom: 5px !important;
    position: relative !important;
    z-index: 2 !important;
    padding: 12px 15px !important;
    font-size: 1rem !important;
    text-align: left !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    border: none !important;
  }

  /* 活跃标签样式 */
  .mobile-profile .profile-tab.active {
    background-color: #ff6b6b !important; /* 粉红色背景 */
    color: white !important; /* 白色文字 */
  }

  /* 标签图标样式 */
  .mobile-profile .profile-tab i {
    width: 20px !important;
    text-align: center !important;
  }

  /* 退出登录按钮样式 */
  .mobile-profile .logout-tab {
    background-color: rgba(255, 107, 107, 0.2) !important;
    border: 1px solid #ff6b6b !important;
    color: #ff6b6b !important;
    margin-top: 10px !important;
  }

  /* 确保个人中心页面的内容区域正确显示 */
  .mobile-profile .profile-tab-content {
    flex: 1 !important;
    padding: 15px !important;
    overflow-y: auto !important;
  }

  /* ===== 表单元素样式 ===== */
  /* 确保表单元素文字可见 */
  .mobile-profile .form-group input,
  .mobile-profile .form-group textarea {
    background-color: #333 !important;
    color: white !important;
    border: 1px solid #444 !important;
  }

  /* 确保设置页面的标签和文字可见 */
  .mobile-profile .settings-container h3,
  .mobile-profile .orders-container h3 {
    color: white !important;
  }

  /* 确保表单标签文字可见 */
  .mobile-profile .form-group label {
    color: #ddd !important;
  }

  /* ===== 底部导航栏样式 ===== */
  /* 确保底部导航栏始终可见 */
  .navbar {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1000 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
  }

  /* 确保移动导航图标容器正确显示 */
  .mobile-nav-icons {
    display: flex !important;
    width: 100% !important;
    justify-content: space-around !important;
    align-items: center !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* ===== 搜索框样式 ===== */
  /* 确保搜索框显示在个人中心模态框上方 */
  .mobile-search-bar {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background-color: #222 !important;
    padding: 10px 15px !important;
    z-index: 1000 !important; /* 确保在个人中心模态框上方 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    height: 60px !important;
    box-sizing: border-box !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* ===== 其他样式 ===== */
  /* 确保个人中心模态框在打开时不会被其他元素遮挡 */
  body.profile-open .mobile-profile.profile-modal {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* iOS安全区域适配 */
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-profile.profile-modal {
      height: calc(100vh - 130px - env(safe-area-inset-bottom)) !important;
      max-height: calc(100vh - 130px - env(safe-area-inset-bottom)) !important;
    }
    
    .navbar {
      padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    }
  }
}
