/* 文件：css/mobile.css
   说明：移动端响应式适配样式 */

/* ========== 基础响应式断点 ========== */
:root {
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
}

/* ========== 超小屏幕（手机）========== */
@media screen and (max-width: 480px) {
  /* 全局调整 */
  body {
    font-size: 14px;
  }
  
  .container {
    padding: 0 10px;
  }
  
  /* 头部导航 */
  .header-content {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  
  .header-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  
  /* 卡片网格 */
  .code-grid {
    grid-template-columns: 1fr !important;
    gap: 15px;
  }
  
  /* 商品卡片 */
  .code-card {
    padding: 15px;
  }
  
  .code-title {
    font-size: 18px;
  }
  
  .code-price {
    font-size: 20px;
  }
  
  /* 表格 */
  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  .table th, .table td {
    padding: 8px;
    font-size: 13px;
  }
  
  /* 表单 */
  .form-group input, 
  .form-group textarea, 
  .form-group select {
    font-size: 16px; /* 防止iOS缩放 */
    padding: 12px;
  }
  
  /* 按钮 */
  .btn {
    width: 100%;
    margin: 5px 0;
    text-align: center;
  }
  
  .btn-sm {
    width: auto;
  }
  
  /* 模态框 */
  .modal-content {
    margin: 20px 10px;
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  /* 用户中心 */
  .user-info {
    flex-direction: column;
    text-align: center;
  }
  
  .user-stats {
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
  }
  
  .stat-item {
    min-width: 80px;
  }
  
  .tabs {
    flex-wrap: wrap;
    gap: 5px;
  }
  
  .tab {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 15px;
  }
  
  /* 支付凭证 */
  .payment-methods {
    flex-direction: column;
    gap: 10px;
  }
  
  .qr-code img {
    max-width: 150px;
  }
  
  .upload-area {
    padding: 20px;
  }
  
  /* 订单卡片（移动端专用） */
  .order-card-mobile {
    display: block;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    background: white;
  }
  
  .order-card-mobile .row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
  }
  
  .order-card-mobile .label {
    color: #666;
    font-size: 13px;
  }
  
  .order-card-mobile .value {
    font-weight: 500;
  }
  
  /* 隐藏桌面端表格，显示移动端卡片 */
  .desktop-table {
    display: none;
  }
  
  .mobile-cards {
    display: block;
  }
}

/* ========== 小屏幕（小平板）========== */
@media screen and (min-width: 481px) and (max-width: 768px) {
  .container {
    padding: 0 15px;
  }
  
  .code-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 15px;
  }
  
  .header-content {
    padding: 0 15px;
  }
  
  .user-info {
    flex-wrap: wrap;
  }
  
  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }
  
  .modal-content {
    margin: 30px 20px;
    max-width: 90%;
  }
  
  /* 表格响应式 */
  .table-responsive {
    overflow-x: auto;
  }
}

/* ========== 中等屏幕（平板）========== */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .code-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  
  .container {
    max-width: 960px;
  }
  
  .modal-content {
    max-width: 80%;
  }
}

/* ========== 大屏幕优化 ========== */
@media screen and (min-width: 1025px) {
  .container {
    max-width: 1200px;
  }
  
  .modal-content {
    max-width: 600px;
  }
}

/* ========== 移动端专用组件 ========== */

/* 移动端底部导航 */
@media screen and (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #eee;
    padding: 8px 0;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  }
  
  .mobile-bottom-nav.hide {
    display: none;
  }
  
  .bottom-nav-item {
    flex: 1;
    text-align: center;
    padding: 5px;
    color: #666;
    text-decoration: none;
    font-size: 12px;
  }
  
  .bottom-nav-item.active {
    color: #4CAF50;
  }
  
  .bottom-nav-item i {
    display: block;
    font-size: 20px;
    margin-bottom: 2px;
  }
  
  /* 为底部导航留出空间 */
  body {
    padding-bottom: 70px;
  }
  
  /* 移动端搜索框 */
  .mobile-search {
    position: sticky;
    top: 60px;
    background: white;
    padding: 10px 15px;
    z-index: 900;
    border-bottom: 1px solid #eee;
  }
  
  .mobile-search input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    background: #f5f5f5;
  }
  
  /* 移动端分类菜单 */
  .category-scroll {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 10px 15px;
    background: white;
    border-bottom: 1px solid #eee;
  }
  
  .category-scroll::-webkit-scrollbar {
    display: none;
  }
  
  .category-item {
    display: inline-block;
    padding: 6px 16px;
    margin-right: 8px;
    background: #f5f5f5;
    border-radius: 20px;
    color: #666;
    font-size: 13px;
    text-decoration: none;
  }
  
  .category-item.active {
    background: #4CAF50;
    color: white;
  }
  
  /* 移动端下拉刷新指示器 */
  .pull-to-refresh {
    text-align: center;
    padding: 10px;
    color: #999;
    font-size: 12px;
    display: none;
  }
  
  .pull-to-refresh.show {
    display: block;
  }
  
  .pull-to-refresh .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 5px;
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  /* 移动端返回顶部按钮 */
  .back-to-top {
    position: fixed;
    bottom: 80px;
    right: 15px;
    width: 45px;
    height: 45px;
    background: #4CAF50;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 45px;
    font-size: 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 900;
    cursor: pointer;
    display: none;
  }
  
  .back-to-top.show {
    display: block;
  }
  
  /* 移动端骨架屏加载效果 */
  .skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
  }
  
  @keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }
  
  /* 移动端空状态 */
  .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
  }
  
  .empty-state i {
    font-size: 60px;
    margin-bottom: 15px;
    display: block;
  }
  
  .empty-state p {
    margin-bottom: 20px;
  }
  
  /* 移动端提示条 */
  .toast-message {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 2000;
    display: none;
    white-space: nowrap;
  }
  
  .toast-message.show {
    display: block;
    animation: fadeInOut 2s ease;
  }
  
  @keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, 20px); }
    15% { opacity: 1; transform: translate(-50%, 0); }
    85% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -20px); }
  }
}

/* ========== 横屏优化 ========== */
@media screen and (max-width: 768px) and (orientation: landscape) {
  .modal-content {
    margin: 20px auto;
    max-height: 80vh;
  }
  
  .code-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  
  .user-info {
    flex-direction: row;
    text-align: left;
  }
}

/* ========== 触摸优化 ========== */
@media (hover: none) and (pointer: coarse) {
  /* 增大点击区域 */
  button, .btn, .nav-item, .tab {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* 移除hover效果 */
  .code-card:hover,
  .btn:hover,
  .nav-item:hover {
    transform: none;
    box-shadow: none;
  }
  
  /* 添加active效果 */
  .btn:active {
    opacity: 0.8;
  }
  
  .code-card:active {
    background: #f9f9f9;
  }
}

/* ========== 暗色模式移动端适配 ========== */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
  .mobile-bottom-nav {
    background: #1a1a1a;
    border-top-color: #333;
  }
  
  .bottom-nav-item {
    color: #999;
  }
  
  .bottom-nav-item.active {
    color: #4CAF50;
  }
  
  .mobile-search input {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
  }
  
  .category-item {
    background: #2d2d2d;
    color: #ccc;
  }
  
  .order-card-mobile {
    background: #2d2d2d;
    border-color: #444;
  }
}

/* ========== 打印样式（移动端）========== */
@media print and (max-width: 768px) {
  .mobile-bottom-nav,
  .back-to-top,
  .mobile-search,
  .category-scroll {
    display: none !important;
  }
  
  body {
    padding-bottom: 0;
  }
  
  .code-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}