/*
  Berichten — log, filters, detailpaneel en tekstkaarten.
  Alleen berichtgerichte regels; gedeelde componenten komen uit components.css.
*/

.msg-tabs {
  margin-top: var(--space-1);
}

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

/* ------------------------------------------------------------ Filters */

.msg-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.msg-filter {
  display: flex;
  flex: 1 1 150px;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.msg-filter__label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.3;
}

.msg-filter__select {
  width: 100%;
}

.msg-count {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}

/* ------------------------------------------------------ Waarschuwing */

.msg-alert {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  border: var(--line-thin) solid var(--line);
  border-inline-start: 4px solid var(--danger);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.msg-alert__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--danger);
}

.msg-alert__head .ph {
  flex: 0 0 auto;
  margin-top: 1px;
}

.msg-alert__text {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.45;
}

.msg-alert__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.msg-alert__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: var(--line-thin) solid var(--line);
}

.msg-alert__info {
  display: flex;
  flex: 1 1 150px;
  flex-direction: column;
  min-width: 0;
}

.msg-alert__name {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.4;
}

.msg-alert__subject {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.msg-alert__retry {
  flex: 0 0 auto;
}

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

.msg-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.msg-list__item {
  min-width: 0;
}

.msg-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
  min-width: 0;
  min-height: var(--tap-min);
  padding: var(--space-3);
  border: var(--line-thin) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) linear;
}

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

.msg-row__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.msg-row__time {
  color: var(--muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.msg-row__title {
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.msg-row__subject {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.msg-row__excerpt {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.msg-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.msg-row__dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted);
}

.msg-row__error {
  color: var(--status-no_show-text);
  font-size: var(--text-xs);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------- Statuspil */

.msg-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
  padding: 2px var(--space-2);
  border: var(--line-thin) solid currentColor;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.3;
  white-space: nowrap;
}

.msg-status .ph {
  font-size: 1em;
  line-height: 1;
}

.msg-status--muted {
  background: var(--surface-2);
  color: var(--muted);
}

.msg-status--ok {
  border-color: transparent;
  background: var(--status-bevestigd-bg);
  color: var(--status-bevestigd-text);
}

.msg-status--info {
  border-color: transparent;
  background: var(--status-aangekomen-bg);
  color: var(--status-aangekomen-text);
}

.msg-status--warn {
  border-color: transparent;
  background: var(--status-bezig-bg);
  color: var(--status-bezig-text);
}

.msg-status--danger {
  border-color: transparent;
  background: var(--status-no_show-bg);
  color: var(--status-no_show-text);
}

/* ----------------------------------------------------------- Detail */

.msg-detail {
  min-width: 0;
}

.msg-detail__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.msg-detail__fact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-bottom: var(--space-2);
  border-bottom: var(--line-thin) solid var(--line);
}

.msg-detail__label {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.msg-detail__value {
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.msg-detail__value--muted {
  color: var(--muted);
}

.msg-detail__value a {
  color: var(--accent);
  text-decoration: underline;
  overflow-wrap: anywhere;
}

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

.msg-detail__subject {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.msg-detail__body {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-detail__error {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--status-no_show-bg);
  color: var(--status-no_show-text);
}

.msg-detail__error .ph {
  flex: 0 0 auto;
  margin-top: 1px;
}

.msg-detail__error-text {
  min-width: 0;
}

.msg-detail__error-text strong {
  display: block;
  font-size: var(--text-sm);
}

.msg-detail__error-text p {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.msg-detail__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
}

/* ----------------------------------------------------------- Teksten */

.msg-intro {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.msg-notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border: var(--line-thin) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
}

.msg-notice .ph {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--brand);
}

.msg-notice p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.msg-templates {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

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

.msg-template__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.msg-template__titles {
  flex: 1 1 200px;
  min-width: 0;
}

.msg-template__when {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

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

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

.msg-template__textarea {
  min-height: 120px;
  resize: vertical;
}

.msg-template__note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.msg-template__note .ph {
  flex: 0 0 auto;
  margin-top: 1px;
}

.msg-template__actions {
  display: flex;
  justify-content: flex-end;
}

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

.msg-vars__label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
}

.msg-vars__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.msg-var.chip {
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.msg-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border: var(--line-thin) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.msg-preview__label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.msg-preview__subject {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.msg-preview__body {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-card__error {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--status-no_show-bg);
  color: var(--status-no_show-text);
  font-size: var(--text-sm);
  line-height: 1.45;
}

/* -------------------------------------------------------- Responsief */

@media (min-width: 768px) {
  .msg-filters {
    align-items: flex-end;
  }

  .msg-filter {
    flex: 0 1 200px;
  }

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

@media (min-width: 1200px) {
  .msg-templates {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 440px) {
  .msg-detail__facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .msg-alert__retry {
    width: 100%;
    justify-content: center;
  }
}

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