:root {
  --primary-color: #044a78;
  --primary-dark: #03365a;
  --bs-primary: #044a78;
  --bs-primary-rgb: 4, 74, 120;
}

/* Bootstrap Theme Overrides */
.btn-primary {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background-color: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
}
.btn-outline-primary {
  color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
  background-color: var(--primary-color) !important;
  color: #fff !important;
}
.text-primary {
  color: var(--primary-color) !important;
}
.bg-primary {
  background-color: var(--primary-color) !important;
}

/* ================= GLOBAL SPINNER ================= */
#global-spinner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #f8f9fa; /* Matches .contain bg */
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
}

#global-spinner.hidden {
  display: none;
}

.spinner-circle {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(4, 74, 120, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spinner-spin 1s linear infinite;
}

@keyframes spinner-spin {
  to {
    transform: rotate(360deg);
  }
}
/* ================================================== */

/* =============== TABLE LOADING SPINNER =============== */
.table-spinner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(244, 246, 249, 0.7); /* match --bg lightly */
  z-index: 9999;
}
.table-spinner.hidden {
  display: none;
}
.table-spinner .spinner-circle {
  width: 50px;
  height: 50px;
}
/* When spinner is active, keep table hidden to avoid layout jumps */
.table-spinner:not(.hidden) + #master-table {
  opacity: 0;
  pointer-events: none;
}
#master-table {
  opacity: 1;
}
/* ===================================================== */

label,
[class^="span-"] {
  color: var(--primary-dark);
}

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: "poppins", sans-serif;
  text-wrap: none;
}

html {
  scroll-behavior: smooth;
  font-size: 12px; /* now 1rem = 14px */
}

nav {
  width: 100%;
  height: 38px;
  background-color: var(--primary-color);
  display: flex;
  justify-content: center;
  align-items: center;
}

nav h1 {
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  margin: 0;
}

.contain {
  min-width: 100%;
  width: auto;
  height: calc(100vh - 38px);
  background-color: #f8f9fa;
  display: flex;
  justify-content: start;
  align-items: stretch;
  /* padding: 1.4rem; */
}

.side-nav {
  width: 50px;
  min-width: 50px;
  height: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-direction: column;
  gap: 2px;
  background-color: var(--primary-color);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  padding: 4px;
  transition: none;
  overflow-y: auto;
}

/* Disable animation temporarily */
.no-transition {
  transition: none !important;
}

.nav-opt-wrap {
  width: 100%;
  background-color: rgba(4, 74, 120, 0.5);
  border-radius: 0.35rem;
}

.side-nav::-webkit-scrollbar {
  width: 4px;
}

.side-nav::-webkit-scrollbar-track {
  background: transparent;
}

.side-nav::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.35);
  border-radius: 8px;
}

.side-nav::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.55);
}

.side-nav:not(.nav-panel-toggle)::-webkit-scrollbar {
  width: 0;
}

.nav-panel-toggle {
  width: 175px;
}

.nav-items {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 3.5rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border-radius: 0.35rem;
  transition: none;
  padding: 12px;
  gap: 14px;
  margin: 0px 0px;
  cursor: pointer;
}

.side-nav:not(.nav-panel-toggle) .nav-opt-wrap {
  width: 40px;
  background-color: transparent;
  border: none;
}

.side-nav:not(.nav-panel-toggle) .nav-items {
  justify-content: center;
  gap: 0;
  padding: 0;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  height: 40px;
  margin: 3px 0;
}

.side-nav:not(.nav-panel-toggle) .nav-toggle {
  height: 40px;
  min-height: 40px;
}

.side-nav:not(.nav-panel-toggle) .nav-items i {
  width: 100%;
  text-align: center;
}

.side-nav:not(.nav-panel-toggle) .nav-items-para {
  display: none;
}

.nav-items:hover {
  background-color: #03365a;
}

.nav-toggle {
  background-color: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  height: 3.5rem;
  min-height: 3.5rem;
}

.nav-toggle:hover {
  background-color: rgba(255, 255, 255, 0.18);
}

.nav-items i {
  font-size: 16px;
  text-align: center;
}

.nav-items-para {
  color: white;
  font-size: 13px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-items-visible {
  display: block;
}

.main-content {
  height: 100%;
  flex: 1;
  min-width: 0;
  overflow: auto;
}

.main-content::-webkit-scrollbar {
  width: 4px;
  /* Without this the HORIZONTAL bar keeps the browser default (~15px, grey)
     while the vertical one is styled -- the two never matched on any page wide
     enough to scroll sideways. Same 4px as the vertical bar. */
  height: 4px;
}
.main-content::-webkit-scrollbar-track {
  background: transparent;
}
.main-content::-webkit-scrollbar-thumb {
  background-color: rgba(26, 26, 46, 0.75);
  border-radius: 6px;
}
.main-content::-webkit-scrollbar-thumb:hover {
  background-color: rgba(26, 26, 46, 0.9);
}
/* Firefox, which ignores every ::-webkit- rule above. Mirrors the table
   scrollbar's own Firefox block in tableDisp.css. */
.main-content {
  scrollbar-width: thin;
  scrollbar-color: rgba(26, 26, 46, 0.75) transparent;
}

/* The hand-rolled tables (.ap-table-wrap) scroll inside their own card rather
   than through Tabulator, so tableDisp.css's ".tabulator .tabulator-tableholder"
   scrollbar never reached them and they fell back to the browser default.
   Same tokens as that rule so a Tabulator table and an .ap-table look alike.
   Lives here, not in tableDisp.css, because two of the six pages that use this
   wrapper (itemView, salesOrderForm) don't load that stylesheet. */
.ap-table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.ap-table-wrap::-webkit-scrollbar-track {
  background: #f0f2f5;
}
.ap-table-wrap::-webkit-scrollbar-thumb {
  background: #044a78;
  border-radius: 6px;
}
.ap-table-wrap::-webkit-scrollbar-thumb:hover {
  background: #044a78;
}
.ap-table-wrap::-webkit-scrollbar-corner {
  background: #f0f2f5;
}
/* Firefox */
.ap-table-wrap {
  scrollbar-width: thin;
  scrollbar-color: #044a78 #f0f2f5;
}

form {
  width: 100%;
  display: grid;
  border: 2px solid var(--primary-color);
  border-radius: 0.5rem;
  grid-template-columns: repeat(32, 1fr);
  gap: 1rem;
  padding: 1rem;
}

.form-control {
  padding: 0.375rem 0.5rem;
}

select {
  width: 100%;
  height: 2.3rem;
  font-size: 1rem;
  appearance: none;
  border: 1.8px solid var(--primary-color);
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2rem;

  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23333' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 12px 8px;
  border-radius: 0.5rem;
  padding: 0.3rem 0.625rem;
  cursor: pointer;
}

.select-tag {
  border: 1.8px solid var(--primary-color);
}

.span-full {
  grid-column: span 32;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-half {
  grid-column: span 16;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-penta {
  grid-column: span 10;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-hexa {
  grid-column: span 12;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-dual {
  grid-column: span 8;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-two {
  grid-column: span 2;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-three {
  grid-column: span 3;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-four {
  grid-column: span 4;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-five {
  grid-column: span 5;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-six {
  grid-column: span 6;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-seven {
  grid-column: span 7;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-eight {
  grid-column: span 8;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-nine {
  grid-column: span 9;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-full input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-half input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-penta input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-hexa input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-dual input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-two input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-three input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-four input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-five input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-six input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-seven input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-eight input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.span-nine input {
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
}

.form-heading {
  border-radius: 0.5rem;
  padding: 0.5rem;
  color: white;
  background-color: var(--primary-color);
  font-size: 22px;
  justify-content: center;
  align-items: center;
}

.form-heading h1 {
  margin: 0;
  font-size: 22px;
}

.stock-header-label {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

.form-subheading {
  border-radius: 0.5rem;
  padding: 0.5rem 0.8rem;
  background-color: var(--primary-color);
  color: white;
  justify-content: flex-start;
  flex-direction: row;
  /* align-items: flex-start; */
}

.form-subheading h1 {
  margin: 0;
  font-size: 1.25rem;
}

.btn-grp {
  border: 2px solid var(--primary-color);
  justify-content: center;
  align-items: center;
  border-radius: 0.5rem;
  padding: 0.5rem;
  gap: 1.2rem;
}

.btn-grp button {
  width: 50%;
  height: 100%;
  /* color: var(--primary-color); */
  color: white;
  background-color: var(--primary-color);
  /* background-color: white; */
  font-size: 1.25rem;
  font-weight: 500;
  padding: 0.5rem 1.5rem;
  border: 2px solid var(--primary-color);
  border-radius: 0.5rem;
  outline: none;
  cursor: pointer;
  transition: all 0.3s ease-in-out;
}

.btn-grp button:hover {
  transform: scale(0.99);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.75);
  cursor: pointer;
}

.active {
  background-color: #03365a;
}

/* Navigaiton panel */

.nav-care-opt {
  width: 100%;
  /* background-color: tomato; */
  height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  transition: height 0.3s ease-in-out;
  margin: 0;
  border-radius: 0.5rem;
  display: block;
  position: static;
  /* background-color: tomato; */
}

.nav-labels-opt {
  width: 100%;
  /* padding: 0 0.2rem; */
  height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  transition: height 0.3s ease-in-out;
  border-radius: 0.5rem;
  display: block;
  position: static;
}

.nav-calc-opt {
  width: 100%;
  height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  transition: height 0.3s ease-in-out;
  border-radius: 0.5rem;
  display: block;
  position: static;
}

.nav-opt-height {
  height: 70px;
  transition: height 0.3s ease-in-out;
  /* border: 2px solid var(--primary-color); */
  border-radius: 0.5rem;
}

.nav-sl-height {
  height: 70px;
  transition: height 0.3s ease-in-out;
  /* border: 2px solid var(--primary-color); */
  border-radius: 0.5rem;
}

/* Remove the dropdown arrow from the datalist in Chrome, Edge, and Safari */
.input-tag[list]::-webkit-calendar-picker-indicator {
  display: none !important;
  -webkit-appearance: none;
}

/* Remove the dropdown arrow from the datalist in Firefox */
.input-tag[list]::-moz-list-dropdown {
  display: none;
}

/* To hide the arrow buttons in number inputs */
.input-tag[type="number"]::-webkit-outer-spin-button,
.input-tag[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Give readonly fields a distinct shade so they're visually identifiable as non-editable */
.input-tag[readonly],
.form-control[readonly] {
  background-color: #eef1f5;
  color: #64748b;
  cursor: not-allowed;
}

/* Main wrapper styling */
.choices {
  width: 100%;
}

/* Control styling */
.choices__inner {
  width: 100%;
  /* height: 2.5rem; */
  border-radius: 0.5rem;
  border: 1px solid black !important;
  /* padding: 0.4rem 0.6rem; */
  padding: 0;
  font-size: 1rem;
  min-height: 0;
}

.choices__list--single {
  padding: 0.375rem 0.5rem;
}

.choices[data-type*="select-one"] .choices__inner {
  padding-bottom: 0;
}

/* Show blinking caret even after selection */
.choices__input {
  caret-color: black;
}

/* Remove dropdown arrow */
.choices[data-type*="select-one"]::after {
  display: none !important;
}

/* Focus ring for Choices.js dropdowns (tab navigation) */
.choices.choices--focused .choices__inner,
.choices:focus-within .choices__inner,
.choices:focus .choices__inner,
.choices.is-focused .choices__inner,
.choices.is-open .choices__inner {
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 3px rgba(4, 74, 120, 0.25) !important;
  transition:
    box-shadow 0.15s ease-in-out,
    border-color 0.15s ease-in-out;
}

/* Allow box-shadow to be visible (not clipped by overflow:hidden) */
.choices.choices--focused,
.choices:focus,
.choices:focus-within {
  overflow: visible !important;
}

/* Ensure the choices container itself shows focus */
.choices:focus {
  outline: none !important;
}

.clientName-label {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-right: 0.2rem;
}

/* Hide arrows in Chrome, Safari, Edge */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Location counter should stay plain, without Bootstrap valid-state ticks */
#locations-count,
#locations-count:valid,
#locations-count:invalid,
#locations-count.is-valid,
#locations-count.is-invalid,
.was-validated #locations-count:valid,
.was-validated #locations-count:invalid {
  background-image: none !important;
  background-position: initial !important;
  background-repeat: no-repeat !important;
  background-size: auto !important;
  padding-right: 0.75rem !important;
}

/* span vertically for specific fields */
.span-row-2 {
  grid-row: span 2;
}

/* ================= RESPONSIVE BREAKPOINTS ================= */

/* Tablet: 769px — 1024px */
@media screen and (max-width: 1024px) {
  .span-two,
  .span-three,
  .span-four,
  .span-five,
  .span-six,
  .span-seven,
  .span-eight,
  .span-nine,
  .span-dual,
  .span-penta,
  .span-hexa {
    grid-column: span 16;
  }

  .contain {
    height: 100vh;
  }

  .contain {
    height: 100vh;
  }

  .btn-grp button {
    width: 100%;
    font-size: 1.1rem;
  }
}

/* Mobile: ≤768px */
@media screen and (max-width: 768px) {
  form {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .span-full,
  .span-half,
  .span-two,
  .span-three,
  .span-four,
  .span-five,
  .span-six,
  .span-seven,
  .span-eight,
  .span-nine,
  .span-dual,
  .span-penta,
  .span-hexa {
    grid-column: span 1;
  }

  .main-content {
    padding: 0.5rem;
  }

  .side-nav {
    width: 140px !important; /* Even narrower on tiny screens */
    min-width: 140px !important;
  }

  .contain {
    height: 100vh;
  }

  nav h1 {
    font-size: 1.2rem;
  }

  .form-heading h1 {
    font-size: 18px;
  }

  .form-subheading h1 {
    font-size: 1rem;
  }

  .btn-grp {
    flex-direction: column !important;
  }

  .btn-grp button {
    width: 100%;
    font-size: 1rem;
  }
}
