/* Hanoi Timepiece - 移动端适配样式 */

/* 移动端优先的响应式设计 */
@media (max-width: 575px) {
  /* 容器调整 */
  .container {
    padding: 0 0.75rem;
  }
  
  /* 头部导航移动端优化 */
  .header .container {
    height: 3.5rem;
  }
  
  .header .logo {
    font-size: 1.25rem;
  }
  
  .header .logo img {
    width: 120px;
    height: 40px;
  }
  
  .header .actions {
    gap: 1rem;
  }
  
  .header .search {
    display: none; /* 移动端隐藏搜索框 */
  }
  
  /* 商品网格移动端优化 */
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .product-card {
    height: auto; /* 自适应高度 */
    min-height: 380px;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 防止内容溢出 */
  }
  
  .product-card-image {
    aspect-ratio: 4/3; /* 保持图片比例，替代固定高度 */
    flex-shrink: 0;
    /* 为不支持aspect-ratio的旧浏览器提供fallback */
    height: 0;
    padding-bottom: 75%; /* 4/3 = 75% */
  }
  
  /* 现代浏览器使用aspect-ratio */
  @supports (aspect-ratio: 4/3) {
    .product-card-image {
      height: auto;
      padding-bottom: 0;
    }
  }
  
  .product-card-content {
    padding: 0.75rem; /* 减少内边距 */
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  
  .product-card-title {
    font-size: 0.875rem;
    min-height: 2.4rem;
  }
  
  .product-card-price-current {
    font-size: 1rem;
  }
  
  .product-card-actions {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .product-card-add-to-cart {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
  }
  
  /* 移动端商品卡片图片上的按钮样式 */
  .product-card-image .product-card-view,
  .product-card-image .product-card-wishlist {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .product-card-image .product-card-view {
    color: #374151;
  }
  
  .product-card-image .product-card-view:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
  }
  
  .product-card-image .product-card-wishlist {
    color: #ef4444;
  }
  
  .product-card-image .product-card-wishlist:hover,
  .product-card-image .product-card-wishlist.active {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
  }
  
  /* 右上角按钮组样式 */
  .product-card-image .absolute.top-3.right-3 {
    z-index: 10;
  }
  
  .product-card-image .absolute.top-3.right-3 .flex.flex-col {
    gap: 0.5rem;
  }
  
  /* 按钮移动端优化 */
  .btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    min-height: 48px; /* 移动端触摸友好的高度 */
  }
  
  /* 标题移动端优化 */
  .title {
    font-size: 1.75rem;
  }
  
  .subtitle {
    font-size: 0.875rem;
  }
  
  /* 模态框移动端优化 */
  .modal {
    padding: 0.5rem;
  }
  
  .modal-content {
    max-height: 95vh;
  }
  
  .modal-header,
  .modal-body {
    padding: 1rem;
  }
  
  /* 表单移动端优化 */
  .form-input,
  .form-textarea {
    font-size: 16px; /* 防止iOS缩放 */
  }
  
  /* 登录注册页面输入框移动端优化 */
  .login-page input[type="text"],
  .login-page input[type="email"],
  .login-page input[type="password"],
  .login-page input[type="tel"],
  .register-page input[type="text"],
  .register-page input[type="email"],
  .register-page input[type="password"],
  .register-page input[type="tel"] {
    width: 100%;
    min-height: 48px; /* 触摸友好的高度 */
    padding: 0.75rem 1rem;
    font-size: 16px; /* 防止iOS缩放 */
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    transition: all 0.2s ease-in-out;
  }
  
  /* 确保所有输入框在移动端都有相同的视觉长度 */
  .login-page .relative input,
  .register-page .flex input {
    width: 100%;
  }
  
  /* 登录页面邮箱/电话输入框特殊处理 */
  .login-page .relative {
    width: 100%;
  }
  
  .login-page .relative input {
    padding-left: 3rem; /* 为+84前缀留出空间 */
  }
  
  /* 注册页面电话输入框特殊处理 */
  .register-page .flex {
    width: 100%;
  }
  
  .register-page .flex > div:first-child {
    min-width: 4rem; /* 固定+84前缀宽度 */
    flex-shrink: 0;
  }
  
  .register-page .flex input {
    flex: 1;
    min-width: 0; /* 允许输入框收缩 */
  }
  
  /* 确保输入框在超小屏幕上也有良好表现 */
  @media (max-width: 375px) {
    .login-page input[type="text"],
    .login-page input[type="email"],
    .login-page input[type="password"],
    .login-page input[type="tel"],
    .register-page input[type="text"],
    .register-page input[type="email"],
    .register-page input[type="password"],
    .register-page input[type="tel"] {
      padding: 0.625rem 0.875rem; /* 稍微减少内边距 */
      font-size: 15px; /* 稍微减小字体 */
    }
    
    .login-page .relative input {
      padding-left: 2.5rem; /* 调整+84前缀空间 */
    }
    
    .register-page .flex > div:first-child {
      min-width: 3.5rem; /* 调整+84前缀宽度 */
      font-size: 14px;
    }
  }
  
  /* 输入框焦点状态优化 */
  .login-page input:focus,
  .register-page input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(134, 94, 123, 0.1);
    transform: none; /* 防止移动端缩放 */
  }
  
  /* 确保输入框在移动端不会因为缩放而变形 */
  .login-page input,
  .register-page input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0.5rem;
  }
  
  /* 优化输入框的触摸体验 */
  .login-page input,
  .register-page input {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* 页脚移动端优化 */
  .footer {
    padding: 2rem 0 1rem;
  }
  
  .footer .container {
    gap: 1.5rem;
  }
  
  .footer .section h3 {
    font-size: 1rem;
  }
  
  .footer .section p,
  .footer .section a {
    font-size: 0.8rem;
  }
}

/* 小屏设备 (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
  .container {
    padding: 0 1rem;
  }
  
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  
  .product-card {
    height: auto; /* 自适应高度 */
  }
  
  .product-card-image {
    aspect-ratio: 4/3; /* 保持图片比例 */
  }
  
  .header .search {
    display: block;
  }
  
  .header .search input {
    width: 150px;
  }
}

/* 平板设备 (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
  
  .product-card {
    height: auto; /* 自适应高度 */
  }
  
  .product-card-image {
    aspect-ratio: 4/3; /* 保持图片比例 */
  }
  
  .header .search input {
    width: 180px;
  }
  
  .title {
    font-size: 2.5rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }
}

/* 桌面设备 (992px+) */
@media (min-width: 992px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }
  
  .product-card {
    height: auto; /* 自适应高度 */
  }
  
  .product-card-image {
    aspect-ratio: 4/3; /* 保持图片比例 */
  }
  
  .header .search input {
    width: 200px;
  }
  
  .title {
    font-size: 3rem;
  }
  
  .subtitle {
    font-size: 1.125rem;
  }
}

/* 大屏设备 (1200px+) */
@media (min-width: 1200px) {
  .container {
    max-width: 1200px;
  }
  
  .product-grid {
    gap: 2rem;
  }
  
  .product-card {
    height: auto; /* 自适应高度 */
  }
  
  .product-card-image {
    aspect-ratio: 4/3; /* 保持图片比例 */
  }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 500px) {
  .header .container {
    height: 3rem;
  }
  
  .product-card {
    height: auto; /* 自适应高度 */
  }
  
  .product-card-image {
    aspect-ratio: 4/3; /* 保持图片比例 */
  }
  
  .product-card-content {
    padding: 0.75rem;
  }
  
  .modal {
    padding: 0.25rem;
  }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  .product-card:hover {
    transform: none; /* 触摸设备禁用悬停效果 */
  }
  
  .product-card:hover .product-card-image img {
    transform: none;
  }
  
  .btn:hover {
    transform: none;
  }
  
  .product-card-add-to-cart:hover {
    transform: none;
  }
  
  /* 增加触摸目标大小 */
  .product-card-wishlist {
    width: 3rem;
    height: 3rem;
  }
  
  .btn {
    min-height: 48px;
    padding: 0.875rem 1.25rem;
  }
}

/* 高DPI屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .product-card-image img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
  :root {
    --secondary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-light: #374151;
    --border-medium: #4b5563;
    --border-dark: #6b7280;
  }
  
  .product-card {
    background: #2d2d2d;
    border: 1px solid var(--border-light);
  }
  
  .header {
    background: #1a1a1a;
    border-bottom-color: var(--border-light);
  }
  
  .modal-content {
    background: #2d2d2d;
  }
  
  .form-input,
  .form-textarea {
    background: #374151;
    border-color: var(--border-medium);
    color: var(--text-primary);
  }
  
  .form-input:focus,
  .form-textarea:focus {
    background: #4b5563;
  }
}

/* 打印样式 */
@media print {
  .header,
  .footer,
  .btn,
  .product-card-actions {
    display: none;
  }
  
  .product-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .product-card-image {
    aspect-ratio: 4/3; /* 保持图片比例 */
  }
  
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  
  .title {
    font-size: 18pt;
  }
  
  .subtitle {
    font-size: 14pt;
  }
}

/* Checkout页面移动端优化 */
@media (max-width: 768px) {
  /* Checkout页面布局调整 */
  .checkout-page .grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  /* 表单区域优化 */
  .checkout-page .form-group {
    margin-bottom: 1rem;
  }
  
  .checkout-page .grid.grid-cols-1.md\\:grid-cols-2 {
    grid-template-columns: 1fr;
  }
  
  .checkout-page .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-3 {
    grid-template-columns: 1fr;
  }
  
  /* 确保所有网格在移动端都是单列 */
  .checkout-page .grid {
    grid-template-columns: 1fr !important;
  }
  
  /* 支付方式区域优化 */
  .checkout-page .space-y-3 > label {
    padding: 1rem;
  }
  
  .checkout-page .space-y-3 > label .flex {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .checkout-page .space-y-3 > label .flex .flex {
    flex-direction: row;
    align-items: center;
  }
  
  /* 订单摘要区域优化 */
  .checkout-page .sticky {
    position: static;
    margin-top: 1rem;
  }
  
  /* 按钮优化 */
  .checkout-page .btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  /* 超小屏幕优化 */
  .checkout-page .container {
    padding: 0 1rem;
  }
  
  .checkout-page .py-12 {
    padding: 1.5rem 0;
  }
  
  .checkout-page .bg-white {
    padding: 1rem;
  }
  
  .checkout-page .space-y-3 > label {
    padding: 0.75rem;
  }
  
  .checkout-page .space-y-3 > label .text-sm {
    font-size: 0.75rem;
  }
  
  /* 确保按钮在小屏幕上可点击 */
  .checkout-page .btn {
    min-height: 48px;
    font-size: 1rem;
  }
  
  /* 优化表单输入框 */
  .checkout-page .form-input {
    min-height: 44px;
    font-size: 16px; /* 防止iOS缩放 */
  }
  
  /* 优化选择框 */
  .checkout-page select.form-input {
    min-height: 44px;
  }
}

/* 确保在所有断点下都有良好的触摸体验 */
@media (max-width: 768px) {
  .checkout-page label {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  .checkout-page input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
  }
}