/*
 * APUF Theme - Alignment Optimizations
 * 界面对齐优化样式
 * 
 * This file contains enhanced alignment and layout improvements
 */

/* ============================================
   Enhanced Container & Layout Alignment
   ============================================ */

/* Ensure all containers are perfectly aligned */
.container {
  max-width: 1200px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
  width: 100% !important;
}

/* Consistent section padding */
section {
  position: relative;
}

section .container {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================
   Header Perfect Alignment
   ============================================ */

/* Header container alignment */
.header-container {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 24px !important;
  min-height: 70px !important;
}

/* Logo alignment */
.site-branding {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: 50px;
}

.custom-logo-link,
.site-logo {
  display: inline-flex;
  align-items: center;
  height: 50px;
  line-height: 1;
}

.custom-logo,
.site-logo img {
  height: 50px;
  width: auto;
  display: block;
  vertical-align: middle;
}

/* Navigation perfect alignment */
.main-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.nav-menu {
  display: flex;
  gap: 16px;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-menu li {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
}

.nav-menu a {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  line-height: 1.5;
  height: 38px;
  white-space: nowrap;
}

/* Header actions alignment */
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  height: 50px;
}

.cart-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  position: relative;
}

.cart-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.cart-count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  padding: 0 4px;
}

.mobile-menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  gap: 5px;
}

.mobile-menu-toggle span {
  display: block;
  width: 24px;
  height: 3px;
  background-color: var(--color-black);
}

/* ============================================
   Product Grid Perfect Alignment
   ============================================ */

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  align-items: stretch;
  margin-bottom: 48px;
}

/* Ensure all product cards are same height */
.product-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Product image wrapper - perfect square */
.product-image-wrapper {
  position: relative;
  width: 100%;
  padding-top: 100%;
  overflow: hidden;
  background-color: #f5f5f5;
  flex-shrink: 0;
}

.product-image-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Product info alignment */
.product-info {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* Product title - fixed height for alignment */
.product-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
  min-height: 44px; /* Exactly 2 lines */
  max-height: 44px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-title a {
  color: #1D1F21;
  text-decoration: none;
}

/* Product price alignment */
.product-price {
  font-size: 18px;
  font-weight: 700;
  color: #29BB9D;
  line-height: 1.2;
  margin: 8px 0;
  min-height: 28px;
  display: flex;
  align-items: center;
}

.product-price del {
  font-size: 14px;
  font-weight: 400;
  color: #999;
  margin-right: 8px;
}

/* Add to cart button - always at bottom */
.add-to-cart-btn {
  width: 100%;
  padding: 12px 20px;
  background-color: #1D1F21;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: auto;
  text-align: center;
  line-height: 1.2;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-to-cart-btn:hover {
  background-color: #29BB9D;
  transform: translateY(-2px);
}

/* ============================================
   Feature Cards Equal Height Alignment
   ============================================ */

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
  align-items: stretch;
}

.feature-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 24px;
  background-color: #fff;
  border-radius: 12px;
  height: 100%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.feature-icon {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: #29BB9D;
  flex-shrink: 0;
}

.feature-icon svg {
  width: 48px;
  height: 48px;
  display: block;
}

.feature-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px 0;
  line-height: 1.3;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feature-description {
  font-size: 14px;
  line-height: 1.6;
  color: #666;
  margin: 0;
  flex: 1;
}

/* ============================================
   Category Cards Alignment
   ============================================ */

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  align-items: stretch;
}

.category-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.category-card a {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
}

.category-image {
  width: 100%;
  height: 200px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.category-info {
  padding: 24px;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.category-info h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1D1F21;
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.category-info p {
  color: #999;
  font-size: 14px;
  margin: 0;
  line-height: 1.4;
}

/* ============================================
   Button Alignment & Consistency
   ============================================ */

.btn,
button.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  height: 44px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  transition: all 0.3s ease;
}

.btn svg {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
}

/* ============================================
   Section Header Alignment
   ============================================ */

.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-title {
  font-size: 32px;
  font-weight: 700;
  color: #1D1F21;
  margin: 0 0 12px 0;
  line-height: 1.2;
}

.section-description {
  font-size: 16px;
  color: #666;
  margin: 0;
  line-height: 1.6;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================
   Hero Section Alignment
   ============================================ */

.hero-slide {
  display: flex;
  align-items: center;
  min-height: 400px;
}

.hero-content {
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero-title {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  color: #fff;
}

.hero-description {
  font-size: 18px;
  line-height: 1.6;
  margin: 0;
  color: #fff;
}

/* ============================================
   Newsletter Section Alignment
   ============================================ */

.newsletter-section {
  padding: 64px 0;
  text-align: center;
}

.newsletter-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 12px 0;
  line-height: 1.2;
}

.newsletter-form {
  display: flex;
  max-width: 500px;
  margin: 24px auto 0;
  gap: 12px;
  align-items: stretch;
}

.newsletter-input {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.5;
  height: 48px;
}

.newsletter-submit {
  padding: 12px 32px;
  background-color: #fff;
  color: #29BB9D;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* ============================================
   Footer Alignment
   ============================================ */

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 48px;
  align-items: start;
}

.footer-section h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 20px 0;
  line-height: 1.3;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-links li {
  line-height: 1.5;
}

.footer-bottom {
  padding-top: 24px;
  margin-top: 48px;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   Responsive Alignment Adjustments
   ============================================ */

@media (max-width: 1024px) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
  }
  
  .features-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}

@media (max-width: 768px) {
  /* Container adjustments */
  .container {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  
  /* Header adjustments */
  .header-container {
    min-height: 60px !important;
  }
  
  .site-branding,
  .custom-logo-link,
  .site-logo {
    height: 40px;
  }
  
  .custom-logo,
  .site-logo img {
    height: 40px;
  }
  
  /* Navigation mobile */
  .main-navigation {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 320px;
    height: 100vh;
    background-color: #fff;
    flex-direction: column;
    justify-content: flex-start;
    padding: 24px;
    transition: left 0.3s ease;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    z-index: 9999;
  }
  
  .main-navigation.active {
    left: 0;
  }
  
  .nav-menu {
    flex-direction: column;
    width: 100%;
    gap: 0;
  }
  
  .nav-menu li {
    width: 100%;
    border-bottom: 1px solid #e2e2e2;
  }
  
  .nav-menu a {
    width: 100%;
    padding: 16px 0;
    height: auto;
    justify-content: flex-start;
  }
  
  /* Products grid mobile */
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
  }
  
  .product-info {
    padding: 16px;
    gap: 8px;
  }
  
  .product-title {
    font-size: 14px;
    min-height: 40px;
    max-height: 40px;
  }
  
  .product-price {
    font-size: 16px;
  }
  
  .add-to-cart-btn {
    padding: 10px 16px;
    font-size: 13px;
    height: 40px;
  }
  
  /* Features mobile */
  .features-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .feature-card {
    padding: 24px 20px;
  }
  
  /* Categories mobile */
  .categories-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
  }
  
  /* Newsletter mobile */
  .newsletter-form {
    flex-direction: column;
    gap: 12px;
  }
  
  .newsletter-input,
  .newsletter-submit {
    width: 100%;
    height: 48px;
  }
  
  /* Hero mobile */
  .hero-slide {
    min-height: 300px;
  }
  
  .hero-title {
    font-size: 28px;
  }
  
  .hero-description {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  /* Products single column on very small screens */
  .products-grid {
    grid-template-columns: 1fr;
  }
  
  /* Categories single column */
  .categories-grid {
    grid-template-columns: 1fr;
  }
  
  /* Section titles smaller */
  .section-title {
    font-size: 24px;
  }
  
  .hero-title {
    font-size: 24px;
  }
}

/* ============================================
   Animation & Interaction Improvements
   ============================================ */

/* Smooth transitions for all interactive elements */
.product-card,
.feature-card,
.category-card,
.btn,
.nav-menu a,
.cart-icon,
.add-to-cart-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover states */
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
}

/* Loading states */
.add-to-cart-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Focus states for accessibility */
.btn:focus,
.add-to-cart-btn:focus,
.nav-menu a:focus,
input:focus {
  outline: 2px solid #29BB9D;
  outline-offset: 2px;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  .header-actions,
  .mobile-menu-toggle,
  .add-to-cart-btn,
  .newsletter-section {
    display: none !important;
  }
  
  .product-card {
    break-inside: avoid;
  }
}
