/* ============================================================================
   REEV BOUTIK — Design system mobile-first
   Couleurs alignées sur Reev Pay (teal/vert) pour cohérence de marque
   ============================================================================ */

:root {
  --c-primary: #0F6E56;
  --c-primary-dark: #085041;
  --c-primary-light: #1D9E75;
  --c-accent: #BA7517;
  --c-success: #1D9E75;
  --c-danger: #E24B4A;
  --c-warning: #EF9F27;

  --c-text: #1A1A1A;
  --c-text-soft: #5F5E5A;
  --c-text-muted: #888780;
  --c-bg: #FFFFFF;
  --c-bg-soft: #F7F7F5;
  --c-bg-tint: #E8F3EE;
  --c-border: #E5E5E0;
  --c-border-strong: #D0D0CB;

  /* Catégorie chips colors (warm pastels) */
  --cat-1: #FFE4B5; --cat-1-dark: #B86F00;
  --cat-2: #C8E6C9; --cat-2-dark: #1B5E20;
  --cat-3: #BBDEFB; --cat-3-dark: #0D47A1;
  --cat-4: #F8BBD0; --cat-4-dark: #880E4F;
  --cat-5: #D7CCC8; --cat-5-dark: #3E2723;
  --cat-6: #FFF9C4; --cat-6-dark: #827717;
  --cat-7: #B2DFDB; --cat-7-dark: #004D40;
  --cat-8: #E1BEE7; --cat-8-dark: #4A148C;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.10);

  --header-h: 56px;
  --footer-h: 64px;
  --max-w: 720px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg-soft);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--c-primary); text-decoration: none; }

/* ============================================================================
   LOADING SCREEN
   ============================================================================ */
.loading-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--c-bg);
  z-index: 9999;
}
.loading-logo {
  font-size: 32px; font-weight: 800;
  color: var(--c-primary);
  text-align: center; line-height: 1;
  letter-spacing: -1px;
}
.loading-logo span { color: var(--c-accent); }
.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--c-bg-tint);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  margin-top: 24px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================================
   APP LAYOUT
   ============================================================================ */
.app {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding-bottom: var(--footer-h);
}
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

/* ============================================================================
   HEADER
   ============================================================================ */
.header {
  position: sticky; top: 0;
  background: var(--c-primary);
  color: white;
  box-shadow: var(--shadow);
  z-index: 100;
}
.header-top {
  display: flex; align-items: center; gap: 12px;
  height: var(--header-h);
  padding: 0 16px;
  max-width: var(--max-w);
  margin: 0 auto;
}
.header-back {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 22px;
  margin-left: -6px;
}
.header-logo {
  flex: 1;
  font-size: 18px; font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
  display: flex; align-items: baseline; gap: 4px;
}
.header-logo strong { color: #FFE4B5; font-weight: 800; }
.header-cart {
  position: relative;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 18px;
}
.header-cart-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  background: var(--c-accent);
  color: white;
  border-radius: 10px;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--c-primary);
}
.header-search {
  padding: 0 16px 12px;
  max-width: var(--max-w);
  margin: 0 auto;
}
.search-input-wrap {
  position: relative;
}
.search-input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 40px;
  border-radius: var(--radius);
  border: none;
  background: rgba(255,255,255,0.95);
  color: var(--c-text);
  font-size: 14px;
  outline: none;
}
.search-input::placeholder { color: var(--c-text-muted); }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--c-text-muted);
  font-size: 16px;
  pointer-events: none;
}

/* ============================================================================
   PAGE TITLE
   ============================================================================ */
.page-title {
  font-size: 22px; font-weight: 700;
  margin: 20px 0 8px;
  color: var(--c-text);
}
.page-subtitle {
  font-size: 13px; color: var(--c-text-soft);
  margin-bottom: 16px;
}

/* ============================================================================
   CATEGORY GRID (homepage)
   ============================================================================ */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px 0;
}
.cat-card {
  background: var(--c-bg);
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  text-align: center;
  border: 1px solid var(--c-border);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 130px;
  justify-content: center;
}
.cat-card:active { transform: scale(0.97); box-shadow: var(--shadow); }
.cat-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800;
  letter-spacing: -1px;
}
.cat-name {
  font-size: 13px; font-weight: 600;
  color: var(--c-text);
  line-height: 1.2;
}
.cat-count {
  font-size: 11px; color: var(--c-text-muted);
  margin-top: -4px;
}

/* ============================================================================
   PRODUCT LIST
   ============================================================================ */
.product-list {
  display: flex; flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}
.product-card {
  display: flex; align-items: stretch;
  background: var(--c-bg);
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  overflow: hidden;
  transition: box-shadow 0.15s;
  position: relative;
}
.product-card:active { box-shadow: var(--shadow); }
.product-thumb {
  width: 70px; min-width: 70px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800;
  letter-spacing: -1px;
}
.product-body {
  flex: 1;
  padding: 10px 12px;
  display: flex; flex-direction: column;
  min-width: 0;
}
.product-name {
  font-size: 14px; font-weight: 600;
  color: var(--c-text);
  line-height: 1.3;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-meta {
  font-size: 11px; color: var(--c-text-muted);
  margin-bottom: auto;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.product-bottom {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px;
  gap: 8px;
}
.product-price {
  font-size: 15px; font-weight: 700;
  color: var(--c-primary);
  white-space: nowrap;
}
.product-price-unit {
  font-size: 11px; color: var(--c-text-muted);
  font-weight: 500;
}
.product-add {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--c-primary);
  color: white;
  font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.product-add:active { background: var(--c-primary-dark); transform: scale(0.92); }
.product-add.in-cart {
  background: var(--c-bg);
  color: var(--c-primary);
  border: 1.5px solid var(--c-primary);
}

.product-qty-control {
  display: flex; align-items: center;
  background: var(--c-primary);
  color: white;
  border-radius: 16px;
  height: 32px;
  flex-shrink: 0;
}
.qty-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 18px; font-weight: 600;
}
.qty-btn:active { opacity: 0.7; }
.qty-value {
  min-width: 24px; text-align: center;
  font-weight: 700;
  font-size: 14px;
}

.product-stock-low {
  position: absolute; top: 6px; right: 6px;
  font-size: 10px; font-weight: 600;
  background: var(--c-warning); color: white;
  padding: 2px 6px;
  border-radius: 4px;
}
.product-out {
  opacity: 0.5;
}

/* ============================================================================
   PRODUCT DETAIL
   ============================================================================ */
.product-detail {
  padding: 0 0 100px;
}
.product-detail-header {
  background: var(--c-bg);
  padding: 24px 16px;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--c-border);
}
.product-detail-thumb {
  width: 120px; height: 120px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 800;
  letter-spacing: -2px;
}
.product-detail-name {
  font-size: 20px; font-weight: 700;
  text-align: center;
  margin: 4px 0 0;
}
.product-detail-cat {
  font-size: 12px; color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.product-detail-info {
  background: var(--c-bg);
  padding: 16px;
  margin-top: 8px;
  border-bottom: 1px solid var(--c-border);
}
.info-row {
  display: flex; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--c-bg-soft);
  font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--c-text-soft); }
.info-value { font-weight: 600; }

/* ============================================================================
   STICKY ADD-TO-CART BAR (product detail)
   ============================================================================ */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--c-bg);
  border-top: 1px solid var(--c-border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  z-index: 90;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.action-bar-price {
  flex: 1;
  display: flex; flex-direction: column;
}
.action-bar-price-label {
  font-size: 11px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.5px;
}
.action-bar-price-value {
  font-size: 22px; font-weight: 700; color: var(--c-primary);
}
.action-bar-btn {
  flex: 1;
  background: var(--c-primary);
  color: white;
  height: 48px;
  border-radius: var(--radius);
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.action-bar-btn:active { background: var(--c-primary-dark); transform: scale(0.98); }
.action-bar-btn.secondary {
  background: var(--c-bg);
  color: var(--c-primary);
  border: 1.5px solid var(--c-primary);
}

/* ============================================================================
   CART
   ============================================================================ */
.cart-page {
  padding-bottom: 120px;
}
.cart-empty {
  padding: 60px 24px;
  text-align: center;
}
.cart-empty-icon {
  font-size: 64px;
  opacity: 0.3;
  margin-bottom: 16px;
}
.cart-empty-text {
  color: var(--c-text-soft);
  margin-bottom: 24px;
}
.cart-item {
  display: flex; gap: 12px;
  background: var(--c-bg);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  margin-bottom: 8px;
}
.cart-item-thumb {
  width: 52px; min-width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
  letter-spacing: -1px;
}
.cart-item-body { flex: 1; min-width: 0; }
.cart-item-name {
  font-size: 14px; font-weight: 600;
  margin: 0 0 4px;
}
.cart-item-price-unit {
  font-size: 12px; color: var(--c-text-muted);
}
.cart-item-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px;
}
.cart-item-total {
  font-weight: 700;
  color: var(--c-primary);
}
.cart-item-remove {
  color: var(--c-danger);
  font-size: 12px;
  padding: 4px 8px;
}

.cart-summary {
  background: var(--c-bg);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  margin-top: 16px;
}
.cart-summary-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}
.cart-summary-total {
  font-size: 18px; font-weight: 700;
  color: var(--c-primary);
  border-top: 1px solid var(--c-border);
  padding-top: 12px;
  margin-top: 8px;
}

/* ============================================================================
   FILTER BAR (catalogue)
   ============================================================================ */
.filter-bar {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 12px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  font-size: 13px;
  color: var(--c-text-soft);
  white-space: nowrap;
}
.filter-chip.active {
  background: var(--c-primary);
  color: white;
  border-color: var(--c-primary);
}

/* ============================================================================
   EMPTY / ERROR STATES
   ============================================================================ */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--c-text-soft);
}
.empty-state-icon { font-size: 56px; opacity: 0.3; margin-bottom: 12px; }

/* ============================================================================
   TOAST
   ============================================================================ */
.toast-container {
  position: fixed;
  bottom: 80px; left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: var(--c-text);
  color: white;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 13px; font-weight: 500;
  margin-top: 8px;
  animation: toast-in 0.3s ease;
  box-shadow: var(--shadow-lg);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   FOOTER NAV (bottom bar)
   ============================================================================ */
.footer-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--c-bg);
  border-top: 1px solid var(--c-border);
  display: flex; justify-content: space-around;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 90;
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  padding: 4px;
  color: var(--c-text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.nav-item.active { color: var(--c-primary); }
.nav-icon { font-size: 20px; }

/* ============================================================================
   SKELETON LOADERS
   ============================================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--c-bg-soft) 25%, var(--c-border) 50%, var(--c-bg-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  height: 80px; margin-bottom: 8px; border-radius: var(--radius);
}

/* ============================================================================
   RESPONSIVE - tablette / desktop
   ============================================================================ */
@media (min-width: 768px) {
  .product-list { display: grid; grid-template-columns: repeat(2, 1fr); }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (min-width: 1024px) {
  .product-list { grid-template-columns: repeat(3, 1fr); }
}
