/* ===============================================
   ADVANCED SHOPPING CART - AMAZON/FLIPKART STYLE
   =============================================== */

/* Cart Badge & Icon */
.cart-icon-container {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.cart-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #ff4444, #cc0000);
  color: white;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bounce 0.5s ease;
  z-index: 10;
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Cart Dropdown */
.cart-dropdown-container {
  position: relative;
}

.cart-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 380px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  max-height: 500px;
  overflow-y: auto;
  transform: translateY(10px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cart-dropdown.show {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.cart-dropdown-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-dropdown-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.more-items {
  font-size: 12px;
  color: #666;
  background: #f5f5f5;
  padding: 2px 8px;
  border-radius: 12px;
}

.cart-dropdown-items {
  max-height: 300px;
  overflow-y: auto;
}

.cart-dropdown-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #f8f8f8;
  transition: background-color 0.2s ease;
}

.cart-dropdown-item:hover {
  background-color: #fafafa;
}

.cart-dropdown-item .item-image {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 6px;
  margin-right: 12px;
}

.cart-dropdown-item .item-details {
  flex: 1;
}

.cart-dropdown-item h4 {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin: 0 0 4px 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cart-dropdown-item .item-price {
  font-size: 13px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 8px;
}

.original-price {
  text-decoration: line-through;
  color: #999;
  font-size: 12px;
}

.remove-item {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.remove-item:hover {
  background: #fee;
  color: #ff4444;
}

.empty-cart-dropdown {
  padding: 40px 20px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.cart-dropdown-footer {
  padding: 16px 20px;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
}

.cart-total {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
  text-align: center;
}

.cart-actions {
  display: flex;
  gap: 8px;
}

.cart-actions button {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary {
  background: white;
  color: #333;
  border: 1px solid #ddd;
}

.btn-secondary:hover {
  background: #f5f5f5;
}

.btn-primary {
  background: linear-gradient(135deg, #ff9500, #ff6600);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ff6600, #e55a00);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Cart Page Layout */
.cart-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.cart-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.cart-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Cart Section */
.cart-section {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.clear-cart-btn {
  background: none;
  border: 1px solid #ddd;
  color: #666;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.clear-cart-btn:hover {
  background: #fee;
  border-color: #ff4444;
  color: #ff4444;
}

/* Cart Items */
.cart-items {
  display: flex;
  flex-direction: column;
}

.cart-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  padding: 24px;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
}

.cart-item:hover {
  background: #fafafa;
}

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

.item-image-container {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  background: #f8f8f8;
}

.item-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0;
  line-height: 1.4;
}

.item-variant {
  font-size: 14px;
  color: #666;
  background: #f0f0f0;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  width: fit-content;
}

.item-seller {
  font-size: 14px;
  color: #666;
}

.item-price-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}

.current-price {
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

.original-price {
  text-decoration: line-through;
  color: #999;
  font-size: 16px;
}

.discount-tag {
  background: linear-gradient(135deg, #00a652, #00b357);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.item-delivery {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #666;
}

.free-delivery {
  background: #00a652;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}

/* Item Controls */
.item-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-end;
  min-width: 160px;
}

.quantity-controls {
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
}

.qty-btn {
  width: 36px;
  height: 36px;
  background: white;
  border: none;
  border-right: 1px solid #ddd;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.qty-btn:hover:not(:disabled) {
  background: #f0f0f0;
}

.qty-btn:disabled {
  cursor: not-allowed;
  color: #ccc;
}

.qty-btn.plus {
  border-right: none;
  border-left: 1px solid #ddd;
}

.qty-input {
  width: 50px;
  height: 36px;
  text-align: center;
  border: none;
  font-size: 14px;
  font-weight: 500;
}

.qty-input:focus {
  outline: none;
  background: #f8f8f8;
}

.item-total {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  text-align: right;
}

.item-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  background: none;
  border: none;
  color: #0066cc;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 0;
  text-align: left;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn:hover {
  color: #0052a3;
}

.action-btn.remove:hover {
  color: #ff4444;
}

.stock-warning {
  background: #fff3cd;
  color: #856404;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  border-left: 3px solid #ffc107;
}

/* Saved for Later */
.saved-for-later-section {
  margin-top: 20px;
}

.saved-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 20px;
}

.saved-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  background: white;
  transition: all 0.2s ease;
}

.saved-item:hover {
  border-color: #ddd;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.saved-item .item-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
}

.saved-item .item-details {
  flex: 1;
}

.saved-item h4 {
  font-size: 16px;
  font-weight: 500;
  color: #333;
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.saved-item .item-price {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
}

.saved-item .item-actions {
  display: flex;
  gap: 8px;
}

.saved-item .item-actions button {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Cart Summary Sidebar */
.cart-summary {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 24px;
  position: sticky;
  top: 20px;
}

.summary-header {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
}

.summary-row.total {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  border-top: 1px solid #f0f0f0;
  padding-top: 16px;
  margin-top: 12px;
}

.savings {
  color: #00a652;
  font-weight: 500;
}

.delivery-fee {
  color: #666;
}

.free-delivery-progress {
  background: #e8f5e8;
  border: 1px solid #00a652;
  border-radius: 6px;
  padding: 12px;
  margin: 16px 0;
  text-align: center;
}

.free-delivery-progress .progress-text {
  font-size: 13px;
  color: #00a652;
  font-weight: 500;
}

.free-delivery-progress .progress-bar {
  background: #f0f0f0;
  height: 6px;
  border-radius: 3px;
  margin: 8px 0;
  overflow: hidden;
}

.progress-fill {
  background: linear-gradient(90deg, #00a652, #00b357);
  height: 100%;
  transition: width 0.3s ease;
}

.checkout-btn {
  width: 100%;
  background: linear-gradient(135deg, #ff9500, #ff6600);
  color: white;
  border: none;
  padding: 16px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 20px;
}

.checkout-btn:hover {
  background: linear-gradient(135deg, #ff6600, #e55a00);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 102, 0, 0.3);
}

.checkout-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Empty Cart */
.empty-cart {
  text-align: center;
  padding: 60px 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.empty-cart-icon {
  font-size: 64px;
  color: #ddd;
  margin-bottom: 20px;
}

.empty-cart h2 {
  font-size: 24px;
  color: #666;
  margin-bottom: 12px;
}

.empty-cart p {
  color: #999;
  font-size: 16px;
  margin-bottom: 30px;
}

.continue-shopping-btn {
  background: linear-gradient(135deg, #ff9500, #ff6600);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.continue-shopping-btn:hover {
  background: linear-gradient(135deg, #ff6600, #e55a00);
  transform: translateY(-1px);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .cart-content {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 16px;
  }
  
  .cart-dropdown {
    width: 320px;
    right: -20px;
  }
  
  .cart-item {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 20px;
  }
  
  .item-image-container {
    width: 100px;
    height: 100px;
    margin: 0 auto;
  }
  
  .item-controls {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }
  
  .quantity-controls {
    order: 2;
  }
  
  .item-total {
    order: 1;
    font-size: 16px;
  }
  
  .item-actions {
    order: 3;
    flex-direction: row;
    gap: 16px;
  }
  
  .saved-items {
    grid-template-columns: 1fr;
  }
  
  .cart-summary {
    position: static;
  }
}

@media (max-width: 480px) {
  .cart-dropdown {
    width: 280px;
  }
  
  .section-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  .cart-item {
    padding: 16px;
  }
  
  .item-name {
    font-size: 16px;
  }
  
  .current-price {
    font-size: 18px;
  }
  
  .item-actions {
    flex-direction: column;
    gap: 8px;
  }
}

/* Animations */
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cart-item {
  animation: fadeIn 0.3s ease-out;
}

.saved-item {
  animation: fadeIn 0.3s ease-out;
}

/* Loading States */
.cart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #666;
}

.cart-loading .spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #f0f0f0;
  border-top: 2px solid #ff9500;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 12px;
}

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

/* Accessibility */
.qty-btn:focus,
.action-btn:focus,
.checkout-btn:focus {
  outline: 2px solid #ff9500;
  outline-offset: 2px;
}

.cart-item:focus-within {
  background: #f8f8ff;
  border-color: #ff9500;
}
