/**
 * @file: cart.css
 * @description: Стили корзины (список товаров, итоги, счётчик)
 * Подключать после base.css
 */
/* Cart page — по макету Pragma */
.flux-cart-title {
  margin: 24px 0 20px;
  font-size: var(--flux-h2);
  font-weight: 800;
  line-height: 1.2;
}
/* Пустая корзина */
.flux-cart--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 32px;
  padding: 48px 24px;
  text-align: center;
}
.flux-cart-empty-msg {
  margin: 0;
  font-size: 16px;
  color: var(--flux-muted);
}
.flux-cart--empty .flux-btn {
  min-width: 200px;
}

/* Скрытый блок «корзина пуста» (показывается через JS после удаления последнего товара) */
.flux-cart__empty-state--hidden {
  display: none !important;
}
.flux-cart--empty .flux-cart__list,
.flux-cart--empty .flux-cart__sidebar {
  display: none !important;
}
.flux-cart--empty .flux-cart__empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.flux-cart {
  display: grid;
  grid-template-columns: 1fr 440px;
  gap: 24px;
  align-items: start;
  margin-top: 24px;
}
.flux-cart__sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.flux-cart-checkout-btn-wrapper {
  flex-shrink: 0;
}
.flux-cart-checkout-btn {
  width: 440px;
  max-width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  box-sizing: border-box;
  flex-shrink: 0;
}
.flux-cart__list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.flux-cart-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  align-items: start;
  padding: 24px 0;
  border-bottom: 1px solid var(--flux-border);
}
.flux-cart-item:first-child {
  padding-top: 0;
}
.flux-cart-item__image {
  width: 96px;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.flux-cart-item__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.flux-cart-item__no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 128px;
  background: var(--flux-bg-secondary, #f5f5f5);
  color: var(--flux-muted, #888);
  font-size: 12px;
}
.flux-cart-item__body {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}
/* ПК: первая строка — top (бейджи+цена) и controls (счётчик+действия); затем название и мета */
.flux-cart-item__top {
  order: 1;
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 0;
}
.flux-cart-item__badges {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* Мобильная версия: наклейка и цена справа от фото — скрыта на ПК */
.flux-cart-item__top-mobile {
  display: none;
}
.flux-cart-item__top-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}
.flux-cart-item__price-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.flux-cart-item__controls {
  order: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.flux-cart-item__title {
  order: 3;
  width: 100%;
}
.flux-cart-item__meta {
  order: 4;
  width: 100%;
}
.flux-cart-item__qty {
  flex-shrink: 0;
}
.flux-cart-item__price {
  font-weight: 800;
  font-size: 16px;
  color: var(--flux-text);
}
.flux-cart-item__price-old {
  font-size: 14px;
  color: var(--flux-muted);
  text-decoration: line-through;
}
.flux-cart-item__discount {
  font-size: 14px;
  font-weight: 700;
  color: #c62828;
}
.flux-cart-item__title {
  font-weight: 600;
  font-size: 15px;
  color: var(--flux-text);
  text-decoration: none;
  display: block;
  margin-bottom: 4px;
  line-height: 1.3;
}
.flux-cart-item__title:hover {
  color: var(--flux-accent);
}
.flux-cart-item__meta {
  font-size: 14px;
  color: var(--flux-muted);
  margin-bottom: 0;
}
.flux-cart-item__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
/* Форма «Удалить» не растягивается — кнопки удалить и избранное в одну линию */
.flux-cart-item__actions .flux-cart-item__action-form {
  display: inline-flex;
}
.flux-cart-item__action {
  padding: 6px;
  border: none;
  background: none;
  color: var(--flux-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.flux-cart-item__action:hover {
  color: var(--flux-text);
  background: #f5f5f5;
}
.flux-cart-item__qty {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--flux-border);
  border-radius: 10px;
  overflow: hidden;
}
/* Форма счётчика — как один блок − N + */
.flux-cart-item__qty.ms3_form {
  flex-shrink: 0;
  padding: 0;
  background: none;
}
.flux-cart-item__qty-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: #f5f5f5;
  font-size: 18px;
  font-weight: 600;
  color: var(--flux-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.flux-cart-item__qty-btn:hover {
  background: #eee;
}
.flux-cart-item__qty-value {
  min-width: 32px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}

/* Блок итогов: текст о доставке, таблица (кнопка вынесена в .flux-cart__sidebar) */
.flux-cart__summary {
  padding: 24px;
  background: #f5f5f5;
  border-radius: 16px;
  position: sticky;
  top: calc(var(--header-only-height, 80px) + 24px);
}
.flux-cart-summary__delivery {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--flux-muted);
  line-height: 1.4;
}
.flux-cart-summary__rows {
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.flux-cart-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 14px;
  color: var(--flux-text);
}
.flux-cart-summary__row dt {
  margin: 0;
  font-weight: 400;
  color: var(--flux-muted);
}
.flux-cart-summary__row dd {
  margin: 0;
  font-weight: 700;
}
.flux-cart-summary__row--discount dd {
  color: #c62828;
}
.flux-cart-summary__row--total {
  padding-top: 12px;
  margin-top: 4px;
  border-top: 1px solid var(--flux-border);
  font-size: 18px;
}
.flux-cart-summary__row--total dd {
  font-weight: 800;
}

/* Мобильная раскладка: одна колонка, сайдбар под списком, без наложения */
@media (max-width: 1023px) {
  .flux-cart {
    grid-template-columns: 1fr;
    grid-auto-flow: row;
  }
  .flux-cart__sidebar {
    min-width: 0;
    width: 100%;
  }
  .flux-cart-checkout-btn {
    width: 100%;
    max-width: 100%;
  }
  .flux-cart__summary {
    position: static;
  }
}

/* Мобильная карточка товара: фото | наклейка+цена (справа от фото), затем название, затем удаление/избранное/счётчик */
@media (max-width: 767px) {
  /* Grid: фото слева на 2 строки, справа top-mobile (строка 1) и body (строка 2) */
  .flux-cart-item {
    grid-template-columns: 80px 1fr;
    grid-template-rows: auto auto;
    gap: 12px;
  }
  .flux-cart-item__image {
    grid-row: 1 / 3;
    grid-column: 1;
  }
  /* Мобильная версия: наклейка и цена справа от фото */
  .flux-cart-item__top-mobile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    grid-row: 1;
    grid-column: 2;
    padding-left: 8px;
  }
  .flux-cart-item__top-mobile .flux-cart-item__badges {
    margin-bottom: 0;
  }
  /* Блок цены в одну линию: текущая цена, старая цена, процент скидки */
  .flux-cart-item__top-mobile .flux-cart-item__price-block {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
  }
  /* ПК версия: скрыть на мобильном */
  .flux-cart-item__top {
    display: none;
  }
  /* Body занимает вторую строку справа */
  .flux-cart-item__body {
    grid-row: 2;
    grid-column: 2;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 8px 0;
    padding-left: 8px;
  }
  .flux-cart-item__title {
    grid-row: 1;
    margin-bottom: 0;
  }
  .flux-cart-item__meta {
    grid-row: 2;
    margin-bottom: 0;
  }
  .flux-cart-item__controls {
    grid-row: 3;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }
}

