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

:root {
  --bg: #F8F8F8;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --border: #e2e2e2;
  --text: #363636;
  --text-muted: #888;
  --accent: #DC2F2F;
  --accent-secondary: #FF894C;
  --accent-glow: rgba(220, 47, 47, 0.08);
  --food: #DC2F2F;
  --equipment: #FF894C;
  --radius: 16px;
  --radius-sm: 8px;
}

html {
  scroll-behavior: auto;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Loader ──────────────────────────────────────────── */
.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-content {
  text-align: center;
}

.loader-logo {
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: pulse-glow 1.5s ease-in-out infinite;
}

.loader-tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 400;
  margin-top: 0.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.loader-bar {
  width: 200px;
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  margin: 2rem auto 0;
  overflow: hidden;
}

.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  border-radius: 3px;
  animation: load-progress 1.5s ease-in-out forwards;
}


@keyframes load-progress {
  0%   { width: 0%; }
  30%  { width: 40%; }
  60%  { width: 70%; }
  100% { width: 100%; }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

/* ── App ─────────────────────────────────────────────── */
.app {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.app.hidden {
  display: none;
}

/* ── Top Bar ─────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(248, 248, 248, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    var(--accent-secondary) 25%,
    var(--accent) 50%,
    var(--accent-secondary) 75%,
    var(--accent) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: brand-shimmer 4s ease-in-out infinite;
}

@keyframes brand-shimmer {
  0%   { background-position: 100% 0; }
  50%  { background-position: 0% 0; }
  100% { background-position: 100% 0; }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.product-counter {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  margin-right: 0.15rem;
  font-variant-numeric: tabular-nums;
}

.product-counter #product-current {
  color: var(--accent);
  font-weight: 700;
}

.product-counter #product-count {
  font-weight: 600;
}

.topbar-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.topbar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

/* ── Popup Overlay & Panel ───────────────────────────── */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(54, 54, 54, 0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.popup-overlay.open {
  opacity: 1;
  visibility: visible;
}

.popup {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 210;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 0 1.25rem 1.5rem;
  max-height: 55vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.popup.open {
  transform: translateY(0);
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0 0.75rem;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.popup-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.popup-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s;
  line-height: 1;
}

.popup-close:hover {
  background: var(--border);
}

.popup-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.popup-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.popup-chip:hover {
  border-color: var(--text-muted);
}

.popup-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.popup-chip .chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.popup-chip .chip-dot.food { background: var(--food); }
.popup-chip .chip-dot.equipment { background: var(--equipment); }
.popup-chip.selected .chip-dot { background: rgba(255,255,255,0.5); }

/* ── Product Pages ───────────────────────────────────── */
.product-pages {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.product-page {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem 2rem;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}

.product-page.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.product-card {
  width: 100%;
  max-width: 900px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.product-visual {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(54, 54, 54, 0.06);
}

.product-visual img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.product-visual:hover img {
  transform: scale(1.05);
}

.product-visual .category-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.7rem;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
}

.category-badge.food {
  color: var(--food);
  border: 1px solid rgba(220, 47, 47, 0.25);
}

.category-badge.equipment {
  color: var(--equipment);
  border: 1px solid rgba(255, 137, 76, 0.3);
}

.product-placeholder {
  font-size: 4rem;
  opacity: 0.3;
}

.product-info {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.product-info-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.info-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.category-badge-inline {
  display: none;
}

.product-id {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.product-name {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.product-meta {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.meta-row:last-child {
  border-bottom: none;
}

.meta-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meta-value {
  font-size: 0.9rem;
  font-weight: 600;
  text-align: right;
}

.product-price-bar {
  margin-top: auto;
  padding-top: 0.75rem;
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
}

.price-col {
  display: flex;
  flex-direction: column;
}

.price-col-ttc .price-value {
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
}

.price-value.ttc .currency {
  opacity: 0.5;
}

.price-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}

.price-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
}

.price-value .currency {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.7;
  margin-left: 0.2rem;
}

.price-old {
  text-decoration: line-through;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-right: 0.5rem;
}

.tax-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-2);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
}

.supplier-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-glow);
  color: var(--accent);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  max-width: 220px;
  text-align: right;
}

.supplier-tag.none {
  background: var(--surface-2);
  color: var(--text-muted);
}


/* ── List View ───────────────────────────────────────── */
.product-list {
  position: absolute;
  inset: 0;
  padding: 60px 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.product-list.hidden {
  display: none;
}

.list-table {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  border-collapse: collapse;
}

.list-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.list-table th {
  background: var(--surface-2);
  padding: 0.6rem 1rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.list-table th:last-child,
.list-table td:last-child {
  text-align: right;
}

.list-table td {
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  vertical-align: middle;
}

.list-table tr:last-child td {
  border-bottom: none;
}

.list-table tbody tr {
  transition: background 0.15s;
  cursor: pointer;
}

.list-table tbody tr:hover td {
  background: var(--accent-glow);
}

.list-product-name {
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.list-product-name img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface-2);
  flex-shrink: 0;
  padding: 3px;
}

.list-price {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.list-price-ttc {
  color: var(--text);
  font-weight: 600;
}

.list-supplier {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-tax {
  font-size: 0.75rem;
  font-weight: 600;
}

.list-id {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ── List view mobile ── */
@media (max-width: 768px) {
  .product-list {
    padding-top: 52px;
  }

  .list-table th,
  .list-table td {
    padding: 0.7rem 0.65rem;
    font-size: 0.72rem;
  }

  .list-product-name img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
  }

  .list-product-name {
    font-size: 0.75rem;
    gap: 0.4rem;
  }

  .list-supplier {
    max-width: 100px;
    font-size: 0.68rem;
  }

  .list-col-tax,
  .list-col-id {
    display: none;
  }
}

/* ── Swipe Hint ──────────────────────────────────────── */
.swipe-hint {
  position: fixed;
  left: 50%;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease, bottom 0.4s ease, top 0.4s ease;
  color: var(--text-muted);
}

.swipe-hint.show-down {
  bottom: 1.5rem;
  top: auto;
  opacity: 1;
  animation: hint-bounce-down 2s ease-in-out infinite;
}

.swipe-hint.show-up {
  top: 5rem;
  bottom: auto;
  opacity: 1;
  animation: hint-bounce-up 2s ease-in-out infinite;
}

.swipe-hint svg {
  display: block;
  filter: drop-shadow(0 1px 3px rgba(54, 54, 54, 0.1));
}

.swipe-hint.show-up svg {
  transform: rotate(180deg);
}

@keyframes hint-bounce-down {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-10px); }
}

@keyframes hint-bounce-up {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(10px); }
}

/* ── Empty State ─────────────────────────────────────── */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  opacity: 0.3;
}

.empty-state-text {
  font-size: 1.1rem;
  font-weight: 500;
}

/* ── Desktop large ────────────────────────────────────── */
@media (min-width: 1200px) {
  .product-card {
    gap: 5rem;
  }
}

/* ── Mobile ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .topbar-inner {
    height: 48px;
    padding: 0 1rem;
  }

  .topbar-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .product-counter {
    font-size: 0.65rem;
  }

  /* ── Full-screen product page ── */
  .product-page {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .product-card {
    display: flex;
    flex-direction: column;
    max-width: none;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    gap: 0;
  }

  /* ── Image hero section ── */
  .product-visual {
    flex: 0 0 auto;
    height: 35vmax;
    min-height: 180px;
    max-height: 40vh;
    width: 100%;
    aspect-ratio: auto;
    border-radius: 0;
    border: none;
    box-shadow: none;
    position: relative;
    padding: 3.5rem 1.5rem 1.5rem;
    margin-top: 48px;
  }

  .product-card[data-category="food"] .product-visual {
    background: linear-gradient(160deg, #fde8e8 0%, #fef1ec 50%, #fff5f0 100%);
  }

  .product-card[data-category="equipment"] .product-visual {
    background: linear-gradient(160deg, #fff0e6 0%, #fff6ef 50%, #fffaf5 100%);
  }

  .product-visual img {
    width: 85%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 24px rgba(54, 54, 54, 0.12));
  }

  .product-visual .category-badge {
    display: none;
  }

  .product-placeholder {
    font-size: 5rem;
    opacity: 0.2;
  }

  /* ── Info card section ── */
  .product-info {
    flex: 1;
    min-height: 0;
    width: 100%;
    background: var(--surface);
    border-radius: 0;
    margin-top: 0;
    padding: 1.25rem 1.25rem 2rem;
    position: relative;
    gap: 0.85rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid var(--border);
  }

  .product-info-header {
    gap: 0.2rem;
  }

  .category-badge-inline {
    display: inline-flex;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.25rem 0.6rem;
    border-radius: 100px;
    flex-shrink: 0;
  }

  .category-badge-inline.food {
    color: var(--food);
    background: rgba(220, 47, 47, 0.08);
  }

  .category-badge-inline.equipment {
    color: var(--equipment);
    background: rgba(255, 137, 76, 0.1);
  }

  .product-name {
    font-size: 1.3rem;
    line-height: 1.2;
    word-break: break-word;
  }

  .product-id {
    font-size: 0.62rem;
    order: -1;
  }

  .product-meta {
    background: var(--bg);
    border-radius: 12px;
    padding: 0.15rem 0.85rem;
  }

  .meta-row {
    padding: 0.55rem 0;
    gap: 0.5rem;
  }

  .meta-label {
    font-size: 0.65rem;
    flex-shrink: 0;
  }

  .meta-value {
    font-size: 0.78rem;
  }

  .supplier-tag {
    max-width: none;
    font-size: 0.7rem;
    white-space: normal;
    word-break: break-word;
    text-align: right;
    line-height: 1.3;
  }

  /* ── Price bar ── */
  .product-price-bar {
    background: var(--bg);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 0.75rem;
  }

  .price-col {
    flex: 1;
  }

  .price-label {
    font-size: 0.6rem;
    margin-bottom: 0.05rem;
  }

  .price-value {
    font-size: 1.25rem;
  }

  .price-col-ttc .price-value {
    font-size: 1.1rem;
  }

}

/* ── Small phones ────────────────────────────────────── */
@media (max-width: 380px) {
  .product-visual {
    height: 30vmax;
    min-height: 160px;
    max-height: 34vh;
  }

  .product-info {
    padding: 1rem 1rem 1.75rem;
    gap: 0.65rem;
  }

  .product-name {
    font-size: 1.1rem;
  }

  .price-value {
    font-size: 1.2rem;
  }
}
