/**
 * app-bookmark-form.css
 * Styles for bookmark and bookmark-group dialogs.
 */
@layer components {
  dialog[data-app-bookmark-dialog] > article.app-bookmark-dialog > header,
  dialog[data-app-bookmark-group-dialog] > article.app-bookmark-dialog > header {
    position: relative;
    padding-inline-end: 2rem;
  }

  dialog[data-app-bookmark-dialog] > article.app-bookmark-dialog > header h2,
  dialog[data-app-bookmark-group-dialog] > article.app-bookmark-dialog > header h2 {
    margin: 0;
  }

  dialog[data-app-bookmark-dialog] [data-bookmark-dialog-close].close,
  dialog[data-app-bookmark-group-dialog] [data-bookmark-group-dialog-close].close {
    position: absolute;
    inset-inline-end: 1rem;
    inset-block-start: 1rem;
    float: none;
    margin: 0;
  }

  dialog[data-app-bookmark-dialog] form,
  dialog[data-app-bookmark-group-dialog] form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
  }

  dialog[data-app-bookmark-dialog] form label,
  dialog[data-app-bookmark-group-dialog] form label {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0;
  }

  dialog[data-app-bookmark-dialog] form input[type="text"],
  dialog[data-app-bookmark-dialog] form select,
  dialog[data-app-bookmark-group-dialog] form input[type="text"],
  dialog[data-app-bookmark-group-dialog] form select {
    width: 100%;
    margin: 0;
  }

  dialog[data-app-bookmark-dialog] form footer,
  dialog[data-app-bookmark-group-dialog] form footer {
    padding-top: var(--app-spacing);
  }

  /* URL preview */
  .app-bookmark-url-preview {
    color: var(--app-muted-color);
    font-size: 0.8rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    margin-bottom: 0.25rem;
  }

  /* Inline field errors */
  .app-bookmark-field-error {
    color: var(--app-action-danger-background);
    font-size: 0.8rem;
    line-height: 1.3;
    min-height: 0;
  }

  .app-bookmark-field-error:empty {
    display: none;
  }

  dialog[data-app-bookmark-dialog] form input[aria-invalid="true"],
  dialog[data-app-bookmark-group-dialog] form input[aria-invalid="true"] {
    border-color: var(--app-action-danger-background);
  }

  /* Group label row with inline new-group link */
  .app-bookmark-group-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .app-bookmark-new-group-link {
    all: unset;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--app-primary);
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
  }

  .app-bookmark-new-group-link:hover {
    text-decoration: underline;
  }

  .app-bookmark-new-group-link:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
    border-radius: 2px;
  }

  .app-bookmark-new-group-link > i {
    font-size: 0.85rem;
  }

  /* Delete button */
  .app-bookmark-delete-btn {
    color: var(--app-action-danger-background);
    border-color: var(--app-action-danger-background);
    width: 100%;
  }

  .app-bookmark-delete-btn:hover {
    background: var(--app-action-danger-background);
    color: var(--app-action-danger-color);
  }

  /* Icon picker */
  .app-bookmark-group-icon-picker {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.3rem;
  }

  .app-bookmark-group-icon-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 1.9rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-border-radius);
    background: transparent;
    color: var(--app-muted-color);
    cursor: pointer;
    padding: 0;
    margin: 0;
    transition: border-color 120ms ease, color 120ms ease;
  }

  .app-bookmark-group-icon-option:hover {
    border-color: var(--app-primary);
    color: var(--app-primary);
  }

  .app-bookmark-group-icon-option.app-bookmark-icon-active {
    border-color: var(--app-primary);
    background: var(--app-primary);
    color: var(--app-primary-inverse);
  }

  .app-bookmark-group-icon-option > i {
    font-size: 0.95rem;
  }

  .app-bookmark-delete-separator {
    margin-block: 0.2rem 0.35rem;
  }
}
