/**
 * company_forms
 *
 * Darstellung des Unternehmens-Formularbuilders im Frontend:
 * Produktbestellung, Summenblock, Datei-Feld und Bestellhistorie.
 * Verwendet die Farbvariablen des Themes, damit Tag- und Nachtmodus greifen.
 */

/* ---------- Überschriften und Beschreibung ---------- */

.cf-heading {
  margin: 28px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color, #e6e6e6);
}

.cf-heading:first-child {
  margin-top: 0;
}

.cf-description {
  margin-bottom: 8px;
}

.cf-empty {
  padding: 18px;
  text-align: center;
  color: var(--text-muted, #8a8a8a);
}

/* ---------- Produktbestellung ---------- */

.cf-order {
  margin-bottom: 24px;
}

.cf-order-items {
  border: 1px solid var(--border-color, #e6e6e6);
  border-radius: 8px;
  overflow: hidden;
}

.cf-order-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--border-color, #e6e6e6);
  transition: background-color .15s ease;
}

.cf-order-item:last-child {
  border-bottom: none;
}

.cf-order-item.is-active {
  background: var(--hover-color, #f6f8fa);
}

.cf-order-thumb {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--hover-color, #f2f2f2);
}

.cf-order-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cf-order-info {
  flex: 1 1 240px;
  min-width: 0;
}

.cf-order-name {
  font-weight: 600;
  line-height: 1.3;
}

.cf-order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 13px;
  color: var(--text-muted, #8a8a8a);
  margin-top: 2px;
}

.cf-order-price {
  font-size: 14px;
  margin-top: 6px;
}

.cf-order-step {
  font-size: 12.5px;
  color: var(--text-muted, #8a8a8a);
  margin-top: 2px;
}

/* Mengensteuerung */

.cf-order-qty {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
}

.cf-qty-btn {
  width: 38px;
  height: 38px;
  line-height: 1;
  font-size: 18px;
  border: 1px solid var(--border-color, #d9d9d9);
  background: transparent;
  color: inherit;
  cursor: pointer;
  user-select: none;
}

.cf-qty-btn:first-child {
  border-radius: 6px 0 0 6px;
}

.cf-qty-btn:last-child {
  border-radius: 0 6px 6px 0;
}

.cf-qty-btn:hover {
  background: var(--hover-color, #f0f0f0);
}

.cf-qty-input {
  width: 74px;
  height: 38px;
  text-align: center;
  border: 1px solid var(--border-color, #d9d9d9);
  border-left: none;
  border-right: none;
  background: transparent;
  color: inherit;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.cf-qty-input::-webkit-outer-spin-button,
.cf-qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cf-order-line {
  flex: 0 0 110px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Summenblock */

.cf-order-summary {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--border-color, #e6e6e6);
  border-radius: 8px;
  background: var(--hover-color, #f9fafb);
}

.cf-sum-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 4px 0;
  font-variant-numeric: tabular-nums;
}

.cf-sum-total {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color, #e0e0e0);
  font-size: 17px;
}

.cf-sum-hint {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--text-muted, #8a8a8a);
}

.cf-sum-hint:empty {
  display: none;
}

/* ---------- Kontrollkästchen und Datei ---------- */

.cf-checkbox {
  margin: 14px 0 18px;
}

.cf-file {
  margin: 14px 0 18px;
}

.cf-file-label {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 1px dashed var(--border-color, #d0d0d0);
  border-radius: 8px;
  cursor: pointer;
}

.cf-file-title {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.cf-file-label input[type="file"] {
  display: block;
  width: 100%;
  max-width: 100%;
}

/* ---------- Bestellhistorie ---------- */

.cf-history-item {
  border: 1px solid var(--border-color, #e6e6e6);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.cf-history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.cf-history-ref {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cf-history-status {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--hover-color, #eef1f4);
  white-space: nowrap;
}

.cf-status-confirmed,
.cf-status-shipped,
.cf-status-completed {
  background: #e2f3e9;
  color: #1f7a4d;
}

.cf-status-rejected {
  background: #fae4e6;
  color: #a5122b;
}

.cf-history-date {
  font-size: 13px;
  color: var(--text-muted, #8a8a8a);
  margin-top: 2px;
}

.cf-history-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 8px 0;
  font-size: 14px;
}

.cf-history-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.cf-history-actions {
  display: flex;
  gap: 8px;
}

.cf-history-details {
  margin-top: 14px;
  overflow-x: auto;
}

.cf-details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.cf-details-table th,
.cf-details-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color, #ececec);
  text-align: left;
  vertical-align: top;
}

.cf-details-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted, #8a8a8a);
}

.cf-details-table .num,
.cf-details-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cf-details-sums {
  margin-top: 10px;
  font-size: 13.5px;
}

.cf-details-sums div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 3px 0;
  font-variant-numeric: tabular-nums;
}

/* ---------- Formularübersicht (mehrere aktive Formulare) ---------- */

.cf-form-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cf-form-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid var(--border-color, #e6e6e6);
  border-radius: 8px;
  transition: background-color .15s ease;
}

.cf-form-list-item:hover {
  background: var(--hover-color, #f6f8fa);
}

.cf-form-list-text {
  min-width: 0;
}

.cf-form-list-title {
  font-weight: 600;
  line-height: 1.3;
}

.cf-form-list-excerpt {
  margin-top: 4px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-muted, #8a8a8a);
}

.cf-form-list-action {
  flex: 0 0 auto;
}

@media (max-width: 575px) {
  .cf-form-list-item {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .cf-form-list-action .button {
    width: 100%;
  }
}

/* ---------- Modal ---------- */

.cf-modal-body {
  max-height: 76vh;
  overflow-y: auto;
}

/* ---------- Backoffice: Produkt-Repeater und Bestellübersicht ---------- */

.admin-product-row .row {
  margin-bottom: 0;
}

.cf-admin-order {
  overflow-x: auto;
  margin-bottom: 18px;
}

.cf-admin-order table {
  width: 100%;
  border-collapse: collapse;
}

.cf-admin-order th,
.cf-admin-order td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-color, #ececec);
  text-align: left;
  white-space: nowrap;
}

.cf-admin-order td.num,
.cf-admin-order th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Mobil ---------- */

@media (max-width: 767px) {
  .cf-order-item {
    align-items: flex-start;
  }

  .cf-order-info {
    flex: 1 1 100%;
  }

  .cf-order-qty {
    flex: 1 1 auto;
  }

  .cf-order-line {
    flex: 1 1 auto;
    text-align: right;
  }

  .cf-history-foot {
    align-items: flex-start;
  }

  .cf-history-actions {
    width: 100%;
  }

  .cf-history-actions .button {
    flex: 1 1 0;
  }

  .cf-modal-body {
    max-height: 70vh;
  }
}
