/* mobile-fix.css - 手机端UI拥挤修复 */
@media (max-width: 768px) {
  /* 修复头部拥挤 */
  header {
    padding: 12px 15px !important;
    font-size: 20px !important;
    flex-wrap: wrap;
  }
  
  .auth-buttons {
    gap: 5px !important;
  }
  
  .auth-btn {
    padding: 4px 8px !important;
    font-size: 12px !important;
  }
  
  /* 修复导航栏拥挤 */
  nav {
    padding: 8px 12px !important;
    flex-wrap: wrap;
    gap: 8px !important;
  }
  
  .nav-links {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  nav a {
    margin: 0 8px !important;
    font-size: 14px;
  }
  
  /* 修复搜索框拥挤 - 重点修复 */
  .search-box {
    width: 100%;
    order: 3;
    margin-top: 8px;
    display: flex !important;
    flex-direction: row !important; /* 确保水平排列 */
    align-items: center !important; /* 垂直居中 */
    flex-wrap: nowrap;
    gap: 6px !important;
  }
  
  .search-box input {
    width: 100% !important;
    max-width: none !important;
    height: 36px !important; /* 增加高度 */
    flex: 1;
    min-width: 0;
    border: 1px solid #c2d9ec !important;
    border-radius: 6px !important;
    padding: 0 12px !important;
    font-size: 14px !important;
    box-sizing: border-box !important;
  }
  
  .search-box button {
    height: 36px !important; /* 与输入框相同高度 */
    padding: 0 16px !important; /* 增加左右内边距 */
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 70px !important; /* 确保按钮有足够宽度 */
    border: none !important;
    border-radius: 6px !important;
    background: #0077cc !important;
    color: #fff !important;
    cursor: pointer;
    font-size: 14px !important;
    font-weight: bold !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .search-box button:hover {
    background: #0062a8 !important;
  }
  
  /* 修复主要内容区拥挤 */
  .container {
    flex-direction: column !important;
    margin: 10px !important;
    gap: 15px !important;
  }
  
  .main, .sidebar {
    flex: none !important;
    width: 100% !important;
  }
  
  /* 修复卡片拥挤 */
  .post-card {
    padding: 12px !important;
    margin-bottom: 12px !important;
  }
  
  /* 修复模态框拥挤 */
  .modal-content {
    width: 90% !important;
    margin: 20px auto !important;
    padding: 15px !important;
  }
  
  /* 修复信息区拥挤 */
  .info-section {
    margin: 10px !important;
    gap: 12px !important;
  }
  
  .info-card {
    padding: 12px !important;
  }
  
  /* 修复画廊拥挤 */
  .gallery {
    margin: 0 10px 15px 10px !important;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  
  .gallery-item {
    height: 100px !important;
  }
  
  /* 修复图片内容拥挤 */
  .content img {
    max-width: 100% !important;
    width: 100% !important;
  }
  
  /* 修复回复列表拥挤 */
  .replies-list li img {
    max-width: 100% !important;
  }
  
  /* 修复环境网格拥挤 */
  .env-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  
  /* 修复登录/注册模态框拥挤 */
  .login-content, .register-content {
    width: 90% !important;
    max-width: 300px !important;
  }
  
  /* 修复窗口标题栏拥挤 */
  .window-titlebar {
    padding: 8px 10px !important;
  }
  
  /* 修复页脚拥挤 */
  footer {
    margin: 15px 0 !important;
    padding: 0 10px !important;
  }
  
  /* 修复英雄区域拥挤 */
  .hero {
    width: calc(100% - 20px) !important;
    margin: 10px 10px 0 10px !important;
    height: 25vh !important;
    min-height: 150px !important;
  }
}

/* 超小屏幕额外优化 */
@media (max-width: 480px) {
  header {
    font-size: 18px !important;
    padding: 10px 12px !important;
  }
  
  .user-info {
    font-size: 14px;
  }
  
  h2 {
    font-size: 18px !important;
  }
  
  .gallery-grid {
    grid-template-columns: 1fr !important;
  }
  
  .post-card {
    padding: 10px !important;
  }
  
  .auth-buttons {
    flex-direction: column;
    gap: 3px !important;
  }
  
  .auth-btn {
    width: 100%;
    text-align: center;
  }
  
  .nav-links {
    justify-content: space-between;
    width: 100%;
  }
  
  nav a {
    margin: 0 5px !important;
    font-size: 13px;
  }
  
  /* 超小屏幕搜索框优化 - 保持水平排列 */
  .search-box {
    flex-direction: row !important; /* 保持水平排列 */
    gap: 6px !important;
  }
  
  .search-box input {
    width: 100% !important;
    height: 38px !important; /* 稍微增加高度 */
  }
  
  .search-box button {
    width: auto !important; /* 不要100%宽度 */
    height: 38px !important; /* 与输入框相同高度 */
    min-width: 65px !important;
    padding: 0 14px !important;
  }
}

/* 小屏幕优化 (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  .search-box {
    flex-wrap: nowrap;
  }
  
  .search-box input {
    flex: 1;
    height: 38px !important;
  }
  
  .search-box button {
    flex-shrink: 0;
    width: auto;
    height: 38px !important;
    min-width: 75px !important;
  }
}

/* 横屏手机优化 */
@media (max-width: 768px) and (orientation: landscape) {
  .hero {
    height: 35vh !important;
  }
  
  .modal-content {
    max-height: 70vh !important;
  }
  
  /* 横屏时搜索框优化 */
  .search-box {
    flex-direction: row !important;
  }
  
  .search-box button {
    width: auto !important;
  }
}

/* 防止iOS输入框缩放 */
@supports (-webkit-touch-callout: none) {
  .search-box input {
    font-size: 16px !important;
  }
}

/* 确保搜索框在Resonance主题下也正确显示 */
.resonance-theme .search-box input {
  background: #333 !important;
  color: #fff !important;
  border: 1px solid #d00 !important;
}

.resonance-theme .search-box button {
  background: #d00 !important;
  color: #fff !important;
}

.resonance-theme .search-box button:hover {
  background: #b00 !important;
}