/* ========================================
   移动端增强样式 - 仅包含触摸优化和性能优化
   注意：基础响应式布局在 main.css 中定义
   ======================================== */

/* ========================================
   触摸设备专用优化
   ======================================== */
@media (hover: none) and (pointer: coarse) {
  /* 移除hover效果，添加active效果 */
  .product-card:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .product-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
  
  .quick-link-item:hover {
    transform: none;
  }
  
  .quick-link-item:active {
    transform: scale(0.95);
  }
  
  button:active,
  .slider-nav:active,
  .banner-nav:active {
    transform: scale(0.9);
  }
  
  a:active {
    opacity: 0.7;
  }
}

/* ========================================
   移动端性能和交互优化 (≤768px)
   ======================================== */
@media (max-width: 768px) {
  /* H5端 - 顶部导航栏 (模拟 iOPEN Mall) */
  .mobile-header {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100% !important; /* Force full width */
    margin: 0;
    padding: 0; /* Remove padding from wrapper */
    z-index: 1000;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }

  /* 顶部搜索栏 */
  .header_in {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 50px;
    padding: 0 10px; /* Reduced padding slightly to be closer to edge */
    box-sizing: border-box;
  }

  /* 为 body 添加 padding-top 以防止内容被 fixed header 遮挡 */
  body {
    padding-top: 50px;
  }

  .header_menu {
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='3' y1='12' x2='21' y2='12'%3E%3C/line%3E%3Cline x1='3' y1='6' x2='21' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='18' x2='21' y2='18'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    flex-shrink: 0;
  }

  .header_logo {
    flex: 1;
    display: flex;
    justify-content: flex-start; /* Logo 靠左，紧接菜单 */
    align-items: center;
    padding-left: 12px;
  }

  .header_logo img {
    height: 32px; /* 调整 Logo 大小适配 */
    width: auto;
  }

  .header_in_r {
    display: flex;
    align-items: center;
    gap: 12px; /* 调整间距 */
    flex-shrink: 0;
  }

  .open_store {
    background-color: #f39c12; /* 橙色背景 */
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 15px; /* 圆角 */
    text-decoration: none;
    white-space: nowrap;
    font-weight: 500;
  }

  .header_search {
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
  }

  .header_noti {
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9'%3E%3C/path%3E%3Cpath d='M13.73 21a2 2 0 0 1-3.46 0'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    cursor: pointer;
  }
  
  /* 添加红点 */
  .header_noti::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 6px;
    background-color: #ff0000;
    border-radius: 50%;
  }

  .chat-widget__button {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    font-size: 20px;
    text-decoration: none;
  }

  /* 使用 SVG 替换字体图标以匹配风格 */
  .chat-widget__button i {
    display: none;
  }
  .chat-widget__button {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
  }

  /* 底部导航栏 */
  .mobile-nav {
    display: flex !important;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* 隐藏 PC 端 header */
  .top-utility-bar,
  .main-header,
  .category-nav {
    display: none;
  }

  /* 优化点击区域 - 符合移动端最小触摸目标 44x44px */
  .mobile-nav-item {
    min-height: 44px;
    min-width: 48px;
    padding: 6px 8px;
  }
  
  .category-list li a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  button,
  .slider-nav,
  .banner-nav {
    min-height: 10px;
    min-width: 10px;
  }
  
  /* 优化滚动性能 */
  .products-track,
  .category-list,
  .category-nav {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  
  .product-card {
    scroll-snap-align: start;
  }
  
  /* 防止文字选择和点击高亮 */
  .products-track,
  .banner-slider,
  .slider-nav,
  .banner-nav {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* 优化输入框 - 防止iOS自动缩放 */
  .search-input {
    font-size: 16px;
  }
  
  /* 移动端隐藏不必要的元素 */
  .product-actions {
    display: none;
  }
  
  /* 优化图片加载性能 */
  .product-image img,
  .banner-slide img {
    will-change: transform;
  }
  
  /* 滚动条隐藏 */
  .products-track::-webkit-scrollbar,
  .brands-tabs::-webkit-scrollbar,
  .new-products-track::-webkit-scrollbar {
    display: none;
  }
  
  /* 平滑滚动 */
  .products-track,
  .brands-tabs,
  .new-products-track {
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  /* H5端 - 容器 */
  .container {
    max-width: 100%; /* Changed from 430px to 100% to fill screen */
    width: 100%;
    padding: 0;
    margin: 0 auto;
  }

  /* H5端 - 轮播图 430×330px */
  .banner-section {
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  .banner-slider {
    max-width: 100%; /* Allow full width */
    width: 100%;
  }

  .banner-slide img {
    width: 100%;
    height: 330px;
    object-fit: cover;
  }

  /* H5端 - 限时抢购标题 430×120px */
  .flash-sale .section-header {
    width: 100%;
    max-width: 100%; /* Allow full width */
    height: 120px;
    background: #000;
    padding: 15px;
    margin: 0 auto;
    border: none;
    border-radius: 12px 12px 0 0; /* Add rounded top corners */
    overflow: hidden; /* Fix: Ensure inner black box respects rounded corners */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 8px;
  }

  .flash-sale .section-header .container {
    max-width: 100%;
    width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start; /* Ensure items align to left */
  }

  .flash-sale .section-title {
    font-size: 16px;
    color: #fff;
    margin: 0;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: flex-start; /* Align text to left */
  }

  .flash-sale .section-title .icon {
    font-size: 18px;
    color: #ff6f00;
  }

  .countdown {
    font-size: 14px;
    color: #fff;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    justify-content: flex-start; /* Align countdown to left */
  }

  .countdown-label {
    margin-right: 8px;
    font-size: 14px;
    color: #fff;
  }

  .time-box {
    background-color: #ff6f00;
    color: #fff;
    padding: 2px 4px; /* Reduced padding */
    border-radius: 4px; /* Slightly smaller radius */
    font-weight: 700;
    min-width: 24px; /* Reduced min-width */
    text-align: center;
    font-size: 14px; /* Reduced font size */
  }

  .time-separator {
    color: #fff;
    font-weight: 700;
    font-size: 14px; /* Reduced font size */
    margin: 0 1px;
  }

  .date-tabs {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
  }

  .date-tab {
    flex: 1;
    padding: 8px 0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    white-space: nowrap;
  }

  .date-tab.active {
    background-color: #fff;
    color: #000;
    border-color: #fff;
    font-weight: 700;
  }
  
  .it720_downbox li {
    width: 20% !important;
  }
}

/* ========================================
   横屏优化 (移动端横屏)
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
  .banner-slide img {
    height: 200px;
  }
  
  .quick-links {
    padding: 10px 0;
  }
  
  .quick-links .container {
    padding: 8px;
  }
  
  .product-section {
    padding: 10px 0;
  }
  
  .flash-sale .section-header {
    height: 100px;
  }
}

/* ========================================
   小屏幕优化 (iPhone SE等 ≤375px)
   ======================================== */
@media (max-width: 375px) {
  .container {
    padding: 0 8px;
  }
  
  .quick-links-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 15px 8px;
  }
  
  .quick-icon {
    width: 48px;
    height: 48px;
  }
  
  .quick-link-item span {
    font-size: 10px;
  }
  
  .flash-sale .product-card {
    flex: 0 0 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
  }
  
  .product-card {
    flex: 0 0 120px;
    min-width: 120px;
  }
  
  .product-title {
    font-size: 10px;
    height: 28px;
  }
  
  .current-price {
    font-size: 14px;
  }
  
  .original-price {
    font-size: 9px;
  }
  
  .discount-badge {
    font-size: 9px;
    padding: 2px 5px;
  }
  
  .section-title {
    font-size: 15px;
  }
  
  .banner-slide img {
    height: 250px;
  }
  
  .mobile-nav-item .nav-icon {
    font-size: 21px;
  }
  
  .mobile-nav-item .nav-label {
    font-size: 9px;
  }
}

/* ========================================
   超大屏幕优化 (≥1400px)
   ======================================== */
@media (min-width: 1400px) {
  .container {
    max-width: 1320px;
  }
  
  .banner-slide img {
    height: 480px;
  }
}

/* ========================================
   高分辨率屏幕优化 (Retina显示屏)
   ======================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .product-image img,
  .banner-slide img,
  .quick-icon img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* ========================================
   辅助功能 - 减少动画
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   安全区域适配 (iPhone X等带刘海屏设备)
   ======================================== */
@supports (padding: env(safe-area-inset-bottom)) {
  .mobile-nav {
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }
  
  body {
    padding-bottom: calc(50px + env(safe-area-inset-bottom));
  }
}

/* ========================================
   Cart Page Mobile Fixes
   ======================================== */
@media (max-width: 768px) {
  /* Fix Cart Item Layout */
  .cart-item {
    display: flex !important;
    flex-wrap: wrap;
    padding: 15px 10px !important;
    gap: 10px !important;
    position: relative;
  }
  
  .checkbox-wrapper {
    width: 30px;
    align-self: center;
  }
  
  .item-image {
    width: 80px !important;
    height: 80px !important;
    flex-shrink: 0;
  }
  
  .item-info {
    flex: 1;
    width: calc(100% - 120px); /* Remaining width */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  
  .item-name {
    font-size: 14px;
    margin-bottom: 5px;
    white-space: normal;
    height: auto;
    -webkit-line-clamp: 2;
  }
  
  /* Reposition quantity and price */
  .item-quantity {
    margin-top: 10px;
    grid-column: auto !important; /* Reset grid */
    justify-self: auto !important;
  }
  
  .item-price {
    position: absolute;
    bottom: 15px;
    right: 10px;
    text-align: right;
  }
  
  .item-subtotal {
    display: none; /* Hide subtotal on mobile to save space */
  }
  
  .item-actions {
    position: absolute;
    top: 10px;
    right: 10px;
  }
  
  /* Fix Cart Footer Overlap */
  .cart-footer {
    position: fixed !important;
    bottom: 56px !important; /* Above mobile nav */
    left: 0;
    width: 100%;
    z-index: 999 !important;
    padding: 10px 15px !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    background: #fff;
  }
  
  /* Ensure content is not hidden */
  .cart-page {
    padding-bottom: 130px !important; /* Nav height + Footer height */
  }
  
  /* Adjust checkout button */
  .checkout-button {
    padding: 10px 20px;
    font-size: 14px;
  }
}

/* Seller Shop Mobile Optimization */
@media (max-width: 768px) {
  .shop-header-section .d-flex {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  
  .shop-logo {
    margin-right: 0 !important;
    margin-bottom: 15px;
  }
  
  .shop-info {
    width: 100%;
    margin-bottom: 15px;
  }
  
  .shop-info h1 {
    justify-content: center;
    font-size: 1.2rem;
  }
  
  .shop-info .d-flex {
    justify-content: center;
  }
  
  .shop-actions {
    width: 100%;
    align-items: center !important;
    flex-direction: row !important;
    justify-content: center;
    gap: 15px;
  }
  
  .shop-actions .btn {
    margin-bottom: 0 !important;
  }
  
  .shop-nav-pills {
    justify-content: center;
    gap: 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .shop-nav-pills .nav-link {
    padding: 0.5rem 0.8rem;
    font-size: 13px;
    white-space: nowrap;
  }
}

/* ========================================
   Mobile Product Details Page (Screenshot Match)
   ======================================== */
@media (max-width: 768px) {
  /* Hide Desktop Breadcrumb is handled by d-lg-none */
  
  /* Mobile Product Header (Vertical Breadcrumb + Title) */
  .mobile-product-header {
    display: flex;
    padding: 10px 15px;
    background: #fff;
    margin-bottom: 10px;
    align-items: stretch; /* Stretch to match height */
  }

  .vertical-breadcrumb {
    display: flex;
    flex-direction: row; /* Keep as row but visually separated */
    gap: 0;
    margin-right: 15px;
    flex-shrink: 0;
  }

  .v-breadcrumb-item {
    writing-mode: vertical-lr; /* Vertical text */
    text-orientation: upright;
    background-color: #f5f5f5; /* Light background for vertical strip */
    color: #666;
    font-size: 12px;
    padding: 8px 4px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #fff; /* Separator */
    letter-spacing: 2px;
    height: auto;
    min-height: 80px; /* Min height */
  }

  .v-breadcrumb-item span {
    display: block;
  }

  .mobile-product-title-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    padding-top: 5px;
  }

  /* Product Main Section Overrides */
  .product-main-section {
    padding: 0 !important;
    margin-bottom: 10px !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Product Gallery */
  .product-gallery {
    background: #fff;
    padding-bottom: 15px;
  }

  .main-image-container {
    margin-bottom: 10px !important;
  }

  .main-image-wrapper img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
  }

  /* Thumbnail Images */
  .thumbnail-images {
    padding: 0 10px;
  }

  .thumbnail-item {
    width: 60px !important;
    height: 60px !important;
    border: 1px solid #eee;
    margin-right: 8px;
  }

  .thumbnail-item.active {
    border-color: #ff6f00;
  }

  /* Product Info Section */
  .product-info-section {
    padding: 15px;
    background: #fff;
    margin-top: 10px; /* Space between gallery and info */
  }

  /* Badges - Green and Orange */
  .product-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0 !important; /* Reset margin */
    margin-bottom: 10px;
  }

  .feature-item {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 2px;
    gap: 4px;
  }
  
  .feature-item i {
    font-size: 14px;
  }

  /* Authentic (Green) */
  .feature-item:nth-child(1) {
    color: #28a745;
    border: 1px solid #28a745;
    background-color: #e8f5e9;
  }

  /* Return (Orange/Red) */
  .feature-item:nth-child(2) {
    color: #ff6f00;
    border: 1px solid #ff6f00;
    background-color: #fff3e0;
  }
  
  /* Free Shipping (Orange) */
  .feature-item:nth-child(3) {
    color: #ff6f00;
    border: 1px solid #ff6f00;
    background-color: #fff3e0;
  }

  /* Large Title below Badges (As seen in bottom of screenshot) */
  .product-title-large-mobile {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    line-height: 1.4;
    margin-bottom: 10px;
    display: block;
  }

  /* Price Layout */
  .product-price-section {
    margin-bottom: 15px;
  }

  .current-price {
    font-size: 24px;
    color: #ff6f00;
    font-weight: 700;
  }

  /* Hide Desktop Title in Info Section */
  .product-info-section .product-title {
    display: none;
  }
}
.mobile-side-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 2000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.mobile-side-menu.open {
    transform: translateX(0);
}

.mobile-menu-header {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}

.close-menu-btn {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    font-size: 24px;
    padding: 5px;
    color: #333;
}

.menu-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.mobile-menu-user {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    background: #fff;
    flex-shrink: 0;
}

.mobile-menu-user .greeting {
    color: #ff6600;
    font-weight: 500;
}

.mobile-menu-user .menu-login-btn {
    border: 1px solid #ff6600;
    color: #ff6600;
    padding: 4px 12px;
    border-radius: 4px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.mobile-menu-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.mobile-category-sidebar {
    width: 100px;
    background: #1a1a1a;
    overflow-y: auto;
    flex-shrink: 0;
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-tab {
    padding: 15px 5px;
    color: #fff;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    border-bottom: 1px solid #333;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
}

.category-tab.active {
    background: #fff;
    color: #333;
    font-weight: 600;
}

.mobile-category-content-area {
    flex: 1;
    overflow-y: auto;
    background: #fff;
}

.category-content-panel {
    display: none;
}

.category-content-panel.active {
    display: block;
}

.category-content-header {
    background: #ffe0cc; /* Light orange */
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-category-title {
    color: #ff6600; /* Darker orange text */
    font-weight: 600;
    font-size: 15px;
}

.view-all-btn {
    background: #ff6600;
    color: #fff;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    text-decoration: none;
}

.subcategory-grid {
    padding: 20px 15px;
}

.subcategory-section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
    padding-left: 5px;
}

.subcategory-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px 10px;
}

.subcategory-item {
    text-align: center;
    font-size: 13px;
    color: #666;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    word-break: break-word;
    line-height: 1.4;
}
