/* Maxmart redesign — reusable components (buttons, chips, badges, forms, cards, product card,
   tabs, steppers, sheets, toast, pager). Page-specific layout lives in pages/*.css. */

/* ---------- Buttons ---------- */
.mm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--mm-btn-h);
  padding: 0 20px;
  border: 1.5px solid transparent;
  border-radius: var(--mm-r-btn);
  font-size: var(--mm-fs-md);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.mm-btn:hover { text-decoration: none; }
.mm-btn[disabled], .mm-btn.is-disabled { opacity: .55; cursor: not-allowed; }
.mm-btn--lg { height: var(--mm-btn-h-lg); padding: 0 28px; border-radius: var(--mm-r-lg); font-size: 16px; }
.mm-btn--sm { height: 36px; padding: 0 14px; font-size: var(--mm-fs-sm); }
.mm-btn--block { display: flex; width: 100%; }
.mm-btn--icon { width: var(--mm-btn-h); padding: 0; }

.mm-btn--accent { background: var(--mm-accent); color: var(--mm-ink); }
.mm-btn--accent:hover { background: var(--mm-accent-hover); color: var(--mm-ink); }
.mm-btn--outline { background: var(--mm-surface); border-color: var(--mm-brand); color: var(--mm-brand); }
.mm-btn--outline:hover { background: var(--mm-brand-tint); color: var(--mm-brand-dark); }
.mm-btn--brand { background: var(--mm-brand); color: #fff; }
.mm-btn--brand:hover { background: var(--mm-brand-dark); color: #fff; }
.mm-btn--dark { background: var(--mm-ink); color: #fff; }
.mm-btn--dark:hover { background: var(--mm-ink-2); color: #fff; }
.mm-btn--ghost { background: transparent; color: var(--mm-brand); }
.mm-btn--ghost:hover { background: var(--mm-brand-soft); }
.mm-btn--on-dark { background: transparent; border-color: rgba(255, 255, 255, .5); color: #fff; }
.mm-btn--on-dark:hover { border-color: #fff; color: #fff; }

.mm-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--mm-surface);
  color: var(--mm-muted);
  cursor: pointer;
}
.mm-icon-btn:hover { color: var(--mm-brand); }
.mm-icon-btn.added, .mm-icon-btn[aria-pressed="true"] { color: var(--mm-sale); }
.mm-icon-btn.added .mm-icon, .mm-icon-btn[aria-pressed="true"] .mm-icon { fill: currentColor; }

.mm-link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--mm-brand);
  font-size: var(--mm-fs-sm);
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Badges & chips ---------- */
.mm-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--mm-r-sm);
  font-size: var(--mm-fs-xs);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .02em;
}
.mm-badge--discount { background: var(--mm-discount); color: #fff; font-size: var(--mm-fs-sm); }
.mm-badge--new { background: var(--mm-brand); color: #fff; }
.mm-badge--accent { background: var(--mm-accent); color: var(--mm-ink); text-transform: uppercase; }
.mm-badge--sale { background: var(--mm-sale); color: #fff; }
.mm-badge--soft { background: var(--mm-brand-soft); color: var(--mm-brand-dark); }
.mm-badge--success { background: var(--mm-success-soft); color: var(--mm-success-ink); }
.mm-badge--neutral { background: var(--mm-bg); color: var(--mm-text-2); }

.mm-count {
  display: inline-block;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 9px;
  background: var(--mm-accent);
  color: var(--mm-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.mm-count:empty { display: none; }

.mm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--mm-border);
  border-radius: var(--mm-r-pill);
  background: var(--mm-surface);
  color: var(--mm-text);
  font-size: var(--mm-fs-md);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}
.mm-chip:hover { border-color: var(--mm-brand); color: var(--mm-brand); text-decoration: none; }
.mm-chip.is-active, .mm-chip[aria-pressed="true"], .mm-chip[aria-current="page"] {
  border-color: var(--mm-brand);
  background: var(--mm-brand-soft);
  color: var(--mm-brand-dark);
  font-weight: 600;
}
.mm-chip__count { color: var(--mm-muted-2); font-size: var(--mm-fs-sm); }
.mm-chip__remove {
  margin: 0 -6px 0 2px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.mm-stock { font-size: var(--mm-fs-xs); font-weight: 600; color: var(--mm-success); }
.mm-stock--out { color: var(--mm-muted-2); }

/* ---------- Forms ---------- */
.mm-field { display: flex; flex-direction: column; gap: 6px; }
.mm-label { font-size: var(--mm-fs-sm); font-weight: 600; color: var(--mm-text-2); }
.mm-label__hint { font-weight: 400; color: var(--mm-muted-2); }
.mm-input, .mm-select, .mm-textarea {
  width: 100%;
  height: var(--mm-control-h);
  padding: 0 14px;
  box-sizing: border-box;
  border: 1px solid var(--mm-border-strong);
  border-radius: var(--mm-r-btn);
  background: var(--mm-surface);
  color: var(--mm-text);
  font-size: var(--mm-fs-base);
}
.mm-textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
.mm-input:focus, .mm-select:focus, .mm-textarea:focus { border-color: var(--mm-brand); outline: none; box-shadow: var(--mm-focus); }
.mm-input-group { display: flex; gap: 8px; }
.mm-input-group > .mm-input { flex: 1; min-width: 0; }

.mm-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--mm-fs-md);
  cursor: pointer;
}
.mm-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--mm-brand); flex: none; }
.mm-check__count { margin-left: auto; color: var(--mm-muted-2); font-size: var(--mm-fs-sm); }

/* Selectable option card (shipping / payment) */
.mm-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--mm-border);
  border-radius: var(--mm-r-lg);
  background: var(--mm-surface);
  cursor: pointer;
}
.mm-option input[type="radio"] { width: 18px; height: 18px; margin: 0; accent-color: var(--mm-brand); flex: none; }
.mm-option__body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.mm-option__title { font-weight: 700; }
.mm-option__sub { font-size: var(--mm-fs-sm); color: var(--mm-muted); }
.mm-option__price { font-weight: 700; white-space: nowrap; }
.mm-option__price--free { color: var(--mm-success); }
.mm-option.is-selected, .mm-option:has(> input[type="radio"]:checked) { border: 2px solid var(--mm-brand); background: var(--mm-brand-tint); padding: 15px 17px; }
.mm-option > .mm-icon { flex: none; color: var(--mm-brand); }

/* Alerts */
.mm-alert { padding: 14px 18px; border-radius: var(--mm-r-tile); font-size: var(--mm-fs-md); background: var(--mm-brand-tint); color: var(--mm-text); }
.mm-alert:empty, .mm-alert.validation-summary-valid { display: none; }
.mm-alert ul { margin: 0; padding-left: 18px; }
.mm-alert--error { background: #FDECEE; color: #8E1B24; }
.mm-alert--warning { background: var(--mm-warning-soft); }
.mm-alert--info { background: var(--mm-brand-soft); color: var(--mm-brand-dark); }

/* ---------- Cards ---------- */
.mm-card {
  background: var(--mm-surface);
  border: 1px solid var(--mm-border);
  border-radius: var(--mm-r-card);
}
.mm-card--pad { padding: 24px; }
.mm-card--pad-lg { padding: 40px; }
@media (max-width: 767.98px) { .mm-card--pad-lg { padding: 24px; } }

.mm-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: var(--mm-surface);
  border: 1px solid var(--mm-border);
  border-radius: var(--mm-r-tile);
}
.mm-tile__icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: var(--mm-r-lg);
  background: var(--mm-brand-soft);
  color: var(--mm-brand);
}
.mm-tile__title { display: block; font-size: var(--mm-fs-base); font-weight: 700; }
.mm-tile__sub { font-size: var(--mm-fs-sm); color: var(--mm-muted); }

/* ---------- Product card ---------- */
.mm-grid-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
@media (max-width: 767.98px) {
  .mm-grid-products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

.mm-product {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--mm-surface);
  border: 1px solid var(--mm-border);
  border-radius: var(--mm-r-card);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.mm-product:hover { box-shadow: var(--mm-shadow-md); border-color: transparent; }
.mm-product__media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  padding: 16px;
  box-sizing: border-box;
  background: var(--mm-surface-2);
}
.mm-product__img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.mm-product__badges { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.mm-product__actions { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 6px; }
.mm-product__actions form { margin: 0; }
.mm-product__body { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.mm-product__name {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
  color: var(--mm-text);
  font-size: var(--mm-fs-md);
  line-height: 1.4;
}
.mm-product__name:hover { color: var(--mm-brand); }
.mm-product__specs { margin: 0; padding: 0; list-style: none; font-size: var(--mm-fs-sm); color: var(--mm-muted); }
.mm-product__specs li::before { content: "· "; }
.mm-product__prices { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.mm-product__old { font-size: var(--mm-fs-sm); color: var(--mm-muted-2); text-decoration: line-through; }
.mm-product__price { font-family: var(--mm-font-display); font-size: var(--mm-fs-h3); font-weight: 800; color: var(--mm-ink); line-height: 1.1; }
.mm-product--sale .mm-product__price { color: var(--mm-sale); }
.mm-product__price--muted { font-family: var(--mm-font); font-size: var(--mm-fs-md); font-weight: 600; color: var(--mm-muted); }
.mm-product__foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.mm-product__compare { font-size: var(--mm-fs-sm); color: var(--mm-muted); }

/* listing variant: price row with an icon cart button */
.mm-product--listing .mm-product__cart-icon { width: 44px; height: 44px; padding: 0; border-radius: var(--mm-r-btn); }

/* list view (category grid/list toggle) */
.mm-grid-products.is-list { grid-template-columns: 1fr; }
.mm-grid-products.is-list .mm-product { flex-direction: row; }
.mm-grid-products.is-list .mm-product__media { width: 220px; height: auto; min-height: 180px; flex: none; }

@media (max-width: 767.98px) {
  .mm-product__media { height: 150px; padding: 10px; }
  .mm-product__body { padding: 12px; gap: 6px; }
  .mm-product__name { font-size: var(--mm-fs-sm); }
  .mm-product__price { font-size: 18px; }
  .mm-product .mm-btn { height: 40px; font-size: var(--mm-fs-sm); }
  .mm-product__actions .mm-icon-btn { width: 34px; height: 34px; }
  .mm-grid-products.is-list .mm-product__media { width: 120px; min-height: 120px; }
}

/* Horizontal scroller (mobile product rails) */
.mm-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(160px, 46%);
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--mm-gutter));
  padding: 0 var(--mm-gutter) 4px;
}
.mm-rail::-webkit-scrollbar { display: none; }
.mm-rail > * { scroll-snap-align: start; }

/* ---------- Quantity stepper ---------- */
.mm-qty {
  display: inline-flex;
  align-items: center;
  height: 40px;
  border: 1px solid var(--mm-border-strong);
  border-radius: var(--mm-r-btn);
  overflow: hidden;
}
.mm-qty button { width: 40px; height: 100%; border: 0; background: var(--mm-surface); font-size: 18px; color: var(--mm-text); cursor: pointer; }
.mm-qty button:hover { background: var(--mm-bg); }
.mm-qty input, .mm-qty span { width: 44px; text-align: center; border: 0; font-weight: 700; background: transparent; }

/* ---------- Tabs ---------- */
.mm-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--mm-border); overflow-x: auto; scrollbar-width: none; }
.mm-tab {
  padding: 14px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--mm-muted);
  font-size: var(--mm-fs-base);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.mm-tab:hover { color: var(--mm-brand); }
.mm-tab.active, .mm-tab[aria-selected="true"] { color: var(--mm-brand); border-bottom-color: var(--mm-brand); }

/* ---------- Checkout stepper (_CheckoutStepper.cshtml, boards 07/08) ---------- */
.mm-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0; padding: 0; list-style: none; font-size: var(--mm-fs-md); font-weight: 600; color: var(--mm-muted-2); }
.mm-steps__item { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.mm-steps__item a { display: flex; align-items: center; gap: 8px; color: inherit; }
.mm-steps__item a:hover { color: var(--mm-brand-dark); }
.mm-steps__dot {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; box-sizing: border-box;
  border: 2px solid var(--mm-border-strong);
  border-radius: 50%;
  font-size: var(--mm-fs-sm);
}
.mm-steps__line { width: 40px; height: 2px; background: var(--mm-border-strong); }
.mm-steps__line.is-done { background: var(--mm-brand); }
.mm-steps__item[aria-current="step"], .mm-steps__item.is-done { color: var(--mm-brand); }
.mm-steps__item[aria-current="step"] .mm-steps__dot,
.mm-steps__item.is-done .mm-steps__dot { border: 0; background: var(--mm-brand); color: #fff; }

/* Order status timeline */
.mm-timeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; padding: 0; list-style: none; }
.mm-timeline li { position: relative; display: flex; flex-direction: column; gap: 2px; padding-top: 18px; font-size: var(--mm-fs-sm); color: var(--mm-muted); }
.mm-timeline li::before { content: ""; position: absolute; top: 4px; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--mm-border); }
.mm-timeline li strong { color: var(--mm-text); font-size: var(--mm-fs-md); }
.mm-timeline li.is-done::before, .mm-timeline li[aria-current="step"]::before { background: var(--mm-brand); }
.mm-timeline li[aria-current="step"] strong { color: var(--mm-brand); }
@media (max-width: 767.98px) {
  .mm-timeline { grid-template-columns: 1fr; gap: 0; }
  .mm-timeline li { padding: 0 0 14px 22px; }
  .mm-timeline li::before { top: 4px; bottom: 0; left: 5px; right: auto; width: 3px; height: auto; }
}

/* ---------- Bottom sheet / drawer ---------- */
.mm-backdrop { position: fixed; inset: 0; z-index: 1040; background: rgba(18, 23, 29, .45); }
.mm-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1050;
  max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--mm-surface);
  border-radius: var(--mm-r-xl) var(--mm-r-xl) 0 0;
  box-shadow: var(--mm-shadow-lg);
}
.mm-sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 16px var(--mm-gutter); border-bottom: 1px solid var(--mm-border); }
.mm-sheet__body { flex: 1; overflow-y: auto; padding: 16px var(--mm-gutter); }
.mm-sheet__foot { padding: 12px var(--mm-gutter) calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--mm-border); }
.mm-drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 1050;
  width: min(420px, 92vw);
  display: flex; flex-direction: column;
  background: var(--mm-surface);
  box-shadow: var(--mm-shadow-lg);
}
[hidden].mm-backdrop, [hidden].mm-sheet, [hidden].mm-drawer { display: none; }
body.mm-lock { overflow: hidden; }

/* ---------- Toast (window.mmToast in mm-layout.js) ---------- */
.mm-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 1060;
  transform: translate(-50%, 12px);
  display: flex; align-items: center; gap: 12px;
  width: max-content; max-width: calc(100vw - 24px); box-sizing: border-box;
  padding: 12px 14px;
  border-radius: var(--mm-r-lg);
  background: var(--mm-ink);
  color: #fff;
  font-size: var(--mm-fs-md);
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(18, 23, 29, .3);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .2s, transform .2s, visibility .2s;
}
.mm-toast.is-visible { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0); }
.mm-toast__icon {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; background: var(--mm-success); color: #fff;
}
.mm-toast__icon .mm-icon { stroke-width: 3; }
.mm-toast__text { flex: 1; }
.mm-toast a { color: var(--mm-accent); font-weight: 700; padding: 8px 0; white-space: nowrap; }
.mm-toast a:hover { color: var(--mm-accent-hover); }
@media (max-width: 767.98px) {
  .mm-toast { left: 12px; right: 12px; width: auto; max-width: none; transform: translateY(12px);
              bottom: calc(var(--mm-tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px); }
  .mm-toast.is-visible { transform: none; }
}

/* ---------- Pager (cs-pager output is a Bootstrap .pagination) ---------- */
.mm-pager .pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; }
.mm-pager .page-item .page-link {
  min-width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--mm-border);
  border-radius: var(--mm-r-btn) !important;
  background: var(--mm-surface);
  color: var(--mm-text);
  font-weight: 600;
}
.mm-pager .page-item.active .page-link { background: var(--mm-brand); border-color: var(--mm-brand); color: #fff; }
.mm-pager .page-item.disabled .page-link { color: var(--mm-placeholder); }

/* ---------- Definition list (specs) ---------- */
.mm-specs { margin: 0; display: grid; grid-template-columns: 1fr; }
.mm-specs > div { display: grid; grid-template-columns: minmax(140px, 40%) 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--mm-border); }
.mm-specs dt { font-weight: 400; color: var(--mm-muted); }
.mm-specs dd { margin: 0; font-weight: 600; }

/* ---------- Bootstrap modal skin ---------- */
.modal-content { border: 0; border-radius: var(--mm-r-xl); box-shadow: var(--mm-shadow-lg); }
.modal-header { border-bottom-color: var(--mm-border); padding: 18px 24px; }
.modal-title { font-family: var(--mm-font-display); font-weight: 800; }
.modal-body { padding: 24px; }
.modal-footer { border-top-color: var(--mm-border); padding: 16px 24px; }
