/* =========================================================
   MAIN GRID CSS
   Generic listing / table pages
   All classes prefixed with nb-grid-
   ========================================================= */

/* =========================================================
   MAIN CONTENT
   ========================================================= */

.nb-grid-content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
/* =========================================================
   TABLE SCROLL AREA
   ========================================================= */

.nb-grid-table-wrap {
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  border: 0;
  background: #ffffff;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nb-grid-skeleton {
  display: flex;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: #ffffff;
  overflow: auto;
}

.nb-grid-skeleton-header,
.nb-grid-skeleton-row {
  display: grid;
  min-width: max-content;
}

.nb-grid-skeleton-header {
  min-height: 34px;
  background: #eef1f4;
  border-bottom: 1px solid #d8dde3;
}

.nb-grid-skeleton-rows {
  display: flex;
  min-height: 0;
  flex: 1 0 auto;
  flex-direction: column;
}

.nb-grid-skeleton-row {
  flex: 1 0 40px;
  min-height: 40px;
  border-bottom: 1px solid #e1e5e9;
}

.nb-grid-skeleton-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  padding: 0 12px;
  border-right: 1px solid #e3e7ea;
}

.nb-grid-skeleton-cell:last-child {
  border-right: 0;
}

.nb-grid-skeleton-bar {
  display: block;
  width: 60%;
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, #e9edf0 25%, #f7f8f9 50%, #e9edf0 75%);
  background-size: 200% 100%;
  animation: nb-grid-skeleton-shimmer 1.5s ease-in-out infinite;
}

.nb-grid-skeleton-cell:nth-child(3n) .nb-grid-skeleton-bar {
  width: 42%;
}

.nb-grid-skeleton-cell:nth-child(4n) .nb-grid-skeleton-bar {
  width: 76%;
}

@keyframes nb-grid-skeleton-shimmer {
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nb-grid-skeleton-bar {
    animation: none;
  }
}

/* =========================================================
   TABLE
   ========================================================= */

.nb-grid-table {
  width: 100%;
  min-width: 100%;
  margin: 0 !important;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
  color: #4b5560;
  font-size: 11px;
}

/* =========================================================
   TABLE HEADER
   ========================================================= */

.nb-grid-table > thead > tr {
  background: #eef1f4;
}

.nb-grid-table > thead > tr > th {
  padding: 10px 14px !important;
  border-top: 0 !important;
  border-bottom: 1px solid #d8dde3 !important;
  border-right: 1px solid #dfe4e8 !important;
  background: #eef1f4 !important;
  color: #66727d;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}

.nb-grid-table > thead > tr > th:last-child {
  border-right: 0 !important;
}

/* =========================================================
   TABLE BODY
   ========================================================= */

.nb-grid-table > tbody > tr > td {
  padding: 8px 12px !important;
  border-top: 0 !important;
  border-bottom: 1px solid #e1e5e9 !important;
  border-right: 1px solid #e3e7ea !important;
  background: transparent !important;
  color: #4c5660;
  vertical-align: middle;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.nb-grid-table > tbody > tr > td:last-child {
  border-right: 0 !important;
}

/* =========================================================
   ALTERNATING ROW PATTERN
   ========================================================= */

/* Row 1, 3, 5, 7... */

.nb-grid-table > tbody > tr:nth-child(odd) {
  background: #ffffff;
}

/* Row 2, 4, 6, 8... */

.nb-grid-table > tbody > tr:nth-child(even) {
  background: #f4f7f7;
}

/* =========================================================
   ROW HOVER
   ========================================================= */

.nb-grid-table > tbody > tr {
  transition: background 0.15s ease;
}

.nb-grid-table > tbody > tr:hover {
  background: #f8efe7 !important;
}

.nb-grid-table > tbody > tr:hover > td {
  background: transparent !important;
}

/* =========================================================
   FIRST COLUMN
   ========================================================= */

.nb-grid-table > tbody > tr > td:first-child {
  color: #4a5560;

  font-weight: 600;
}

/* =========================================================
   LAST ROW
   ========================================================= */

.nb-grid-table > tbody > tr:last-child > td {
  border-bottom: 1px solid #e1e5e9 !important;
}

/* =========================================================
   EMPTY STATE
   ========================================================= */

.nb-grid-empty {
  display: flex;
  width: 100%;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
  color: #8b959e;
  text-align: center;
}

.nb-grid-empty p {
  margin: 0;
  font-size: 14px;
}

.nb-grid-empty-icon {
  color: #c4cbd1;
  font-size: 42px;
}

.nb-grid-empty-retry {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid #d1d8df;
  border-radius: 5px;
  background: #ffffff;
  color: #59646c;
  font-size: 12px;
  font-weight: 600;
}

.nb-grid-empty-retry:hover,
.nb-grid-empty-retry:focus {
  border-color: #f58220;
  color: #df6d0d;
}

.nb-grid-empty-retry:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.nb-grid-submit-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: nb-grid-submit-spin 0.7s linear infinite;
  vertical-align: -2px;
}

@keyframes nb-grid-submit-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nb-grid-submit-spinner {
    animation: none;
  }
}

.nb-grid-actions {
  white-space: nowrap;
  text-align: center;
}

.nb-grid-action {
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  padding: 4px 8px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nb-grid-action-view {
  color: #337ab7;
  font-weight: 600;
  position: relative;
}

.nb-grid-action-view[aria-busy='true'] {
  color: transparent;
}

.nb-grid-action-view .nb-grid-submit-spinner {
  position: absolute;
  top: calc(50% - 6.5px);
  left: calc(50% - 6.5px);
  margin: 0;
  color: #337ab7;
}

.nb-grid-action-edit {
  color: #5cb85c;
  font-weight: 600;
}

.nb-grid-action-delete {
  color: #d9534f;
  font-weight: 600;
}

.nb-grid-action:hover,
.nb-grid-action:focus {
  background: #ffffff;
}

.nb-grid-action-view:hover,
.nb-grid-action-view:focus {
  border-color: #337ab7;
}

.nb-grid-action-edit:hover,
.nb-grid-action-edit:focus {
  border-color: #5cb85c;
}

.nb-grid-action-delete:hover,
.nb-grid-action-delete:focus {
  border-color: #d9534f;
}

.nb-grid-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.nb-grid-modal-backdrop {
  position: fixed;
  z-index: 1100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31, 42, 51, 0.45);
  padding: 20px;
  overflow-y: auto;
}

.nb-grid-modal {
  width: min(100%, 440px);
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 12px 36px rgba(31, 42, 51, 0.22);
  padding: 24px;
}

.nb-party-form-modal {
  display: flex;
  width: min(100%, 440px);
  max-height: calc(100vh - 24px);
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.nb-party-modal-header,
.nb-party-modal-footer {
  flex: 0 0 auto;
  padding: 14px 18px;
  background: #fff;
}

.nb-party-modal-header {
  border-bottom: 1px solid #e1e5e9;
}

.nb-party-modal-header h3 {
  margin: 0;
}

.nb-party-modal-body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 18px;
}

.nb-party-modal-body .form-group:last-child {
  margin-bottom: 0;
}

.nb-party-modal-footer {
  border-top: 1px solid #e1e5e9;
}

.nb-master-form-modal {
  --nb-modal-body-height: clamp(250px, calc(100vh - 300px), 420px);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  padding: 0;
}

.nb-master-modal-header,
.nb-master-modal-footer {
  flex: 0 0 auto;
  padding: 14px 18px;
}

.nb-master-modal-header {
  border-bottom: 1px solid #e1e5e9;
}

.nb-master-modal-header h3 {
  margin: 0;
}

.nb-modal-body {
  flex: 0 0 var(--nb-modal-body-height);
  height: var(--nb-modal-body-height);
  min-height: var(--nb-modal-body-height);
  max-height: var(--nb-modal-body-height);
  overflow-y: auto;
  box-sizing: border-box;
}

.nb-master-form-modal .nb-modal-body {
  flex: 0 1 auto;
  height: auto;
  min-height: 0;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  padding: 14px 18px;
}

.nb-master-modal-footer {
  border-top: 1px solid #e1e5e9;
}

.nb-grid-modal h3 {
  margin: 0 0 10px;
  color: #2f3a42;
  font-size: 20px;
}

.nb-grid-modal p {
  color: #606b73;
}

.nb-modal-error-message {
  white-space: pre-line;
}

.nb-grid-modal-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 18px 0;
  border-top: 1px solid #e1e5e9;
  border-bottom: 1px solid #e1e5e9;
  padding: 10px 0;
}

.nb-grid-modal-details dt,
.nb-grid-modal-details dd {
  margin: 4px 0;
}

.nb-grid-modal-details dt {
  color: #7a858d;
  font-weight: 600;
}

.nb-grid-modal-details dd {
  color: #2f3a42;
  text-align: right;
}

.nb-grid-modal-actions {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
}

.nb-grid-modal-actions > .nb-grid-modal-cancel:not(:only-child),
.nb-grid-modal-actions > .nb-grid-modal-save:not(:only-child),
.nb-grid-modal-actions > .nb-grid-modal-delete:not(:only-child) {
  min-width: 0;
  min-height: 40px;
  flex: 1 1 0;
}

.nb-grid-modal-cancel,
.nb-grid-modal-save,
.nb-grid-modal-delete {
  border: 1px solid;
  border-radius: 3px;
  padding: 7px 14px;
}

.nb-grid-modal-cancel {
  border-color: #aab3ba;
  background: #ffffff;
  color: #59646c;
}

.nb-grid-modal-save {
  border-color: #f58220;
  background: #f58220;
  color: #ffffff;
}

.nb-grid-modal-save:hover,
.nb-grid-modal-save:focus {
  border-color: #df6d0d;
  background: #df6d0d;
  color: #ffffff;
}

.nb-grid-modal-delete {
  border-color: #d9534f;
  background: #d9534f;
  color: #ffffff;
}

/* Vendor edit modal */
.nb-vendor-modal {
  --nb-modal-body-height: clamp(320px, calc(100vh - 250px), 560px);
  display: flex;
  flex-direction: column;
  width: min(500px, 100%);
  max-height: min(92vh, 900px);
  padding: 0;
  overflow: hidden;
  border: 1px solid #cfd4d9;
  border-radius: 0;
}

.nb-vendor-modal-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 10px 16px;
  border-bottom: 1px solid #e1e5e9;
  background: #fff;
}

.nb-vendor-modal-header h3 {
  margin: 0;
  color: #657078;
  font-size: 22px;
  font-weight: 400;
}

.nb-vendor-modal-close {
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: #929292;
  font-size: 24px;
  line-height: 1;
}

.nb-vendor-modal-close:hover,
.nb-vendor-modal-close:focus {
  color: #f58220;
  outline: 0;
}

.nb-vendor-modal .nb-grid-tabs {
  display: flex;
  flex: 0 0 auto;
  padding: 0px;
  border-bottom: 1px solid #cfd4d9;
  background: #fff;
}

.nb-vendor-modal .nb-grid-tabs button {
  display: inline-flex;
  flex: 1 1 50%;
  min-height: 35px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 14px 6px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: #fff;
  color: #687279;
  font-size: 14px;
}

.nb-vendor-modal .nb-grid-tabs button i {
  font-size: 20px;
}

.nb-vendor-modal .nb-grid-tabs button.active {
  border-bottom-color: #f58220;
  background: #ebe2d9;
  color: #303a45;
  font-weight: 600;
}

.nb-vendor-modal-body {
  padding: 12px 16px;
  background: #fff;
}

.nb-master-modal-fields {
  /* display: grid; */
  /* grid-template-columns: repeat(2, minmax(0, 1fr)); */
  gap: 10px 12px;
}

.nb-master-modal-fields .form-group {
  min-width: 0;
  margin: 0 0 10px;
}

.nb-master-modal-fields .nb-master-modal-field-full {
  grid-column: 1 / -1;
}

.nb-master-modal-fields label {
  display: block;
  margin: 0 0 4px;
  color: #687279;
  font-size: 14px;
  font-weight: 400;
}

.nb-master-modal-fields .form-control {
  height: 40px;
  font-size: 14px;
}

.nb-master-modal-fields textarea.form-control {
  height: 80px;
  font-size: 14px;
}

.nb-master-modal-fields .nb-master-modal-field-full .form-control {
  min-height: 40px;
}

.nb-vendor-material-list {
  overflow: hidden;
  border: 1px solid #e6e9ed;
}

.nb-vendor-material-table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  table-layout: fixed;
  color: #687279;
  font-size: 12px;
}

.nb-vendor-material-table th,
.nb-vendor-material-table td {
  border-right: 1px solid #e6e9ed;
  border-bottom: 1px solid #e6e9ed;
  vertical-align: middle;
}

.nb-vendor-material-table th:last-child,
.nb-vendor-material-table td:last-child {
  border-right: 0;
}

.nb-vendor-material-table th {
  height: 40px;
  padding: 4px 8px;
  border-bottom: 1px solid #e6e9ed;
  color: #59636b;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.nb-vendor-material-table th:last-child,
.nb-vendor-material-table td:last-child {
  width: 150px;
}

.nb-vendor-material-table td {
  min-height: 40px;
  padding: 4px 8px;
}

.nb-vendor-material-table tr:last-child td {
  border-bottom: 0;
}

.nb-vendor-material-table label {
  margin: 0;
  color: #687279;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.nb-vendor-material-table input[type='checkbox'] {
  width: 20px;
  height: 20px;
  margin: 0 4px 0 0;
  accent-color: #2699ed;
  vertical-align: middle;
}

.nb-vendor-material-table .form-control {
  width: 100%;
  height: 35px;
  font-size: 12px;
}

.nb-vendor-material-empty {
  color: #8b959e;
  text-align: center;
}

.nb-vendor-modal-footer {
  flex: 0 0 auto;
  min-height: 58px;
  padding: 10px 16px;
  border-top: 1px solid #e1e5e9;
  background: #fff;
}

.nb-vendor-modal-footer .nb-grid-modal-save {
  min-height: 40px;
  border-radius: 6px;
  font-size: 14px;
}

@media (max-width: 640px) {
  .nb-grid-modal-backdrop {
    align-items: flex-start;
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }

  .nb-party-form-modal {
    width: 100%;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px);
    margin: auto 0;
  }

  .nb-party-modal-header,
  .nb-party-modal-footer {
    padding-right: 14px;
    padding-left: 14px;
  }

  .nb-party-modal-body {
    padding: 14px;
  }

  .nb-vendor-modal {
    max-height: calc(100vh - 16px);
  }

  .nb-master-form-modal {
    --nb-modal-body-height: clamp(220px, calc(100vh - 270px), 360px);
  }

  .nb-vendor-modal {
    --nb-modal-body-height: clamp(220px, calc(100vh - 210px), 460px);
  }

  .nb-vendor-modal-header h3 {
    font-size: 20px;
  }

  .nb-vendor-modal .nb-grid-tabs {
    padding: 0 14px;
  }

  .nb-vendor-modal .nb-grid-tabs button {
    flex: 1 1 50%;
    min-height: 42px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .nb-vendor-modal-body {
    padding: 16px 14px;
  }

  .nb-master-form-modal .nb-modal-body {
    padding: 16px 14px;
  }

  .nb-master-modal-fields {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .nb-master-modal-fields .form-group {
    grid-column: 1 / -1;
  }

  .nb-master-modal-fields .nb-master-modal-field-half,
  .nb-master-modal-fields .nb-master-modal-field-full {
    grid-column: 1 / -1;
  }

  .nb-master-modal-fields label {
    font-size: 14px;
  }

  .nb-master-modal-fields .form-control {
    height: 40px;
    font-size: 14px;
  }

  .nb-vendor-material-table th,
  .nb-vendor-material-table td {
    padding: 8px 10px;
  }

  .nb-vendor-material-table th:last-child,
  .nb-vendor-material-table td:last-child {
    width: 130px;
  }

  .nb-vendor-material-table th {
    height: 48px;
    font-size: 12px;
  }

  .nb-vendor-material-table label {
    font-size: 14px;
  }

  .nb-vendor-modal-footer {
    justify-content: flex-end;
    padding: 12px 14px;
  }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 767px) {
  .nb-grid-table-wrap:has(> .mobile-card) {
    overflow-x: hidden;
    overflow-y: auto;
    padding: 6px 8px;
    background: #f4f6f8;
  }

  .mobile-card {
    display: block;
    width: 100%;
    min-width: 0;
    background: transparent;
  }

  .mobile-card > thead {
    display: none;
  }

  .mobile-card > tbody {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .mobile-card > tbody > tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid #dfe5eb;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(31, 42, 51, 0.08);
  }

  .mobile-card-master > tbody > tr {
    grid-template-columns: minmax(0, 0.65fr) minmax(0, 1.35fr);
  }

  .mobile-card > tbody > tr:nth-child(even),
  .mobile-card > tbody > tr:hover {
    background: #fff !important;
  }

  .mobile-card > tbody > tr > td {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    padding: 6px 9px !important;
    border-right: 0 !important;
    border-bottom: 1px solid #edf0f2 !important;
    background: transparent !important;
    font-size: 13px;
    overflow-wrap: anywhere;
  }

  .mobile-card > tbody > tr > td::before {
    content: attr(data-label);
    margin-bottom: 2px;
    color: #7a858d;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.35px;
    text-transform: uppercase;
  }

  .mobile-card > tbody > tr > .mobile-card-wide,
  .mobile-card > tbody > tr > .nb-grid-actions {
    grid-column: 1 / -1;
  }

  .mobile-card > tbody > tr > .mobile-card-primary {
    color: #2f3a42;
    font-weight: 700;
  }

  .mobile-card > tbody > tr > .mobile-card-quotation-id {
    display: block;
  }

  .mobile-card > tbody > tr > .mobile-card-quotation-id::before {
    display: block;
  }

  .mobile-card-quotation-id-value {
    display: block;
    max-width: 100%;
    overflow: hidden;
    font-size: 12px;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
  }

  .mobile-card > tbody > tr > .nb-grid-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 7px 9px !important;
    border-bottom: 0 !important;
  }

  .mobile-card > tbody > tr > .nb-grid-actions::before {
    display: none;
  }

  .mobile-card .nb-grid-action {
    min-width: 0;
    min-height: 32px;
    padding: 4px 3px;
    border-radius: 4px;
    background: transparent;
    font-size: 12px;
  }

  .mobile-card .nb-grid-action-view {
    border-color: #b7cde0;
    color: #527fa5;
  }

  .mobile-card .nb-grid-action-edit {
    border-color: #bfd9c1;
    color: #5b9560;
  }

  .mobile-card .nb-grid-action-delete {
    border-color: #e2c0be;
    color: #b96c68;
  }

  .mobile-card .nb-grid-action-view:hover,
  .mobile-card .nb-grid-action-view:focus {
    background: #f3f7fa;
  }

  .mobile-card .nb-grid-action-edit:hover,
  .mobile-card .nb-grid-action-edit:focus {
    background: #f4f8f4;
  }

  .mobile-card .nb-grid-action-delete:hover,
  .mobile-card .nb-grid-action-delete:focus {
    background: #fbf5f4;
  }

  .mobile-card > tbody > tr > .nb-grid-actions:has(> .nb-grid-action:nth-child(2):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 359px) {
  .mobile-card > tbody > tr {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-card > tbody > tr > .mobile-card-wide,
  .mobile-card > tbody > tr > .nb-grid-actions {
    grid-column: 1;
  }

  .mobile-card > tbody > tr > .nb-grid-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-card > tbody > tr > .nb-grid-actions:has(> .nb-grid-action:nth-child(3)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* =========================================================
   PRINT
   ========================================================= */

@media print {
  .nb-grid-content {
    overflow: visible;
  }

  .nb-grid-table-wrap {
    overflow: visible;
  }

  .nb-grid-table {
    min-width: 100%;
  }

  .nb-grid-table > tbody > tr:nth-child(even) {
    background: #f4f6f8 !important;
  }
}
