:host {
  display: block;
}

.media-field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.media-field-row app-input { flex: 1; }

.editor-grid {
  display: grid;
  gap: 12px;
}

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

.editor-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.editor-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.editor-grid.compact {
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--text-primary, #1e3c38);
  font-weight: var(--font-weight-semibold, 600);
}

label.full,
app-form-field.full {
  grid-column: 1 / -1;
}

.field-desc {
  display: block;
  font-weight: var(--font-weight-normal, 400);
  font-size: var(--font-size-xs, 0.75rem);
  line-height: 1.4;
  color: var(--text-secondary, #5f6e6a);
  margin: -2px 0 2px;
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color, #d3dad9);
  border-radius: 10px;
  font: inherit;
  background: var(--bg-primary, #fff);
}

input[type='checkbox'] {
  width: auto;
  padding: 0;
}

input[type='color'] {
  min-height: 44px;
  padding: 4px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggles {
  align-items: start;
}

.sortable-list,
.stack-list {
  display: grid;
  gap: 10px;
}

.sortable-item,
.sub-card {
  border: 1px solid var(--border-color, #d3dad9);
  border-radius: var(--radius-md, 12px);
  padding: 12px;
  background: var(--bg-secondary, #fbfcfc);
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--primary-color, #497671);
  background: var(--primary-color, #497671);
  color: #fff;
  padding: 0 14px;
  font-weight: var(--font-weight-bold, 700);
  cursor: pointer;
  transition: background-color var(--transition-fast, 120ms ease),
    border-color var(--transition-fast, 120ms ease),
    transform var(--transition-fast, 120ms ease),
    box-shadow var(--transition-fast, 120ms ease);

  &:hover {
    background: var(--primary-hover, #3d635f);
    border-color: var(--primary-hover, #3d635f);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.1));
  }

  &:active {
    transform: translateY(0);
  }

  &:focus-visible {
    outline: 2px solid var(--primary-color, #497671);
    outline-offset: 2px;
  }

  &:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
  }
}

button.secondary {
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #1e3c38);
  border-color: var(--border-color, #d3dad9);

  &:hover {
    background: var(--bg-secondary, #f5f5f5);
    border-color: var(--primary-color, #497671);
  }

  &:focus-visible {
    outline-color: var(--primary-color, #497671);
  }
}

@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;

    &:hover {
      transform: none;
    }
  }
}

.editor-error {
  margin: 0;
  color: var(--error-color, #991b1b);
}

.preview-validation {
  margin: 0 0 12px;
  padding-left: 1.25rem;
  color: var(--warning-color, #b45309);

  &.has-errors {
    color: var(--error-color, #991b1b);
  }

  li.is-warning {
    color: var(--warning-color, #b45309);
  }

  li.is-error {
    color: var(--error-color, #991b1b);
  }
}

.preview-validation-ok {
  margin: 0 0 12px;
  color: var(--text-secondary, #5f6e6a);
}

.preview-changes {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-base, 0.875rem);

  th,
  td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color, #d3dad9);
  }

  th {
    color: var(--text-secondary, #5f6e6a);
    font-weight: var(--font-weight-semibold, 600);
  }

  .preview-before {
    color: var(--text-secondary, #5f6e6a);
    text-decoration: line-through;
  }

  .preview-after {
    color: var(--text-primary, #1e3c38);
    font-weight: var(--font-weight-semibold, 600);
  }
}

@media (max-width: 900px) {
  .editor-grid.two,
  .editor-grid.three,
  .editor-grid.four {
    grid-template-columns: 1fr;
  }
}

.languages-summary { display: grid; gap: 6px; }
.languages-summary__chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.languages-summary__chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-full, 999px);
  border: 1px solid var(--border-color, #d3dad9);
  font-size: var(--font-size-sm, 0.8125rem); font-weight: var(--font-weight-semibold, 600);
  em { font-style: normal; font-weight: var(--font-weight-normal, 400); font-size: var(--font-size-xs, 0.75rem); color: var(--text-secondary, #6b7280); }
}
.languages-summary__chip--default { border-color: var(--primary-color, #2f8f5b); }
.languages-summary__manage { font-size: var(--font-size-sm, 0.8125rem); text-decoration: underline; color: var(--text-primary, #1e3c38); }
.languages-summary__manage:focus-visible { outline: 2px solid var(--primary-color, #2f8f5b); outline-offset: 2px; }
