/*
  Klanten — zoeken, klantkaart, historie en import/export.
  Alleen klantgerichte regels; gedeelde knoppen, velden en kaarten komen
  uit components.css.
*/

.customers-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.customers-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  min-width: 0;
}

.customers-head__titles {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.customers-count {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

/* ----------------------------------------------------------- Werkbalk */

.customers-toolbar {
  display: flex;
  flex: 1 1 420px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  min-width: 0;
}

.customers-search {
  position: relative;
  display: flex;
  flex: 1 1 260px;
  align-items: center;
  min-width: 0;
  max-width: 520px;
}

.customers-search > .ph {
  position: absolute;
  left: var(--space-3);
  z-index: 1;
  color: var(--muted);
  pointer-events: none;
}

.customers-search__input {
  width: 100%;
  min-height: var(--tap-min);
  padding-left: calc(var(--space-3) * 2 + 18px);
}

.customers-toolbar .page__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* ------------------------------------------------------------ Lijst */

.customers-list-area {
  min-width: 0;
}

.customers-list {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: var(--line-thin) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.customers-list__head,
.customers-row {
  display: grid;
  grid-template-columns:
    minmax(0, 2fr)
    minmax(0, 1.1fr)
    minmax(0, 1.2fr)
    minmax(0, 1fr)
    80px
    110px
    40px;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  padding: 0 var(--space-4);
}

.customers-list__head {
  min-height: 44px;
  border-bottom: var(--line-thin) solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.customers-row {
  position: relative;
  min-height: 56px;
  border-bottom: var(--line-thin) solid var(--line);
  color: var(--ink);
  text-decoration: none;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.customers-row:last-child {
  border-bottom: 0;
}

.customers-row:hover {
  background: var(--surface-2);
}

.customers-row:focus-visible {
  z-index: 1;
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: calc(-1 * var(--focus-width));
  background: var(--surface-2);
}

.customers-row::after {
  content: "→";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  color: var(--muted);
  font-size: var(--text-md);
  line-height: 1;
  transition:
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.customers-row:hover::after,
.customers-row:focus-visible::after {
  color: var(--accent);
  transform: translateX(2px);
}

.customers-row__person {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.customers-row__names {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.customers-row__name {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customers-row__phone {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customers-row__phone--mobile {
  display: none;
  font-size: var(--text-xs);
}

.customers-row__labels {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
}

.customers-row__flag,
.customers-row__noshow {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.customers-row__last {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.customers-warn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-width: 28px;
  min-height: 28px;
  padding: 0 var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--status-bezig-bg);
  color: var(--warn);
  line-height: 1;
}

.customers-noshow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 24px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--status-no_show-bg);
  color: var(--status-no_show-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  font-variant-numeric: tabular-nums;
}

.customers-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-height: 22px;
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 11px;
  font-weight: var(--weight-medium);
  line-height: 1.3;
  white-space: nowrap;
}

.customers-label.chip--active {
  background: var(--accent);
  color: var(--on-accent);
}

.customers-label__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.customers-label__remove:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.customers-label__remove:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
}

.customers-labels {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  min-width: 0;
}

.customers-labels__add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.customers-labels__input {
  flex: 1 1 140px;
  min-width: 0;
}

.customers-muted {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}

.customers-list__more {
  margin: var(--space-3) 0 0;
  text-align: center;
}

.customers-empty {
  padding: var(--space-5) var(--space-3);
}

/* ---------------------------------------------------------- Laden */

.customers-loading {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.customers-loading .skeleton {
  width: 100%;
  min-height: 56px;
  border-radius: var(--radius);
}

/* --------------------------------------------------- Detail en kaarten */

.customers-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.customers-detail__error {
  margin: 0;
}

.customers-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.customers-section__title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  overflow-wrap: anywhere;
}

.customers-profile {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.customers-profile__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 0;
}

.customers-profile__titles {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.customers-profile__name {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  overflow-wrap: anywhere;
}

.customers-warning {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3);
  border: var(--line-thin) solid var(--line);
  border-left: var(--line-thick) solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--status-no_show-bg);
  color: var(--status-no_show-text);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.customers-warning > .ph {
  flex: 0 0 auto;
  color: var(--danger);
}

.customers-contact {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
}

.customers-contact__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: var(--space-3);
  align-items: baseline;
  padding: var(--space-2) 0;
  border-bottom: var(--line-thin) solid var(--line);
}

.customers-contact__row:last-child {
  border-bottom: 0;
}

.customers-contact__row dt {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.customers-contact__row dd {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  text-align: right;
  overflow-wrap: anywhere;
}

.customers-link {
  color: var(--link);
  text-decoration: none;
}

.customers-link:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.customers-link:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
  border-radius: 2px;
}

.customers-marketing {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  cursor: default;
}

.customers-marketing input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.customers-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.customers-actions .btn {
  flex: 0 1 auto;
}

.customers-noshow-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.customers-noshow-block__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

.customers-noshow-block__text {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
}

.customers-noshow-block.is-blocked {
  border-color: var(--status-no_show-text);
}

.customers-noshow-block.is-blocked .customers-section__title {
  color: var(--danger);
}

.customers-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
}

.customers-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--space-3);
  border: var(--line-thin) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.customers-stat dt {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.3;
}

.customers-stat dd {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.customers-history {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.customers-history__item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: var(--space-3);
  align-items: center;
  min-width: 0;
  min-height: var(--tap-min);
  padding: var(--space-2) 0;
  border-bottom: var(--line-thin) solid var(--line);
  color: inherit;
  text-decoration: none;
}

.customers-history__item:last-child {
  border-bottom: 0;
}

.customers-history__item:hover {
  background: var(--surface-2);
}

.customers-history__item:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-sm);
}

.customers-history__date {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: var(--ink);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.customers-history__date strong {
  font-weight: var(--weight-medium);
}

.customers-history__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.customers-history__main .list__title {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
}

.customers-history__main .list__sub {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
}

.customers-history__amount {
  justify-self: end;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  white-space: nowrap;
}

.customers-notes {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.customers-notes__input {
  min-height: 96px;
  resize: vertical;
}

.customers-notes__actions,
.customers-edit__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.customers-merge,
.customers-merge__results {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.customers-merge__result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-width: 0;
  min-height: var(--tap-min);
  padding: var(--space-2);
  border: 0;
  border-bottom: var(--line-thin) solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.customers-merge__result:hover {
  background: var(--surface-2);
}

.customers-merge__result:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
}

.customers-merge__person {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* ------------------------------------------------------- Formulieren */

.customers-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.customers-form__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  min-width: 0;
}

.customers-form .field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.customers-form .field__label {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
}

.customers-form .field__hint {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.customers-form .field__error,
.customers-form__error {
  margin: 0;
  color: var(--danger);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
}

.customers-conflict {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3);
  border: var(--line-thin) solid var(--line);
  border-left: var(--line-thick) solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--status-no_show-bg);
  color: var(--status-no_show-text);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.customers-conflict p {
  margin: 0;
}

/* ----------------------------------------------------------- Import */

.customers-import {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.customers-import__intro {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
}

.customers-import__file {
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-2);
  border: var(--line-thin) dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--text-sm);
}

.customers-import__file:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
}

.customers-import__text {
  width: 100%;
  min-height: 160px;
  padding: var(--space-3);
  border: var(--line-thin) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  resize: vertical;
}

.customers-import__text:focus-visible,
.customers-import__text.is-dragover {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.customers-import__result {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: var(--line-thin) solid var(--ok);
  border-left: var(--line-thick) solid var(--ok);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.customers-import__result:has(.customers-import__first-error),
.customers-import__result:has(.customers-import__errors li) {
  border-color: var(--danger);
  border-left-color: var(--danger);
  background: var(--status-no_show-bg);
}

.customers-import__summary {
  margin: 0;
  font-weight: var(--weight-medium);
}

.customers-import__first-error {
  margin: 0;
  color: var(--danger);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.customers-import__errors {
  margin: 0;
  padding-left: var(--space-4);
  color: var(--danger);
  font-size: var(--text-xs);
  line-height: 1.5;
}

/* ------------------------------------------------------------- Mobiel */

@media (max-width: 767px) {
  .customers-head {
    flex-direction: column;
    align-items: stretch;
  }

  .customers-toolbar {
    flex: 1 1 auto;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .customers-search {
    flex: 1 1 auto;
    max-width: none;
  }

  .customers-toolbar .page__actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin-left: 0;
  }

  .customers-toolbar .page__actions .btn {
    width: 100%;
    min-height: var(--tap-min);
    justify-content: center;
  }

  .customers-list {
    gap: var(--space-2);
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .customers-list__head {
    display: none;
  }

  .customers-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "person last"
      "labels labels"
      "flag noshow";
    gap: var(--space-2) var(--space-3);
    min-height: 0;
    padding: var(--space-3);
    border: var(--line-thin) solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .customers-row::after {
    display: none;
  }

  .customers-row__person {
    grid-area: person;
    align-self: start;
  }

  .customers-row__phone {
    display: none;
  }

  .customers-row__phone--mobile {
    display: block;
  }

  .customers-row__labels {
    grid-area: labels;
  }

  .customers-row__flag {
    grid-area: flag;
  }

  .customers-row__noshow {
    grid-area: noshow;
    justify-self: end;
    align-self: center;
  }

  .customers-row__last {
    grid-area: last;
    align-self: start;
    justify-self: end;
  }

  .customers-row__last::before {
    content: "Laatste bezoek";
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: var(--weight-semibold);
    line-height: 1.3;
    letter-spacing: 0.04em;
    text-align: right;
    text-transform: uppercase;
  }

  .customers-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .customers-form__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .customers-actions {
    align-items: stretch;
  }

  .customers-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .customers-history__item {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "date amount"
      "main main"
      "status status";
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3) 0;
  }

  .customers-history__date {
    grid-area: date;
  }

  .customers-history__main {
    grid-area: main;
  }

  .customers-history__amount {
    grid-area: amount;
    align-self: start;
  }

  .customers-history__item > .status {
    grid-area: status;
    justify-self: start;
  }
}

@media (max-width: 420px) {
  .customers-contact__row {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
  }

  .customers-contact__row dd {
    text-align: left;
  }

  .customers-notes__actions .btn,
  .customers-edit__actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .customers-label {
    max-width: 100%;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .customers-row,
  .customers-row::after {
    transition: none;
  }
}
