* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

body {
  font-family: 'Segoe UI', sans-serif;
  color: #333;
  background: #f9f6f0;
  overflow-x: hidden;
}

header {
  background: #2d6a2d;
  color: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo { font-size: 1.5rem; font-weight: bold; display: flex; align-items: center; gap: 0.5rem; }

nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 1.25rem;
}

nav a {
  color: white;
  text-decoration: none;
  font-size: 1rem;
  white-space: nowrap;
}

nav a:hover { text-decoration: underline; }

#logout-btn {
  color: white;
  background: none;
  border: none;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}

#logout-btn:hover { text-decoration: underline; }

.hero {
  background: linear-gradient(135deg, #4a9e4a, #2d6a2d);
  background-size: cover;
  background-position: center;
  color: white;
  text-align: center;
  padding: 5rem 2rem;
  position: relative;
}

.hero.has-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.hero > * { position: relative; z-index: 1; }

.hero h1 { font-size: 2.5rem; margin-bottom: 1rem; }
.hero p { font-size: 1.2rem; margin-bottom: 2rem; }

.btn {
  background: #f5a623;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  text-decoration: none;
  display: inline-block;
}

.btn:hover { background: #d4891a; }

.btn-secondary {
  background: #ccc;
  color: #333;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  margin-top: 0.5rem;
}

.btn-secondary:hover { background: #bbb; }

#products, #contact {
  max-width: 1100px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}

#products h2, #contact h2 { font-size: 2rem; margin-bottom: 1.5rem; color: #2d6a2d; }

.filters { margin-bottom: 1.5rem; }

.filter-btn {
  background: white;
  border: 2px solid #2d6a2d;
  color: #2d6a2d;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.filter-btn.active, .filter-btn:hover {
  background: #2d6a2d;
  color: white;
}

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

.product-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 1.2rem;
  text-align: center;
}

.product-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 0.8rem;
  background: #f0eee8;
}

.product-card h3 { font-size: 1.1rem; margin-bottom: 0.3rem; }
.product-card .category { font-size: 0.8rem; color: #888; text-transform: uppercase; margin-bottom: 0.5rem; }
.product-card .price { font-size: 1.1rem; font-weight: bold; color: #2d6a2d; margin-bottom: 0.8rem; }
.product-cart-controls { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.product-cart-controls .btn { width: 100%; }

/* Product card qty controls */
.product-qty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.qty-display {
  min-width: 28px;
  text-align: center;
  font-weight: bold;
  font-size: 1rem;
}

.card-qty-input {
  width: 52px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 0.25rem 0.3rem;
  font-size: 0.95rem;
  height: 30px;
}

.card-qty-input::-webkit-inner-spin-button,
.card-qty-input::-webkit-outer-spin-button { opacity: 1; }

.in-cart-label {
  font-size: 0.82rem;
  color: #2d6a2d;
  font-weight: 600;
  text-align: center;
}

/* Shared qty button */
.qty-btn {
  background: #2d6a2d;
  color: white;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.qty-btn:hover { background: #235523; }

#contact form {
  display: flex;
  flex-direction: column;
  max-width: 600px;
  gap: 1rem;
}

#contact input, #contact textarea {
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
}

#contact-status { margin-top: 1rem; color: #2d6a2d; font-weight: bold; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal.hidden { display: none; }

.modal-content {
  background: white;
  border-radius: 10px;
  padding: 2rem;
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-content h2 { margin-bottom: 1rem; color: #2d6a2d; }

/* Cart */
.cart-total-line { margin: 1rem 0 0.5rem; }

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.75rem 0;
  border-bottom: 1px solid #eee;
  gap: 0.75rem;
}

.cart-item-main {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

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

.cart-qty-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.qty-input {
  width: 52px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 0.25rem 0.3rem;
  font-size: 0.9rem;
  height: 30px;
}

.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button { opacity: 1; }

.cart-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  min-width: 90px;
}

.cart-item-price {
  font-weight: bold;
  color: #2d6a2d;
  font-size: 0.95rem;
}

.cart-remove-btn {
  background: none;
  border: none;
  color: #c0392b;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  text-decoration: underline;
  white-space: nowrap;
}

.cart-remove-btn:hover { color: #922b21; }

.empty-cart { color: #888; font-style: italic; padding: 0.5rem 0; }

#order-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

#order-form input {
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
}

/* Auth Modal */
.auth-tabs {
  display: flex;
  border-bottom: 2px solid #eee;
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 0.65rem;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  color: #888;
  transition: color 0.15s;
}

.auth-tab.active {
  color: #2d6a2d;
  border-bottom-color: #2d6a2d;
  font-weight: 600;
}

#login-form, #signup-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#login-form input, #signup-form input {
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
}

.form-error {
  color: #c0392b;
  font-size: 0.88rem;
  min-height: 1.2em;
}

/* Account Modal */
#account-info {
  background: #f9f6f0;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.orders-heading {
  font-size: 1.1rem;
  color: #2d6a2d;
  margin-bottom: 0.75rem;
}

.no-orders { color: #888; font-style: italic; }

.order-card {
  border: 1px solid #e0ddd8;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}

.order-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.order-id { font-weight: 600; font-size: 0.95rem; }
.order-date { color: #888; font-size: 0.85rem; margin-left: auto; }

.order-status {
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-pending    { background: #fff3cd; color: #7d5a00; }
.status-processing { background: #d0e8ff; color: #084298; }
.status-shipped    { background: #d1f0f5; color: #0c5460; }
.status-delivered  { background: #d4f0dd; color: #145523; }
.status-cancelled  { background: #f8d7da; color: #721c24; }

.order-items {
  color: #555;
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
  line-height: 1.4;
}

.order-total {
  font-weight: 600;
  color: #2d6a2d;
  font-size: 0.95rem;
}

footer {
  background: #2d6a2d;
  color: white;
  text-align: center;
  padding: 1.5rem;
  margin-top: 3rem;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  header {
    padding: 0.75rem 1rem;
  }

  .logo { font-size: 1.25rem; }

  nav { gap: 0 1rem; width: 100%; justify-content: flex-start; }
  nav a, #logout-btn { font-size: 0.92rem; }

  .hero { padding: 3rem 1.25rem; }
  .hero h1 { font-size: 1.85rem; }
  .hero p { font-size: 1rem; margin-bottom: 1.5rem; }

  #products, #contact {
    margin: 2rem auto;
    padding: 0 1rem;
  }

  #products h2, #contact h2 { font-size: 1.5rem; margin-bottom: 1rem; }

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

  .product-card { padding: 0.9rem; }
  .product-card h3 { font-size: 1rem; }
  .product-card .price { font-size: 1rem; }

  .modal-content {
    padding: 1.25rem;
    width: 94%;
    max-height: 88vh;
  }

  .modal-content h2 { font-size: 1.3rem; }

  .cart-item { flex-wrap: wrap; }
  .cart-item-right { min-width: 0; align-items: flex-end; }
}

@media (max-width: 480px) {
  header {
    padding: 0.6rem 0.9rem;
    gap: 0.5rem;
  }

  .logo { font-size: 1.1rem; }
  .logo #logo-img { height: 32px !important; }

  nav { gap: 0.4rem 0.9rem; }
  nav a, #logout-btn { font-size: 0.88rem; }

  .hero { padding: 2.25rem 1rem; }
  .hero h1 { font-size: 1.5rem; line-height: 1.25; }
  .hero p { font-size: 0.95rem; }

  .btn, .btn-secondary {
    padding: 0.65rem 1.2rem;
    font-size: 0.95rem;
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .product-card { padding: 0.7rem; }
  .product-card h3 { font-size: 0.95rem; }
  .product-card .category { font-size: 0.7rem; }
  .product-card .price { font-size: 0.95rem; margin-bottom: 0.5rem; }

  .qty-btn { width: 34px; height: 34px; font-size: 1.15rem; }
  .card-qty-input, .qty-input { width: 44px; height: 34px; font-size: 0.9rem; }

  .filter-btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.8rem;
  }

  /* Mobile-friendly form inputs — 16px prevents iOS zoom on focus */
  input, textarea, select {
    font-size: 16px !important;
  }

  .modal-content {
    padding: 1rem;
    width: 96%;
    border-radius: 8px;
  }

  .cart-item-main { gap: 0.3rem; }
  .cart-item-name { font-size: 0.9rem; }
  .cart-item-price { font-size: 0.9rem; }

  footer {
    padding: 1.25rem 1rem;
    font-size: 0.85rem;
    margin-top: 2rem;
  }
}
