/* ============================================
   全站响应式优化 - 鲜送 (XianSong)
   ============================================
   移动优先设计,PC端增强
   断点: 480px / 768px / 1024px / 1200px
   ============================================ */

/* ============================================
   1. CSS变量 - 响应式设计令牌
   ============================================ */
:root {
  /* 容器宽度 */
  --container-xs: 100%;
  --container-sm: 540px;
  --container-md: 720px;
  --container-lg: 960px;
  --container-xl: 1140px;
  
  /* 间距 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  
  /* 字体大小 */
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  
  /* 触控区域 */
  --touch-min: 44px;
  --touch-lg: 48px;
  
  /* 导航高度 */
  --navbar-height: 56px;
  --bottom-nav-height: 60px;
  
  /* 安全区域 */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================
   2. 基础重置
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: var(--text-base);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
  color: #1f2937;
  background: #f9fafb;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* 移动端优化 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

/* 防止iOS双指缩放 */
img, video {
  max-width: 100%;
  height: auto;
}

/* ============================================
   3. 容器系统
   ============================================ */
.container, .container-fluid {
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding-right: var(--space-md);
  padding-left: var(--space-md);
}

@media (min-width: 576px) {
  .container { max-width: var(--container-sm); }
}

@media (min-width: 768px) {
  .container { max-width: var(--container-md); }
}

@media (min-width: 1024px) {
  .container { max-width: var(--container-lg); }
}

@media (min-width: 1200px) {
  .container { max-width: var(--container-xl); }
}

/* ============================================
   4. 响应式网格
   ============================================ */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-right: calc(var(--space-md) * -0.5);
  margin-left: calc(var(--space-md) * -0.5);
}

.col, [class*="col-"] {
  padding-right: calc(var(--space-md) * 0.5);
  padding-left: calc(var(--space-md) * 0.5);
  width: 100%;
}

/* 移动端: 全宽 */
@media (max-width: 767.98px) {
  .col-sm-6, .col-md-4, .col-md-6, .col-lg-3, .col-lg-4, .col-lg-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  /* 两列布局 */
  .row-mobile-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }
}

/* 平板: 两列 */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-md-6 { flex: 0 0 50%; max-width: 50%; }
  .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
}

/* 桌面: 多列 */
@media (min-width: 1024px) {
  .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
  .col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
}

/* ============================================
   5. 导航栏响应式
   ============================================ */
/* PC端导航 */
.sn-wrap {
  max-width: var(--container-lg);
  margin: 0 auto;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.sn-row {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.sn-r1 {
  border-bottom: 1px solid #f0f0f0;
  position: relative;
  z-index: 20;
}

.sn-r2 {
  position: relative;
  z-index: 10;
}

.sn-logo {
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  padding: 4px 8px;
  flex-shrink: 0;
}

.sn-logo img {
  display: block;
}

.sn-links {
  display: flex;
  gap: 0;
  flex: 1;
  overflow: hidden;
  justify-content: center;
  padding: 3px 0;
  min-width: 0;
}

.sn-lk {
  font-size: var(--text-sm);
  color: #475569;
  text-decoration: none;
  padding: 3px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

.sn-lk:hover {
  color: #16a34a;
  background: #f0fdf4;
}

.sn-auth {
  display: flex;
  gap: 6px;
  padding: 3px 8px;
  flex-shrink: 0;
}

.sn-abtn {
  font-size: var(--text-xs);
  color: #6b7280;
  text-decoration: none;
  padding: 2px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  white-space: nowrap;
}

.sn-abtn:hover {
  background: #f3f4f6;
}

.sn-abtn.primary {
  color: white;
  background: #3b82f6;
  border-color: #3b82f6;
}

.sn-cities {
  display: flex;
  gap: 0;
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  white-space: nowrap;
  border-left: 1px solid #e5e7eb;
  padding: 2px 4px;
  align-items: center;
  overflow: hidden;
}

.sn-cities::-webkit-scrollbar {
  display: none;
}

.snc {
  font-size: var(--text-xs);
  color: #374151;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.snc:hover {
  color: #16a34a;
}

/* 移动端导航 */
@media (max-width: 767.98px) {
  .sn-links {
    display: none;
  }
  
  .sn-cities {
    display: none;
  }
  
  .sn-auth {
    margin-left: auto;
  }
  
  .sn-abtn {
    font-size: 11px;
    padding: 4px 8px;
  }
}

/* ============================================
   6. 移动端底部导航
   ============================================ */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #fff;
  border-top: 1px solid #e5e7eb;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

@media (max-width: 767.98px) {
  .mobile-bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
  
  /* 为底部导航留出空间 */
  body {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
  }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #6b7280;
  font-size: 10px;
  padding: 6px 0;
  min-width: var(--touch-min);
  transition: color 0.2s;
}

.bottom-nav-item.active {
  color: #16a34a;
}

.bottom-nav-item:hover {
  color: #16a34a;
}

.bottom-nav-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 2px;
}

.bottom-nav-label {
  font-size: 10px;
  line-height: 1.2;
}

/* ============================================
   7. 卡片组件响应式
   ============================================ */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@media (max-width: 767.98px) {
  .card {
    border-radius: 8px;
    margin-bottom: var(--space-sm);
  }
  
  .card-body {
    padding: var(--space-md);
  }
}

/* ============================================
   8. 表格响应式
   ============================================ */
@media (max-width: 767.98px) {
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* 卡片式表格 */
  .table-mobile-card {
    display: block;
  }
  
  .table-mobile-card thead {
    display: none;
  }
  
  .table-mobile-card tbody {
    display: block;
  }
  
  .table-mobile-card tr {
    display: block;
    background: #fff;
    border-radius: 8px;
    margin-bottom: var(--space-sm);
    padding: var(--space-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }
  
  .table-mobile-card td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-xs) 0;
    border: none;
    text-align: right;
  }
  
  .table-mobile-card td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6b7280;
    text-align: left;
  }
}

/* ============================================
   9. 按钮响应式
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 10px 20px;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  min-height: var(--touch-min);
  text-decoration: none;
}

@media (max-width: 767.98px) {
  .btn {
    padding: 12px 20px;
    font-size: var(--text-base);
    width: 100%;
  }
  
  .btn-group-mobile {
    display: flex;
    gap: var(--space-sm);
  }
  
  .btn-group-mobile .btn {
    flex: 1;
  }
}

/* ============================================
   10. 表单响应式
   ============================================ */
.form-control, .form-select {
  width: 100%;
  padding: 12px 16px;
  font-size: var(--text-base);
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: var(--touch-min);
}

@media (max-width: 767.98px) {
  .form-control, .form-select {
    font-size: 16px; /* 防止iOS缩放 */
    padding: 14px 16px;
  }
  
  .form-group {
    margin-bottom: var(--space-lg);
  }
  
  .form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
  }
}

/* ============================================
   11. 模态框响应式
   ============================================ */
@media (max-width: 767.98px) {
  .modal-dialog {
    margin: var(--space-sm);
    max-width: calc(100% - var(--space-md));
  }
  
  .modal-content {
    border-radius: 12px;
  }
  
  .modal-body {
    padding: var(--space-md);
  }
  
  .modal-footer {
    padding: var(--space-md);
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .modal-footer .btn {
    width: 100%;
  }
}

/* ============================================
   12. 导航标签响应式
   ============================================ */
.nav-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  padding: 12px 16px;
  font-size: var(--text-sm);
  color: #6b7280;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
}

.nav-tab:hover {
  color: #16a34a;
}

.nav-tab.active {
  color: #16a34a;
  border-bottom-color: #16a34a;
  font-weight: 600;
}

@media (max-width: 767.98px) {
  .nav-tabs {
    padding: 0 var(--space-sm);
  }
  
  .nav-tab {
    padding: 12px;
    font-size: var(--text-base);
  }
}

/* ============================================
   13. 列表响应式
   ============================================ */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: #fff;
  border-radius: 8px;
  margin-bottom: var(--space-sm);
  text-decoration: none;
  color: inherit;
  transition: background 0.2s;
}

.list-item:hover {
  background: #f9fafb;
}

@media (max-width: 767.98px) {
  .list-item {
    padding: var(--space-md);
    gap: var(--space-sm);
  }
  
  .list-item-content {
    flex: 1;
    min-width: 0;
  }
  
  .list-item-title {
    font-size: var(--text-base);
    font-weight: 500;
    margin-bottom: 4px;
  }
  
  .list-item-desc {
    font-size: var(--text-sm);
    color: #6b7280;
  }
  
  .list-item-action {
    flex-shrink: 0;
  }
}

/* ============================================
   14. 产品网格响应式
   ============================================ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

@media (min-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
  }
}

@media (min-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.product-card {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.2s;
}

.product-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.product-card-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.product-card-body {
  padding: var(--space-sm);
}

.product-card-title {
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card-price {
  font-size: var(--text-lg);
  font-weight: 700;
  color: #dc2626;
}

.product-card-price small {
  font-size: var(--text-xs);
  font-weight: 400;
  color: #9ca3af;
}

@media (max-width: 767.98px) {
  .product-grid {
    gap: var(--space-xs);
  }
  
  .product-card-body {
    padding: var(--space-xs);
  }
  
  .product-card-title {
    font-size: var(--text-xs);
    -webkit-line-clamp: 1;
  }
  
  .product-card-price {
    font-size: var(--text-base);
  }
}

/* ============================================
   15. 搜索框响应式
   ============================================ */
.search-box {
  display: flex;
  gap: var(--space-sm);
  max-width: var(--container-md);
  margin: 0 auto;
  padding: var(--space-md);
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  font-size: var(--text-base);
  border: 2px solid #e5e7eb;
  border-radius: 24px;
  outline: none;
  transition: border-color 0.2s;
  min-height: var(--touch-min);
}

.search-input:focus {
  border-color: #16a34a;
}

.search-btn {
  padding: 12px 24px;
  background: #16a34a;
  color: white;
  border: none;
  border-radius: 24px;
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  min-height: var(--touch-min);
}

@media (max-width: 767.98px) {
  .search-box {
    padding: var(--space-sm);
  }
  
  .search-input {
    font-size: 16px; /* 防止iOS缩放 */
  }
}

/* ============================================
   16. 页脚响应式
   ============================================ */
.site-footer {
  background: #1f2937;
  color: #9ca3af;
  padding: var(--space-xl) 0;
  margin-top: var(--space-xl);
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xl);
  max-width: var(--container-lg);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

@media (max-width: 767.98px) {
  .footer-content {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
  }
}

@media (max-width: 479.98px) {
  .footer-content {
    grid-template-columns: 1fr;
  }
}

.footer-section h4 {
  color: #fff;
  font-size: var(--text-base);
  margin-bottom: var(--space-md);
}

.footer-section a {
  display: block;
  color: #9ca3af;
  text-decoration: none;
  padding: 4px 0;
  font-size: var(--text-sm);
}

.footer-section a:hover {
  color: #16a34a;
}

.footer-bottom {
  text-align: center;
  padding-top: var(--space-lg);
  margin-top: var(--space-lg);
  border-top: 1px solid #374151;
  font-size: var(--text-xs);
}

/* ============================================
   17. 工具类响应式
   ============================================ */
/* 隐藏/显示 */
@media (max-width: 767.98px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: block !important; }
  .d-mobile-none { display: none !important; }
  .d-mobile-flex { display: flex !important; }
  .d-mobile-block { display: block !important; }
}

@media (min-width: 768px) {
  .hide-desktop { display: none !important; }
  .show-desktop { display: block !important; }
  .d-desktop-none { display: none !important; }
  .d-desktop-flex { display: flex !important; }
  .d-desktop-block { display: block !important; }
}

/* 间距 */
@media (max-width: 767.98px) {
  .mt-mobile-0 { margin-top: 0 !important; }
  .mt-mobile-sm { margin-top: var(--space-sm) !important; }
  .mt-mobile-md { margin-top: var(--space-md) !important; }
  .mb-mobile-0 { margin-bottom: 0 !important; }
  .mb-mobile-sm { margin-bottom: var(--space-sm) !important; }
  .mb-mobile-md { margin-bottom: var(--space-md) !important; }
  .p-mobile-sm { padding: var(--space-sm) !important; }
  .p-mobile-md { padding: var(--space-md) !important; }
}

/* 文本 */
@media (max-width: 767.98px) {
  .text-mobile-center { text-align: center !important; }
  .text-mobile-left { text-align: left !important; }
  .text-mobile-right { text-align: right !important; }
  .text-mobile-sm { font-size: var(--text-sm) !important; }
  .text-mobile-base { font-size: var(--text-base) !important; }
}

/* ============================================
   18. 特殊组件
   ============================================ */
/* 滑动操作 */
@media (max-width: 767.98px) {
  .swipe-action {
    position: relative;
    overflow: hidden;
  }
  
  .swipe-action-content {
    transition: transform 0.3s;
  }
  
  .swipe-action-actions {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
  }
  
  .swipe-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    color: white;
    font-size: var(--text-sm);
  }
}

/* 悬浮操作栏 */
@media (max-width: 767.98px) {
  .floating-action-bar {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: var(--space-sm) var(--space-md);
    display: flex;
    gap: var(--space-sm);
    z-index: 999;
  }
  
  .floating-action-bar .btn {
    flex: 1;
  }
}

/* ============================================
   19. 动画优化
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 移动端简化动画 */
@media (max-width: 767.98px) {
  .fade-in {
    animation: fadeIn 0.2s ease-out;
  }
  
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ============================================
   20. 打印样式
   ============================================ */
@media print {
  .mobile-bottom-nav,
  .sn-wrap,
  .site-footer,
  .btn,
  .search-box {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
    font-size: 12pt;
  }
  
  .container {
    max-width: 100%;
    padding: 0;
  }
}
