/* Cart Badge */
.cart-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cart-icon {
  font-size: 1.2rem;
}

.cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #2a2a2a;
  color: #ffffff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Product Selectors */
.product-selector {
  margin: 0.8rem 0;
}

.product-selector label:first-child {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.selector-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.selector-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid #dddddd;
  background: #f9f9f9;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.selector-option:hover {
  background: #eeeeee;
  border-color: #d6d6d6;
}

.selector-option input[type="radio"] {
  display: none;
}

.selector-option input[type="radio"]:checked + span,
.selector-option input[type="radio"]:checked ~ span {
  color: var(--accent);
}

.selector-option input[type="radio"]:checked ~ .color-swatch {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(85, 85, 85, 0.25);
}

.selector-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(85, 85, 85, 0.08);
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #d6d6d6;
  display: block;
}

/* Quantity Controls */
.quantity-input {
  margin-bottom: 0.6rem;
}

.quantity-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 140px;
}

.quantity-controls button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #dddddd;
  background: #f9f9f9;
  color: #1a1a1a;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.quantity-controls button:hover {
  background: #eeeeee;
  border-color: #d6d6d6;
}

.quantity-controls input {
  flex: 1;
  min-width: 2rem;
  text-align: center;
  border: 1px solid #dddddd;
  background: #ffffff;
  color: #1a1a1a;
  border-radius: var(--radius-md);
  padding: 0.4rem;
  font-size: 0.9rem;
  -moz-appearance: textfield;
}

.quantity-controls .cart-quantity-value {
  flex: 1;
  min-width: 2rem;
  text-align: center;
  display: block;
}

.quantity-controls input::-webkit-outer-spin-button,
.quantity-controls input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Cart Modal */
.cart-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-modal.active {
  opacity: 1;
  visibility: visible;
}

.cart-modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid #dddddd;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-soft);
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.cart-header h2 {
  font-size: 1.3rem;
  margin: 0;
}

.cart-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.cart-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1a1a1a;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  min-height: 200px;
  max-height: 400px;
}

.cart-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  display: none;
}

.cart-empty p {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.cart-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.cart-item:last-child {
  border-bottom: none;
}

.cart-item-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid #dddddd;
}

.cart-item-details {
  flex: 1;
}

.cart-item-details h4 {
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
}

.cart-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.cart-item-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-item-controls .quantity-controls {
  max-width: 120px;
}

.cart-item-price {
  font-weight: 600;
  font-size: 0.95rem;
}

.cart-item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  align-self: flex-start;
}

.cart-item-remove:hover {
  background: rgba(255, 0, 0, 0.1);
  color: #ff4444;
}

.cart-footer {
  padding: 1.2rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.cart-total strong {
  font-size: 1.3rem;
  color: #2a2a2a;
}

/* Cart Notification */
.cart-notification {
  position: fixed;
  top: 80px;
  right: 1.5rem;
  background: #2a2a2a;
  color: #ffffff;
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius-pill);
  font-weight: 500;
  z-index: 101;
  transform: translateX(400px);
  transition: transform 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.cart-notification.show {
  transform: translateX(0);
}

[dir="rtl"] .cart-badge {
  right: auto;
  left: -6px;
}

[dir="rtl"] .cart-notification {
  right: auto;
  left: 1.5rem;
  transform: translateX(-400px);
}

[dir="rtl"] .cart-notification.show {
  transform: translateX(0);
}

/* Responsive — mobile-first cart */
@media (max-width: 768px) {
  .cart-modal {
    padding: 0.75rem;
    align-items: flex-end;
  }

  .cart-modal-content {
    max-height: 92vh;
    width: 100%;
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .cart-header {
    padding: 1rem 1.25rem;
  }

  .cart-header h2 {
    font-size: 1.15rem;
  }

  .cart-close {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    font-size: 1.75rem;
    -webkit-tap-highlight-color: transparent;
  }

  .cart-items {
    max-height: 280px;
    padding: 0.75rem 1.25rem;
  }

  .cart-item {
    flex-direction: row;
    gap: 0.75rem;
    padding: 0.75rem 0;
  }

  .cart-item-image {
    width: 72px;
    min-width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--radius-md);
  }

  .cart-item-details h4 {
    font-size: 0.9rem;
  }

  .cart-item-meta {
    font-size: 0.75rem;
  }

  .cart-footer {
    padding: 1rem 1.25rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .cart-total {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }

  .cart-total strong {
    font-size: 1.2rem;
  }

  .cart-modal .btn-full {
    min-height: 48px;
    font-size: 1rem;
  }

  .selector-options {
    gap: 0.4rem;
  }

  .selector-option {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    min-height: 36px;
  }
}

@media (max-width: 480px) {
  .cart-modal {
    padding: 0.5rem;
  }

  .cart-modal-content {
    max-height: 90vh;
  }

  .cart-items {
    max-height: 240px;
    padding: 0.5rem 1rem;
  }

  .cart-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .cart-item-image {
    width: 100%;
    min-width: 0;
    height: 140px;
    object-fit: cover;
  }

  .cart-empty {
    padding: 2rem 1rem;
  }

  .cart-empty .btn {
    min-height: 44px;
    width: 100%;
  }
}

@media (max-width: 360px) {
  .cart-modal-content {
    border-radius: 12px 12px 0 0;
  }

  .cart-header,
  .cart-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .cart-items {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
