/* ─── Workflow steps strip ───────────────────────────────────────────────── */
.workflow-steps {
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border: 1px solid #e2e5ea;
  border-radius: 10px;
  padding: 18px 32px;
  margin-bottom: 20px;
}

.wf-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  position: relative;

  &:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 18px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: #dde1e7;
    z-index: 0;
  }

  &.done::after {
    background: #0a6b6b;
  }

  &.active::after {
    background: #c9a227;
  }
}

.wf-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #dde1e7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  color: #7a8394;
  z-index: 1;
  position: relative;

  .wf-step.done & {
    background: #0a6b6b;
    border-color: #0a6b6b;
    color: #fff;
  }

  .wf-step.active & {
    border-color: #c9a227;
    color: #c9a227;
    font-weight: 700;
  }
}

.wf-label {
  font-size: 11.5px;
  font-weight: 500;
  color: #7a8394;

  .wf-step.done & {
    color: #0a6b6b;
  }

  .wf-step.active & {
    color: #c9a227;
  }
}

/* ─── Form card ──────────────────────────────────────────────────────────── */
.form-card {
  background: #fff;
  border: 1px solid #e2e5ea;
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}

.fsc-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid #e2e5ea;
  background: #fafbfc;
}

.fsc-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1a2332;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.fsc-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a2332;
}

.fsc-sub {
  margin-left: auto;
  font-size: 12px;
  color: #7a8394;
}

.fsc-body {
  padding: 18px 20px;
}

/* ─── Grid rows ──────────────────────────────────────────────────────────── */
.form-row {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;

  &.c4 {
    grid-template-columns: repeat(4, 1fr);
  }

  &.c3 {
    grid-template-columns: repeat(3, 1fr);
  }

  &.c2 {
    grid-template-columns: repeat(2, 1fr);
  }

  &:last-child {
    margin-bottom: 0;
  }
}

/* ─── Form group / label ─────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: #3d4a5c;
}

.req {
  color: #d9363e;
}

/* ─── Inputs / selects ───────────────────────────────────────────────────── */
.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dde1e7;
  border-radius: 6px;
  font-size: 13px;
  color: #1a2332;
  background: #fff;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;

  &:focus {
    border-color: #0a6b6b;
    box-shadow: 0 0 0 3px rgba(10, 107, 107, 0.08);
  }
}

.input-ro {
  background: #f4f5f7;
  color: #5a6476;
  cursor: default;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a8394' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.textarea {
  resize: vertical;
  min-height: 80px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-secondary {
  background: #fff;
  border: 1px solid #dde1e7;
  color: #3d4a5c;

  &:hover {
    background: #f4f5f7;
  }
}

.btn-ghost {
  background: transparent;
  color: #0a6b6b;

  &:hover {
    background: rgba(10, 107, 107, 0.06);
  }
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ─── Lot chips ──────────────────────────────────────────────────────────── */
.lots-display {
  min-height: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.lot-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e8eaed;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  color: #3d4a5c;
}

.lot-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #7a8394;
  font-size: 12px;
  line-height: 1;
  padding: 0;
}

/* ─── Source selector ────────────────────────────────────────────────────── */
.src-selector {
  border: 1px solid #e2e5ea;
  border-radius: 8px;
  overflow: hidden;
  margin: 14px;
}

.src-type-tabs {
  display: flex;
  border-bottom: 1px solid #e2e5ea;
  background: #f4f5f7;
}

.src-tab {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  color: #7a8394;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;

  &.active {
    color: #1a2332;
    border-bottom-color: #c9a227;
  }

  &:hover:not(.active) {
    color: #3d4a5c;
  }
}

.src-tab-panel {
  display: block;
  padding: 14px;
}

.src-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e2e5ea;
  border-radius: 7px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;

  &:hover {
    border-color: #0a6b6b;
    background: rgba(10, 107, 107, 0.03);
  }

  &.selected {
    border-color: #0a6b6b;
    border-left: 3px solid #0a6b6b;
    background: rgba(10, 107, 107, 0.04);
  }

  input[type="checkbox"] {
    flex-shrink: 0;
    cursor: pointer;
  }
}

.src-icon {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;

  &.src-icon--chem {
    background: #fef3cd;
    color: #856404;
  }

  &.src-icon--mech {
    background: #fde8e8;
    color: #9b1c1c;
  }

  &.src-icon--ndt {
    background: #dbeafe;
    color: #1e40af;
  }

  &.src-icon--insp {
    background: #dcfce7;
    color: #166534;
  }

  &.src-icon--vis {
    background: #d1faf7;
    color: #0a6b6b;
  }
}

.src-info {
  flex: 1;
  min-width: 0;
}

.src-title {
  font-size: 13px;
  font-weight: 500;
  color: #1a2332;
}

.src-meta {
  font-size: 11.5px;
  color: #7a8394;
  margin-top: 2px;
}

.src-result {
  flex-shrink: 0;
}

.src-footer {
  padding: 10px 14px;
  border-top: 1px solid #e2e5ea;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── Badge ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
}

.b-pass {
  background: #dcfce7;
  color: #166534;
}

.b-fail {
  background: #fde8e8;
  color: #9b1c1c;
}

/* ─── Alert ──────────────────────────────────────────────────────────────── */
.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: #1e40af;
}

/* ─── Preferences ────────────────────────────────────────────────────────── */
.pref-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pref-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid #e2e5ea;
  border-radius: 6px;
  font-size: 12.5px;
  color: #3d4a5c;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;

  input {
    opacity: 0;
    width: 0;
    height: 0;
  }
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #c4c9d4;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;

  &::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
  }
}

.toggle-switch input:checked+.toggle-slider {
  background: #0a6b6b;
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(16px);
}

/* ─── Chemistry column picker ────────────────────────────────────────────── */
.column-select {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.col-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid #e2e5ea;
  border-radius: 5px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s;

  input {
    flex-shrink: 0;
    cursor: pointer;
  }

  &.selected {
    border-color: #0a6b6b;
    background: rgba(10, 107, 107, 0.06);
    color: #0a6b6b;
  }
}

/* ─── Utility ────────────────────────────────────────────────────────────── */
.text-sm {
  font-size: 12px;
}

.text-muted {
  color: #7a8394;
}

.lots-display {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.lot-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;

  &:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
  }

  &.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
  }

  .lot-chip-qty {
    opacity: 0.75;
    font-size: 11px;
  }
}

::ng-deep .pref-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

::ng-deep .pref-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  color: #374151;

  span {
    font-weight: 500;
  }
}

::ng-deep .toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;

  input {
    opacity: 0;
    width: 0;
    height: 0;
  }
}

::ng-deep .toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  /* OFF colour — grey */
  border-radius: 34px;
  transition: background-color 0.2s;

  &::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
  }
}

::ng-deep .toggle-switch input:checked+.toggle-slider {
  background-color: var(--button-primary-bg-default);
  /* ON colour — teal/green like Image 2 */
}

::ng-deep .toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(20px);
}


@media screen and (max-width: 1024px) {

  .FormOverView {
    overflow-x: hidden;
  }

  .workflow-steps {
    padding: 14px 16px;
    flex-wrap: wrap;
    row-gap: 14px;
  }

  .wf-label {
    font-size: 10.5px;
  }

  .form-row {
    &.c4 {
      grid-template-columns: repeat(2, 1fr);
    }

    &.c3 {
      grid-template-columns: repeat(2, 1fr);
    }

    &.c2 {
      grid-template-columns: 1fr;
    }
  }

  .fsc-hdr {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .fsc-sub {
    margin-left: 0;
    flex-basis: 100%;
  }

  .pref-grid {
    grid-template-columns: 1fr;
  }

  ::ng-deep .pref-grid {
    grid-template-columns: 1fr;
  }

  .column-select {
    grid-template-columns: repeat(3, 1fr);
  }

  .src-type-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .src-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .src-item {
    flex-wrap: wrap;
  }

  .src-result {
    margin-left: 50px;
  }

  .src-footer {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  ::ng-deep gb-formgrid {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media screen and (max-width: 768px) {

  .workflow-steps {
    padding: 12px;
    gap: 10px;
  }

  .wf-step {
    &:not(:last-child)::after {
      top: 15px;
    }
  }

  .wf-circle {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .wf-label {
    font-size: 9.5px;
    text-align: center;
  }

  .form-card {
    margin-bottom: 12px;
  }

  .fsc-hdr {
    padding: 12px 14px;
  }

  .fsc-num {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .fsc-title {
    font-size: 13px;
  }

  .fsc-sub {
    font-size: 11px;
  }

  .fsc-body {
    padding: 14px 12px;
  }

  .form-row {
    row-gap: 12px;
    margin-bottom: 12px;

    &.c4,
    &.c3,
    &.c2 {
      grid-template-columns: 1fr;
    }
  }

  ::ng-deep gb-input,
  ::ng-deep gb-date,
  ::ng-deep gb-newpicklist,
  ::ng-deep gb-combobox,
  ::ng-deep gb-textarea,
  ::ng-deep gb-checkbox {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .lots-display {
    gap: 6px;
  }

  .lot-chip {
    font-size: 11px;
    padding: 3px 9px;
  }

  .src-selector {
    margin: 10px 0;
  }

  .src-type-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .src-tab {
    padding: 7px 12px;
    font-size: 11px;
  }

  .src-tab-panel {
    padding: 10px;
  }

  .src-item {
    flex-wrap: wrap;
    padding: 10px;
    gap: 8px;
  }

  .src-icon {
    width: 32px;
    height: 32px;
    font-size: 9px;
  }

  .src-title {
    font-size: 12px;
  }

  .src-meta {
    font-size: 10.5px;
  }

  .src-result {
    margin-left: 44px;
    flex-basis: 100%;
  }

  .src-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .pref-grid,
  ::ng-deep .pref-grid {
    grid-template-columns: 1fr;
  }

  .pref-toggle,
  ::ng-deep .pref-toggle {
    padding: 8px 10px;
    font-size: 12px;
  }

  .column-select {
    grid-template-columns: repeat(2, 1fr);
  }

  .col-item {
    font-size: 11px;
    padding: 5px 6px;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  .btn-sm {
    width: auto;
  }

  ::ng-deep gb-formgrid {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media screen and (max-width: 480px) {

  .workflow-steps {
    flex-direction: column;
    align-items: stretch;
  }

  .wf-step {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;

    &:not(:last-child)::after {
      display: none;
    }
  }

  .wf-label {
    text-align: left;
  }

  .column-select {
    grid-template-columns: 1fr 1fr;
  }

  .src-icon {
    width: 28px;
    height: 28px;
    font-size: 8px;
  }

  .src-result {
    margin-left: 0;
  }

  .badge {
    font-size: 10.5px;
    padding: 2px 8px;
  }

  .toggle-switch,
  ::ng-deep .toggle-switch {
    width: 38px;
    height: 20px;
  }

  ::ng-deep .toggle-slider::before {
    height: 14px;
    width: 14px;
  }

  ::ng-deep .toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(16px);
  }
}

.form-row.c3 {
  .form-group {
    min-width: 0;      
    max-width: 100%;
  }

  ::ng-deep gb-combobox {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  ::ng-deep .select,
  ::ng-deep select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
}

.pref-grid,
::ng-deep .pref-grid {
  min-width: 0;
}

.pref-toggle,
::ng-deep .pref-toggle {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;

  span {
    min-width: 0;
    overflow-wrap: break-word;
  }
}

.toggle-switch,
::ng-deep .toggle-switch {
  flex-shrink: 0; 
}

.column-select {
  min-width: 0;
}

.col-item {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;

  ::ng-deep gb-checkbox {
    display: inline-flex;
    max-width: 100%;
    box-sizing: border-box;
  }
}

@media screen and (max-width: 1024px) {
  .pref-toggle,
  ::ng-deep .pref-toggle {
    padding: 8px 10px;
  }

  .col-item {
    padding: 5px 6px;
  }
}

@media screen and (max-width: 480px) {
  .pref-toggle,
  ::ng-deep .pref-toggle {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .col-item {
    font-size: 10.5px;
  }
}

@media screen and (max-width: 480px) {

  ::ng-deep gb-combobox[formcontrolname="MtrTypeName"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;

    * {
      max-width: 100% !important;
      box-sizing: border-box !important;
    }

    input,
    select,
    .select,
    .mat-select,
    .mat-mdc-select,
    .mat-select-trigger,
    .mat-mdc-select-trigger {
      width: 100% !important;
      max-width: 100% !important;
      box-sizing: border-box !important;
    }
  }

  .form-row.c3 {
    display: block !important;

    .form-group {
      width: 100% !important;
      max-width: 100% !important;
      box-sizing: border-box !important;
      margin-bottom: 12px;
    }
  }
}