:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #16181c;
  --muted: #6b7280;
  --border: #edeef1;
  --accent: #ff5a36;
  --accent-dark: #e0451f;
  --accent-tint: #fff1ed;
  --green: #16a34a;
  --green-tint: #f0fdf4;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.06);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Header */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  z-index: 10;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; flex-direction: column; line-height: 1.1; }
.logo-mark { font-weight: 800; font-size: 1.4rem; color: var(--accent); letter-spacing: -0.02em; }
.logo-sub { font-size: 0.68rem; color: var(--muted); font-weight: 500; }

.topbar-stores { display: flex; align-items: center; gap: 10px; }
.store-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
}
.store-logo img { height: 100%; width: auto; object-fit: contain; display: block; }
/* AKÍ and Coral's logo art is white-on-transparent, so it needs a solid
   brand-colored background to actually be visible - the others are already
   colored and read fine on white. */
.store-logo-aki { background: #dc2626; border-color: #dc2626; }
.store-logo-coral { background: #0891b2; border-color: #0891b2; }

/* Hero */
.hero {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 24px 24px;
  text-align: center;
}
.hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 14px;
}
.hero h1 .accent { color: var(--accent); }
.hero-sub {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 32px;
  line-height: 1.5;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 6px 6px 6px 20px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}
.search-box:focus-within { border-color: var(--accent); }
.search-icon { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: inherit;
  padding: 12px 0;
  color: var(--text);
  background: transparent;
}
.search-box input::placeholder { color: #b0b4bb; }
.search-box button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.search-box button:hover { background: var(--accent-dark); }

/* Suggestions dropdown */
.search-wrap { position: relative; }
.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
  text-align: left;
  z-index: 5;
}
.suggestions-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.suggestion-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestion-chip {
  background: #f6f7f8;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.suggestion-chip:hover { background: var(--accent-tint); border-color: var(--accent); }
.suggestion-chip.suggestion-any { background: transparent; border-style: dashed; color: var(--muted); }

/* Shopping list */
.list-chips {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.list-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--text);
  color: #fff;
  padding: 7px 8px 7px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  text-transform: capitalize;
}
.list-chip button {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.list-chip button:hover { background: rgba(255, 255, 255, 0.32); }

.list-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}
.compare-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 32px;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.compare-btn:hover { background: var(--accent-dark); }
.clear-list-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 8px 4px;
}
.clear-list-btn:hover { color: var(--text); }

/* Summary */
.summary { max-width: 720px; margin: 0 auto; padding: 32px 24px 0; }
.summary-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--green-tint);
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 12px 16px;
}
.summary-row .item-name {
  font-weight: 700;
  text-transform: capitalize;
}
.summary-row .item-detail {
  font-size: 0.82rem;
  color: var(--muted);
}
.summary-row .item-price {
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}
.summary-row.no-match {
  background: #f6f7f8;
  border-color: var(--border);
}
.summary-row.no-match .item-price { color: var(--muted); }
.summary-total {
  margin-top: 4px;
  text-align: right;
  font-size: 0.85rem;
  color: var(--muted);
}
.summary-total strong { color: var(--text); }

/* Per-item result block (shown when comparing a list) */
.item-block { margin-bottom: 44px; }
.item-block:last-child { margin-bottom: 0; }
.item-block-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.item-block-title {
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: capitalize;
}
.item-block-count { font-size: 0.8rem; color: var(--muted); }

/* Status / loading / empty */
.status-bar {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 24px;
  color: var(--muted);
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

/* Results */
.results { max-width: 960px; margin: 0 auto; padding: 32px 24px 64px; }
.results-title { font-size: 1.3rem; font-weight: 700; margin: 0 0 20px; }

.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.group-card .product-name {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
  min-height: 2.6em;
  color: inherit;
  text-decoration: none;
}
a.product-name:hover { color: var(--accent-dark); text-decoration: underline; }
.store-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.88rem;
}
.store-row.best {
  background: var(--green-tint);
  border: 1px solid #bbf7d0;
}
.store-row .store-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-weight: 600;
  min-width: 0;
}
.store-row .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.store-row .price { font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.store-row.best .price { color: var(--green); }
.best-badge {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--green);
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}
.savings-banner {
  margin-top: 4px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 10px;
  text-align: center;
}

.all-results { margin-top: 40px; }
.all-results summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 0;
}
.all-products {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.product-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.product-row:last-child { border-bottom: none; }
.product-row a { color: var(--text); text-decoration: none; }
.product-row a:hover { text-decoration: underline; }
.product-row .price-cell { font-weight: 700; white-space: nowrap; }

/* Footer */
.footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}
.footer-brand { margin-top: 8px; color: var(--text); }

/* Add-to-cart buttons + clickable titles/rows in results */
.store-row {
  gap: 8px;
}
.store-row-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 8px;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  border-radius: 8px;
  padding: 2px 6px;
  margin: -2px -6px;
  transition: background 0.15s;
}
.store-row-link:hover { background: rgba(0, 0, 0, 0.04); }
.store-row-link:hover .store-name { text-decoration: underline; }
.store-row-link .store-name { flex: 1 1 auto; }
.store-row-link .item-name {
  flex-basis: 100%;
  display: block;
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--muted);
}
.cart-btn {
  flex-shrink: 0;
  background: #f6f7f8;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cart-btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.store-row-wrap { margin-bottom: 2px; }
.cart-btn.in-cart {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}
.product-row { align-items: center; }
.product-row .cart-btn { margin-left: 8px; }

/* Floating cart */
.cart-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 20;
}
.cart-fab:hover { background: #000; }

.cart-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: min(380px, calc(100vw - 32px));
  max-height: min(70vh, 600px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 21;
  overflow: hidden;
}
.cart-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.cart-panel-header h3 { margin: 0; font-size: 1.05rem; }
.cart-panel-actions { display: flex; align-items: center; gap: 10px; }
.cart-clear {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.cart-close {
  background: #f6f7f8;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}
.cart-body { overflow-y: auto; padding: 16px 18px 18px; }

.cart-empty { color: var(--muted); font-size: 0.9rem; text-align: center; padding: 24px 0; }

.cart-recommendation {
  background: var(--green-tint);
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  line-height: 1.4;
}
.cart-recommendation strong { color: var(--green); }

.cart-store-group { margin-bottom: 14px; }
.cart-store-group:last-child { margin-bottom: 0; }
.cart-store-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.cart-store-title .count { font-weight: 500; color: var(--muted); }
.cart-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}
.cart-item-row:last-child { border-bottom: none; }
.cart-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item-price { font-weight: 700; white-space: nowrap; }
.cart-item-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}
.cart-item-remove:hover { color: var(--accent); }

.cart-total {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}

@media (max-width: 560px) {
  .cart-fab { bottom: 16px; right: 16px; }
  .cart-panel { bottom: 0; right: 0; left: 0; width: 100%; border-radius: 16px 16px 0 0; max-height: 80vh; }
}

@media (max-width: 560px) {
  .hero h1 { font-size: 1.8rem; }
  .search-box { flex-wrap: nowrap; padding-left: 14px; }
  .search-box button { padding: 10px 16px; }
  .topbar-stores { display: none; }
}
