/* ─── Reset & Base ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #e63946;
  --primary-dark: #c1121f;
  --accent: #f4a261;
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #1d3557;
  --text-light: #6c757d;
  --border: #dee2e6;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ─── */
header {
  background: var(--primary);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(230,57,70,0.3);
}

header h1 {
  font-size: 20px;
  font-weight: 700;
}

.lang-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.lang-btn:hover { background: rgba(255,255,255,0.3); }

/* ─── Splash ─── */
.splash {
  position: fixed;
  inset: 0;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  color: #fff;
}

.splash h2 {
  font-size: 24px;
  margin-bottom: 32px;
  font-weight: 600;
}

.lang-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 260px;
}

.lang-options button {
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 16px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-options button:hover {
  background: rgba(255,255,255,0.25);
  border-color: #fff;
}

/* ─── Search ─── */
.search-bar {
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.search-bar input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 24px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: var(--primary);
}

/* ─── Categories ─── */
.categories {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.categories::-webkit-scrollbar { display: none; }

.cat-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.cat-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.cat-btn:hover:not(.active) {
  border-color: var(--primary);
}

/* ─── Products Grid ─── */
.products {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.product-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.product-card:active {
  transform: scale(0.97);
}

.product-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #f0f0f0;
}

.product-card .info {
  padding: 10px 12px;
}

.product-card .name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card .price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.product-card .price-current {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.product-card .price-old {
  font-size: 12px;
  color: var(--text-light);
  text-decoration: line-through;
}

.product-card .discount-badge {
  font-size: 11px;
  background: #d4edda;
  color: #155724;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.product-card .store-tag {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ─── Loading ─── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 20px;
  color: var(--text-light);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Error ─── */
.error {
  text-align: center;
  padding: 80px 20px;
}

.error p { margin-bottom: 16px; font-size: 16px; }

.error button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 16px;
  cursor: pointer;
}

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-light);
  font-size: 16px;
}

/* ─── Hidden ─── */
.hidden { display: none !important; }

/* ─── Product Detail Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.modal {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #fff;
  border-radius: 20px 20px 0 0;
  z-index: 201;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  padding: 20px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f8f8f8;
  border-radius: 12px;
  margin-bottom: 16px;
}

.modal h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.modal .detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.modal .detail-row .label {
  color: var(--text-light);
}

.modal .detail-row .value {
  font-weight: 600;
}

.modal .close-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 16px;
  cursor: pointer;
}
