/* Machinery Cart Widget Styles */
.machinery-cart-widget {
  position: relative;
  display: inline-block;
}

.cart-icon-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  padding: 8px;
  transition: all 0.3s ease;
}

.cart-icon-link:hover {
  color: inherit;
  text-decoration: none;
}

.cart-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cart-icon svg {
  width: 24px;
  height: 24px;
  transition: transform 0.2s ease;
}

.cart-icon:hover svg {
  transform: scale(1.1);
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ffe900;
  color: #000;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Cart Dropdown */
.cart-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 400px;
  background: #fff;
  border: 1px solid #e1e1e1;
  border-radius: 8px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 500px;
  overflow: hidden;
}

.machinery-cart-widget:hover .cart-dropdown,
.machinery-cart-widget.cart-hover .cart-dropdown,
.machinery-cart-widget.mobile-cart-open .cart-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Force keep-open to override any other states */
.machinery-cart-widget.cart-keep-open .cart-dropdown {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
}

.cart-dropdown-content {
  padding: 20px;
}

/* Cart Items */
.cart-items {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.cart-item {
  display: flex;
  align-items: flex-start;
  padding: 15px 0;
  border-bottom: 1px solid #f0f0f0;
  position: relative;
  transition: all 0.2s ease;
}

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

.cart-item:hover {
  background-color: #fafafa;
  border-radius: 6px;
  margin: 0 -10px;
  padding: 15px 10px;
}

.cart-item-image {
  flex: 0 0 60px;
  margin-right: 15px;
}

.cart-item-image img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #e1e1e1;
}

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

.cart-item-name {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px 0;
  line-height: 1.3;
  color: #333;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.cart-item-price {
  font-size: 13px;
  color: #666;
  line-height: 1.4;
}

.cart-item-price .quantity {
  font-weight: 600;
  color: #333;
}

.cart-item-price .price {
  font-weight: 700;
  color: #000;
  font-size: 14px;
}

.cart-item-price .discount-info {
  color: #888;
  font-size: 12px;
}

.cart-item-remove {
  position: absolute;
  top: 15px;
  right: 5px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: #999;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.cart-item-remove:hover {
  background: #f5f5f5;
  color: #e74c3c;
  transform: scale(1.1);
}

/* Cart Footer */
.cart-footer {
  border-top: 2px solid #f0f0f0;
  padding-top: 20px;
}

.cart-total {
  text-align: center;
  margin-bottom: 20px;
  font-size: 16px;
  font-weight: 600;
}

.total-label {
  color: #333;
}

.total-amount {
  color: #000;
  font-weight: 700;
  font-size: 18px;
}

.total-tax-info {
  color: #888;
  font-size: 14px;
  font-weight: normal;
}

.cart-button {
  display: block;
  width: 100%;
  background: #ffe900;
  color: #000;
  text-align: center;
  padding: 15px 20px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
  border: 2px solid #ffe900;
}

.cart-button:hover {
  background: #f0d500;
  border-color: #f0d500;
  color: #000;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 233, 0, 0.3);
}

/* Empty Cart */
.cart-empty {
  text-align: center;
  padding: 40px 20px;
  color: #888;
}

.cart-empty p {
  margin: 0;
  font-size: 16px;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .cart-dropdown {
    width: 350px;
    right: -20px;
  }

  .machinery-cart-widget:hover .cart-dropdown {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
  }

  .machinery-cart-widget.mobile-cart-open .cart-dropdown,
  .machinery-cart-widget.cart-keep-open .cart-dropdown {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
  }

  .cart-item-name {
    font-size: 13px;
  }

  .cart-item-image {
    flex: 0 0 50px;
    margin-right: 12px;
  }

  .cart-item-image img {
    width: 50px;
    height: 50px;
  }
}

@media (max-width: 480px) {
  .cart-dropdown {
    width: 300px;
    right: -40px;
  }

  .cart-dropdown-content {
    padding: 15px;
  }

  .cart-item {
    padding: 12px 0;
  }

  .cart-item:hover {
    margin: 0 -8px;
    padding: 12px 8px;
  }

  .cart-item-name {
    font-size: 12px;
  }

  .cart-item-price {
    font-size: 12px;
  }

  .cart-button {
    padding: 12px 16px;
    font-size: 13px;
  }
}

/* Scrollbar Styling */
.cart-items::-webkit-scrollbar {
  width: 6px;
}

.cart-items::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.cart-items::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.cart-items::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Loading Animation */
.cart-dropdown.loading {
  pointer-events: none;
}

.cart-dropdown.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #ffe900;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Arrow indicator */
.cart-dropdown::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #fff;
  z-index: 10000;
}

.cart-dropdown::after {
  content: "";
  position: absolute;
  top: -9px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #e1e1e1;
  z-index: 9999;
}
