/* General reset for cross-browser consistency */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Roboto', sans-serif;
}

body {
  font-family: 'Roboto', sans-serif;
  background-color: #f5f5f5;
  color: #333;
}

header, footer {
  text-align: center;
  padding: 20px;
  background-color: #333;
  color: #fff;
}

header {
  position: sticky;
  top: 10px;
  z-index: 1000; /* Ensures the header stays above other elements */
  background-color: #333;
  color: #fff;
  padding: 20px 20px 10px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}


h1, h2 {
  margin-bottom: 15px;
}

section {
  width: 90%;
  max-width: 1000px;
  margin: auto;
  background: #fff;
  padding: 20px 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
}

/* Form styling */
form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Label styling */
label {
  font-weight: 500;
  color: #555;
  margin-bottom: 5px;
}

/* Input styling */
input[type="text"], input[type="date"], select, textarea {
  padding: 10px 15px;
  font-size: 1rem;
  border: none;
  border-bottom: 1px solid #ddd;
  border-radius: 0;
  width: 100%;
  transition: border-color 0.3s, box-shadow 0.3s;
  background-color: transparent;
}

input[type="text"]:focus, input[type="date"]:focus, select:focus, textarea:focus {
  border-color: #007bff;
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
  outline: none;
}

/* Button styling */
button {
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  background-color: #007bff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.1s;
  align-self: flex-start;
  margin-top: 10px;
}

button:hover {
  background-color: #0056b3;
}

button:active {
  transform: scale(0.98);
}

/* Product table layout */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

table tbody {
  width: 100%;
}

table tr {
  display: table-row; /* Set default display to table-row */
  border-bottom: 1px solid #ddd; /* Line between rows */
}

table td {
  padding: 10px;
  vertical-align: middle;
  border: none; /* Remove borders around cells */
  white-space: nowrap; /* Prevent text from wrapping */
  overflow: hidden;
  text-overflow: ellipsis; /* Show ellipsis for overflowing text */
}

/* Align Qty field and buttons */
table td input[name*="quantity_"] {
  width: calc(70% - 10px); /* Adjust width for buttons */
  display: inline-block;
  margin-right: 10px;
}

/* Quantity container to hold the input and buttons */
.quantity-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Action buttons styling */
.action-buttons {
  display: inline-flex; /* Align buttons inline with the Qty field */
  gap: 5px;
  vertical-align: middle;
}

.action-buttons button {
  font-size: 14px;
  padding: 8px 12px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.1s;
}

.action-buttons button:hover {
  background-color: #0056b3;
}

.action-buttons button:active {
  transform: scale(0.98);
}

/* Category Section Styling */
.category-section {
  border: none;
  padding: 10px;
  margin-bottom: 10px;
  background-color: #f9f9f9;
}

.category-section h3 {
  display: flex;
  align-items: center;
  gap: 10px; /* Add space between the arrow and the name */
  font-size: 1.2em;
  background-color: #e9ecef;
  padding: 10px;
  border-radius: 5px;
}

.toggle-arrow {
  cursor: pointer;
  font-size: 1.2em;
  color: #007bff;
  transition: transform 0.2s ease; /* Smooth transition for arrow rotation */
}

.category-fields {
  margin-top: 10px;
  display: block; /* Default to visible */
}

.toggle-arrow:hover {
  color: #0056b3;
}

.category-name {
  flex-grow: 1;
  text-align: left;
}

.not-applicable-checkbox {
  margin-top: 10px;
  display: block;
}

/* Billing and Shipping Sections */
.section {
  border: 1px solid #ddd;
  border-radius: 5px;
  margin-bottom: 15px;
  background-color: #f9f9f9;
  padding: 15px;
}

.section h4 {
  padding: 10px;
  cursor: pointer;
  font-size: 1.2em;
  background-color: #f1f1f1;
  border-bottom: 1px solid #ddd;
  border-radius: 5px;
}

.section-content {
  display: none;
  padding: 15px;
}

.dropdown-arrow {
  cursor: pointer;
  font-size: 1em;
  margin-right: 8px;
  color: #007bff;
}

.dropdown-arrow:hover {
  color: #0056b3;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  h1, h2 {
    font-size: 1.5rem;
  }

  form {
    gap: 15px;
  }

  label, input, select, textarea, button {
    width: 100%;
  }

  /* Adjust table columns for mobile */
  table {
    display: block;
    width: 100%;
  }

  table tbody {
    display: block;
  }

  table tr {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px; /* Add spacing between rows for better UX on mobile */
  }

  table td {
    display: block;
    width: 100%; /* Each field takes the full width on mobile */
    padding: 8px 0;
  }

  .quantity-container {
    flex-direction: column;
    gap: 5px;
    width: 100%;
  }

  .action-buttons {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
  }

  .category-section {
    padding: 15px;
    margin-bottom: 15px;
  }

  .category-section h3 {
    font-size: 1.5em;
    padding: 15px;
  }

  .section {
    padding: 20px;
  }

  .form-section {
    padding: 20px;
    background-color: #e9ecef;
    border-radius: 8px;
    margin-bottom: 20px;
  }

  .form-section h2 {
    font-size: 1.5em;
    margin-bottom: 10px;
  }

  .currency-filter {
    width: 50%;
  }
}

@media (max-width: 480px) {
  /* Further stack fields for smaller screens */
  table td {
    font-size: 0.85rem;
    padding: 8px;
  }

  .action-buttons {
    flex-direction: row;
    width: 100%;
  }

  .action-buttons button {
    width: calc(50% - 5px);
  }
}

/* Button Group Styling for Add/Remove Buttons */
.button-group button {
  min-width: 40px;
  height: 40px;
  line-height: 1;
}

.button-group button:hover {
  background-color: #0056b3;
}

.button-group button:active {
  transform: scale(0.95);
}

/* Improved form section styling for better readability */
.form-section {
  margin-bottom: 20px;
  padding: 20px;
  background-color: #e9ecef;
  border-radius: 8px;
}

.form-section h2 {
  margin-bottom: 10px;
  font-size: 1.6em;
  color: #007bff;
}

.form-section .notes {
  margin-top: 15px;
  font-size: 1rem;
  color: #555;
}

.currency-filter {
  width: 50%;
  margin-top: 10px;
}

.currency-filter label {
  font-weight: 500;
  color: #555;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  color: #555;
}

.currency-filter {
  width: 50%; /* Or any appropriate width */
  margin-top: 10px; /* Adjust as needed for spacing */

  .button-toggle-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
  }
  
  .button-toggle {
    padding: 10px 20px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
  }
  
  .button-toggle.active {
    background-color: #0056b3;
    font-weight: bold;
  }
  
  .button-toggle:hover {
    background-color: #0056b3;
  }
  

  .not-applicable-btn {
    padding: 8px 12px;
    font-size: 1rem;
    background-color: #e9ecef; /* Default grey background */
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
  }
  
  .not-applicable-btn.selected {
    background-color: #ff4d4d; /* Red background when selected */
    color: #fff; /* White text when selected */
  }
  
  .not-applicable-btn:hover {
    background-color: #ff9999; /* Lighter red on hover */
  }
  
}

/* Product table styling */
.product-table {
    width: 100%;
    margin-bottom: 1rem;
}

.product-table th,
.product-table td {
    padding: 0.5rem;
    vertical-align: middle;
}

/* Column widths */
.product-table .product-select {
    width: 20%;
    min-width: 150px;
}

/* Specific styling for product table dropdowns */
.product-table .product-select {
    height: auto;
    min-height: 38px;
    line-height: 1.4;
    /* Ensure dropdown can expand to show full content */
    max-height: none;
}

.product-table .product-select option {
    /* Override any default browser styling */
    height: auto !important;
    min-height: 2.5em !important;
    line-height: 1.4 !important;
    padding: 8px 12px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    /* Ensure text is fully visible */
    text-overflow: unset !important;
    overflow: visible !important;
    /* Better readability for long descriptions */
    font-size: 14px !important;
}

/* Ensure the dropdown list itself can expand */
.product-table .product-select:focus {
    /* Allow dropdown to expand beyond normal bounds */
    overflow: visible;
}

.product-table .description-col {
    width: 40%;
    min-width: 200px;
}

.product-table .price-col {
    width: 15%;
    min-width: 100px;
    white-space: nowrap;
}

.product-table .quantity-col {
    width: 10%;
    min-width: 80px;
}

/* Quantity input styling */
.quantity-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 120px;
}

.quantity-input {
    width: 60px !important;
    text-align: center;
}

/* Price formatting */
.price-display {
    position: relative;
    padding-left: 1rem;
}

.price-display::before {
    content: attr(data-currency);
    position: absolute;
    left: 0;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 0.25rem;
}

.add-button,
.remove-button {
    padding: 0.25rem 0.5rem;
    min-width: 30px;
}

/* General form-select styling for all dropdowns */
.form-select {
    height: auto;
    min-height: 38px;
    line-height: 1.4;
}

.form-select option {
    height: auto;
    min-height: 2.5em;
    line-height: 1.4;
    padding: 8px 12px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Browser-specific fixes for all dropdowns */
.form-select option {
    /* Firefox */
    -moz-appearance: none;
    /* Webkit browsers */
    -webkit-appearance: none;
    /* Ensure proper text wrapping */
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Mobile-specific dropdown improvements */
@media (max-width: 768px) {
    .form-select option,
    .product-table .product-select option {
        min-height: 3em;
        padding: 12px 16px;
        font-size: 16px;
    }
}
  
/* Force dropdown options to be fully visible */
select:focus option,
select:hover option {
    height: auto !important;
    min-height: 3em !important;
    max-height: none !important;
    overflow: visible !important;
    text-overflow: unset !important;
}

/* Additional aggressive fixes for all select elements */
select option {
    height: auto !important;
    min-height: 3em !important;
    max-height: none !important;
    line-height: 1.5 !important;
    padding: 10px 15px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    text-overflow: unset !important;
    overflow: visible !important;
    /* Force complete display */
    display: block !important;
    position: relative !important;
    /* Ensure text is not clipped */
    clip: auto !important;
    clip-path: none !important;
}

/* Override any framework or browser defaults */
* select option {
    height: auto !important;
    min-height: 3em !important;
    max-height: none !important;
    overflow: visible !important;
    text-overflow: unset !important;
}

/* Specific fix for product dropdowns */
.product-select option,
.form-select option {
    height: auto !important;
    min-height: 3em !important;
    max-height: none !important;
    line-height: 1.5 !important;
    padding: 10px 15px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    text-overflow: unset !important;
    overflow: visible !important;
    /* Force text to display completely */
    display: block !important;
    position: relative !important;
    /* Ensure text is not clipped */
    clip: auto !important;
    clip-path: none !important;
}
  