:root {
  --bs-primary: #9e1c3e;
  --bs-primary-rgb: 158, 28, 62;
  --bs-link-color-rgb: 158, 28, 62;
  --bs-link-hover-color-rgb: 134, 24, 53;

  --focus-color: #6c757d;
  --focus-shadow: rgba(108, 117, 125, 0.25);

  --table-cell-py: 1rem;
  --table-cell-px: 1rem;

  --step-height: 37.5rem;

  --page-overlay: 0.7; /* 0 = image fully visible, 1 = fully covered */
  --page-gap: clamp(0.75rem, 12vw, 12rem); /* space to the left, right and bottom of the panel */
  --page-content-width: 640px;
}

/* Let the browser's root viewport handle scrolling naturally (never put overflow-y: auto on both html and body) */
html {
  height: auto;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-image:
    linear-gradient(
      rgba(255, 255, 255, var(--page-overlay)),
      rgba(255, 255, 255, var(--page-overlay))
    ),
    url('/static/images/cropped-coming-soon-gmbh.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: scroll;
}

.page {
  min-height: 100vh;
  padding: 2rem 1rem; /* Prevents the card from touching screen edges on mobile */
  display: flow-root;
}

.page-content {
  width: 100%;
  max-width: var(--page-content-width);
  margin: 1rem auto;
  padding: 2rem;
  background: var(--bs-tertiary-bg);
  border-radius: 0.75rem;
  box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.1);
}

@media (max-width: 575.98px) {
  .page {
    padding: 1rem 0.75rem;
  }

  .page-content {
    margin: 0.5rem auto;
    padding: 1.25rem;
  }
}

/* Buttons */
.btn-primary {
  --bs-btn-bg: #9e1c3e;
  --bs-btn-border-color: #9e1c3e;
  --bs-btn-hover-bg: #861835;
  --bs-btn-hover-border-color: #7e1632;
  --bs-btn-active-bg: #7e1632;
  --bs-btn-active-border-color: #761530;
  --bs-btn-disabled-bg: #9e1c3e;
  --bs-btn-disabled-border-color: #9e1c3e;
  --bs-btn-focus-shadow-rgb: 158, 28, 62;
}

.form-control:focus {
  border-color: var(--focus-color);
  box-shadow: 0 0 0 0.25rem var(--focus-shadow);
}

/* Table */
.table > :not(caption) > * > * {
  padding: var(--table-cell-py) var(--table-cell-px);
}

/* Mobile-first: natural flow so the whole page scrolls */
.artikel-scroll {
  max-height: none;
  overflow-y: visible;
}

.artikel-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bs-tertiary-bg);
}

/* Quantity column & input sizing */
.col-menge {
  width: 11.5rem;
}

.col-menge .form-control {
  min-width: 1.5rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  text-align: right;
  /* Hide Chrome/Safari/Edge number spinners to free up width */
  -moz-appearance: textfield;
}

.col-menge .form-control::-webkit-outer-spin-button,
.col-menge .form-control::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Reduce horizontal table cell padding on mobile so Bezeichnung + Menge have room */
@media (max-width: 575.98px) {
  .table > :not(caption) > * > * {
    padding: 0.75rem 0.5rem;
  }

  .col-menge {
    width: 7.5rem;
  }
}

/* Stepper */
.stepper {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.stepper-btn {
  display: block;
  width: 100%;
  padding: 0.5rem 0 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.stepper-btn:hover:not(:disabled) {
  text-decoration: underline;
}

.stepper-btn:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

.stepper-btn:disabled {
  cursor: default;
}

/* Mobile (< 576px): Collapse labels into a clean 3-segment progress bar */
@media (max-width: 575.98px) {
  .stepper {
    gap: 0.375rem;
  }

  .stepper-btn {
    padding: 0;
    height: 0.75rem; /* Keeps an accessible tap area below the top border */
  }

  .stepper-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
}

/* Step layout — Mobile-first: natural document height & full-page scrolling */
.step-body {
  display: flex;
  flex-direction: column;
  height: auto;
}

.step-body--address {
  height: auto;
}

.step-body > .card {
  flex: 0 0 auto;
}

.step-body > .step-fill,
.step-scroll {
  flex: none;
  overflow-y: visible;
}

.summary-scroll {
  max-height: none;
  overflow-y: visible;
}

.summary-notes {
  max-height: none;
  overflow-y: visible;
  white-space: pre-wrap;
}

/* Desktop (>= 768px): Fixed-height card with internal scrolling containers */
@media (min-width: 768px) {
  body {
    background-attachment: fixed;
  }

  .step-body {
    height: var(--step-height);
  }

  .step-body--address {
    height: auto;
    min-height: var(--step-height);
  }

  .step-body > .step-fill {
    flex: 1 1 0;
    min-height: 0;
  }

  .step-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
  }

  .artikel-scroll {
    max-height: 420px;
    overflow-y: auto;
  }

  .summary .card-body {
    padding: 6px 1rem;
  }

  .summary-scroll {
    max-height: 16rem;
    overflow-y: auto;
  }

  .summary-notes {
    max-height: 6rem;
    overflow-y: auto;
  }
}
