:root {
  --primary-color: #b91c1c;
  --primary-color-dark: #991b1b;
  --secondary-color: #f3f4f6;
  --text-color: #1f2937;
  --border-color: #d1d5db;
  --white: #ffffff;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;

  --radius-6: 6px;
  --radius-10: 10px;

  --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--secondary-color);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  font-size: 16px;
}

.hidden {
  display: none !important;
}

/* =========================
   HLAVNÝ KONTAJNER & HLAVIČKA
   ========================= */

.container {
  max-width: 1200px;
  margin: 2rem auto;
  background-color: var(--white);
  padding: 20px 40px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: 20px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.logo {
  max-width: 250px;
  height: auto;
}

.header-auth-links {
  margin-top: 0;
  color: var(--text-color);
  font-size: 0.95rem;
}

.header-auth-links a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

.header-auth-links a:hover {
  text-decoration: underline;
}

/* =========================
   NADPISY
   ========================= */

h2,
h3 {
  color: var(--text-color);
  border-bottom: 2px solid var(--secondary-color);
  padding-bottom: 10px;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.welcome-message {
  text-align: center;
  border: none;
  margin-top: 0;
}

/* =========================
   FORMULÁRE & INPUTY
   ========================= */

.form-group {
  margin-bottom: var(--space-4);
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 1rem;
  background-color: #ffffff;
}

.form-group textarea {
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: 0;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: normal;
  font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin-top: 3px;
}

/* =========================
   TLAČIDLÁ
   ========================= */

.button {
  background-color: var(--primary-color);
  color: var(--white);
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
  width: 100%;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.button:hover {
  background-color: var(--primary-color-dark);
  box-shadow: 0 6px 16px rgba(185, 28, 28, 0.25);
}

.button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.25);
}

/* Na väčších obrazovkách nie full-width */
@media (min-width: 640px) {
  .button {
    width: auto;
  }
}

/* Ak potrebuješ vyslovene full-width */
.button.btn-block {
  width: 100% !important;
}

/* =========================
   SEKCIÁ – KARTY
   ========================= */

.auth-section,
#customer-main-tabs,
.loyalty-info {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-10);
  box-shadow: var(--shadow-soft);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

/* Vernostný blok */

.loyalty-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fffbe6;
  border-color: #facc15;
  padding: 10px 15px;
  border-radius: 8px;
}

.loyalty-info p {
  margin: 0;
  font-weight: 700;
  color: #713f12;
}

.loyalty-info .button {
  width: auto;
  padding: 8px 12px;
  font-size: 0.95em;
}

/* LOGIN panel – na väčších šírkach nech nie je “rozpleštený” */
#login-tab {
  max-width: 520px;
  margin: 0 auto;
}

/* =========================
   TAB NAVIGÁCIA
   ========================= */

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  border-bottom: none;
  margin-bottom: var(--space-4);
}

.tab-button {
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  border-radius: 10px;
  background: #fff;
  color: #6b7280;
  font-size: 1.05rem;
  font-weight: 700;
  border: 1px solid var(--border-color);
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.tab-button.active {
  color: var(--primary-color);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.15);
  background: #fff;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* =========================
   CENNÍK – PUBLIC & ORDER
   ========================= */

#public-pricelist-container .product-category,
#order-pricelist-container .product-category {
  margin: 1.5rem 0 0.75rem;
  font-weight: 700;
  font-size: 1.05rem;
}

#public-pricelist-container .product-item,
#order-pricelist-container .product-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--secondary-color);
}

#public-pricelist-container .product-item:first-of-type,
#order-pricelist-container .product-item:first-of-type {
  border-top: 1px solid var(--secondary-color);
}

/* Verejný cenník – jednoduchý blok */

#public-pricelist-container .product-item {
  display: block;
}

/* ===== CENNÍK PO PRIHLÁSENÍ – JEDNA POLOŽKA (FIX MNOŽSTVA) ===== */

#order-pricelist-container {
  max-height: none;
  overflow: visible;
}

/* Riadok v cenníku: flex, nie grid */

#order-pricelist-container .product-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 12px 0;
}

/* Názov položky */

#order-pricelist-container .product-item .pi-title {
  flex: 1 1 200px;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cena */

#order-pricelist-container .product-item .pi-price {
  flex: 0 0 auto;
  font-weight: 700;
  text-align: right;
}

/* Množstvo – tu bol problém */

#order-pricelist-container .product-item .pi-qty {
  flex: 0 0 150px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#order-pricelist-container .product-item .pi-qty input[type="number"] {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

/* Akcie – tlačidlá (Pridať, Kusy, Info) */

#order-pricelist-container .product-item .pi-actions {
  flex: 1 1 200px;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Sekundárne "pill" tlačidlá – Info / Kusy */

.info-btn,
.by-piece-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  font-size: 0.9rem;
}

.info-btn i,
.by-piece-button i {
  margin-right: 6px;
}

.info-btn:hover,
.by-piece-button:hover {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.10);
  color: var(--primary-color);
}

/* Primárne tlačidlo (Pridať) – kompaktné na desktopoch */

@media (min-width: 640px) {
  #order-pricelist-container .product-item .button {
    width: auto;
  }
}

/* Mini-popover pri Info */

.b2c-popover {
  position: absolute;
  z-index: 1001;
  background: #fff;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18);
  max-width: 320px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

.b2c-popover h6 {
  margin: 0 0 6px 0;
  font-size: 1rem;
}

.b2c-popover .muted {
  color: #6b7280;
  font-size: 0.9em;
}

/* Skryť šípky number inputu */

#orderForm input[type=number]::-webkit-outer-spin-button,
#orderForm input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#orderForm input[type=number] {
  appearance: textfield;
  -moz-appearance: textfield;
}

/* =========================
   AKCIA TÝŽDŇA
   ========================= */

.akcia-title {
  display: inline-block;
  margin: 1.5rem 0 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 12px;
  border: 2px solid #b91c1c;
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.95rem;
}

.akcia-title::before {
  content: "AKCIA!";
  display: inline-block;
  margin-right: 0.75rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  background: #b91c1c;
  color: #ffffff;
  font-size: 0.8rem;
}

/* =========================
   SÚHRN OBJEDNÁVKY / HISTÓRIA
   ========================= */

.total-summary {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-6);
  background: #fafafa;
  text-align: center;
  font-size: 1.05em;
}

.min-order-warning {
  color: var(--primary-color);
  font-weight: 700;
  margin-top: 0.4rem;
  text-align: center;
}

.history-item {
  border: 1px solid var(--border-color);
  border-radius: 5px;
  margin-bottom: 15px;
  overflow: hidden;
}

.history-header {
  background-color: var(--secondary-color);
  padding: 12px 15px;
  font-weight: bold;
}

.history-body {
  padding: 15px;
}

.history-body ul {
  padding-left: 20px;
  margin-top: 5px;
}

/* Tabuľky v pomocníkovi */

.table-container table {
  width: 100%;
  border-collapse: collapse;
}

.table-container th,
.table-container td {
  padding: 8px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}

.table-container thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

.muted {
  color: #6b7280;
}

.mini-btn {
  border: 0;
  background: #e5e7eb;
  color: #111827;
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font: 600 12px/1 Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mini-btn.primary {
  background: #2563eb;
  color: #fff;
}

.mini-btn.danger {
  background: #ef4444;
  color: #fff;
}

/* =========================
   MODAL OKNÁ
   ========================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #fff;
  color: var(--text-color);
  padding: 30px;
  border-radius: 10px;
  width: min(680px, 92vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-height: 80vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.modal-close {
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  background: none;
  border: none;
  color: #9ca3af;
}

.modal-close:hover {
  color: #4b5563;
}

/* Špeciálny modal pre info o produkte */

#product-info-modal .modal-content {
  max-width: 720px;
  width: 92vw;
}

#product-info-modal .meta {
  color: #6b7280;
  font-size: 0.95em;
  margin: 0.25rem 0 1rem;
}

#product-info-modal .kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 16px;
}

#product-info-modal .kv div:nth-child(odd) {
  color: #6b7280;
}

#product-info-modal .kv div:nth-child(even) {
  font-weight: 600;
}

/* =========================
   RESPONSIVE – TABLET & MOBIL
   ========================= */

/* Tablet a menšie – container cez celú šírku */

@media (max-width: 1024px) {
  .container {
    margin: 1rem;
    padding: 16px;
  }
}

/* MOBILNÉ ZARIADENIA */

@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    padding: 0;
    background-color: var(--white);
  }

  .container {
    width: 100%;
    margin: 0;
    padding: 15px;
    box-shadow: none;
    border-radius: 0;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    text-align: left;
  }

  .logo {
    max-width: 190px;
  }

  .header-auth-links {
    font-size: 0.9rem;
  }

  .auth-section,
  #customer-main-tabs,
  .loyalty-info {
    padding: 1rem;
    box-shadow: none;
    border-radius: 8px;
  }

  .loyalty-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .loyalty-info .button {
    width: 100%;
    justify-content: center;
  }

  .tab-nav {
    flex-direction: column;
    gap: 0.5rem;
  }

  .tab-button {
    width: 100%;
    text-align: center;
  }

  /* Najdôležitejší FIX – celý riadok v cenníku ide POD SEBA */

  #order-pricelist-container .product-item {
    flex-direction: column;
    align-items: flex-start;
  }

  #order-pricelist-container .product-item .pi-title {
    width: 100%;
    white-space: normal;
  }

  #order-pricelist-container .product-item .pi-price,
  #order-pricelist-container .product-item .pi-qty,
  #order-pricelist-container .product-item .pi-actions {
    width: 100%;
  }

  #order-pricelist-container .product-item .pi-qty {
    justify-content: flex-start;
  }

  #order-pricelist-container .product-item .pi-qty input[type="number"] {
    width: 100%;
  }

  #order-pricelist-container .product-item .pi-actions {
    justify-content: flex-start;
  }

  #order-pricelist-container .product-item .pi-actions .button,
  #order-pricelist-container .product-item .pi-actions .info-btn,
  #order-pricelist-container .product-item .pi-actions .by-piece-button {
    flex: 1 1 100%;
    justify-content: center;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    padding: 1.25rem 1rem;
    max-height: 90vh;
    border-radius: 0.75rem;
  }

  .modal-header h4 {
    font-size: 1rem;
  }

  .history-item {
    font-size: 0.95rem;
  }

  .total-summary {
    font-size: 1rem;
  }
}

/* ÚPLNE MALÉ MOBILY */

@media (max-width: 480px) {
  h2,
  h3 {
    font-size: 1.05rem;
  }

  .welcome-message {
    font-size: 1rem;
  }

  .logo {
    max-width: 160px;
  }

  .table-container th,
  .table-container td {
    font-size: 0.85rem;
  }
}
