/* ========================================
   SHOPPING CART SIDEBAR STYLES
   ======================================== */

/* Overlay that appears behind the sidebar */
.cart-sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

/* Main sidebar container */
.cart-sidebar {
  position: fixed;
  top: 0;
  right: -450px; /* Hidden off-screen by default */
  width: 450px;
  height: 100vh;
  background-color: #ffffff;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1050;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cart-sidebar.active {
  right: 0; /* Slides in when active */
}

/* Sidebar header */
.cart-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  background-color: #f9fafb;
}

.cart-sidebar-title {
  font-size: 20px;
  font-weight: 600;
  color: #111827;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-sidebar-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s ease;
  line-height: 1;
}

.cart-sidebar-close:hover {
  color: #111827;
}

/* Sidebar body (scrollable content area) */
.cart-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* Empty cart message */
.cart-empty-message {
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;
}

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

.cart-empty-text {
  font-size: 16px;
  margin-bottom: 24px;
}

/* Cart item styling */
.cart-sidebar-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid #f3f4f6;
  transition: background-color 0.2s ease;
}

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

.cart-sidebar-item:hover {
  background-color: #f9fafb;
  margin: 0 -8px;
  padding: 16px 8px;
  border-radius: 8px;
}

/* Item image */
.cart-item-image {
  width: 80px;
  height: 80px;
  background-color: #f3f4f6;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 32px;
  overflow: hidden;
  position: relative;
}

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

.cart-item-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 32px;
  color: #9ca3af;
}

/* Item details */
.cart-item-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0; /* Allow text truncation */
}

.cart-item-name {
  font-size: 15px;
  font-weight: 500;
  color: #111827;
  margin: 0;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.cart-item-price {
  font-size: 14px;
  color: #6b7280;
}

/* Quantity controls */
.cart-item-quantity-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

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

.cart-quantity-btn {
  background-color: #ffffff;
  border: none;
  color: #6b7280;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  font-size: 14px;
}

.cart-quantity-btn:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.cart-quantity-btn:active {
  background-color: #e5e7eb;
}

.cart-quantity-value {
  min-width: 40px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  padding: 0 8px;
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  background-color: #ffffff;
  line-height: 28px;
}

/* Input field styling for quantity (if used) */
.cart-sidebar .dQuantity {
  width: 50px;
  text-align: center;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 14px;
  font-weight: 500;
}

.cart-sidebar .dQuantity:disabled {
  background-color: #f9fafb;
  color: #6b7280;
}

.cart-sidebar .quantity-exceed-max {
  border-color: #ef4444;
  background-color: #fef2f2;
}

/* Item subtotal */
.cart-item-subtotal {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
}

/* Remove button */
.cart-item-remove {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s ease;
  font-size: 16px;
  align-self: flex-start;
}

.cart-item-remove:hover {
  color: #dc2626;
}

/* Sidebar footer */
.cart-sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid #e5e7eb;
  background-color: #f9fafb;
}

/* Cart summary */
.cart-summary {
  margin-bottom: 20px;
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  color: #6b7280;
}

.cart-summary-row.total {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  margin-bottom: 0;
}

.cart-summary-label {
  font-weight: 500;
}

.cart-summary-value {
  font-weight: 600;
}

/* Checkout button */
.cart-checkout-btn {
  width: 100%;
  padding: 14px 24px;
  background-color: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.cart-checkout-btn:hover {
  background-color: #059669;
}

.cart-checkout-btn:active {
  transform: scale(0.98);
}

.cart-checkout-btn:disabled {
  background-color: #d1d5db;
  cursor: not-allowed;
  transform: none;
}

/* Continue shopping link */
.cart-continue-shopping {
  text-align: center;
  color: #6b7280;
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
}

.cart-continue-shopping:hover {
  color: #111827;
}

/* Scrollbar styling for cart body */
.cart-sidebar-body::-webkit-scrollbar {
  width: 6px;
}

.cart-sidebar-body::-webkit-scrollbar-track {
  background: #f3f4f6;
}

.cart-sidebar-body::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.cart-sidebar-body::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Clickable image link */
.cart-item-image-link {
  text-decoration: none;
  display: block;
  cursor: pointer;
}

.cart-item-image-link:hover .cart-item-image {
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

/* Clickable name link */
.cart-item-name-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.cart-item-name-link:hover .cart-item-name {
  color: #10b981;
  transition: color 0.2s ease;
}

.cart-item-name-link:visited {
  color: inherit;
}

/* Login button (same style as checkout) */
.cart-login-btn {
  width: 100%;
  padding: 14px 24px;
  background-color: #3b82f6;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.cart-login-btn:hover {
  background-color: #2563eb;
}

.cart-login-btn:active {
  transform: scale(0.98);
}

.cart-login-btn:disabled {
  background-color: #d1d5db;
  cursor: not-allowed;
  transform: none;
}

/* Cart Buttons Container */
.cart-buttons-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

/* Ensure all buttons have consistent spacing */
.cart-offline-checkout-btn,
.cart-checkout-btn,
.cart-login-btn {
  margin: 0 !important;
  width: 100%;
}

/* Continue shopping link spacing */
.cart-continue-shopping {
  margin-top: 8px;
  display: block;
  text-align: center;
}

/* Animation for item addition */
@keyframes slideInItem {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.cart-sidebar-item.newly-added {
  animation: slideInItem 0.3s ease;
}

/* Badge notification on cart icon */
.cart-badge {
  background-color: #10b981;
  color: white;
  border-radius: 50%;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  position: absolute;
  top: -8px;
  right: -8px;
}

/* Prevent body scroll when sidebar is open */
body.no-scroll {
  overflow: hidden;
}

/* ========================================
   OFFLINE CHECKOUT MODAL STYLES
   ======================================== */

/* Offline Checkout Button */
.cart-offline-checkout-btn {
  width: 100%;
  padding: 14px 24px;
  background-color: #8b5cf6;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.cart-offline-checkout-btn:hover {
  background-color: #7c3aed;
}

.cart-offline-checkout-btn:active {
  transform: scale(0.98);
}

.cart-offline-checkout-btn:disabled {
  background-color: #d1d5db;
  cursor: not-allowed;
  transform: none;
}

/* Offline Checkout Modal Overlay */
#offlineCheckoutOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1060;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#offlineCheckoutOverlay.active {
  opacity: 1;
  visibility: visible;
}

/* Offline Checkout Modal */
#offlineCheckoutModal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 500px;
  max-height: 85vh; /* Reduced to ensure it fits better */
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  z-index: 1070;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#offlineCheckoutModal.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* Modal Header */
.offline-checkout-modal-header {
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
  background-color: #f9fafb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0; /* Prevent header from shrinking */
}

.offline-checkout-modal-title {
  font-size: 20px;
  font-weight: 600;
  color: #111827;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

#closeOfflineCheckoutModal {
  background: none;
  border: none;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s ease;
  line-height: 1;
}

#closeOfflineCheckoutModal:hover {
  color: #111827;
}

/* Modal Body - FIXED SCROLL */
.offline-checkout-modal-body {
  flex: 1;
  overflow-y: auto; /* Enable scrolling */
  padding: 24px;
  max-height: calc(85vh - 140px); /* Calculate available space for content */
}

/* Form Styles */
#offlineCheckoutForm {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px; /* Increased gap for better spacing */
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0; /* Remove bottom margin since we're using gap */
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-color: #ffffff;
  font-family: inherit;
  width: 100%; /* Ensure full width */
  box-sizing: border-box; /* Include padding in width calculation */
}

.form-group textarea {
  resize: vertical; /* Allow vertical resize only */
  min-height: 80px; /* Minimum height for textarea */
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-group input.error,
.form-group select.error,
.form-group textarea.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Delivery Options */
.delivery-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.delivery-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 12px 16px; /* Increased padding */
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-weight: normal;
  margin-bottom: 0;
}

.delivery-options label:hover {
  border-color: #8b5cf6;
  background-color: #faf5ff;
}

.delivery-options input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

/* Conditional Field - IMPROVED LAYOUT */
#dropoffLocationGroup {
  display: none;
  animation: fadeIn 0.3s ease;
  margin-top: 8px; /* Add spacing from radio buttons */
}

#dropoffLocationGroup.show {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

/* Form Actions */
.form-actions {
  margin-top: 24px;
  text-align: center;
  flex-shrink: 0; /* Prevent actions from shrinking */
}

#offlineCheckoutSubmitBtn {
  background-color: #8b5cf6;
  color: #ffffff;
  border: none;
  padding: 14px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  width: 100%;
}

#offlineCheckoutSubmitBtn:hover {
  background-color: #7c3aed;
}

#offlineCheckoutSubmitBtn:active {
  transform: scale(0.98);
}

#offlineCheckoutSubmitBtn:disabled {
  background-color: #d1d5db;
  cursor: not-allowed;
  transform: none;
}

/* Loading State */
.btn-loading {
  position: relative;
  color: transparent;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ========================================
   TOAST NOTIFICATION STYLES
   ======================================== */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.toast {
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  color: white;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(400px);
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 100%;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.hide {
  transform: translateX(400px);
  opacity: 0;
}

.toast-success {
  background-color: #10b981;
  border-left: 4px solid #059669;
}

.toast-error {
  background-color: #ef4444;
  border-left: 4px solid #dc2626;
}

.toast-warning {
  background-color: #f59e0b;
  border-left: 4px solid #d97706;
}

.toast-info {
  background-color: #3b82f6;
  border-left: 4px solid #2563eb;
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.toast-close:hover {
  opacity: 1;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
  .cart-sidebar {
    width: 100%;
    right: -100%;
  }
  
  .cart-sidebar.active {
    right: 0;
  }
  
  /* Offline Checkout Modal Responsive */
  #offlineCheckoutModal {
    width: 95%;
    margin: 20px;
    max-height: 90vh; /* Slightly taller on mobile */
  }
  
  .offline-checkout-modal-body {
    max-height: calc(90vh - 140px);
    padding: 20px;
  }
  
  .offline-checkout-modal-header {
    padding: 20px;
  }
  
  .delivery-options {
    gap: 8px;
  }
  
  .delivery-options label {
    padding: 12px 16px;
  }

  /* Toast responsive */
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
  
  .toast {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .cart-sidebar-header {
    padding: 16px 20px;
  }
  
  .cart-sidebar-body {
    padding: 16px 20px;
  }
  
  .cart-sidebar-footer {
    padding: 16px 20px;
  }
  
  .cart-sidebar-title {
    font-size: 18px;
  }
  
  .cart-item-image {
    width: 60px;
    height: 60px;
  }
  
  .cart-item-name {
    font-size: 14px;
  }
  
  .cart-item-price {
    font-size: 13px;
  }
  
  /* Offline Checkout Modal Mobile */
  .offline-checkout-modal-header {
    padding: 16px 20px;
  }
  
  .offline-checkout-modal-body {
    padding: 16px 20px;
  }
  
  .offline-checkout-modal-title {
    font-size: 18px;
  }
  
  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 10px 12px;
  }

  .toast {
    padding: 14px 16px;
    font-size: 13px;
  }
}