/* ==========================================
   1. RESET AND BASE STYLES
========================================== */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --dark: #111827;
  --text: #374151;
  --muted: #6b7280;
  --light: #f9fafb;
  --border: #e5e7eb;
  --white: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--light);
  color: var(--text);
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

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

.container {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================
   2. HEADER
========================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.navbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  color: var(--dark);
  font-size: 1.5rem;
  font-weight: 800;
  text-decoration: none;
}

.logo span {
  color: var(--primary);
}

.cart-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  color: var(--dark);
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cart-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.cart-count {
  display: grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--primary);
  color: var(--white);
  font-size: 0.8rem;
}

/* ==========================================
   3. HERO
========================================== */

.hero {
  padding: 5rem 0;
  background: linear-gradient(135deg, #eff6ff, #ffffff);
}

.hero .container {
  max-width: 760px;
  margin-left: max(1rem, calc((100% - 1120px) / 2));
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.hero h1 {
  max-width: 680px;
  margin: 0;
  color: var(--dark);
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 1.05;
}

.hero-text {
  max-width: 600px;
  margin: 1.25rem 0 1.75rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.hero-button,
.checkout-button {
  display: inline-block;
  padding: 0.8rem 1.2rem;
  border: none;
  border-radius: 0.6rem;
  background: var(--primary);
  color: var(--white);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}

.hero-button:hover,
.checkout-button:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* ==========================================
   4. PRODUCT CATALOG
========================================== */

.catalog-section {
  padding: 4rem 0 5rem;
}

.catalog-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.catalog-header h2 {
  margin: 0;
  color: var(--dark);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.search-box input {
  width: min(320px, 100%);
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  outline: none;
  background: var(--white);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.filter-button {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  color: var(--text);
  font-weight: 600;
  transition: all 0.2s ease;
}

.filter-button:hover,
.filter-button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--white);
}

.status-message {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

.error-message {
  color: var(--danger);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.5rem;
}

.product-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--white);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.product-image {
  width: 100%;
  height: 220px;
  object-fit: contain;
  margin-bottom: 1rem;
}

.product-category {
  margin: 0;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.product-card h3 {
  margin: 0.5rem 0;
  color: var(--dark);
  font-size: 1rem;
  line-height: 1.4;
}

.product-rating {
  margin: 0.25rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 1rem;
}

.product-price {
  color: var(--dark);
  font-size: 1.1rem;
}

.add-to-cart {
  padding: 0.6rem 0.8rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--dark);
  color: var(--white);
  font-weight: 700;
}

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

/* ==========================================
   5. SHOPPING CART
========================================== */

.cart-overlay {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(17, 24, 39, 0.45);
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: min(420px, 100%);
  height: 100vh;
  padding: 1.25rem;
  background: var(--white);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.cart-drawer.open {
  transform: translateX(0);
}

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.cart-header h2 {
  margin: 0;
  color: var(--dark);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background: var(--light);
  color: var(--dark);
  font-size: 1.5rem;
}

.icon-button:hover {
  background: var(--border);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.empty-cart-message {
  text-align: center;
  color: var(--muted);
}

.cart-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.cart-item-image {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.cart-item h3 {
  margin: 0;
  color: var(--dark);
  font-size: 0.9rem;
  line-height: 1.3;
}

.cart-item-price {
  margin: 0.25rem 0;
  color: var(--primary);
  font-weight: 700;
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.quantity-button,
.remove-button {
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text);
}

.quantity-button {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 0.35rem;
}

.remove-button {
  margin-left: auto;
  padding: 0.3rem 0.5rem;
  border-radius: 0.35rem;
  color: var(--danger);
}

.cart-summary {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.total-row {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--dark);
  font-size: 1.1rem;
}

.checkout-button {
  width: 100%;
  margin-top: 0.75rem;
}

/* ==========================================
   6. CHECKOUT MODAL
========================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(17, 24, 39, 0.55);
}

.modal-content {
  position: relative;
  width: min(460px, 100%);
  padding: 2.5rem;
  border-radius: 1rem;
  background: var(--white);
  text-align: center;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.success-icon {
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: #dcfce7;
  color: var(--success);
  font-size: 2rem;
  font-weight: 800;
}

.modal-content h2 {
  color: var(--dark);
}

.modal-content p {
  color: var(--muted);
}

/* ==========================================
   7. FOOTER
========================================== */

.site-footer {
  padding: 1.5rem 0;
  background: var(--dark);
  color: #d1d5db;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

/* ==========================================
   8. RESPONSIVE DESIGN
========================================== */

@media (max-width: 700px) {
  .hero {
    padding: 4rem 0;
  }

  .catalog-header {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box input {
    width: 100%;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
  }

  .product-card {
    padding: 1rem;
  }

  .product-image {
    height: 180px;
  }
}

@media (max-width: 420px) {
  .navbar {
    min-height: 64px;
  }

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

  .category-filters {
    gap: 0.5rem;
  }

  .filter-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }
}

/* Keep HTML hidden elements hidden, even when CSS sets display */
[hidden] {
  display: none !important;
}
