@charset "UTF-8";

/* Cart Sidebar */
.cart-sidebar {
  position: fixed;
  inset: 0;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-sidebar.active {
  opacity: 1;
  visibility: visible;
}

.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(47, 47, 47, 0.45);
  z-index: 9998;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: -100%;
  width: 530px;
  max-width: 90vw;
  height: 100vh;
  height: 100dvh; /* Динамическая высота viewport для мобильных */
  background: #FBF5EC;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cart-sidebar.active .cart-drawer {
  right: 0;
}

/* Cart Header */
.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid rgba(85, 47, 36, 0.1);
  flex-shrink: 0;
}

.cart-header h3 {
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 125%;
  color: #2F2F2F;
  margin: 0;
}

.cart-header .cart-count {
  font-weight: 500;
  font-size: 1rem;
  line-height: 150%;
  color: #575757;
  margin-top: 0.25rem;
}

.cart-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #2F2F2F;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, transform 0.2s ease;
}

.cart-close:hover {
  color: #552F24;
  transform: scale(1.1);
}

/* Cart Content */
.cart-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  padding-bottom: 2rem; /* Extra space for buttons */
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling in Safari */
  overscroll-behavior: contain; /* Prevent scroll chaining */
  min-height: 0;
  max-height: 100%;
}

.cart-content::-webkit-scrollbar {
  width: 6px;
}

.cart-content::-webkit-scrollbar-track {
  background: transparent;
}

.cart-content::-webkit-scrollbar-thumb {
  background: rgba(85, 47, 36, 0.2);
  border-radius: 3px;
}

.cart-content::-webkit-scrollbar-thumb:hover {
  background: rgba(85, 47, 36, 0.3);
}

/* Cart Items */
.cart-items {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.cart-item {
  display: flex;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(85, 47, 36, 0.1);
}

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

.cart-item__image {
  flex: 0 0 100px;
  width: 100px;
  height: 100px;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #ffffff;
}

.cart-item__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item__details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cart-item__name {
  font-weight: 600;
  font-size: 1rem;
  line-height: 150%;
  color: #2F2F2F;
}

.cart-item__name a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.cart-item__name a:hover {
  color: #552F24;
}

.cart-item__attributes {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
  line-height: 150%;
  color: #575757;
}

.cart-item__attr {
  display: block;
}

.cart-item__attr strong {
  font-weight: 500;
}

.cart-item__quantity {
  display: none; /* Скрываем стандартный вывод количества */
}

.cart-item__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

.cart-item__price {
  font-weight: 600;
  font-size: 1rem;
  line-height: 150%;
  color: #2F2F2F;
}

.cart-item__quantity-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid rgba(85, 47, 36, 0.18);
  border-radius: 0.5rem;
  padding: 0.25rem;
  background: #ffffff;
}

.cart-item__qty-btn {
  width: 2rem;
  height: 2rem;
  border: none;
  background: transparent;
  color: #552F24;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.cart-item__qty-btn:hover {
  background: rgba(85, 47, 36, 0.1);
}

.cart-item__qty-btn:active {
  background: rgba(85, 47, 36, 0.15);
}

.cart-item__qty-value {
  font-weight: 500;
  font-size: 1rem;
  line-height: 150%;
  color: #2F2F2F;
  min-width: 1.5rem;
  text-align: center;
}

.cart-item__remove {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #575757;
  text-decoration: none;
  border-radius: 0.25rem;
  transition: color 0.2s ease, background 0.2s ease;
}

.cart-item__remove:hover {
  color: #552F24;
  background: rgba(85, 47, 36, 0.1);
}

.cart-item__remove svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Cart Summary */
.cart-summary {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(85, 47, 36, 0.1);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-shrink: 0; /* Prevent shrinking */
}

.cart-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9375rem;
  line-height: 150%;
}

.cart-summary__label {
  color: #575757;
}

.cart-summary__value {
  color: #2F2F2F;
  font-weight: 500;
}

.cart-summary__row--total {
  font-size: 1.125rem;
  font-weight: 600;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(85, 47, 36, 0.1);
}

.cart-summary__row--total .cart-summary__label,
.cart-summary__row--total .cart-summary__value {
  color: #2F2F2F;
  font-weight: 600;
}

/* Cart Buttons */
.cart-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(85, 47, 36, 0.1);
  flex-shrink: 0; /* Prevent shrinking */
}

.cart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 1rem;
  line-height: 150%;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  cursor: pointer;
}

.cart-button--primary {
  background: #552F24;
  color: #FBF5EC;
}

.cart-button--primary:hover {
  background: #43241b;
  transform: translateY(-1px);
}

.cart-button--secondary {
  background: #ffffff;
  color: #552F24;
  border-color: #552F24;
}

.cart-button--secondary:hover {
  background: #FBF5EC;
  border-color: #43241b;
}

.cart-button svg {
  width: 1.5rem;
  height: 1.5rem;
}

/* Empty Cart */
.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  min-height: 300px;
}

.cart-empty__message {
  font-weight: 500;
  font-size: 1rem;
  line-height: 150%;
  color: #575757;
  margin-bottom: 1.5rem;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .cart-drawer {
    width: 100%;
    max-width: 100vw;
    border-radius: 0;
    height: 100vh;
    height: 100dvh; /* Динамическая высота viewport для мобильных */
  }

  .cart-header {
    padding: 1.25rem 1.25rem 0.75rem;
    flex-shrink: 0;
  }

  .cart-content {
    padding: 1.25rem;
    padding-bottom: 2rem; /* Extra space for buttons */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling in Safari */
    overscroll-behavior: contain; /* Prevent scroll chaining */
    min-height: 0;
    flex: 1 1 auto;
  }

  .cart-item {
    gap: 0.75rem;
  }

  .cart-item__image {
    flex: 0 0 80px;
    width: 80px;
    height: 80px;
  }

  .cart-item__name {
    font-size: 0.9375rem;
  }

  .cart-button {
    padding: 0.875rem 1.25rem;
    font-size: 0.9375rem;
  }
}

body.cart-open {
  overflow: hidden;
}

