/* Стили для страницы корзины */
.cart-page-container {
    padding: 50px 0;
    margin-top: 100px;
}
div.modal-content {
    color: #333;
}
.cart-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 30px;
    text-align: center;
    color: #333;
}

.cart-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Добавлено для выравнивания по верху */
    gap: 30px;
}

.cart-items-container {
    flex: 1;
    min-width: 300px;
    background: #fff;
    color: #333;
    border-radius: 8px;
    padding: 20px;
    border: 2px solid #ccc; /* Увеличиваем толщину обводки и оставляем серый цвет */
    border-radius: 5px; /* Добавляем скругление в 1 пиксель */
    /* margin-right удалено, так как gap уже обеспечивает отступ */
}

.cart-summary {
    width: 300px;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    position: sticky;
    border: 2px solid #ccc; /* Увеличиваем толщину обводки и оставляем серый цвет */
    border-radius: 5px; /* Добавляем скругление в 1 пиксель */
    top: 120px; /* Учитываем высоту заголовка */
}

h3 {
    color: #333;
}

.summary-row {
    color: #333;
}

.cart-items-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    padding-bottom: 15px;
    color: #333;
    border-bottom: 1px solid #eee;
    font-weight: bold;
    margin-bottom: 15px;
    gap: 15px; /* Добавляем промежутки между колонками */
}

.header-product {
    grid-column: 1;
}

.header-price {
    grid-column: 2;
    text-align: center;
}

.header-quantity {
    grid-column: 3;
    text-align: center;
}

.header-total {
    grid-column: 4;
    text-align: center;
}

.cart-item {
    display: grid;
    grid-template-columns: 3.2fr 1fr 1fr 1fr;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    gap: 15px; /* Добавляем промежутки между колонками */
}

.item-product {
    display: flex;
    align-items: center;
    grid-column: 1;
}


.cart-product {
    width: 80px;
    height: auto;
    border-radius: 4px;
}
img.cart-image {
    width: 80px;
    height: auto;
    border-radius: 4px;
}
.product-name {
    font-weight: 500;
}

.item-price {
    grid-column: 2;
    text-align: center;
}

.item-quantity {
    grid-column: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.item-total {
    grid-column: 4;
    text-align: center;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.item-quantity input {
    width: 50px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
}

.quantity-btn {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.quantity-btn:hover {
    background: #e9ecef;
}

.remove-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 0.9rem;
}

.remove-item:hover {
    color: #c82333;
}

.product-price-mobile {
    display: none;
}

.empty-cart-message {
    text-align: center;
    padding: 40px 0;
}

.empty-cart-message p {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: #666;
}


.cart-summary h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 25px;
}

.summary-actions .btn {
    width: 100%;
}

.continue-shopping {
    margin-top: 20px;
    text-align: center;
}

.continue-shopping a {
    color: #007bff;
    text-decoration: none;
}

.continue-shopping a:hover {
    text-decoration: underline;
}

/* ====== БАЗОВЫЕ ЗАЩИТЫ ОТ ПЕРЕПОЛНЕНИЙ ====== */
:root {
  /* Если у тебя уже есть переменная под высоту шапки — используй её. Иначе можно менять здесь. */
  --header-height: 80px;
}

.cart-page-container {
  /* чтобы контент не уехал под фикс-хедер на узких экранах */
  padding-top: max(50px, var(--header-height));
}

.cart-items-container,
.cart-summary {
  overflow: hidden; /* сглаживает возможные всплески переполнений */
}

.product-name {
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Картинки не должны “распирать” карточку */
img.cart-image, .cart-product {
  display: block;
  max-width: 80px;
  width: 100%;
  height: auto;
}

/* ====== ПЛАНШЕТЫ (до 992px) — колонка вместо двух ====== */
@media (max-width: 992px) {
  .cart-content {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
  }

  .cart-items-container {
    margin-bottom: 0;
  }

  .cart-summary {
    width: 100%;
    position: static; /* отключаем sticky */
    top: auto;
  }
}

/* ====== МОБИЛКИ (до 768px) — компактная карточная раскладка ====== */
@media (max-width: 768px) {
  .cart-title {
    font-size: 1.8rem;
    margin-bottom: 20px;
  }

  /* Прячем шапку колонок */
  .cart-items-header {
    display: none;
  }

  /* Перестраиваем каждую строку товара в карточку */
  .cart-item {
    display: grid;
    grid-template-columns: 80px 1fr; /* слева фото, справа контент */
    grid-template-rows: auto auto auto; /* имя/цена, количество, сумма/удалить */
    gap: 10px 12px;
    padding: 12px 0;
  }

  .item-product {
    grid-column: 1 / 2;
    grid-row: 1 / 4;
    align-items: flex-start;
    gap: 10px;
  }

  .item-product .product-name {
    font-weight: 600;
    line-height: 1.25;
  }

  /* Цена переносится под названием (мобильная версия) */
  .product-price-mobile {
    display: block;
    font-size: 0.95rem;
    color: #555;
    margin-top: 6px;
  }

  /* Прячем настольные версии колонок цены/итога */
  .item-price,
  .item-total {
    display: none;
  }

  /* Количество — шире и удобнее для тача */
  .item-quantity {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    align-items: flex-start;
    gap: 8px;
  }

  .quantity-controls {
    gap: 8px;
  }

  .quantity-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
  }

  .item-quantity input {
    width: 64px;
    padding: 8px;
    font-size: 16px; /* без зума на iOS */
  }

  /* Итог по позиции и кнопка удаления — в одну линию, справа выравниваем сумму */
  .cart-item .row-bottom {
    grid-column: 2 / 3;
    grid-row: 3 / 4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
  }

  .row-bottom .mobile-item-total {
    margin-left: auto;
    font-weight: 600;
    font-size: 1rem;
  }

  .remove-item {
    order: -1; /* сначала показать удалить, затем сумму справа */
    font-size: 0.95rem;
    gap: 6px;
    padding: 6px 0;
  }

  /* Блок итогов корзины */
  .cart-summary h3 {
    font-size: 1.3rem;
  }

  .summary-row {
    font-size: 1rem;
  }

  .summary-actions .btn {
    padding: 12px 14px;
    font-size: 1rem;
    border-radius: 8px;
  }
}

/* ====== СУПЕР-УЗКИЕ (до 480px) — ещё компактнее ====== */
@media (max-width: 480px) {
  .cart-page-container {
    padding: 36px 0;
    margin-top: calc(var(--header-height) - 20px);
  }

  .cart-item {
    grid-template-columns: 70px 1fr;
    gap: 8px 10px;
  }

  img.cart-image, .cart-product {
    max-width: 70px;
    border-radius: 6px;
  }

  .quantity-btn {
    width: 34px;
    height: 34px;
  }

  .item-quantity input {
    width: 58px;
  }
}

/* ====== ДОП. ХЕЛПЕРЫ ДЛЯ МОБИЛЬНОЙ ВЕРСИИ ====== */
/* Добавь в HTML внутри .cart-item один вспомогательный контейнер:
   <div class="row-bottom">
     <button class="remove-item">…</button>
     <div class="mobile-item-total">…</div>
   </div>
   На десктопе он не помешает, а на мобиле красиво выстроит низ карточки. */
@media (min-width: 769px) {
  .row-bottom,
  .mobile-item-total,
  .product-price-mobile {
    display: none !important; /* на десктопе они не нужны */
  }
}

