/* Keep toastr default colors even when Bootstrap dark theme toast styles are active */
#toast-container > .toast-success,
html[data-bs-theme="dark"] #toast-container > .toast-success {
  background-color: #51a351 !important;
  color: #fff !important;
}

#toast-container > .toast-error,
html[data-bs-theme="dark"] #toast-container > .toast-error {
  background-color: #bd362f !important;
  color: #fff !important;
}

#toast-container > .toast-info,
html[data-bs-theme="dark"] #toast-container > .toast-info {
  background-color: #2f96b4 !important;
  color: #fff !important;
}

#toast-container > .toast-warning,
html[data-bs-theme="dark"] #toast-container > .toast-warning {
  background-color: #f89406 !important;
  color: #fff !important;
}

.admin-topbar {
  position: fixed;
  top: 0.75rem;
  right: 1rem;
  left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0;
  z-index: 1600;
  pointer-events: auto;
}

.admin-topbar,
html[data-bs-theme="dark"] .admin-topbar,
html[data-bs-theme="light"] .admin-topbar {
  background: transparent !important;
  color: var(--bs-body-color) !important;
}

.admin-topbar__menu {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  width: auto;
  margin-left: 0;
  pointer-events: auto;
  background: var(--bs-body-bg);

  margin: 0.5rem;
}

#main > header {
  position: relative;
  z-index: 1061;
}

#main .burger-btn {
  position: relative;
  z-index: 1062;
  display: inline-flex;
  align-items: center;
}

@media screen and (max-width: 1199.98px) {
  #sidebar.active .sidebar-wrapper {
    z-index: 2000 !important;
  }

  .sidebar-backdrop {
    z-index: 1999 !important;
  }

  #sidebar.active ~ #main .burger-btn {
    display: none !important;
  }
}

.admin-topbar__track-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.admin-topbar__track-input {
  width: 260px;
  max-width: 260px;
  min-width: 0;
}

.admin-topbar__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 12px !important;
  background: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

.admin-topbar__toggle:hover,
.admin-topbar__toggle:focus,
html[data-bs-theme="dark"] .admin-topbar__toggle:hover,
html[data-bs-theme="dark"] .admin-topbar__toggle:focus {
  background: var(--bs-secondary-bg) !important;
  color: var(--bs-body-color) !important;
  border-color: var(--bs-primary) !important;
}

.admin-topbar__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: #2563eb;
  color: #ffffff;
  flex: 0 0 auto;
}

.admin-topbar__name {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.admin-topbar__dropdown {
  z-index: 1601 !important;
  background: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
  border: 1px solid var(--bs-border-color);
  border-radius: 12px !important;
  box-shadow: 0 12px 32px rgba(15, 15, 21, 0.12);
  overflow: hidden;
}

.admin-topbar__dropdown-track-section {
  min-width: min(280px, calc(100vw - 2rem));
}

.admin-topbar__track-form--dropdown {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.admin-topbar__track-form--dropdown .admin-topbar__track-input {
  width: 100%;
  max-width: 100%;
}

.admin-topbar__track-form--dropdown .btn {
  white-space: nowrap;
  flex: 0 0 auto;
}

.admin-topbar__track-form--desktop-dashboard .admin-topbar__track-input {
  width: clamp(170px, 22vw, 260px);
}

.admin-topbar__track-form--desktop-dashboard .btn {
  white-space: nowrap;
  flex: 0 0 auto;
}

.admin-topbar__track-form--desktop-dashboard {
  display: none;
}

.admin-topbar__dropdown-track-section--mobile-only {
  display: none;
}

@media screen and (min-width: 1200px) {
  .admin-topbar {
    left: auto;
    right: 1rem;
  }

  .admin-topbar__track-form--desktop-dashboard {
    display: inline-flex;
  }
}

@media screen and (max-width: 1199.98px) {
  .admin-topbar__dropdown-track-section--mobile-only {
    display: block;
  }

  .admin-topbar__track-form--desktop-dashboard {
    display: none !important;
  }

  .admin-topbar {
    left: 4rem;
    right: 0.5rem;
    top: 0.5rem;
  }

  .admin-topbar__menu {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
    /* padding: 0.5rem; */
  }

  .admin-topbar__track-form--dropdown {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
  }

  .admin-topbar__track-input {
    width: 100%;
    max-width: 100%;
  }

  .admin-topbar__toggle {
    width: 100%;
    min-height: 44px;
    justify-content: space-between;
  }
}

@media screen and (max-width: 420px) {
  .admin-topbar__track-form--dropdown {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-topbar__track-form--dropdown .btn {
    width: 100%;
  }
}

table th,
table td {
  white-space: nowrap;
}

/* Make Select2 follow active Bootstrap theme colors instead of fixed white */
.select2-container--bootstrap-5 .select2-selection,
.select2-container--bootstrap-5 .select2-dropdown,
.select2-container--bootstrap-5
  .select2-dropdown
  .select2-search
  .select2-search__field {
  background-color: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
  border-color: var(--bs-border-color) !important;
}

.select2-container--bootstrap-5
  .select2-selection--single
  .select2-selection__rendered,
.select2-container--bootstrap-5
  .select2-selection--multiple
  .select2-selection__rendered,
.select2-container--bootstrap-5 .select2-results__option,
.select2-container--bootstrap-5
  .select2-search--dropdown
  .select2-search__field,
.select2-container--bootstrap-5 .select2-search--inline .select2-search__field {
  color: var(--bs-body-color) !important;
}

.select2-container--bootstrap-5
  .select2-results__option.select2-results__option--highlighted {
  background-color: var(--bs-secondary-bg) !important;
  color: var(--bs-body-color) !important;
}

.select2-container--bootstrap-5 .select2-results__option[aria-selected="true"] {
  background-color: var(--bs-tertiary-bg) !important;
}

.select2-container--bootstrap-5 .select2-selection__placeholder,
.select2-container--bootstrap-5
  .select2-results__option.select2-results__message {
  color: var(--bs-secondary-color) !important;
}

html[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
html[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown,
html[data-bs-theme="dark"]
  .select2-container--bootstrap-5
  .select2-dropdown
  .select2-search
  .select2-search__field,
html[data-bs-theme="dark"]
  .select2-container--bootstrap-5
  .select2-results__option,
html[data-bs-theme="dark"]
  .select2-container--bootstrap-5
  .select2-results__option.select2-results__option--highlighted,
html[data-bs-theme="dark"]
  .select2-container--bootstrap-5
  .select2-results__option[aria-selected="true"] {
  background-color: rgb(27, 27, 40) !important;
}


/* fixed height for selected container div */
#products_container {
  min-height: 300px;
}

#products_container .selected-product-label {
  min-height: calc(1.5em + 0.75rem + 2px);
  display: flex;
  align-items: center;
}

/* Remove browser stepper controls on POS quantity input for cleaner spacing */
#sales_form .product-quantity,
#sales_form .product-discount {
  -moz-appearance: textfield;
  appearance: textfield;
}

#sales_form .product-quantity::-webkit-outer-spin-button,
#sales_form .product-quantity::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#sales_form .product-discount::-webkit-outer-spin-button,
#sales_form .product-discount::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#sales_form .product-item .form-label {
  font-weight: 700;
}

html[data-bs-theme="light"] #sales_form .product-item .form-label {
  color: #dc3545;
}

html[data-bs-theme="dark"] #sales_form .product-item .form-label {
  color: #dc3545;
}

/* Match .form-control / .btn row height and full column width (pos line items) */
#products_container .pos-item-total-field.badge.item-total {
  --bs-badge-padding-x: 0.75rem;
  --bs-badge-padding-y: 0.375rem;
  --bs-badge-font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: calc(1.5em + 0.75rem + 2px);
  font-weight: 400;
  line-height: 1.5;
  box-sizing: border-box;
}
