@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

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

:root {
  --white: #ffffff;
  --cream: #faf8f4;
  --ink: #0e0e0e;
  --ink-soft: #2a2a2a;
  --muted: #888880;
  --border: #e8e5de;
  --border-light: #f0ede6;
  --accent: #e63329;
  --accent-2: #d4870a;
  --green: #1e8c4e;
  --sidebar-w: 240px;
  --header-h: 64px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-md: 0 6px 30px rgba(0,0,0,0.10);
  --shadow-lg: 0 16px 60px rgba(0,0,0,0.14);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1.5rem;
}

.logo {
  font-family: 'Playfair Display', serif;
  font-weight: 700; font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--ink); white-space: nowrap;
  flex-shrink: 0;
}
.logo span { color: var(--accent); }

.header-center { flex: 1; max-width: 480px; margin: 0 auto; }

.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  padding: 9px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar svg { color: var(--muted); flex-shrink: 0; }
.search-bar input {
  border: none; background: none;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.9rem; color: var(--ink);
  outline: none; width: 100%;
}
.search-bar input::placeholder { color: var(--muted); }
.search-bar:focus-within {
  border-color: var(--ink-soft);
  box-shadow: 0 0 0 4px rgba(14,14,14,0.06);
}

.cart-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--ink); color: var(--white);
  border: none; border-radius: 100px;
  padding: 9px 18px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap; flex-shrink: 0; position: relative;
}
.cart-btn:hover { background: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.cart-btn:active { transform: scale(0.97); }

.cart-count {
  background: var(--accent); color: white;
  border-radius: 50%; width: 20px; height: 20px;
  font-size: 0.72rem; display: flex; align-items: center;
  justify-content: center; font-weight: 700;
  animation: pop 0.3s ease;
}
.cart-count.hidden { display: none; }
@keyframes pop { 0%{transform:scale(0)} 70%{transform:scale(1.3)} 100%{transform:scale(1)} }

.hero-banner {
  margin-top: var(--header-h);
  background: var(--ink);
  color: var(--white);
  padding: 4rem 2rem 3.5rem var(--sidebar-w);
  position: relative;
  overflow: hidden;
  min-height: 280px;
  display: flex; flex-direction: column; justify-content: center;
}
.hero-banner::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 80% at 80% 50%, rgba(230,51,41,0.18) 0%, transparent 60%);
  pointer-events: none;
}
.hero-banner::after {
  content: '✦';
  position: absolute; right: 10%; top: 50%; transform: translateY(-50%);
  font-size: 15rem; opacity: 0.04; pointer-events: none;
  font-family: serif; line-height: 1;
}
.hero-content { position: relative; max-width: 680px; }
.hero-tag {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(255,255,255,0.45);
  margin-bottom: 1rem;
}
.hero-tag::before {
  content: ''; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}
.hero-banner h1 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: clamp(2rem, 3.5vw, 3.2rem);
  font-weight: 800; line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}
.hero-banner h1 em {
  font-style: italic; color: var(--accent);
  font-weight: 800;
}
.hero-banner p {
  font-size: 0.92rem; line-height: 1.7;
  color: rgba(255,255,255,0.55); max-width: 420px;
}
.hero-scroll-hint {
  position: absolute; bottom: 2rem; right: 2rem;
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; color: rgba(255,255,255,0.35);
  animation: bobDown 2.5s ease-in-out infinite;
}
@keyframes bobDown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.app-layout {
  display: flex; min-height: calc(100vh - var(--header-h));
  position: relative;
}

.sidebar-nav {
  position: sticky; top: var(--header-h);
  width: var(--sidebar-w); flex-shrink: 0;
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overflow-x: hidden;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 3rem 1rem 3rem;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-label {
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); padding: 0 0.75rem;
  margin-bottom: 0.75rem;
}

#shopsNav { display: flex; flex-direction: column; gap: 4px; }

.shop-tab {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px;
  border: none; border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer; text-align: left; width: 100%;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.88rem; font-weight: 500;
  color: var(--muted);
  transition: all var(--transition);
  position: relative;
  height: auto;
  min-height: 44px;
  overflow: visible;
  line-height: 1.2;
}
.shop-tab .icon { font-size: 1.2rem; flex-shrink: 0; display: inline-flex; align-items: center; }
.shop-tab .tab-name { flex: 1; }
.shop-tab .tab-count {
  font-size: 0.7rem; color: var(--muted);
  background: var(--cream); border-radius: 100px;
  padding: 1px 7px; font-weight: 600;
}
.shop-tab:hover { background: var(--cream); color: var(--ink); }
.shop-tab.active {
  background: var(--ink); color: var(--white);
  box-shadow: var(--shadow-sm);
}
.shop-tab.active .tab-count {
  background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.7);
}
.shop-tab.active::before {
  content: '';
  position: absolute; left: -1rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.mobile-nav-toggle {
  display: none;
  align-items: center; gap: 10px;
  padding: 12px 1.25rem;
  background: var(--white);
  border: none; border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.9rem; font-weight: 600;
  color: var(--ink); width: 100%;
}

.main-content {
  flex: 1; min-width: 0;
  padding: 2rem 2rem 4rem;
}

.section-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 2rem;
  padding: 1.75rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
}
.section-icon { font-size: 2.2rem; line-height: 1; }
.section-title-group { flex: 1; }
.section-title-group h2 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.5rem; font-weight: 700;
  letter-spacing: -0.02em;
  color: #0e0e0e !important;
  opacity: 1 !important;
}
.section-title-group p {
  display: none;
}
.section-header .badge {
  font-size: 0.8rem; font-weight: 700;
  padding: 6px 16px; border-radius: 100px;
  background: var(--ink);
  color: var(--white); border: none;
  letter-spacing: 0.02em;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.product-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  animation: fadeUp 0.4s ease both;
}
.product-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}

.product-img-wrap {
  position: relative; overflow: hidden;
  aspect-ratio: 16 / 10; height: auto; background: var(--cream);
}
.product-img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center; display: block;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.product-card:hover .product-img { transform: scale(1.07); }

.product-badge {
  position: absolute; top: 12px; left: 12px;
  background: var(--white); border-radius: 100px;
  padding: 4px 10px; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.04em; color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.product-info { padding: 16px 18px 18px; }
.product-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem; font-weight: 700;
  letter-spacing: -0.01em; margin-bottom: 4px;
  line-height: 1.3;
}
.product-unit {
  font-size: 0.78rem; color: var(--muted);
  margin-bottom: 14px;
}
.product-footer {
  display: flex; align-items: center; justify-content: space-between;
}
.product-price {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem; font-weight: 700;
  letter-spacing: -0.02em;
}
.product-price.free { color: var(--green); }

.add-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--white);
  font-size: 1.3rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--ink);
}
.add-btn:hover {
  background: var(--ink); color: var(--white);
  border-color: var(--ink); transform: scale(1.15) rotate(90deg);
}
.add-btn.added {
  background: var(--green); color: white; border-color: var(--green);
  animation: added-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes added-pop {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.product-card:nth-child(1) { animation-delay: 0ms; }
.product-card:nth-child(2) { animation-delay: 60ms; }
.product-card:nth-child(3) { animation-delay: 120ms; }
.product-card:nth-child(4) { animation-delay: 180ms; }
.product-card:nth-child(5) { animation-delay: 240ms; }
.product-card:nth-child(6) { animation-delay: 300ms; }
.product-card:nth-child(7) { animation-delay: 360ms; }
.product-card:nth-child(8) { animation-delay: 420ms; }

.search-header {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 2rem;
}
.search-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem; font-weight: 700;
}
.search-header .result-count {
  font-size: 0.85rem; color: var(--muted);
}

.no-results {
  text-align: center; padding: 5rem 2rem;
  color: var(--muted);
}
.no-results .no-icon { font-size: 3rem; margin-bottom: 1rem; }
.no-results h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem; margin-bottom: 0.5rem; color: var(--ink);
}
.cart-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200; opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  backdrop-filter: blur(2px);
}
.cart-overlay.open { opacity: 1; pointer-events: all; }

.cart-sidebar {
  position: fixed; top: 0; right: 0;
  width: 420px; max-width: 100vw; height: 100vh;
  background: var(--white); z-index: 210;
  display: flex; flex-direction: column;
  transform: translateX(110%);
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -20px 0 60px rgba(0,0,0,0.12);
}
.cart-sidebar.open { transform: translateX(0); }

.cart-header {
  padding: 1.5rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.cart-header h3 {
  font-family: 'Playfair Display', serif;
  font-weight: 700; font-size: 1.3rem;
}
.cart-close {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid var(--border);
  background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); color: var(--ink);
}
.cart-close:hover { background: var(--ink); color: var(--white); border-color: var(--ink); }

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

.cart-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 0; border-bottom: 1px solid var(--border-light);
  animation: fadeUp 0.3s ease;
}
.cart-item img {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: var(--radius-sm); flex-shrink: 0;
  border: 1px solid var(--border);
}
.cart-item-info { flex: 1; }
.cart-item-name { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.cart-item-shop { font-size: 0.75rem; color: var(--muted); margin-bottom: 6px; }
.cart-item-price {
  font-family: 'Playfair Display', serif;
  font-weight: 700; font-size: 1rem;
}
.cart-item-qty {
  display: flex; align-items: center; gap: 10px;
  margin-top: 2px;
}
.qty-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--border);
  background: none; cursor: pointer;
  font-size: 1rem; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); color: var(--ink);
}
.qty-btn:hover { background: var(--ink); color: var(--white); border-color: var(--ink); }
.qty-num { font-weight: 700; min-width: 18px; text-align: center; font-size: 0.9rem; }

.cart-empty {
  text-align: center; padding: 3rem 1rem; color: var(--muted);
}
.cart-empty .empty-icon { font-size: 3rem; margin-bottom: 1rem; display: block; }
.cart-empty p { font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.cart-empty span { font-size: 0.85rem; }

.cart-footer {
  padding: 1.25rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
}
.cart-total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 1rem;
}
.cart-total span { font-size: 0.85rem; color: var(--muted); }
.cart-total strong {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem; font-weight: 900;
}
.checkout-btn {
  width: 100%; padding: 16px;
  background: var(--ink); color: var(--white);
  border: none; border-radius: 100px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.95rem; font-weight: 700;
  cursor: pointer; letter-spacing: 0.01em;
  transition: all var(--transition);
}
.checkout-btn:hover {
  background: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(230,51,41,0.3);
}
.checkout-btn:active { transform: scale(0.98); }

.toast {
  position: fixed; bottom: 2rem; left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--ink); color: var(--white);
  padding: 12px 24px; border-radius: 100px;
  font-size: 0.88rem; font-weight: 600;
  z-index: 300; transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none; white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar-nav { display: none; }
  .hero-banner { padding: 4rem 1.5rem 3rem; }
  .hero-banner::after { display: none; }

  .mobile-nav-toggle { display: flex; }
  .main-content { padding: 1.5rem 1.25rem 3rem; }
  .sidebar-nav.mobile-open {
    display: flex; flex-direction: column;
    position: static; width: 100%; height: auto;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 1rem;
    overflow: visible;
  }
  #shopsNav.mobile-open { 
    display: flex;
    flex-direction: row; 
    flex-wrap: wrap; 
    gap: 8px; 
    height: auto;
    overflow: visible;
  }
  .sidebar-nav.mobile-open .shop-tab {
    width: auto; flex-shrink: 0; padding: 10px 16px;
    height: auto;
    overflow: visible;
  }
  .sidebar-nav.mobile-open .shop-tab::before { display: none; }
  .sidebar-nav.mobile-open .tab-count { display: none; }
  .sidebar-nav.mobile-open .sidebar-label { display: none; }
}

@media (max-width: 600px) {
  .header-center { display: none; }
  .logo { font-size: 1.1rem; }
  .cart-btn span:not(.cart-count) { display: none; }
  .hero-banner h1 { font-size: 2.4rem; }
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .product-img-wrap { aspect-ratio: 16 / 10; height: auto; }
  .product-name { font-size: 0.9rem; }
  .product-price { font-size: 1rem; }
}

@media (max-width: 380px) {
  .products-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .product-info { padding: 12px; }
}