.btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.4rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-register {
    padding: 0.5rem 1.2rem;
}
.btn:hover {
    background: var(--primary-dark);
}
.btn--outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn--outline:hover {
    background: rgba(67, 97, 238, 0.05);
}
.btn--ghost {
    color: var(--gray);
    border: none;
    font-weight: bold;
}
.btn--ghost:hover {
    color: var(--danger);
}
.btn--sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}
.btn--lg {
    padding: 0.4rem 0.8rem;
    font-size: 1.1rem;
}
.btn--block {
    width: 100%;
    text-align: center;
}
.btn--link {
    background: none;
    color: var(--primary);
    padding: 0.44rem;
}
.btn--disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-form {
    max-width: 500px;
    margin: 0 auto;
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.form-title {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--dark);
}
.form-group {
    margin-bottom: 1.2rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
}
.form-group input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}
.form-error {
    color: var(--danger);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}
.form-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--gray);
}
.form-footer a {
    color: var(--primary);
    text-decoration: none;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}
.product-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}
.product-card:hover {
    transform: translateY(-5px);
}
.product-card__image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding-top: 20px;
    height: 300px; /* фиксированная высота карточки */
    overflow: hidden;
}
/* ✅ Изображения — целиком, без обрезки, без искажений */
.product-card__image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
}
.product-card__placeholder {
    font-size: 3rem;
    color: #ccc;
}
.product-card__body {
    padding: 1.2rem;
}
.product-card__category {
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 0.1rem;
}
.product-card__category a {
    color: var(--primary);
    text-decoration: none;
}
.product-card__title a {
    color: var(--dark);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 500;
}
.product-card__desc {
    color: var(--gray);
    margin-top: 0.2rem;
    font-size: 0.95rem;
    line-height: 1.5em; /* Задайте высоту строки */
    height: 3em; /* Высота равна line-height * 2 */
    overflow: hidden;
}
.product-card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.rem;
    flex-wrap: wrap; /* Позволяет элементам переноситься при нехватке места */
    gap: 0.5rem; /* Добавляем небольшой отступ между элементами */
}
.price {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap; /* Запрещаем перенос цены */
}

/* ======================
   Страница деталей товара — ВСЕГДА ВЕРТИКАЛЬНО
====================== */

.product-detail {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.product-main-image {
    text-align: center;
    margin-bottom: 1.5rem;
}

.product-main-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-width: 600px;
    width: 100%;
    display: block;
    margin: 0 auto;
}

.product-gallery {
    margin: 1.5rem 0;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 8px;
}

.product-gallery h3 {
    margin-top: 0;
    margin-bottom: 12px;
    color: #333;
    font-size: 1.25rem;
}

.gallery-images {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0;
    scroll-behavior: smooth;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.gallery-images::-webkit-scrollbar {
    display: none;
}

.gallery-item {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    overflow: hidden;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-item:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 2px solid #eee;
    border-radius: 4px;
    display: block;
}

.product-detail__info {
    margin-top: 1.5rem;
}

.product-detail__title {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--dark);
}

.product-detail__desc {
    margin-bottom: 1.5rem;
    color: var(--dark);
    line-height: 1.6;
}

.product-detail__price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

/* ======================
   Корзина — цена и кнопка СПРАВА, иконка корзины
====================== */

.cart-items {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.8rem;
}

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

.cart-img {
    width: 70px;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

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

.cart-item__info h3 {
    margin-bottom: 0.2rem;
    font-size: 1.1rem;
}

.cart-item__info p {
    font-size: 0.95rem;
    color: var(--gray);
}

.cart-item__quantity {
    font-weight: 500;
    white-space: nowrap;
}

/* Блок с ценой и кнопкой — прижат к правому краю */
.cart-item__price-and-remove {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto; /* ← КЛЮЧ: прижимает к правому краю */
}

.cart-item__total {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.2rem;
}

/* ✅ Красивая кнопка удаления — на всех экранах */
.cart-item__remove {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--gray);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.cart-item__remove:hover {
    background: rgba(230, 57, 70, 0.08);
    color: var(--danger);
    transform: scale(1.05);
}

.cart-item__remove svg {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    fill: none;
}

.cart-summary {
    text-align: right;
    margin-top: 1.5rem;
}

.total-amount {
    color: var(--primary);
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .cart-item__remove {
        width: 32px;
        height: 32px;
    }
    .cart-item__remove svg {
        width: 28px;
        height: 28px;
    }
}

/* ======================
   Профиль
====================== */

.profile-page .profile-info {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.profile-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ======================
   Боковая панель и макет
====================== */

.layout {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
}
.sidebar {
    width: 250px;
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    height: fit-content;
}
.category-list {
    list-style: none;
}
.category-list li {
    margin-bottom: 0.5rem;
}
.category-list a {
    text-decoration: none;
    color: var(--gray);
    display: block;
    padding: 0.4rem 0;
    border-radius: 4px;
    transition: background 0.2s;
}
.category-list a:hover,
.category-list a.active {
    background: var(--primary);
    color: white;
}
.content {
    flex: 1;
}

/* ======================
   Выпадающее меню
====================== */

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown__toggle {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.dropdown__toggle:hover {
    background: var(--primary-dark);
}

.dropdown__menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    list-style: none;
    margin: 0.3rem 0 0;
    padding: 0.5rem 0;
    min-width: 200px;
    z-index: 1000;
    display: none;
}

.dropdown__menu.show {
    display: block;
}

.dropdown__menu li {
    margin: 0;
}

.dropdown__menu a {
    display: block;
    padding: 0.6rem 1rem;
    color: var(--dark);
    text-decoration: none;
}

.dropdown__menu a:hover {
    background: #f0f0f0;
}

/* ======================
   Модальное окно
====================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    position: relative;
}

.close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 28px;
    cursor: pointer;
    color: var(--gray);
}

.close:hover {
    color: var(--danger);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--dark);
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: var(--gray);
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    color: gray;
}

.btn--primary {
    background: var(--primary);
    color: white;
}

.btn--primary:hover {
    background: var(--primary-dark);
}

/* ======================
   Адаптивность (мобильные улучшения)
====================== */

@media (max-width: 768px) {
    .header__right {
        display: flex;
        flex-wrap: nowrap;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.2rem;
    }

    .product-card {
        padding: 0.2rem;
    }

    .product-card__image {
        height: 160px; /* адаптация под мобильные */
    }

    .product-card__body {
        padding: 0.1rem;
    }

    .product-card__category {
        margin-bottom: 0.05rem;
        font-size: 0.7rem;
    }

    .product-card__title a {
        font-size: 0.85rem;
        margin-bottom: 0.05rem;
        line-height: 1.1;
        display: block;
    }

    .product-card__desc {
        font-size: 0.7rem;
        margin-bottom: 0.05rem;
        line-height: 1.15;
    }

    .price {
        font-size: 0.75rem;
        font-weight: 600;
        margin-bottom: 0;
    }

    .btn.btn--sm {
        text-align: center;
        font-size: 0.5rem;
        padding: 0.2rem;
        width: 80%;
        box-sizing: border-box;
    }

    #btn-detail{
        text-align: center;
        font-size: 1rem;
        padding: 0.42rem;
        width: 35%;
        box-sizing: border-box;
    }

    .favorite-btn {
        margin-right: 0 !important;
    }

    .favorite-remove-btn {
        margin-right: 0 !important;
    }
    .product-card__desc {
        color: var(--gray);
        margin-bottom: 0.5rem;
        font-size: 0.6rem;
        line-height: 1.5em;
        height: 3em;
        overflow: hidden;
    }
}


#basket-product {
    margin-top: 0.5rem;
    width: 24px;
    height: 24px;
    filter: brightness(0) saturate(100%) invert(50%);
    margin-right: 0.5rem;
}

.favorite-btn {
    border: none;
    background: none;
    margin-top: 0.05rem;
    margin-right: 0.75rem;
}

.favorite-remove-btn {
    border: none;
    background: none;
    margin-top: 0.4rem;
    margin-right: 0.75rem;
}

.basket-like {
    display: flex;
    justify-content: end;
    align-items: center; /* Выравнивание по центру по вертикали */
    gap: 0.5rem; /* Отступ между иконками */
    white-space: nowrap; /* Запрет переноса */
}

.cart-btn {
    filter: brightness(0) saturate(100%) invert(50%);
}

textarea {
    padding-left: 5px;
}

/* ============= КАРУСЕЛЬ С ТОВАРАМИ ============= */
#heroCarousel {
  position: relative;
}

#heroCarousel .carousel-inner {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

#heroCarousel .carousel-indicators {
  bottom: 12px;
  z-index: 2;
}

@media (max-width: 768px) {
  #heroCarousel .carousel-indicators {
    display: none;
  }
}

#heroCarousel .carousel-control-prev,
#heroCarousel .carousel-control-next {
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  opacity: 1;
  z-index: 2;
}

#heroCarousel .carousel-control-next {
  background: none;
  border: none;
}

#heroCarousel .carousel-control-prev {
  background: none;
  border: none;
}

#heroCarousel .carousel-control-prev-icon,
#heroCarousel .carousel-control-next-icon {
  filter: invert(50%);
  opacity: 0.15;
}

.carousel-product-card {
  display: flex;
  background: white;
  height: 100%;
  padding: 12px;
  box-sizing: border-box;
}

.carousel-product-image-wrapper {
  width: 170px;
  min-width: 170px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9f9f9;
  border-radius: 8px;
  overflow: hidden;
}

.carousel-product-image {
  width: 100%;
  height: 150px;
  object-fit: contain;
  object-position: center;
  background-color: #ffffff;
}

.carousel-placeholder {
  font-size: 2rem;
  color: #ccc;
}

.carousel-product-content {
  flex: 1;
  padding: 0 0 0 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.carousel-product-content .product-card__category a {
  font-size: 0.85rem;
  color: #6c757d;
  text-decoration: none;
  margin-left: 0.5rem;
}

.carousel-product-content .product-card__title {
  font-size: 1.2rem;
  margin: 0;
  line-height: 1.3;
}

.carousel-product-content .product-card__title a {
  color: #212529;
  text-decoration: none;
  margin-left: 0.5rem;
}

.carousel-product-content .product-card__desc {
  font-size: 0.9rem;
  color: #6c757d;
  margin-right: 0.5rem;
  line-height: 1.4;
  max-height: calc(0.9rem * 1.4 * 3);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  margin-left: 0.5rem;
}

.carousel-product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
}

.carousel-product-footer .price {
  font-weight: bold;
  font-size: 1.25rem;
  color: #e74c3c;
  white-space: normal;
  word-break: break-word;
  min-width: 0;
}

/* Адаптив */
@media (max-width: 768px) {
  .carousel-product-card {
    padding: 10px;
  }
  .carousel-product-image-wrapper {
    width: 130px;
    min-width: 130px;
  }
  .carousel-product-content {
    padding: 0 0 0 12px;
  }
  .carousel-product-content .product-card__title {
    font-size: 1.05rem;
  }
  .carousel-product-content .product-card__desc {
    font-size: 0.85rem;
    max-height: 36px;
  }
  .carousel-product-footer .price {
    font-size: 1.1rem;
  }
  #btn-detail{
      text-align: center;
      font-size: 0.7rem;
      padding: 0.57rem 0.5rem;
      width: 37%;
      box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    #btn-detail{
      text-align: center;
      font-size: 0.7rem;
      padding: 0.57rem 0.5rem;
      width: 45%;
      box-sizing: border-box;
    }

  #btn-button-add {
    text-align: center;
    font-size: 0.7rem;
    padding: 0.75rem 0.5rem;
    width: 45%;
    box-sizing: border-box;
  }
    
  .btn_order {
    padding: 0.6rem 2.5rem; 
    margin-top: 7.5px
  }
  .carousel-product-card {
    padding: 8px;
  }
  .carousel-product-image-wrapper {
    width: 110px;
    min-width: 110px;
  }
  .carousel-product-content {
    padding: 0 0 0 10px;
  }
  .carousel-product-content .product-card__title {
    font-size: 1rem;
  }
.carousel-product-content .product-card__desc {
    line-height: 1.4;
    font-size: 0.85rem;
    margin-right: 1.75rem;
    max-height: calc(0.8rem * 1.4 * 3);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    margin-left: 0.5rem;
    margin-bottom: 0;
}
}
.carousel-product-footer .price {
    font-size: 1rem;
    margin-bottom: 1rem;
    margin-left: 0.5rem;
  }

.order-list-desktop {
        display: none !important;
    }

.order-list-mobile {
    display: block;
}

    @media (min-width: 768px) {
        .order-list-desktop {
            display: block !important;
        }
        .order-list-mobile {
            display: none;
        }
    }

.order-list-desktop {
    display: none !important;
}

.order-list-mobile {
    display: block;
}


@media (min-width: 768px) {
    .order-list-desktop {
        display: block !important;
    }
    .order-list-mobile {
        display: none;
    }
}