.sale-item-row {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}
.sale-item-name { flex: 1; font-weight: 500; }
.sale-item-qty { width: 80px; text-align: center; }
.sale-item-total { width: 100px; text-align: right; font-weight: 500; }

.product-card {
  background: #f8f9fa;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  border-color: var(--primary-color);
}

.product-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.product-price {
  color: var(--primary-color);
  font-weight: 500;
}

/* Receipt Preview Styles */
#receipt-container {
  flex: 1;
  min-width: 300px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  font-family: 'Courier New', Courier, monospace;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
}

.receipt-header h4 {
  text-align: center;
  margin: 0 0 10px 0;
  font-size: 1.2em;
  font-weight: bold;
}

.receipt-header p {
  text-align: center;
  font-size: 0.8em;
  margin: 0 0 5px 0;
  color: #666;
}

.receipt-body {
  flex: 1;
  margin: 15px 0;
  min-height: 150px;
}

.receipt-item-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9em;
}

.receipt-footer {
  border-top: 1px dashed #999;
  padding-top: 10px;
}

.receipt-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9em;
}

.receipt-row.total {
  font-weight: bold;
  font-size: 1em;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid #eee;
}

/* Ensure receipt is properly isolated from other elements */
#receipt-container * {
  font-family: 'Courier New', Courier, monospace;
}

/* Button Styles - Using existing Layout styles */
#newSaleModal .modal-footer {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  background: white;
  position: sticky;
  bottom: 0;
  z-index: 10;
  flex-wrap: wrap;
}

#clearSaleBtn, #checkoutBtn {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 120px;
  font-size: 16px;
}

#checkoutBtn {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
}

#clearSaleBtn {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(203, 213, 225, 0.6);
  color: var(--text-dark);
}

#checkoutBtn:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
  transform: translateY(-2px);
}

#clearSaleBtn:hover {
  background: white;
  border-color: var(--text-light);
}

/* Responsive receipt styles */
@media (max-width: 768px) {
  #receipt-container {
    padding: 15px;
    min-width: 100%;
  }
  
  .sale-item-row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .sale-item-name {
    font-size: 0.9em;
  }
  
  .sale-item-qty, .sale-item-total {
    font-size: 0.8em;
    margin-top: 4px;
  }
  
  /* Make receipt items stack vertically */
  .receipt-item-row {
    flex-direction: column;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
  }
  
  /* Adjust summary layout */
  .receipt-summary {
    gap: 10px;
  }
  
  /* Keep buttons adjacent on mobile */
  #newSaleModal .modal-footer {
    flex-direction: row; /* Keep buttons side-by-side */
    padding: 16px 20px;
  }
  
  #clearSaleBtn, #checkoutBtn {
    width: auto; /* Allow buttons to size naturally */
    margin-bottom: 0; /* Remove bottom margin since they're side-by-side */
    padding: 14px;
    font-size: 16px; /* Slightly smaller font to fit better */
    min-height: 46px; /* Smaller minimum height to fit better */
    min-width: 100px; /* Smaller minimum width */
  }
}

/* Print styles for better formatting */
@media print {
  #receipt-container {
    page-break-inside: avoid;
    break-inside: avoid;
    max-width: 100%;
    margin: 0;
    padding: 10px;
    box-shadow: none;
    border: none;
  }
  
  .receipt-item-row {
    font-size: 12px;
  }
  
  #receipt-items > div {
    page-break-inside: avoid;
    break-inside: avoid;
  }
  
  /* Ensure visibility during print operations */
  @media (max-width: 768px) {
    #receipt-container {
      visibility: visible !important;
      position: static !important;
      display: block !important;
    }
  }
}

/* Ensure all New Sale Modal elements are visible */
#newSaleModal .modal-body > div {
  display: flex !important;
  gap: 20px !important;
  flex-wrap: wrap !important;
  padding: 20px !important;
}

#newSaleModal .modal-body > div > div {
  flex: 1 !important;
  min-width: 280px !important;
}

/* Mobile-specific fixes for New Sale Modal */
@media (max-width: 768px) {
  #newSaleModal .modal-body > div {
    flex-direction: column !important;
    gap: 15px !important;
    padding: 15px !important;
  }
  
  #newSaleModal .modal-body > div > div {
    min-width: 100% !important;
  }
  
  #saleProductGrid {
    max-height: 250px !important;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
    gap: 10px !important;
  }
  
  .product-card {
    padding: 10px !important;
  }
  
  .product-name {
    font-size: 0.85rem !important;
  }
  
  .product-price {
    font-size: 0.8rem !important;
  }
  
  #receipt-container {
    min-width: 100% !important;
  }
}

/* Fix for content extending beyond touchable bounds on mobile */
@media (max-width: 768px) {
  #newSaleModal .modal-container {
    max-height: 90vh !important;
    overflow-y: auto !important;
  }
  
  #newSaleModal .modal-body {
    max-height: calc(90vh - 160px) !important; /* Reduced height to accommodate buttons */
    overflow-y: auto !important;
  }
  
  #saleProductGrid {
    max-height: 200px !important;
    overflow-y: auto !important;
  }
  
  #saleItemsList {
    max-height: 150px !important;
    overflow-y: auto !important;
  }
  
  #receipt-items {
    max-height: 200px !important;
    overflow-y: auto !important;
  }
  
  /* Ensure the modal doesn't extend beyond screen bounds */
  #newSaleModal {
    align-items: flex-start !important;
    padding-top: 5vh !important;
  }
  
  /* Ensure buttons are visible and accessible */
  #newSaleModal .modal-footer {
    position: sticky !important;
    bottom: 0 !important;
    background: white !important;
    padding: 16px !important;
    margin: 0 !important;
    z-index: 10 !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
    flex-direction: row; /* Keep buttons side-by-side */
  }
  
  #newSaleModal .modal-footer button {
    padding: 14px !important;
    font-size: 16px !important;
    min-height: 46px !important;
    min-width: 100px !important;
    margin-bottom: 0 !important;
  }
}

@media (max-width: 480px) {
  #newSaleModal .modal-container {
    width: 98% !important;
    margin: 1% !important;
    max-height: 95vh !important;
  }
  
  #newSaleModal .modal-body > div {
    padding: 10px !important;
  }
  
  #newSaleModal .modal-body {
    max-height: calc(95vh - 140px) !important; /* Adjusted for smaller screens */
  }
  
  #saleProductGrid {
    max-height: 180px !important;
  }
  
  #saleItemsList {
    max-height: 130px !important;
  }
  
  #receipt-items {
    max-height: 180px !important;
  }
  
  /* Ensure buttons are clearly visible on small screens */
  #newSaleModal .modal-footer {
    padding: 12px !important;
    flex-direction: row; /* Keep buttons side-by-side even on small screens */
  }
  
  #newSaleModal .modal-footer button {
    padding: 12px !important;
    font-size: 15px !important; /* Even smaller font for very small screens */
    min-height: 44px !important;
    min-width: 90px !important;
    margin-bottom: 0 !important;
  }
}