/**
 * Web3 Robot Shop - Mobile Responsive Styles
 * Comprehensive mobile adaptation for all screen sizes
 */

/* ===== 基础移动端变量 ===== */
:root {
  --mobile-padding: 16px;
  --mobile-radius: 8px;
}

/* ===== 通用移动端优化 ===== */
@media (max-width: 768px) {
  /* 触摸优化 */
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* 防止横屏时文字放大 */
  html {
    -webkit-text-size-adjust: 100%;
  }

  /* 滚动优化 */
  body {
    -webkit-overflow-scrolling: touch;
  }

  /* 容器适配 */
  .container,
  .container--no-max {
    padding-left: var(--mobile-padding) !important;
    padding-right: var(--mobile-padding) !important;
  }
}

/* ===== Header 移动端适配 ===== */
@media (max-width: 768px) {
  /* 头部布局 */
  .pageheader {
    padding: 8px 10px !important;
  }

  .pageheader__layout {
    gap: 4px !important;
  }

  /* Logo 区域 */
  .logo-area__middle,
  .logo-area__middle__inner {
    flex-shrink: 1;
    min-width: 0;
  }

  .logo {
    flex-wrap: nowrap !important;
    gap: 4px !important;
  }

  /* FDOG Logo 移动端适配 */
  .fdog-header-logo .logo__link {
    gap: 6px !important;
  }

  .fdog-logo-img {
    height: 32px !important;
    width: auto !important;
  }

  .fdog-logo-text {
    font-size: 13px !important;
    font-weight: 600 !important;
  }

  /* Footer Logo 移动端 */
  .footer-logo-wrap {
    gap: 8px !important;
  }

  .footer-fdog-logo {
    height: 40px !important;
  }

  .footer-logo-text {
    font-size: 16px !important;
  }

  /* 隐藏桌面版导航 */
  .navigation--left,
  .navigation__tier-1-container,
  #main-nav {
    display: none !important;
  }

  /* 隐藏移动端菜单按钮 */
  .mobile-nav-toggle,
  .mobile-nav-icon,
  .header-hamburger,
  .navigation-toggle-icon,
  .logo-area__left {
    display: none !important;
  }

  /* 头部右侧区域 */
  .logo-area__right,
  .logo-area__right__inner {
    gap: 4px !important;
    flex-shrink: 0;
  }

  /* 账户链接紧凑化 */
  .header-account-link {
    padding: 6px !important;
  }

  .header-account-link svg {
    width: 20px !important;
    height: 20px !important;
  }

  /* 隐藏搜索链接（节省空间） */
  .show-search-link {
    display: none !important;
  }

  /* 钱包按钮移动端 - 更紧凑 */
  .wallet-btn,
  #walletBtn {
    padding: 2px 6px !important;
    font-size: 10px !important;
    gap: 3px !important;
    border-radius: 4px !important;
    white-space: nowrap;
    max-width: 90px !important;
    height: 28px !important;
    line-height: 1 !important;
  }

  .wallet-btn .wallet-icon,
  #walletBtn .wallet-icon,
  .wallet-btn svg,
  #walletBtn svg {
    width: 14px !important;
    height: 14px !important;
  }

  .wallet-btn .wallet-address,
  #walletBtn .wallet-btn-text,
  .wallet-btn-text {
    max-width: 60px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 10px !important;
  }

  /* 购物车链接 */
  .cart-link {
    padding: 6px !important;
  }

  .cart-link svg {
    width: 20px !important;
    height: 20px !important;
  }

  /* 隐藏头部次要元素 */
  .header-disclosures,
  .desktop-only,
  .announcement-bar__left,
  .announcement-bar__right {
    display: none !important;
  }

  /* 公告栏移动端 */
  .announcement-bar {
    padding: 8px 12px !important;
  }

  .announcement-bar__announcements {
    font-size: 13px !important;
  }
}

/* 更小屏幕的优化 */
@media (max-width: 480px) {
  .logo__link {
    font-size: 16px !important;
  }

  /* 小屏幕隐藏 Home 文字，只显示图标 */
  .home-nav-link {
    padding: 4px !important;
    font-size: 0 !important;
  }

  .home-nav-link svg {
    width: 16px !important;
    height: 16px !important;
  }

  .wallet-btn,
  #walletBtn {
    padding: 5px 8px !important;
  }

  .wallet-btn-text {
    max-width: 60px !important;
    font-size: 10px !important;
  }

  .header-account-link svg,
  .cart-link svg {
    width: 18px !important;
    height: 18px !important;
  }
}

/* ===== 移动端导航抽屉 ===== */
@media (max-width: 768px) {
  .mobile-navigation-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 10000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .navigation__mobile-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
  }

  .mobile-nav-back,
  .mobile-nav-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .navigation__tier-1 li {
    border-bottom: 1px solid #f3f4f6;
  }

  .navigation__link {
    display: block;
    padding: 16px !important;
    font-size: 16px !important;
    color: #374151 !important;
  }

  .navigation__children-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: 16px !important;
  }

  .navigation__tier-2-container {
    position: static !important;
    background: #f9fafb !important;
    box-shadow: none !important;
  }

  .navigation__tier-2 {
    padding: 0 !important;
  }

  .navigation__tier-2 .navigation__link {
    padding-left: 32px !important;
  }
}

/* ===== Hero/Slider 移动端适配 ===== */
@media (max-width: 768px) {
  /* Hero 轮播主容器 */
  .hero-slideshow {
    height: 50vh !important;
    min-height: 280px !important;
    max-height: 400px !important;
  }

  /* Hero 幻灯片内容 */
  .hero-slideshow .slide-content {
    bottom: 10% !important;
    left: 16px !important;
    right: 16px !important;
    text-align: center;
  }

  .hero-slideshow .slide-content h2 {
    font-size: 24px !important;
    margin-bottom: 8px !important;
  }

  .hero-slideshow .slide-content p {
    font-size: 14px !important;
    margin-bottom: 12px !important;
  }

  /* Hero 导航点 */
  .hero-nav {
    bottom: 12px !important;
    gap: 8px !important;
  }

  .hero-nav .dot {
    width: 10px !important;
    height: 10px !important;
  }

  /* Hero 箭头按钮 */
  .hero-arrows {
    padding: 0 8px !important;
  }

  .hero-arrows button {
    width: 40px !important;
    height: 60px !important;
    font-size: 28px !important;
    opacity: 0.7 !important;
  }

  /* 旧版 slideshow 样式 */
  .slideshow,
  .slideshow__slide {
    min-height: 280px !important;
    height: 50vh !important;
    max-height: 400px !important;
  }

  .slideshow__image img {
    object-fit: cover;
    object-position: center;
  }

  .slideshow__text-content {
    padding: 16px !important;
  }

  .slideshow__heading {
    font-size: 22px !important;
    line-height: 1.2 !important;
  }

  .slideshow__subheading {
    font-size: 14px !important;
  }

  .slideshow__button {
    padding: 10px 20px !important;
    font-size: 13px !important;
  }

  /* 轮播指示器 */
  .slideshow__nav,
  .slideshow__dots {
    bottom: 12px !important;
  }

  .slideshow__nav-item,
  .slideshow__dots button {
    width: 8px !important;
    height: 8px !important;
    margin: 0 4px !important;
  }

  /* Flickity 轮播箭头 */
  .slideshow .flickity-button,
  .slideshow__slides .flickity-button {
    width: 36px !important;
    height: 36px !important;
  }
}

/* 小屏幕进一步优化 */
@media (max-width: 480px) {
  .hero-slideshow {
    height: 45vh !important;
    min-height: 240px !important;
    max-height: 320px !important;
  }

  .hero-slideshow .slide-content h2 {
    font-size: 20px !important;
  }

  .hero-slideshow .slide-content p {
    font-size: 13px !important;
  }

  .hero-arrows button {
    width: 32px !important;
    height: 48px !important;
    font-size: 24px !important;
  }

  .slideshow,
  .slideshow__slide {
    min-height: 220px !important;
    max-height: 300px !important;
  }

  .slideshow__heading {
    font-size: 18px !important;
  }
}

/* ===== 产品网格移动端适配 ===== */
@media (max-width: 768px) {
  /* 2列布局 */
  .product-list,
  .collection-products,
  .grid--collection {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    padding: 0 var(--mobile-padding) !important;
  }

  /* 产品卡片 */
  .product-block,
  .cc-product-block,
  .grid__item {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .product-block__inner {
    border-radius: var(--mobile-radius) !important;
  }

  /* 产品图片 */
  .product-block__image {
    aspect-ratio: 1 / 1;
  }

  .product-block__image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  /* 产品信息 */
  .product-block__title {
    font-size: 13px !important;
    line-height: 1.3 !important;
    padding: 8px 8px 0 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .product-block__price {
    font-size: 14px !important;
    padding: 4px 8px 8px !important;
  }

  /* Quick add 按钮 */
  .product-block__quick-add {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    padding: 10px !important;
    font-size: 13px !important;
  }
}

/* 小屏幕单列布局 */
@media (max-width: 480px) {
  .product-list,
  .collection-products,
  .grid--collection {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .product-block__title {
    font-size: 15px !important;
  }

  .product-block__price {
    font-size: 16px !important;
  }
}

/* ===== 产品详情页移动端适配 ===== */
@media (max-width: 768px) {
  .product-main {
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
  }

  /* 产品图片画廊 */
  .product__photos {
    width: 100% !important;
    max-width: none !important;
    order: 1;
  }

  .product__photos img {
    width: 100% !important;
    height: auto !important;
  }

  /* 产品信息 */
  .product__details {
    width: 100% !important;
    padding: var(--mobile-padding) !important;
    order: 2;
  }

  .product__title {
    font-size: 22px !important;
    margin-bottom: 8px !important;
  }

  .product__price {
    font-size: 20px !important;
    margin-bottom: 16px !important;
  }

  /* 加入购物车按钮 */
  .product__add-to-cart,
  .btn--add-to-cart {
    width: 100% !important;
    padding: 16px !important;
    font-size: 16px !important;
    border-radius: var(--mobile-radius) !important;
    position: sticky;
    bottom: 16px;
    z-index: 100;
  }

  /* 产品描述 */
  .product__description {
    font-size: 14px !important;
    line-height: 1.6 !important;
    margin-top: 20px !important;
  }
}

/* ===== 购物车页面移动端适配 ===== */
@media (max-width: 768px) {
  .cart-table {
    display: block !important;
  }

  .cart-table thead {
    display: none !important;
  }

  .cart-table tbody {
    display: block !important;
  }

  .cart-table tr {
    display: flex !important;
    flex-wrap: wrap !important;
    padding: 16px !important;
    border-bottom: 1px solid #e5e7eb !important;
    gap: 12px !important;
  }

  .cart-table td {
    border: none !important;
    padding: 0 !important;
  }

  /* 购物车商品 */
  .cart-product {
    width: 100% !important;
    display: flex !important;
    gap: 12px !important;
  }

  .cart-product img {
    width: 70px !important;
    height: 70px !important;
    flex-shrink: 0;
  }

  .cart-quantity {
    margin-top: 8px !important;
  }

  /* 购物车汇总 */
  .cart-summary {
    padding: 16px !important;
    margin: 16px !important;
    border-radius: var(--mobile-radius) !important;
  }

  .checkout-btn {
    padding: 14px !important;
    font-size: 15px !important;
  }
}

/* ===== Checkout 页面移动端适配 ===== */
@media (max-width: 900px) {
  .checkout-container {
    grid-template-columns: 1fr !important;
    padding: var(--mobile-padding) !important;
    gap: 16px !important;
  }

  .checkout-sidebar {
    position: static !important;
    order: 1;
  }

  .checkout-main {
    order: 2;
  }
}

@media (max-width: 768px) {
  .checkout-header {
    padding: 12px 16px !important;
  }

  .checkout-header .logo {
    font-size: 18px !important;
  }

  .checkout-main,
  .checkout-sidebar {
    padding: 16px !important;
    border-radius: var(--mobile-radius) !important;
  }

  .section-title {
    font-size: 16px !important;
    margin-bottom: 12px !important;
  }

  /* 购物车商品 */
  .cart-item {
    padding: 12px 0 !important;
    gap: 12px !important;
  }

  .cart-item img {
    width: 60px !important;
    height: 60px !important;
  }

  .cart-item-name {
    font-size: 14px !important;
  }

  .cart-item-price {
    font-size: 13px !important;
  }

  /* 支付按钮 */
  .pay-btn,
  .connect-btn {
    padding: 14px !important;
    font-size: 15px !important;
    border-radius: var(--mobile-radius) !important;
  }

  /* 钱包信息 */
  .wallet-section {
    padding: 12px !important;
  }

  .wallet-connected {
    flex-wrap: wrap;
  }

  .wallet-balance {
    width: 100%;
    margin-top: 8px;
  }

  /* 支付步骤 */
  .payment-steps .step {
    padding: 10px !important;
  }

  .step-number {
    width: 24px !important;
    height: 24px !important;
    font-size: 12px !important;
  }

  .step-text {
    font-size: 13px !important;
  }

  /* 价格行 */
  .price-row {
    font-size: 14px !important;
  }

  .price-row.total {
    font-size: 16px !important;
  }
}

/* ===== 弹窗移动端适配 ===== */
@media (max-width: 768px) {
  .web3-modal .modal-content {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 90vh !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
  }

  .modal-header {
    padding: 16px !important;
  }

  .modal-header h2 {
    font-size: 18px !important;
  }

  .modal-body {
    padding: 16px !important;
  }

  /* 订单信息 */
  .order-items {
    padding: 10px !important;
  }

  .order-item {
    font-size: 13px !important;
    padding: 6px 0 !important;
  }

  .total-row {
    font-size: 13px !important;
  }

  .total-row.final {
    font-size: 16px !important;
  }

  /* 支付按钮 */
  .payment-actions {
    flex-direction: column !important;
  }

  .payment-actions .btn {
    padding: 14px !important;
  }

  /* 成功页面 */
  .success-page {
    padding: 30px 16px !important;
  }

  .success-icon {
    width: 60px !important;
    height: 60px !important;
    font-size: 30px !important;
  }

  .success-page h2 {
    font-size: 20px !important;
  }

  .success-actions {
    flex-direction: column !important;
  }

  .success-actions .btn {
    width: 100% !important;
  }
}

/* ===== 通知提示移动端适配 ===== */
@media (max-width: 768px) {
  .web3-notification {
    top: 50% !important;
    bottom: auto !important;
    left: 50% !important;
    right: auto !important;
    width: calc(100% - 32px) !important;
    max-width: 300px !important;
    transform: translate(-50%, -50%) scale(0.8) !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .web3-notification.show {
    transform: translate(-50%, -50%) scale(1) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .notification-content {
    width: 100% !important;
    padding: 14px 16px !important;
    border-radius: var(--mobile-radius) !important;
  }
}

/* ===== 邀请面板移动端适配 ===== */
@media (max-width: 768px) {
  .invite-panel {
    padding: 16px !important;
    border-radius: var(--mobile-radius) !important;
    margin: 16px !important;
  }

  .invite-panel h3 {
    font-size: 16px !important;
  }

  .invite-code {
    font-size: 20px !important;
  }

  .invite-link-box {
    flex-direction: column !important;
  }

  .invite-link-box input {
    width: 100% !important;
    font-size: 12px !important;
  }

  .copy-btn {
    width: 100% !important;
    padding: 12px !important;
  }

  .invite-stats {
    flex-direction: column !important;
    gap: 16px !important;
  }

  .stat-value {
    font-size: 20px !important;
  }
}

/* ===== Footer 移动端适配 ===== */
@media (max-width: 768px) {
  .section-footer,
  footer {
    padding: 32px var(--mobile-padding) !important;
  }

  .footer__blocks {
    display: flex !important;
    flex-direction: column !important;
    gap: 24px !important;
  }

  .footer__block {
    width: 100% !important;
    text-align: center !important;
  }

  .footer__heading {
    font-size: 14px !important;
    margin-bottom: 12px !important;
  }

  .footer__links {
    font-size: 13px !important;
  }

  .footer__links li {
    margin-bottom: 8px !important;
  }

  /* 社交链接 */
  .social-links__list {
    justify-content: center !important;
  }

  .social-links__list li {
    margin: 0 8px !important;
  }

  /* 版权信息 */
  .footer__lower {
    flex-direction: column !important;
    gap: 16px !important;
    text-align: center !important;
  }
}

/* ===== Rewards 页面移动端适配 ===== */
@media (max-width: 768px) {
  .rewards-container {
    padding: var(--mobile-padding) !important;
  }

  .rewards-header {
    padding: 24px 16px !important;
  }

  .rewards-header h1 {
    font-size: 24px !important;
  }

  .rewards-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }

  .reward-card {
    padding: 16px !important;
  }
}

/* ===== Orders 页面移动端适配 ===== */
@media (max-width: 768px) {
  .orders-container {
    padding: var(--mobile-padding) !important;
  }

  .order-card {
    padding: 16px !important;
    margin-bottom: 12px !important;
  }

  .order-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  .order-id {
    font-size: 14px !important;
  }

  .order-items-list {
    margin: 12px 0 !important;
  }

  .order-item-row {
    flex-direction: column !important;
    gap: 4px !important;
  }
}

/* ===== 集合页面移动端适配 ===== */
@media (max-width: 768px) {
  .collection-header {
    padding: 24px var(--mobile-padding) !important;
  }

  .collection-header__title {
    font-size: 24px !important;
  }

  .collection-header__description {
    font-size: 14px !important;
  }

  /* 筛选器 */
  .collection-filters {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .filter-btn,
  .sort-select {
    width: 100% !important;
    padding: 12px !important;
  }
}

/* ===== 按钮触摸优化 ===== */
@media (max-width: 768px) {
  button,
  .btn,
  a.btn,
  input[type="submit"] {
    min-height: 44px !important;
    min-width: 44px;
  }

  /* 防止按钮文字太小 */
  button,
  .btn {
    font-size: 14px !important;
  }
}

/* ===== 输入框移动端优化 ===== */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px !important; /* 防止 iOS 自动缩放 */
    padding: 12px !important;
    border-radius: var(--mobile-radius) !important;
  }
}

/* ===== 表单移动端优化 ===== */
@media (max-width: 768px) {
  .form-group {
    margin-bottom: 16px !important;
  }

  .form-label {
    font-size: 14px !important;
    margin-bottom: 6px !important;
  }

  .form-row {
    flex-direction: column !important;
    gap: 16px !important;
  }
}

/* ===== 空状态移动端适配 ===== */
@media (max-width: 768px) {
  .empty-cart,
  .empty-state {
    padding: 40px 20px !important;
  }

  .empty-cart h2,
  .empty-state h2 {
    font-size: 20px !important;
  }

  .empty-cart p,
  .empty-state p {
    font-size: 14px !important;
  }
}

/* ===== 加载状态 ===== */
@media (max-width: 768px) {
  .loading-spinner {
    width: 32px !important;
    height: 32px !important;
  }
}

/* ===== 固定底部按钮栏 ===== */
@media (max-width: 768px) {
  .fixed-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 12px 16px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    gap: 12px;
  }

  .fixed-bottom-bar .btn {
    flex: 1;
  }

  /* 当有固定底部栏时，给内容添加底部 padding */
  .has-fixed-bottom-bar {
    padding-bottom: 80px !important;
  }
}

/* ===== iOS 安全区域适配 ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .fixed-bottom-bar {
      padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .web3-modal .modal-content {
      padding-bottom: env(safe-area-inset-bottom);
    }
  }
}

/* ===== 横屏优化 ===== */
@media (max-width: 900px) and (orientation: landscape) {
  .slideshow,
  .slideshow__slide {
    min-height: 250px !important;
  }

  .product-list,
  .collection-products,
  .grid--collection {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .web3-modal .modal-content {
    max-height: 80vh !important;
  }
}

/* ===== 打印样式（隐藏不必要元素）===== */
@media print {
  .mobile-nav-toggle,
  .web3-notification,
  .web3-modal,
  .fixed-bottom-bar {
    display: none !important;
  }
}
