@import './correspondence-tokens';

.cc-dialog {
  display: flex;
  flex-direction: column;
  font-family: $cr-font;
  width: min(720px, 92vw);
  height: min(680px, 88vh);
}

.cc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 4px;

  h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: $cr-ink;
  }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: $cr-ink-muted;
  cursor: pointer;
  flex-shrink: 0;

  &:hover {
    background: $cr-surface-muted;
    color: $cr-ink;
  }
}

.cc-stepper {
  display: flex;
  gap: 4px;
  padding: 14px 24px;
  border-bottom: 1px solid $cr-border;
}

.cc-step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: default;
  font-family: $cr-font;

  &.done {
    cursor: pointer;
  }
}

.cc-step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: $cr-surface-muted;
  color: $cr-ink-muted;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.cc-step.active .cc-step-dot {
  background: $cr-accent;
  color: white;
}

.cc-step.done .cc-step-dot {
  background: $cr-accent-light;
  color: $cr-accent-dark;
}

.cc-step-label {
  font-size: 12.5px;
  font-weight: 600;
  color: $cr-ink-muted;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cc-step.active .cc-step-label {
  color: $cr-ink;
}

.cc-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px;
}

.cc-step-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: $cr-ink-muted;
}

.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.field-hint {
  font-size: 11.5px;
  color: $cr-ink-muted;
}

.link-btn {
  font-family: $cr-font;
  font-size: 11.5px;
  font-weight: 600;
  color: $cr-accent;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;

  &:hover {
    color: $cr-accent-dark;
  }
}

.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: 100%;

  &:focus {
    border-color: $cr-accent;
    box-shadow: 0 0 0 3px rgba($cr-accent, 0.12);
  }
}

.cc-field-row {
  display: flex;
  gap: 14px;
}

.cc-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.cc-section-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: $cr-ink-muted;
}

.cc-suggest-block {
  background: $cr-surface-muted;
  border: 1px solid $cr-border;
  border-radius: 8px;
  padding: 12px 14px;
}

.cc-suggest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cc-suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cc-chip {
  font-family: $cr-font;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid $cr-accent;
  color: $cr-accent-dark;
  background: white;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;

  &:hover {
    background: $cr-accent-light;
  }
}

.cc-suggest-empty {
  margin: 0;
  font-size: 12.5px;
  color: $cr-ink-muted;
}

.cc-field-editor-row {
  display: flex;
  align-items: center;
  gap: 8px;

  .field-input {
    flex: 1;
  }
}

.cc-add-table-row {
  display: flex;
  gap: 8px;
  align-items: center;

  .field-input {
    width: 220px;
  }
}

.cc-table-draft {
  border: 1px solid $cr-border;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cc-table-draft-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cc-table-draft-name {
  font-weight: 700;
  color: $cr-ink;
}

.cc-table-columns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.cc-col-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  background: $cr-surface-muted;
  color: $cr-ink;
  border-radius: 999px;
  padding: 3px 4px 3px 10px;

  button {
    border: none;
    background: transparent;
    color: $cr-ink-muted;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px;
  }
}

.cc-col-input {
  width: 140px;
}

.cc-table-draft-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;

  th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: $cr-ink-muted;
    padding: 6px 8px;
  }

  td {
    padding: 4px 8px;
  }
}

.cc-preview-card {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid $cr-border;
  border-radius: 10px;
  padding: 16px;
  background: $cr-surface-muted;
}

.cc-preview-icon {
  color: $cr-accent;
  font-size: 34px;
  width: 34px;
  height: 34px;
}

.cc-preview-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.cc-preview-name {
  font-weight: 600;
  color: $cr-ink;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-preview-meta {
  font-size: 12px;
  color: $cr-ink-muted;
}

.cc-mode-toggle {
  display: inline-flex;
  background: $cr-surface-muted;
  border: 1px solid $cr-border;
  border-radius: 999px;
  padding: 3px;
  align-self: flex-start;
}

.toggle-btn {
  font-family: $cr-font;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: $cr-ink-muted;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;

  mat-icon {
    font-size: 16px;
    width: 16px;
    height: 16px;
  }

  &.active {
    background: $cr-accent;
    color: white;
  }
}

.cc-footer {
  display: flex;
  align-items: center;
  padding: 14px 24px 20px;
  border-top: 1px solid $cr-border;
  gap: 10px;
}

.cc-footer-spacer {
  flex: 1;
}

.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: 9px 18px;

  &:disabled {
    opacity: 0.6;
    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;

  &:hover:not(:disabled) {
    background: $cr-surface-muted;
  }
}

.btn-sm {
  font-size: 12.5px;
  padding: 6px 12px;

  mat-icon {
    font-size: 16px;
    width: 16px;
    height: 16px;
  }
}
