:root {
  font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  color-scheme: light dark;
  color: rgba(255, 255, 255, 0.87);
  background-color: #242424;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  font-weight: 500;
  color: #646cff;
  text-decoration: inherit;
}
a:hover {
  color: #535bf2;
}

body {
  margin: 0;
  display: flex;
  place-items: center;
  min-width: 320px;
  min-height: 100vh;
}

h1 {
  font-size: 3.2em;
  line-height: 1.1;
}

button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  background-color: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.25s;
}
button:hover {
  border-color: #646cff;
}
button:focus,
button:focus-visible {
  outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
  :root {
    color: #213547;
    background-color: #ffffff;
  }
  a:hover {
    color: #747bff;
  }
  button {
    background-color: #f9f9f9;
  }
}
/* Reset Vite starter constraints so the app can span full width */
html, body, #root { width: 100%; min-height: 100%; }
#root { max-width: none !important; margin: 0 !important; padding: 0 !important; }

/* Global */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --radius: 12px;
  --card-bg: #222B45;
  --text-muted: #8F9BB3;
}

body {
  background-color: #1A2238;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.app-container {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: var(--space-4);
  box-sizing: border-box;
}

/* Themes (kept) */
.dark { background-color: #1A2238; color: #DCE1EB; }
.light { background-color: #F5F5F5; color: #333; }
.industrial { background: linear-gradient(135deg, #0F161D, #1A2533); color: #DCE1EB; }
.industrial .product-container { border: 0; background: linear-gradient(135deg, rgba(34,43,69,.6), rgba(51,102,255,.08)); }
.construction { background: linear-gradient(135deg, #1A2B3D, #2E3F55); color: #E1E5EB; }
.construction .product-container { border: 2px solid rgba(60,120,255,.5); }
.heavy-machinery { background: linear-gradient(135deg, #0A0F14, #1A1F26); color: #F8C12E; }
.heavy-machinery .product-container { border: 3px solid rgba(248,193,46,.8); }
.light-gray { background: linear-gradient(135deg, #F0F3F7, #DDE3E7); color: #2A2D34; }
.white-blue { background: #FFFFFF; color: #1F2D3D; }
.minimal-light { background: linear-gradient(135deg, #FAFAFA, #ECECEC); color: #333; }

/* Topbar */
.topbar { text-align: center; margin-bottom: var(--space-3); }
.app-title { display: none; }
.app-subtitle { font-size: clamp(12px, 3.2vw, 16px); margin: 0; opacity: .9; text-align: center; }

/* Buttons */
.header-buttons {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--space-2); margin: var(--space-3) auto;
}
.primary-button, .danger-button {
  padding: 10px 14px; font-size: 13px; border-radius: var(--radius);
  width: auto; min-width: 170px; max-width: 220px;
  background: linear-gradient(135deg, #3366FF, #274BDB);
  color: #fff; border: none; font-weight: 600;
  box-shadow: 0 4px 10px rgba(0,0,0,.3);
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease;
  cursor: pointer;
}
.primary-button:hover, .danger-button:hover { transform: translateY(-1px); }
.danger-button { background: linear-gradient(135deg, #E04C4C, #B12020); }

/* Product grid — default: phones; >=400px: 2 cols; >=640px: fixed tracks */
.product-container {
  width: 100%; margin: 0 auto; padding: var(--space-3); padding-inline: var(--space-3);
  display: grid;
  grid-template-columns: 1fr;                          /* phones: 1 column */
  --grid-gap: clamp(10px, 1.2vw, 20px); gap: var(--grid-gap);
  justify-content: flex-start; justify-items: stretch; /* left-align, cards fill track */
  align-items: start; align-content: start;            /* avoid tall stretch */
  border-radius: 15px; box-sizing: border-box;
  background: linear-gradient(135deg, rgba(34,43,69,.6), rgba(51,102,255,.08));
  max-width: none;

  /* min-height logic: rows & gaps */
  --row-height: 200px;      /* phone card min-height */
  --min-rows: 3;            /* phones = 3 rows */
  min-height: calc(var(--row-height) * var(--min-rows) + var(--grid-gap) * (var(--min-rows) - 1));
}

/* ≥400px phones: 2 columns */
@media (min-width: 400px) and (max-width: 639.98px) {
  .product-container { grid-template-columns: repeat(2, 1fr); }
}

/* ≥640px tablets/desktop */
@media (min-width: 640px) {
  .product-container {
    grid-template-columns: repeat(auto-fit, 250px);
    justify-items: start;       /* left-align fixed-width cards */
    --row-height: 250px;        /* match desktop card height */
    --min-rows: 4;              /* EXTRA ROW on non-phone view */
  }
}

/* Cards */
.product-card {
  position: relative; background-color: var(--card-bg); border-radius: var(--radius);
  padding: var(--space-3); display: flex; flex-direction: column; align-items: center;
  text-align: center; border: 1px solid rgba(51,102,255,.35);
  justify-self: stretch; box-sizing: border-box;
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
  will-change: transform, box-shadow, border-color; transform-origin: center; cursor: pointer;
}
@media (max-width: 639.98px) {
  .product-card { width: auto; height: auto; min-height: 200px; }
}
@media (min-width: 640px) {
  .product-card { width: 250px; height: 250px; justify-self: start; }
}

/* Hover / focus glow */
.product-card:hover,
.product-card:focus-visible {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 18px rgba(51,102,255,.55), 0 8px 18px rgba(0,0,0,.35);
  border-color: rgba(51,102,255,.9);
  z-index: 2;
}
.product-card:active {
  transform: translateY(0) scale(0.99);
  box-shadow: 0 0 10px rgba(51,102,255,.45), 0 4px 12px rgba(0,0,0,.3);
}
.product-card:focus-within { outline: 2px solid #6aa4ff; outline-offset: 2px; }

.product-image { width: 100%; max-width: 160px; height: 110px; object-fit: contain; }
.product-info { width: 100%; text-align: center; }
.product-name { font-size: 14px; font-weight: 700; word-break: break-word; }
.product-article { font-size: 12px; color: var(--text-muted); }
.product-amount { font-size: 13px; margin-top: 2px; }

.no-products { text-align: center; padding: var(--space-4); opacity: .9; }

/* Pagination — desktop/tablet default (grid), centered on phones */
.pagination {
  position: sticky; bottom: 0;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: var(--space-3);
  padding: var(--space-3); margin: var(--space-3) auto 0; max-width: 900px;
  background: linear-gradient(135deg, rgba(34,43,69,.9), rgba(51,102,255,.12));
  border-radius: var(--radius); backdrop-filter: blur(4px);
}
.page-btn {
  padding: 10px 14px; font-size: 13px; font-weight: 700;
  border: none; border-radius: var(--radius); cursor: pointer;
  background: linear-gradient(135deg, #222B45, #1A2238); color: #DCE1EB;
}
.page-btn:disabled { opacity: .5; cursor: not-allowed; }
.page-status { text-align: center; font-weight: 600; }

/* Phones: no horizontal scroll + centered pagination */
@media (max-width: 639.98px) {
  .header-buttons, .product-container, .pagination {
    width: 100%; box-sizing: border-box; margin-left: auto; margin-right: auto;
  }
  .product-container { padding-inline: var(--space-2); }

  /* force centered pagination on phones */
  .pagination {
    display: flex !important; justify-content: center; align-items: center;
    gap: var(--space-3); text-align: center; padding-inline: var(--space-2);
  }
  .pagination .page-btn:first-child { order: 1; }
  .pagination .page-status        { order: 2; }
  .pagination .page-btn:last-child{ order: 3; }
  .pagination .page-btn, .pagination .page-status { flex: 0 0 auto; }
}
