/* CSS Reset and Variables */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --text-color: #1e293b;
  --text-light: #64748b;
  --background: #f8fafc;
  --white: #ffffff;
  --border-color: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  cursor: pointer;
  border: none;
  font-family: inherit;
}

/* Header Styles */
.site-header {
  background-color: var(--white);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.logo a {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.main-nav {
  flex: 1;
}

.nav-list {
  display: flex;
  gap: 2rem;
  justify-content: center;
}

.nav-list a {
  color: var(--text-color);
  font-weight: 500;
  transition: color 0.2s;
}

.nav-list a:hover {
  color: var(--primary-color);
}

/* Cart Styles */
.cart-container {
  position: relative;
}

.cart-toggle {
  background: none;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 1.5rem;
  position: relative;
}

.cart-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: var(--primary-color);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 600;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 320px;
  background-color: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 200;
}

/*
 * SHOPPING CART INTERACTION:
 * Both hover AND click work to open the cart on all devices.
 *
 * The cart dropdown covers elements behind it using:
 * - position: absolute (positions relative to .cart-container)
 * - z-index: 200 (ensures it appears above other content)
 * - box-shadow: provides visual depth/separation
 */

/* Hover to show cart */
.cart-container:hover .cart-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Click/tap to toggle cart */
.cart-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.cart-dropdown h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.cart-items {
  max-height: 300px;
  overflow-y: auto;
}

.empty-cart {
  color: var(--text-light);
  text-align: center;
  padding: 2rem 0;
}

.cart-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.cart-item-image {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  background-color: var(--background);
  flex-shrink: 0;
}

.cart-item-details {
  flex: 1;
}

.cart-item-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.cart-item-price {
  font-size: 0.85rem;
  color: var(--text-light);
}

.cart-item-quantity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.cart-item-quantity input {
  width: 50px;
  padding: 0.25rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: center;
  font-size: 0.85rem;
}

.cart-item-remove {
  background: none;
  color: #ef4444;
  font-size: 0.8rem;
  padding: 0.25rem;
}

.cart-item-remove:hover {
  text-decoration: underline;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  padding: 1rem 0;
  border-top: 1px solid var(--border-color);
  margin-top: 0.5rem;
}

.checkout-btn {
  width: 100%;
  padding: 0.75rem;
  background-color: var(--primary-color);
  color: var(--white);
  font-weight: 600;
  border-radius: var(--radius);
  transition: background-color 0.2s;
}

.checkout-btn:hover {
  background-color: var(--primary-hover);
}

/* Main Content */
.main-content {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* Breadcrumb */
.breadcrumb {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.breadcrumb a {
  color: var(--primary-color);
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb span {
  color: var(--text-light);
  margin: 0 0.5rem;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 2rem 0 3rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.hero p {
  color: var(--text-light);
  font-size: 1.1rem;
}

/* Products Section */
.products-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

/*
 * CSS TABLELESS PRODUCT LIST LAYOUT
 * ---------------------------------
 * This product grid uses CSS Flexbox instead of HTML tables for layout.
 *
 * Why Tableless (Flexbox) Layout?
 * 1. Semantic HTML: Tables are for tabular data, not layout. Products are not tabular data.
 * 2. Responsive Design: Flexbox naturally adapts to different screen sizes with flex-wrap,
 *    allowing the grid to show 4 columns on desktop, 3 on tablet, 2 on mobile, 1 on small screens.
 * 3. Accessibility: Screen readers understand the content structure better without table markup.
 * 4. Flexibility: Items can grow/shrink (flex: 1 1 calc(25% - 1.5rem)) and wrap automatically.
 * 5. Gap Property: Modern gap property provides consistent spacing without margin hacks.
 * 6. Maintainability: Easier to modify layout without changing HTML structure.
 *
 * Flexbox Properties Used:
 * - display: flex - Enables flexbox container
 * - flex-wrap: wrap - Allows items to wrap to new lines
 * - gap: 1.5rem - Consistent spacing between items
 * - flex: 1 1 calc(25% - 1.5rem) - Flex-grow, flex-shrink, and flex-basis for responsive columns
 */
.product-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.product-card {
  background-color: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  flex: 1 1 calc(25% - 1.5rem);
  min-width: 220px;
  max-width: calc(25% - 1.125rem);
  transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.product-card-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background-color: var(--background);
  cursor: pointer;
}

.product-card-content {
  padding: 1rem;
}

.product-card-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.product-card-name:hover {
  color: var(--primary-color);
}

.product-card-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.add-to-cart-btn {
  width: 100%;
  padding: 0.75rem;
  background-color: var(--primary-color);
  color: var(--white);
  font-weight: 600;
  border-radius: var(--radius);
  transition: background-color 0.2s;
}

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

/* Product Detail Page */
.product-detail {
  display: flex;
  gap: 3rem;
  background-color: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.product-image-container {
  flex: 1;
  max-width: 500px;
}

.product-full-image {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  background-color: var(--background);
  min-height: 300px;
}

.product-info {
  flex: 1;
}

.product-info h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.product-info .product-price {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 1.5rem;
}

.product-description {
  color: var(--text-light);
  line-height: 1.8;
  margin-bottom: 2rem;
}

.product-actions .add-to-cart-btn {
  width: auto;
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

/* Footer */
.site-footer {
  background-color: var(--white);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  text-align: center;
  color: var(--text-light);
}

/* Responsive Design */
@media (max-width: 992px) {
  .product-card {
    flex: 1 1 calc(33.333% - 1.5rem);
    max-width: calc(33.333% - 1rem);
  }
}

@media (max-width: 768px) {
  .header-container {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .main-nav {
    order: 3;
    width: 100%;
  }

  .nav-list {
    gap: 1rem;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .product-card {
    flex: 1 1 calc(50% - 1rem);
    max-width: calc(50% - 0.75rem);
  }

  .product-detail {
    flex-direction: column;
    gap: 2rem;
  }

  .product-image-container {
    max-width: 100%;
  }

  .hero h1 {
    font-size: 1.75rem;
  }
}

@media (max-width: 480px) {
  .header-container {
    padding: 1rem;
  }

  .main-content {
    padding: 1rem;
  }

  .product-card {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .cart-dropdown {
    width: 280px;
    right: -50px;
  }

  .nav-list {
    font-size: 0.9rem;
  }
}

/* Placeholder image styles */
.placeholder-image {
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Product Image Slider Styles */
.product-swiper {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
}

.product-swiper .swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-slide-image {
  width: 100%;
  height: auto;
  min-height: 400px;
  object-fit: cover;
  border-radius: var(--radius);
}

.product-thumbs {
  width: 100%;
}

.product-thumbs .swiper-slide {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.product-thumbs .swiper-slide-thumb-active {
  opacity: 1;
}

.product-thumb-image {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
}

.product-swiper .swiper-button-next,
.product-swiper .swiper-button-prev {
  color: var(--primary-color);
  background-color: rgba(255, 255, 255, 0.9);
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.product-swiper .swiper-button-next::after,
.product-swiper .swiper-button-prev::after {
  font-size: 18px;
  font-weight: bold;
}

.product-swiper .swiper-pagination-bullet {
  background-color: var(--primary-color);
}

.product-swiper .swiper-pagination-bullet-active {
  background-color: var(--primary-color);
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
}

.no-products {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
  width: 100%;
}

.nav-list a.active {
  color: var(--primary-color);
  font-weight: 600;
}

