/* ===============================================
   WORLDFEAST SHOP - Global Styles
   Apple-inspired Premium Arab Food Shopping Mall
=============================================== */

/* Import Variables */
@import url('../variables.css');

/* ============= Base Shop Styles ============= */
html {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: var(--font-primary);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

main {
  background: var(--color-white);
  width: 100%;
  overflow-x: hidden;
}

/* ============= Shop Container ============= */
.container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* ============= Shop Header ============= */
.main-header {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  border-bottom: 1px solid var(--color-border-light);
  transition: var(--transition-base);
}

.main-header.scrolled {
  box-shadow: var(--shadow-md);
}

.main-nav {
  padding: var(--space-lg) 0;
}

.main-nav .container {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Top Section */
.top-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Logo */
.logo {
  flex-shrink: 0;
}

.logo a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: var(--transition-fast);
}

.logo a:hover {
  transform: scale(1.02);
  opacity: 0.9;
}

.logo img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

/* Top Navigation */
.top-nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.top-nav-link {
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: var(--transition-base);
  position: relative;
  padding: var(--space-xs) 0;
}

.top-nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary);
  transform: scaleX(0);
  transition: var(--transition-base);
}

.top-nav-link:hover {
  color: var(--color-primary);
}

.top-nav-link:hover::after {
  transform: scaleX(1);
}

/* Bottom Section - Category Navigation */
.bottom-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.category-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2xl);
  width: 100%;
  padding: 0;
}

.category-link {
  text-decoration: none;
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  padding: var(--space-sm) var(--space-md);
  position: relative;
  transition: var(--transition-base);
}

.category-link::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: var(--transition-base);
}

.category-link:hover {
  color: var(--color-primary);
}

.category-link:hover::before,
.category-link.active::before {
  width: 100%;
}

.category-link.active {
  color: var(--color-primary);
}

/* Green Dividers */
.green-divider1,
.green-divider2 {
  display: none; /* Hide legacy dividers */
}

/* ============= Search & Filter Section ============= */
.search-section {
  padding: var(--space-2xl) 0;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  margin: var(--space-xl) 0;
}

.search-container {
  display: flex;
  gap: var(--space-lg);
  align-items: center;
  max-width: 800px;
  margin: 0 auto;
}

.search-bar {
  flex: 1;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: var(--space-md) var(--space-xl);
  padding-left: calc(var(--space-xl) + 24px);
  border: 2px solid var(--color-border-light);
  border-radius: 8px;
  font-size: var(--text-base);
  background: var(--color-white);
  transition: var(--transition-base);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(126, 211, 33, 0.1);
}

.search-bar i {
  position: absolute;
  left: var(--space-lg);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-tertiary);
  pointer-events: none;
}

/* ============= Product Grid ============= */

.section-header {
  text-align: center;
  margin-bottom: var(--space-md);
}

.section-header h2 {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-tight);
}

.section-header-p {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.section-header-p p {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-lg);
  padding: 0;
}

/* ============= Product Card ============= */
.product-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.product-image {
  position: relative;
  width: 100%;
  padding-bottom: 100%; /* 1:1 Aspect Ratio */
  overflow: hidden;
  background: var(--color-bg-secondary);
}

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

/* Wishlist Button */
.wishlist-btn {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.wishlist-btn i {
  color: var(--color-text-secondary);
  font-size: var(--text-lg);
  transition: var(--transition-base);
}

.wishlist-btn:hover i,
.wishlist-btn.active i {
  color: var(--color-primary);
}

.wishlist-btn.active i {
  font-weight: 900;
}

/* Product Info */
.product-info {
  padding: var(--space-lg);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-info h3 {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
  line-height: var(--leading-snug);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: calc(var(--text-base) * var(--leading-snug) * 2); /* Reserve space for 2 lines */
}

/* Price Info - 2 Line Layout */
.price-info {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-xs) var(--space-sm);
  margin-bottom: var(--space-md);
  min-height: 52px; /* Fixed height to align all ratings */
}

/* First line: current price (sale price) + discount */
.price-info .current-price {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  order: 1;
}

.price-info .discount {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  order: 2;
}

/* Second line: original price (crossed out) - takes full width */
.price-info .original-price {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  text-decoration: line-through;
  order: 3;
  flex-basis: 100%;
}

/* Legacy support for non-discount items */
.original-price {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  text-decoration: line-through;
}

.current-price {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
}

.discount {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

/* Rating */
.rating {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.stars {
  display: flex;
  gap: 2px;
}

.stars i {
  color: #FFD700;
  font-size: var(--text-sm);
}

.rating-count {
  color: var(--color-text-tertiary);
  font-size: var(--text-sm);
}

/* Product Actions */
.product-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: auto;
}

.buy-now,
.add-to-cart {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: var(--transition-bounce);
  border: none;
  position: relative;
  overflow: hidden;
}

.buy-now {
  background: var(--color-primary);
  color: var(--color-white);
}

.buy-now:hover {
  background: var(--color-primary-hover);
}

.add-to-cart {
  background: var(--color-white);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.add-to-cart:hover {
  background: var(--color-primary-light);
}

.product-cart-count {
  position: absolute;
  top: -3px;
  right: -2px;
  background: var(--color-primary);
  color: var(--color-white) !important;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 20px;
  font-weight: var(--font-bold);
  opacity: 0;
  transform: scale(0);
  transition: var(--transition-bounce);
  z-index: 10;
  pointer-events: none;
}

.product-cart-count.show {
  opacity: 1;
  transform: scale(1);
}

/* ============= Empty States ============= */
.no-products {
  grid-column: 1 / -1;
  padding: var(--space-5xl) var(--space-xl);
  text-align: center;
}

.empty-section {
  max-width: 400px;
  margin: 0 auto;
}

.empty-section i {
  font-size: var(--text-5xl);
  color: var(--color-border-medium);
  margin-bottom: var(--space-lg);
  display: block;
}

.empty-section h3 {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
}

.empty-section p {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

/* ============= Footer ============= */
/* Hide footer-brands on specific pages */
body.login-page .footer-brands,
body.register-page .footer-brands,
body.customer-service-page .footer-brands,
body.community-page .footer-brands {
  display: none !important;
}

/* Hide cart on login and register pages */
body.login-page .cart-modal,
body.register-page .cart-modal,
body.login-page .bottom-action-buttons,
body.register-page .bottom-action-buttons {
  display: none !important;
}

.main-footer {
  background: var(--color-white);
  border-top: 1px solid var(--color-border-light);
  padding: var(--space-5xl) 0 var(--space-3xl);
  margin-top: 0;
  position: relative;
  overflow: hidden;
}

.main-footer .container {
  position: relative;
  z-index: 1;
}

/* Footer Brands Section */
.footer-brands {
  padding: var(--space-3xl) 0;
  margin-bottom: var(--space-4xl);
  border-bottom: 1px solid var(--color-border-light);
}

.footer-brands-title {
  text-align: center;
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-3xl);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  position: relative;
  display: inline-block;
  width: 100%;
}

.footer-brands-title::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: var(--color-primary);
  border-radius: var(--radius-full);
}

.footer-brands-grid {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: var(--space-md);
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg);
  background: none;
  border-radius: 0;
}

.footer-brand-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
  background: var(--color-white);
  border-radius: var(--radius-sm);
  transition: var(--transition-base);
  cursor: pointer;
  aspect-ratio: 1;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.footer-brand-item:hover {
  box-shadow: 0 4px 12px rgba(126, 211, 33, 0.2);
  border-color: var(--color-primary);
  background: var(--color-white);
}

.footer-brand-item img {
  max-width: 85%;
  max-height: 85%;
  object-fit: contain;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.footer-brand-item:hover img {
  opacity: 1;
}

/* Footer Links Section */
.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xl);
  border-bottom: none;
}

.footer-link {
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  letter-spacing: var(--tracking-normal);
  text-transform: none;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  transition: var(--transition-base);
  position: relative;
}

.footer-link:hover {
  color: var(--color-primary);
  background: rgba(126, 211, 33, 0.05);
}

/* Footer Bottom Section */
.footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) 0 0;
  text-align: center;
}

.footer-logo {
  flex-shrink: 0;
  transition: var(--transition-base);
  margin: 0 auto var(--space-lg);
}

.footer-logo:hover {
  transform: scale(1.05);
}

.footer-logo img {
  height: 50px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.footer-text {
  flex: 1;
  text-align: center;
  width: 100%;
}

.footer-text p {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  margin: var(--space-xs) 0;
}

.footer-text p:first-child {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  font-style: normal;
  margin-bottom: var(--space-sm);
}

.footer-text p:last-child {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  opacity: 0.7;
}

/* Legacy Footer Styles */
footer {
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border-light);
  padding: var(--space-4xl) 0 var(--space-2xl);
  margin-top: var(--space-5xl);
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-2xl);
  margin-bottom: var(--space-3xl);
}

.footer-section h4 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-lg);
}

.footer-section ul {
  list-style: none;
}

.footer-section ul li {
  margin-bottom: var(--space-sm);
}

.footer-section a {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: var(--transition-base);
}

.footer-section a:hover {
  color: var(--color-primary);
}

/* ============= Responsive Design ============= */
@media (max-width: 1024px) {
  .category-nav {
    gap: var(--space-lg);
    overflow-x: auto;
    justify-content: flex-start;
    padding: 0 var(--space-md);
  }

  .product-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
  }
}

@media (max-width: 768px) {
  .top-section {
    flex-direction: column;
    gap: var(--space-lg);
  }

  .top-nav-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .category-nav {
    gap: var(--space-md);
  }

  .category-link {
    font-size: var(--text-xs);
    padding: var(--space-xs) var(--space-sm);
  }

  .section-header h2 {
    font-size: var(--text-3xl);
  }

  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
  }

  .product-info {
    padding: var(--space-md);
  }

  .product-actions {
    flex-direction: column;
  }

  /* Footer Responsive */
  .footer-brands {
    padding: var(--space-2xl) 0;
    margin-bottom: var(--space-3xl);
  }

  .footer-brands-title {
    font-size: var(--text-lg);
    margin-bottom: var(--space-2xl);
  }

  .footer-brands-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-sm);
    padding: var(--space-md);
  }

  .footer-brand-item {
    padding: var(--space-xs);
  }

  .footer-links {
    gap: var(--space-md);
    padding: var(--space-2xl) 0;
  }

  .footer-link {
    font-size: var(--text-xs);
    padding: var(--space-xs) var(--space-md);
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: var(--space-2xl);
  }

  .footer-logo img {
    height: 50px;
  }

  .footer-text {
    text-align: center;
  }
}

@media (max-width: 480px) {
  .logo img {
    height: 28px;
  }

  .top-nav-link {
    font-size: var(--text-xs);
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .section-header h2 {
    font-size: var(--text-2xl);
  }

  .section-header-p p {
    font-size: var(--text-base);
  }

  /* Footer Mobile */
  .main-footer {
    padding: var(--space-4xl) 0 var(--space-2xl);
  }

  .footer-brands {
    padding: var(--space-xl) 0;
    margin-bottom: var(--space-2xl);
  }

  .footer-brands-title {
    font-size: var(--text-base);
    margin-bottom: var(--space-lg);
  }

  .footer-brands-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: var(--space-sm);
  }

  .footer-brand-item {
    padding: 4px;
  }

  .footer-links {
    gap: var(--space-sm);
    padding: var(--space-xl) 0;
  }

  .footer-link {
    font-size: 10px;
    padding: var(--space-xs) var(--space-sm);
  }

  .footer-logo img {
    height: 40px;
  }

  .footer-text p:first-child {
    font-size: var(--text-sm);
  }

  .footer-text p:last-child {
    font-size: 10px;
  }
}

/* ===============================================
   페이지 로드 시 깜빡임 방지
=============================================== */
body {
  opacity: 0;
  transition: opacity 0.1s ease;
}

body.loaded {
  opacity: 1;
}

/* ===============================================
   Login Modal (Wishlist Feature)
=============================================== */
.login-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.login-modal.show {
  opacity: 1;
  visibility: visible;
}

.login-modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 90%;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.login-modal.show .login-modal-content {
  transform: scale(1);
}

.login-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.login-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #1f2937;
}

.login-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.login-modal-close:hover {
  background-color: #f3f4f6;
  color: #1f2937;
}

.login-modal-body {
  padding: 24px;
}

.login-modal-body p {
  margin: 0 0 24px 0;
  color: #6b7280;
  font-size: 15px;
  line-height: 1.6;
}

.modal-buttons {
  display: flex;
  gap: 12px;
}

.modal-buttons button {
  flex: 1;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.modal-login-btn {
  background-color: #2563eb;
  color: white;
}

.modal-login-btn:hover {
  background-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.modal-cancel-btn {
  background-color: #f3f4f6;
  color: #6b7280;
}

.modal-cancel-btn:hover {
  background-color: #e5e7eb;
  color: #1f2937;
}

/* ============= Hide Footer Brands and Bottom Search on Mypage ============= */
/* 마이페이지와 마이페이지 하위 페이지에서 브랜드 섹션과 하단 검색바만 숨기기 */
body.mypage-page .footer-brands,
body.mypage-page .bottom-search-bar,
body.profile-page .footer-brands,
body.profile-page .bottom-search-bar,
body.addresses-page .footer-brands,
body.addresses-page .bottom-search-bar {
  display: none !important;
}