/**
 * MatricaDiszkont – Kosár oldal UI (CSS-only, mobilbarát)
 * Verzió: 1.0.1 · md-cart-page-header
 * Scope: .j2store .j2store-cart
 */

body.view-carts #sp-main-body,
body.view-carts .sp-main-body {
  background: #f4f7fb;
}

body.view-carts .page-header,
body.view-carts .md-cart-page-header {
  margin-bottom: 22px;
}

body.view-carts .md-cart-page-header {
  position: relative;
  padding: 22px 24px 20px;
  border: 1px solid rgba(74, 109, 146, 0.12);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(232, 240, 247, 0.72) 100%);
  box-shadow:
    0 14px 34px rgba(44, 62, 80, 0.08),
    0 2px 8px rgba(74, 109, 146, 0.06);
  overflow: hidden;
}

body.view-carts .md-cart-page-header__eyebrow {
  display: block;
  margin: 0 0 6px;
  padding-left: 2px;
  font-family: 'Metropolis', system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #4a6d92;
}

body.view-carts .md-cart-page-header__title,
body.view-carts .page-header h1 {
  margin: 0;
  padding-left: 2px;
  font-family: 'Metropolis', system-ui, sans-serif;
  font-size: clamp(1.55rem, 4vw, 2.05rem);
  font-weight: 800;
  line-height: 1.15;
  color: #3d4654;
  letter-spacing: -0.03em;
}

body.view-carts .md-cart-page-header__lead {
  margin: 10px 0 0;
  padding-left: 2px;
  max-width: 42rem;
  font-family: 'Metropolis', system-ui, sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #6b7585;
}

.j2store .j2store-cart {
  --md-cart-font: 'Metropolis', system-ui, sans-serif;
  --md-cart-surface: #f8fafc;
  --md-cart-card: #ffffff;
  --md-cart-border: rgba(148, 163, 184, 0.32);
  --md-cart-text: #2d3436;
  --md-cart-muted: #64748b;
  --md-cart-accent: #4a6d92;
  --md-cart-success: #2f6b4f;
  --md-cart-success-bg: #ecfdf3;
  --md-cart-warn: #b7791f;
  --md-cart-warn-bg: #fffbeb;
  --md-cart-danger: #c53030;
  --md-cart-danger-bg: #fff5f5;
  --md-cart-radius: 16px;
  --md-cart-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
  font-family: var(--md-cart-font);
  max-width: 980px;
  margin: 0 auto;
  padding-bottom: 8px;
}

/* ===== Kosár terméklista ===== */
.j2store-cart #j2store-cart-form {
  background: var(--md-cart-card);
  border: 1px solid var(--md-cart-border);
  border-radius: var(--md-cart-radius);
  box-shadow: var(--md-cart-shadow);
  padding: 8px 10px 16px;
  margin-bottom: 18px;
}

.j2store-cart .j2store-cart-table {
  width: 100%;
  margin: 0;
  border: none !important;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
}

.j2store-cart .j2store-cart-table thead th {
  border: none !important;
  background: var(--md-cart-surface);
  color: var(--md-cart-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px 14px;
  white-space: nowrap;
}

.j2store-cart .j2store-cart-table thead th:first-child {
  border-radius: 12px 0 0 12px;
}

.j2store-cart .j2store-cart-table thead th:last-child {
  border-radius: 0 12px 12px 0;
  text-align: right;
}

.j2store-cart .j2store-cart-table tbody tr {
  border-bottom: 1px solid var(--md-cart-border);
}

.j2store-cart .j2store-cart-table tbody tr:last-child {
  border-bottom: none;
}

.j2store-cart .j2store-cart-table tbody td {
  border: none !important;
  padding: 10px 12px;
  vertical-align: top;
  color: var(--md-cart-text);
}

.j2store-cart .j2store-cart-table tbody td:first-child {
  min-width: 0;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 2px 12px;
  align-items: start;
  line-height: 1.22;
}

/* J2Store <br> tagok felesleges sorközt adnak – elrejtjük, a grid/gap adja a térközt */
.j2store-cart .j2store-cart-table tbody td:first-child br {
  display: none;
}

.j2store-cart .cart-thumb-image {
  display: block;
  grid-row: 1 / span 8;
  margin: 0;
}

.j2store-cart .cart-thumb-image img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--md-cart-border);
  background: #fff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.05);
}

.j2store-cart .cart-product-name {
  display: block;
  grid-column: 2;
  max-width: none;
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1.22;
  color: #3d4654;
}

.j2store-cart .cart-item-options {
  display: block;
  grid-column: 1 / -1;
  clear: none;
  margin-top: 4px;
}

.j2store-cart .cart-item-options small {
  display: block;
  color: var(--md-cart-muted);
  font-size: 0.82rem;
  line-height: 1.22;
  padding: 0;
  margin: 0;
}

.j2store-cart .cart-product-unit-price,
.j2store-cart .cart-product-sku {
  display: block;
  grid-column: 2;
  margin-top: 1px;
  font-size: 0.82rem;
  line-height: 1.2;
  color: var(--md-cart-muted);
}

.j2store-cart .cart-item-title {
  font-weight: 700;
  margin-right: 4px;
}

/* AI előnézet a tételsorban – kompakt margó */
.j2store-cart .md-cart-ai-preview-wrap {
  margin: 4px 0 2px !important;
}

.j2store-cart .cart-line-subtotal {
  text-align: right;
  font-size: 1.05rem;
  font-weight: 800;
  color: #3d4654;
  white-space: nowrap;
}

.j2store-cart .j2store-cart-table input[type="number"],
.j2store-cart .j2store-cart-table .input-mini {
  width: 68px;
  max-width: 100%;
  text-align: center;
  border: 1px solid var(--md-cart-border);
  border-radius: 10px;
  padding: 8px 6px;
  font-weight: 700;
  background: #fff;
}

.j2store-cart .j2store-cart-table .j2store-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  min-width: 42px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 10px !important;
  border: 1px solid rgba(197, 48, 48, 0.25) !important;
  background: var(--md-cart-danger-bg) !important;
  color: var(--md-cart-danger) !important;
  font-weight: 700;
  text-decoration: none !important;
  box-shadow: none !important;
}

.j2store-cart .j2store-cart-table .j2store-remove:hover {
  background: #fee2e2 !important;
  border-color: rgba(197, 48, 48, 0.45) !important;
}

/* ===== Akció gombok ===== */
.j2store-cart .j2store-cart-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 0 !important;
}

.j2store-cart .j2store-cart-buttons .btn {
  border: none;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.92rem;
  padding: 11px 18px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.j2store-cart .j2store-cart-buttons .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.j2store-cart .j2store-cart-buttons .btn-warning {
  background: var(--md-cart-warn-bg) !important;
  color: #9a6700 !important;
  border: 1px solid rgba(183, 121, 31, 0.25) !important;
}

.j2store-cart .j2store-cart-buttons .btn-primary {
  background: #e8f0f7 !important;
  color: var(--md-cart-accent) !important;
  border: 1px solid rgba(74, 109, 146, 0.22) !important;
}

.j2store-cart .j2store-cart-buttons .btn-danger {
  background: var(--md-cart-danger-bg) !important;
  color: var(--md-cart-danger) !important;
  border: 1px solid rgba(197, 48, 48, 0.22) !important;
}

/* ===== Összesen ===== */
.j2store-cart #md-totals {
  margin-top: 18px !important;
}

.j2store-cart #md-totals h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: #3d4654;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.j2store-cart .cart-footer {
  width: 100%;
  max-width: 440px;
  margin-left: auto;
  margin-right: 0;
  border: 1px solid var(--md-cart-border) !important;
  border-radius: var(--md-cart-radius) !important;
  overflow: hidden;
  background: var(--md-cart-card);
  box-shadow: var(--md-cart-shadow);
}

.j2store-cart .cart-footer th,
.j2store-cart .cart-footer td {
  border: none !important;
  padding: 12px 16px !important;
  font-size: 0.94rem;
}

.j2store-cart .cart-footer th {
  color: var(--md-cart-muted);
  font-weight: 700;
}

.j2store-cart .cart-footer td {
  text-align: right;
  font-weight: 800;
  color: #3d4654;
  white-space: nowrap;
}

.j2store-cart .cart-footer tr:last-child th,
.j2store-cart .cart-footer tr:last-child td {
  background: var(--md-cart-success-bg);
  color: var(--md-cart-success);
  font-size: 1.02rem;
}

.j2store-cart .cart-footer .buttons-right {
  display: none;
}

/* ===== Kupon ===== */
.j2store-cart .cart-estimator-discount-block .coupon {
  background: var(--md-cart-card) !important;
  border: 1px solid var(--md-cart-border) !important;
  border-radius: var(--md-cart-radius) !important;
  padding: 16px !important;
  margin-top: 0 !important;
  box-shadow: var(--md-cart-shadow);
}

.j2store-cart .cart-estimator-discount-block .coupon form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.j2store-cart .cart-estimator-discount-block input[type="text"] {
  flex: 1 1 220px;
  min-height: 46px !important;
  padding: 10px 14px !important;
  border: 1px solid var(--md-cart-border) !important;
  border-radius: 12px !important;
  background: #fff;
  font-size: 0.95rem;
}

.j2store-cart .cart-estimator-discount-block input[type="submit"],
.j2store-cart .cart-estimator-discount-block .button {
  min-height: 46px !important;
  padding: 0 18px !important;
  border-radius: 12px !important;
  border: none !important;
  background: var(--md-cart-success) !important;
  color: #fff !important;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(47, 107, 79, 0.22);
}

/* ===== Extra termék dobozok ===== */
.j2store-cart .custom-fields-container {
  display: grid;
  gap: 12px;
}

.j2store-cart .custom-field {
  border: 1px solid var(--md-cart-border) !important;
  border-radius: 14px !important;
  padding: 16px !important;
  background: var(--md-cart-card) !important;
  margin: 0 !important;
  box-shadow: var(--md-cart-shadow);
}

.j2store-cart .custom-field-with-image {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.j2store-cart .custom-field-image {
  flex: 0 0 88px;
}

.j2store-cart .custom-field-image img {
  width: 100%;
  height: auto;
  border-radius: 12px !important;
  border: 1px solid var(--md-cart-border) !important;
  background: #fff;
}

.j2store-cart .custom-field-content {
  flex: 1;
  min-width: 0;
}

.j2store-cart .md-cf-title {
  display: block;
  font-weight: 800 !important;
  font-size: 0.98rem;
  color: #3d4654;
  margin-bottom: 8px !important;
}

.j2store-cart .md-cf-checklabel {
  font-weight: 600;
  color: var(--md-cart-text);
  margin-left: 8px !important;
}

.j2store-cart .md-cf-desc {
  font-size: 0.88rem !important;
  color: var(--md-cart-muted) !important;
  margin-top: 8px !important;
  line-height: 1.45 !important;
}

.j2store-cart .custom-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--md-cart-success);
  vertical-align: middle;
}

/* ===== Pénztár gomb alul ===== */
.j2store-cart .checkout-bottom-container {
  margin-top: 28px !important;
  text-align: center;
  padding: 8px 0 36px !important;
}

.j2store-cart .checkout-bottom-container .btn,
.j2store-cart .checkout-bottom-container a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 440px);
  min-height: 52px;
  margin-top: 6px !important;
  padding: 14px 24px !important;
  border-radius: 14px !important;
  border: none !important;
  background: linear-gradient(135deg, #3d8b5f 0%, #2f6b4f 100%) !important;
  color: #fff !important;
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(47, 107, 79, 0.28) !important;
  text-decoration: none !important;
}

.j2store-cart .checkout-bottom-container .btn:hover,
.j2store-cart .checkout-bottom-container a.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(47, 107, 79, 0.34) !important;
  color: #fff !important;
}

/* ===== Üres kosár ===== */
.j2store-cart .cart-no-items {
  display: block;
  padding: 28px 20px;
  text-align: center;
  background: var(--md-cart-card);
  border: 1px dashed var(--md-cart-border);
  border-radius: var(--md-cart-radius);
  color: var(--md-cart-muted);
  font-weight: 600;
}

/* ===== MOBIL: termékkártya + qty/összeg sor ===== */
@media (max-width: 767.98px) {
  /*
   * helix-admin-custom-css.css (576px) kényszerít: td:nth-child(1) { width:25% !important }
   * → a terméknév oszlop ~25%-ra zsugorodik → betűnként törés. Itt felülírjuk.
   */
  .j2store .j2store-cart .j2store-cart-table th:nth-child(1),
  .j2store .j2store-cart .j2store-cart-table td:nth-child(1) {
    width: 100% !important;
    max-width: 100% !important;
  }

  .j2store .j2store-cart .j2store-cart-table th:nth-child(2),
  .j2store .j2store-cart .j2store-cart-table td:nth-child(2),
  .j2store .j2store-cart .j2store-cart-table th:nth-child(3),
  .j2store .j2store-cart .j2store-cart-table td:nth-child(3),
  .j2store .j2store-cart .j2store-cart-table th:nth-child(4),
  .j2store .j2store-cart .j2store-cart-table td:nth-child(4) {
    width: auto !important;
    max-width: none !important;
  }

  .j2store .j2store-cart .cart-product-name {
    width: auto !important;
    max-width: 100% !important;
    font-size: 0.92rem !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }

  body.view-carts #sp-main-body,
  body.view-carts .sp-main-body {
    overflow-x: hidden;
  }

  body.view-carts .md-cart-page-header {
    padding: 18px 16px 16px;
    border-radius: 16px;
  }

  body.view-carts .md-cart-page-header__lead {
    font-size: 0.88rem;
  }

  body.view-carts .j2store .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  body.view-carts .j2store [class*='col-'] {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .j2store .j2store-cart {
    max-width: 100%;
    padding-left: 4px;
    padding-right: 4px;
  }

  .j2store-cart #j2store-cart-form {
    padding: 8px;
    overflow: hidden;
  }

  .j2store-cart .j2store-cart-table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .j2store-cart .j2store-cart-table thead {
    display: none;
  }

  .j2store-cart .j2store-cart-table tbody {
    display: block;
    width: 100%;
  }

  .j2store-cart .j2store-cart-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 8px 10px;
    align-items: center;
    background: var(--md-cart-surface);
    border: 1px solid var(--md-cart-border);
    border-radius: 14px;
    padding: 10px;
    margin-bottom: 10px;
    border-bottom: none;
  }

  .j2store-cart .j2store-cart-table tbody td {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0;
    text-align: left !important;
    box-sizing: border-box;
  }

  .j2store-cart .j2store-cart-table tbody td::before {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--md-cart-muted);
  }

  /* 1. sor: termék infó – flex (a nested grid összeesett, betűnként törte a nevet) */
  .j2store-cart .j2store-cart-table tbody td:first-child {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    gap: 6px 10px;
    width: 100%;
    min-width: 0;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--md-cart-border);
  }

  .j2store-cart .j2store-cart-table tbody td:first-child::before {
    content: none;
    display: none;
  }

  .j2store-cart .cart-thumb-image {
    flex: 0 0 60px;
    width: 60px;
    grid-row: auto;
    margin: 0;
  }

  .j2store-cart .cart-thumb-image img {
    width: 60px;
    height: 60px;
    border-radius: 9px;
  }

  .j2store-cart .cart-product-name {
    flex: 1 1 calc(100% - 72px);
    min-width: 0;
    max-width: 100%;
    display: block;
    grid-column: auto;
    font-size: 0.9rem;
    line-height: 1.25;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
  }

  .j2store-cart .cart-item-options {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    grid-column: auto;
    margin-top: 0;
  }

  .j2store-cart .cart-product-unit-price,
  .j2store-cart .cart-product-sku {
    flex: 1 1 calc(100% - 72px);
    min-width: 0;
    grid-column: auto;
    margin-left: 70px;
  }

  .j2store-cart .md-cart-ai-preview-wrap {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    grid-column: auto;
  }

  .j2store-cart .md-cart-ai-card {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* 2. sor bal: mennyiség + törlés */
  .j2store-cart .j2store-cart-table tbody td:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
    width: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .j2store-cart .j2store-cart-table tbody td:nth-child(2)::before {
    content: 'Mennyiség';
    display: block;
    flex: 1 1 100%;
    margin-bottom: 2px;
  }

  /* Áfa oszlop mobilon elrejtve (mindig 0 Ft – felesleges hely) */
  .j2store-cart .j2store-cart-table tbody td:nth-child(3):not(.cart-line-subtotal) {
    display: none !important;
  }

  /* 2. sor jobb: összeg */
  .j2store-cart .j2store-cart-table tbody td.cart-line-subtotal {
    grid-column: 2;
    grid-row: 2;
    width: auto;
    align-self: end;
    text-align: right !important;
    padding-top: 0;
    border-top: none;
    font-size: 1.08rem;
    white-space: nowrap;
  }

  .j2store-cart .j2store-cart-table tbody td.cart-line-subtotal::before {
    content: 'Összesen';
    display: block;
    margin-bottom: 2px;
    text-align: right;
  }

  /* Ha nincs külön Áfa oszlop: qty + összeg marad */
  .j2store-cart .j2store-cart-table tbody td:nth-child(3).cart-line-subtotal {
    grid-column: 2;
    grid-row: 2;
  }

  .j2store-cart .j2store-cart-table .j2store-remove {
    margin-top: 0;
    min-height: 36px;
    padding: 0 10px;
  }

  .j2store-cart .j2store-cart-buttons {
    flex-direction: column;
  }

  .j2store-cart .j2store-cart-buttons .btn {
    width: 100%;
  }

  .j2store-cart .cart-footer {
    max-width: none;
    margin-left: 0;
  }

  .j2store-cart .cart-estimator-discount-block .coupon form {
    flex-direction: column;
    align-items: stretch;
  }

  .j2store-cart .cart-estimator-discount-block input[type="text"],
  .j2store-cart .cart-estimator-discount-block input[type="submit"],
  .j2store-cart .cart-estimator-discount-block .button {
    width: 100%;
    flex: 0 0 auto;
    min-height: 42px !important;
  }

  .j2store-cart .custom-field-with-image {
    flex-direction: row;
    align-items: flex-start;
  }

  .j2store-cart .custom-field-image {
    flex-basis: 72px;
  }

  .j2store-cart .cart-footer {
    display: block;
    width: 100%;
  }

  .j2store-cart .cart-footer tbody,
  .j2store-cart .cart-footer tr {
    display: block;
    width: 100%;
  }

  .j2store-cart .cart-footer tr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px !important;
    border-bottom: 1px solid var(--md-cart-border);
  }

  .j2store-cart .cart-footer tr:last-child {
    border-bottom: none;
  }

  .j2store-cart .cart-footer th,
  .j2store-cart .cart-footer td {
    display: block;
    padding: 0 !important;
    border: none !important;
  }

  .j2store-cart .cart-footer th {
    flex: 1 1 auto;
    text-align: left !important;
  }

  .j2store-cart .cart-footer td {
    flex: 0 0 auto;
    text-align: right !important;
  }

  .j2store-cart .checkout-bottom-container {
    padding-bottom: 28px !important;
  }

  .j2store-cart .checkout-bottom-container .btn,
  .j2store-cart .checkout-bottom-container a.btn {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 420px) {
  .j2store-cart .custom-field-with-image {
    flex-direction: column;
    align-items: stretch;
  }

  .j2store-cart .custom-field-image {
    flex-basis: auto;
    width: 120px;
    margin: 0 auto 8px;
  }
}
