/* ==========================================================================
   FELEX.UA — NON-EMPTY CART POP-UP MODAL TYPOGRAPHY & STYLES (POLISHED)
   Matching theme typography: 'Nunito', sans-serif / inherit
   ========================================================================== */

/* Overrides for Bootstrap / LeoFeature Modal Dialog Container */
#blockcart-modal-ecm .modal-dialog {
  max-width: 720px;
  width: 100%;
  margin: 30px auto;
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mobile: бокові відступи — окно не прижато до країв */
@media (max-width: 575px) {
  #blockcart-modal-ecm .modal-dialog {
    width: auto !important;
    max-width: none !important;
    margin: 20px 12px !important;
    min-height: calc(100vh - 40px);
  }

  #blockcart-modal-ecm .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px !important;
    overflow: hidden !important;
  }
}

/* Fallback: якщо Bootstrap перекриває margin на .modal-dialog,
   використовуємо padding на самому modal (wrapper) */
@media (max-width: 575px) {
  #blockcart-modal-ecm {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

#blockcart-modal-ecm .modal-content {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.cart-modal {
  font-family: inherit;
  width: 100%;
  max-width: 720px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  margin: 0 auto;
}

/* Header */
.cart-modal__header {
  position: relative;
  min-height: 56px;
  border-bottom: 1px solid #e8ecf1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #ffffff;
}

.cart-modal__header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-modal__title {
  font-family: inherit;
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  color: #1f1f1f;
}

.cart-modal__count-badge {
  font-family: inherit;
  font-size: 12px;
  color: #4e5f70;
  background: #f4f6f8;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.cart-modal__close {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
  opacity: 0.65;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cart-modal__close:hover {
  opacity: 1;
  transform: scale(1.08);
}

.cart-modal__close::before,
.cart-modal__close::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 3px;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: #111111;
}

.cart-modal__close::before { transform: rotate(45deg); }
.cart-modal__close::after { transform: rotate(-45deg); }

/* Modal Body & Items Scroll Area */
.cart-modal__body {
  padding: 0;
  max-height: 420px;
  overflow-y: auto;
  flex: 1;
}

.cart-modal__body::-webkit-scrollbar {
  width: 5px;
}
.cart-modal__body::-webkit-scrollbar-track {
  background: #f8fafc;
}
.cart-modal__body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.cart-modal__body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.cart-items-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* DESKTOP ITEM ROW */
.cart-item-desktop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e8ecf1;
  gap: 14px;
  transition: background-color 0.2s ease;
}

.cart-item-desktop:hover {
  background-color: #fbfcfd;
}

.cart-item-desktop:last-child {
  border-bottom: none;
}

.cart-item-desktop__left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.cart-item-desktop__right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* Thumbnail */
.cart-item__image,
.cart-item-mobile__image {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e8ecf1;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-item__image img,
.cart-item-mobile__image img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.cart-item__info {
  flex: 1;
  min-width: 0;
}

.cart-item__code,
.cart-item-mobile__code {
  font-family: inherit;
  font-size: 12px;
  color: #8892a0;
  margin-bottom: 2px;
  font-weight: 500;
}

/* Product Title — Refined size, weight and color (no blue link!) */
.cart-item__name,
.cart-item-mobile__name,
.cart-modal a.label {
  font-family: inherit !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  color: #4e5f70 !important;
  text-decoration: none !important;
  line-height: 1.35 !important;
  display: block !important;
  margin-bottom: 4px !important;
  transition: color 0.2s ease !important;
}

.cart-item__name:hover,
.cart-item-mobile__name:hover,
.cart-modal a.label:hover {
  color: #fe5c45 !important;
}

.cart-item__badge,
.cart-item-mobile__badge {
  font-family: inherit;
  display: inline-block;
  font-size: 11px;
  color: #d97706;
  background: #fffbe6;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

/* Touchspin Controls — Compact & Balanced */
/* Скасовуємо theme.css ~3364: background-color:white на .btn-touchspin */
.touchspin-group,
#blockcart-modal-ecm .bootstrap-touchspin,
#blockcart-modal-ecm .touchspin-group {
  display: inline-flex !important;
  align-items: center !important;
  border: 1px solid #e8ecf1 !important;
  border-radius: 6px !important;
  overflow: hidden !important;
  background: #f4f6f8 !important;
  height: 32px !important;
  vertical-align: middle !important;
}

/* Кнопки +/- : скасовуємо white background і розміри з theme.css ~3364-3371 */
#blockcart-modal-ecm .bootstrap-touchspin .btn-touchspin,
#blockcart-modal-ecm .touchspin-btn,
.touchspin-btn {
  font-family: inherit !important;
  width: 32px !important;
  min-width: 32px !important;
  height: 32px !important;
  border: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  color: #4e5f70 !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  line-height: 1 !important;
  transition: background-color 0.2s ease !important;
  touch-action: manipulation;
  /* Скасовуємо Bootstrap position/z-index для .input-group-btn > .btn */
  position: static !important;
  z-index: auto !important;
}

/* Псевдоелементи кнопок — прозорі */
#blockcart-modal-ecm .bootstrap-touchspin .btn-touchspin::before,
#blockcart-modal-ecm .bootstrap-touchspin .btn-touchspin::after,
#blockcart-modal-ecm .touchspin-btn::before,
#blockcart-modal-ecm .touchspin-btn::after {
  display: none !important;
  background: transparent !important;
}

#blockcart-modal-ecm .bootstrap-touchspin .btn-touchspin:hover:not(:disabled),
#blockcart-modal-ecm .touchspin-btn:hover:not(:disabled),
.touchspin-btn:hover:not(:disabled) {
  background: rgba(78, 95, 112, 0.12) !important;
  background-color: rgba(78, 95, 112, 0.12) !important;
}

#blockcart-modal-ecm .bootstrap-touchspin .btn-touchspin:disabled,
#blockcart-modal-ecm .touchspin-btn:disabled,
.touchspin-btn:disabled {
  opacity: 0.35 !important;
  cursor: not-allowed !important;
}

.touchspin-input,
#blockcart-modal-ecm .touchspin-input,
#blockcart-modal-ecm .bootstrap-touchspin .cart_quantity_input {
  font-family: inherit !important;
  width: 38px !important;
  height: 32px !important;
  border: 0 !important;
  border-left: 1px solid #e8ecf1 !important;
  border-right: 1px solid #e8ecf1 !important;
  background: #ffffff !important;
  text-align: center !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #1f1f1f !important;
  outline: none !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  flex-shrink: 0 !important;
}

/* Prices */
#blockcart-modal-ecm .cart-item__price,
#blockcart-modal-ecm .cart-item-mobile__price,
#blockcart-modal-ecm .product-price {
  text-align: right !important;
  min-width: 90px !important;
  flex-shrink: 0 !important;
}

/* Ціна товару */
#blockcart-modal-ecm .cart-item__price .current-price,
#blockcart-modal-ecm .cart-item-mobile__price .current-price,
#blockcart-modal-ecm .current-price.price {
  font-family: inherit !important;
  font-size: 17px !important;
  font-weight: 600 !important;
  color: #1f1f1f !important;
  line-height: 1.2 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Стара ціна (перекреслена) */
#blockcart-modal-ecm .cart-item__price .old-price,
#blockcart-modal-ecm .cart-item-mobile__price .old-price,
#blockcart-modal-ecm .old-price.regular-price {
  font-family: inherit !important;
  font-size: 12px !important;
  font-weight: 400 !important;
  color: #8892a0 !important;
  text-decoration: line-through !important;
  line-height: 1.2 !important;
  margin-top: 2px !important;
  padding: 0 !important;
}

/* Remove / Delete Button — Perfectly Centered Circle Hover (Overrides front.css) */
#blockcart-modal-ecm .cart-item__remove,
#blockcart-modal-ecm .cart-item-mobile__remove,
#blockcart-modal-ecm .remove-from-cart {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  color: #94a3b8 !important;
  border: 0 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: color 0.2s ease, background-color 0.2s ease !important;
  flex-shrink: 0 !important;
  touch-action: manipulation;
  float: none !important;
  position: relative !important;
  line-height: 1 !important;
}

#blockcart-modal-ecm .cart-item__remove:hover,
#blockcart-modal-ecm .cart-item-mobile__remove:hover,
#blockcart-modal-ecm .remove-from-cart:hover {
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

#blockcart-modal-ecm .cart-item__remove svg,
#blockcart-modal-ecm .cart-item-mobile__remove svg,
#blockcart-modal-ecm .remove-from-cart svg {
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor !important;
  display: block !important;
}

/* MOBILE CARD STRUCTURE (360px - 448px) */
.cart-item-mobile {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border-bottom: 1px solid #e8ecf1;
  background: #ffffff;
  gap: 10px;
}

.cart-item-mobile:last-child {
  border-bottom: none;
}

.cart-item-mobile__top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}

.cart-item-mobile__info {
  flex: 1;
  min-width: 0;
}

.cart-item-mobile__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px dashed #e8ecf1;
  gap: 8px;
}

.cart-item-mobile__qty {
  flex-shrink: 0;
}

/* Actions: price + remove — єдина група справа */
#blockcart-modal-ecm .cart-item-mobile__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Price block: виводить new price і old price одним стовпцем */
#blockcart-modal-ecm .cart-item-mobile__price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  min-width: 0;
  padding: 0;
}

/* Modal Footer & Buttons — Compact & Clean */
.cart-modal__footer {
  background: #fcfdfe;
  border-top: 1px solid #e8ecf1;
  padding: 16px 20px;
  flex-shrink: 0;
}

/* Рядок підсумку — label і сума разом справа, без великого розриву */
/* Скасовуємо float-based layout з theme.css (~рядок 22267) */
.cart-summary-line {
  display: flex !important;
  align-items: baseline !important;
  justify-content: flex-end !important;
  gap: 14px !important;
  width: 100% !important;
  margin-bottom: 14px !important;
  clear: none !important;
  float: none !important;
}

.cart-summary-line::after {
  display: none !important;
}

/* Напис «Разом» */
#blockcart-modal-ecm .cart-summary-label,
#blockcart-modal-ecm .total_modal {
  font-family: inherit !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  color: #1f1f1f !important;
  padding: 0 !important;
  margin: 0 !important;
  flex: 0 0 auto !important;
  text-align: right !important;
}

/* Підсумкова сума */
#blockcart-modal-ecm .cart-summary-amount,
#blockcart-modal-ecm .right.line {
  font-family: inherit !important;
  font-size: 20px !important;
  font-weight: 600 !important;
  color: #1f1f1f !important;
  line-height: 1.2 !important;
  padding: 0 !important;
  margin: 0 !important;
  flex: 0 0 auto !important;
  text-align: right !important;
  float: none !important;
}

@media (max-width: 479px) {
  #blockcart-modal-ecm .cart-item__price .current-price,
  #blockcart-modal-ecm .cart-item-mobile__price .current-price,
  #blockcart-modal-ecm .current-price.price {
    font-size: 16px !important;
  }

  #blockcart-modal-ecm .cart-item__price .old-price,
  #blockcart-modal-ecm .cart-item-mobile__price .old-price,
  #blockcart-modal-ecm .old-price.regular-price {
    font-size: 12px !important;
  }

  #blockcart-modal-ecm .cart-summary-amount,
  #blockcart-modal-ecm .right.line {
    font-size: 20px !important;
  }
}

.cart-actions-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-checkout {
  font-family: inherit;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, #fe5c45, #fd4547);
  color: #ffffff !important;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(254, 92, 69, 0.22);
  transition: transform 0.2s ease, opacity 0.2s ease;
  order: 1;
}

.btn-checkout:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-one-click {
  font-family: inherit;
  width: 100%;
  min-height: 44px;
  border: 1px solid #4e5f70;
  border-radius: 6px;
  background: transparent;
  color: #4e5f70 !important;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  order: 2;
}

.btn-one-click:hover {
  background: #4e5f70;
  color: #ffffff !important;
}

.btn-continue-shopping {
  font-family: inherit;
  display: block;
  text-align: center;
  margin-top: 12px;
  color: #5f6268;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease;
  order: 3;
}

.btn-continue-shopping:hover {
  color: #4e5f70;
}

/* Wide Screens (>= 480px) Order logic */
@media (min-width: 480px) {
  .cart-actions-group {
    flex-direction: row;
    gap: 12px;
  }
  .btn-one-click {
    order: 1;
    flex: 1.5;
    width: auto;
  }
  .btn-checkout {
    order: 2;
    flex: 2;
    width: auto;
  }
}

/* ==========================================================================
   DISCOUNT BADGE — бейдж знижки під назвою товару
   Показується тільки якщо $product.has_discount = true
   ========================================================================== */
#blockcart-modal-ecm .cart-item__discount-badge,
#blockcart-modal-ecm .cart-item-mobile__discount-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 5px;
  padding: 3px 8px;
  border-radius: 8px;
  background: #fff4df;
  color: #d97706;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ==========================================================================
   TASK 1 — Захист пустого кошика від overflow-y:auto
   felex-cart-with-product.css завантажується ПІСЛЯ felex-empty-cart-popup.css
   (обидва priority=150, але cart-with-product йде другим у ps_shoppingcart.tpl),
   тому .cart-modal__body { overflow-y:auto } може перекрити overflow:hidden з
   felex-empty-cart-popup.css. Підвищена специфічність виправляє це.
   ========================================================================== */
#blockcart-modal-ecm .cart-modal.empty-cart-modal .empty-cart-modal__body {
  overflow: hidden !important;
  max-height: none !important;
}

/* ==========================================================================
   TASK 2 — Підстрахування 320px: стискаємо bottom-row мобільної карточки
   На viewport < 360px зменшуємо min-width ціни і gap, щоб уникнути
   горизонтального скролу. Структура (old price під new price, remove окремо)
   не змінюється.
   ========================================================================== */
@media (max-width: 359px) {
  #blockcart-modal-ecm .cart-item-mobile__price,
  #blockcart-modal-ecm .cart-item__price {
    min-width: 70px !important;
  }

  #blockcart-modal-ecm .cart-item-mobile__actions {
    gap: 6px !important;
  }

  .cart-item-mobile__bottom {
    gap: 6px !important;
  }
}

/* ==========================================================================
   INSUFFICIENT STOCK WARNING (.qty_error) — Варіант №1 (компактне попередження)
   Під блоком кількості товару, окремим рядком, без фону та рамки,
   не зміщує ціну та кнопку видалення товару.
   ========================================================================== */
#blockcart-modal-ecm .qty,
#blockcart-modal-ecm .cart-item-mobile__qty {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 104px;
  flex-shrink: 0;
}

#blockcart-modal-ecm .qty .qty_error:empty {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

#blockcart-modal-ecm .qty .qty_error:not(:empty) {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  margin-top: 6px !important;
  padding: 0 !important;
  width: max-content !important;
  font-family: inherit !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 1.25 !important;
  color: #c94d3e !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  white-space: nowrap !important;
  opacity: 1;
  transition: opacity 0.22s ease;
}

#blockcart-modal-ecm .qty .qty_error.is-fading-out {
  opacity: 0 !important;
}

#blockcart-modal-ecm .qty .qty_error:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='8' cy='8' r='6.5' stroke='%23c94d3e' stroke-width='1.4'/%3E%3Cpath d='M8 4.8v3.8' stroke='%23c94d3e' stroke-width='1.4' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11.2' r='0.8' fill='%23c94d3e'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

/* Desktop: фіксуємо попередження під .touchspin-group без зміщення ціни та кнопки видалення */
#blockcart-modal-ecm .cart-item-desktop__right .qty .qty_error:not(:empty) {
  position: absolute !important;
  top: calc(100% + 6px) !important;
  left: 0 !important;
  margin-top: 0 !important;
}

/* Mobile: вирівнюємо верхній рядок .cart-item-mobile__bottom по верху,
   щоб при появі .qty_error ціна і хрестик залишалися на тій самій осі з [- 1 +] */
#blockcart-modal-ecm .cart-item-mobile__bottom {
  align-items: flex-start;
}

#blockcart-modal-ecm .cart-item-mobile__qty {
  padding-top: 2px;
}

#blockcart-modal-ecm .cart-item-mobile__actions {
  min-height: 36px;
}
