@import './correspondence-tokens';

:host {
  display: block;
  font-family: $cr-font;
  background: $cr-surface-muted;
  min-height: 100%;
}

.cr-page {
  padding: 28px 32px;
  max-width: 1200px;
  margin: 0 auto;
}

.cr-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;

  h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: $cr-ink;
  }
}

.cr-page-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: $cr-ink-muted;
}

.cr-filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: $cr-surface;
  border: 1px solid $cr-border;
  border-radius: $cr-radius;
  padding: 16px 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.cr-filter-actions {
  display: flex;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: $cr-ink-muted;
}

.field-input {
  font-family: $cr-font;
  font-size: 14px;
  color: $cr-ink;
  padding: 9px 11px;
  border: 1px solid $cr-border;
  border-radius: 8px;
  outline: none;
  background: $cr-surface;
  width: 180px;

  &:focus {
    border-color: $cr-accent;
    box-shadow: 0 0 0 3px rgba($cr-accent, 0.12);
  }
}

.cr-loading,
.cr-empty,
.cr-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 20px;
  color: $cr-ink-muted;
  text-align: center;

  mat-icon {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: $cr-border;
  }

  p {
    max-width: 420px;
    margin: 0;
  }
}

.cr-table-wrap {
  background: $cr-surface;
  border: 1px solid $cr-border;
  border-radius: $cr-radius;
  overflow: hidden;
}

.cr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;

  thead th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: $cr-ink-muted;
    padding: 12px 18px;
    background: $cr-surface-muted;
    border-bottom: 1px solid $cr-border;
  }

  td {
    padding: 13px 18px;
    border-bottom: 1px solid $cr-border;
    color: $cr-ink;
  }

  tbody tr:last-child td {
    border-bottom: none;
  }
}

.cr-direction-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: $cr-surface-muted;
  color: $cr-ink-muted;

  &.in {
    background: #e0f2fe;
    color: #0369a1;
  }
}

.cr-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  background: $cr-status-pending-bg;
  color: $cr-status-pending;

  &.processed {
    background: $cr-status-processed-bg;
    color: $cr-status-processed;
  }

  &.failed {
    background: $cr-status-failed-bg;
    color: $cr-status-failed;
  }
}

.btn {
  font-family: $cr-font;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.btn-primary {
  background: $cr-accent;
  color: white;

  &:hover:not(:disabled) {
    background: $cr-accent-dark;
  }
}

.btn-ghost {
  background: transparent;
  color: $cr-ink-muted;
  border: 1px solid $cr-border;

  &:hover:not(:disabled) {
    background: $cr-surface-muted;
  }
}

.btn-sm {
  font-size: 12.5px;
  padding: 7px 12px;

  mat-icon {
    font-size: 16px;
    width: 16px;
    height: 16px;
  }
}

.cr-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid $cr-border;
}

.cr-page-info {
  font-size: 12.5px;
  color: $cr-ink-muted;
}

.cr-page-buttons {
  display: flex;
  gap: 8px;
}
