/* Copyright 2026 The Chromium Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file. */

/* #css_wrapper_metadata_start
 * #type=style-lit
 * #import=//resources/cr_elements/cr_shared_style_lit.css.js
 * #import=//resources/cr_elements/cr_shared_vars.css.js
 * #scheme=relative
 * #include=cr-shared-style-lit
 * #css_wrapper_metadata_end */

cr-dialog {
  --cr-dialog-background-color: var(--color-sys-surface);
  --cr-dialog-border-radius: 12px;
  --cr-dialog-shadow: none;
  --cr-dialog-width: 100%;
}

cr-dialog::part(dialog) {
  box-shadow: none;
}

/* Needed to prevent the dialog body from being scrollable. */
cr-dialog::part(wrapper) {
  height: auto;
  max-height: none;
}

[slot='title'] {
  display: grid;
  gap: 4px;
  padding: 20px 20px 16px 20px;
}

h1 {
  color: var(--color-sys-on-surface);
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  margin: 0;
}

p.description {
  color: var(--color-sys-on-surface-subtle);
  font-size: 13px;
  font-weight: 400;
  line-height: 20px;
  margin: 0;
}

[slot='body'] {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 20px 16px 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#nameWrapper {
  position: relative;
  transition: background-color 200ms ease-in-out;
}

cr-input {
  --cr-input-error-display: none;
  --cr-input-focus-outline-color: var(--cr-focus-outline-color);
  --cr-input-font-size: 13px;
  --cr-input-hover-background-color: var(--color-sys-surface-variant);
  --cr-input-placeholder-color: var(--color-sys-state-disabled);
  font-weight: 400;
  line-height: 18px;
}

cr-input:focus-within {
  --cr-input-hover-background-color: var(--color-sys-surface);
  --cr-input-background-color: var(--color-sys-surface);
}

#generatedPlaceholder {
  align-items: center;
  bottom: 0;
  display: flex;
  gap: 6px;
  left: 100%;
  margin-left: 8px;
  pointer-events: none;
  position: absolute;
  top: 0;
  white-space: pre;
}

#generatedNameText {
  color: var(--cr-input-placeholder-color, var(--color-sys-state-disabled));
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
}

#tabHint {
  background-color: var(--color-sys-surface-variant);
  border-radius: 4px;
  color: var(--color-sys-on-surface-subtle);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  opacity: 0.5;
}

.cr-form-field-label {
  --cr-form-field-label-color: var(--color-sys-on-surface);
  --cr-form-field-label-font-size: 12px;
  --cr-form-field-label-line-height: 18px;
  font-weight: 500;
}

#textareaWrapper {
  display: flex;
  flex-direction: column;
  position: relative;

  border: 1px solid var(--cr-fallback-color-neutral-outline);
  border-radius: 8px;
  background-color: var(--color-sys-surface);

  transition: background-color 200ms ease-in-out;
  overflow: hidden;
}

#textareaWrapper[loading] {
  background-color: var(--color-sys-surface);
  border-color: var(--cr-fallback-color-neutral-outline);
}

#textareaWrapper:focus-within {
  border-color: var(--cr-focus-outline-color);
  box-shadow: 0 0 0 1px var(--cr-focus-outline-color);
}

/* Only add the background hover color when user is not focused and we are not
 * loading refinement.
 */
#textareaWrapper:not([loading]):hover:not(:focus-within) {
  background-color: var(--color-sys-surface-variant);
}

#textareaWrapper[error] {
  border-color: var(--color-sys-error);
}

#textareaWrapper[error]:focus-within {
  border-color: var(--color-sys-error);
  box-shadow: 0 0 0 1px var(--color-sys-error);
}

textarea {
  display: block;
  width: 100%;
  /* LINT.IfChange(textarea_height) */
  height: 175px;
  /* LINT.ThenChange(textarea_without_refinement_height) */
  box-sizing: border-box;
  resize: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
  color: var(--cr-primary-text-color);
  border: none;
  outline: none;
  background-color: transparent;
  padding: 10px 10px 0 10px;
  flex-grow: 1;
}

/* Increase height to account for missing refinement buttons to keep dialog
 * height consistent. */
#textareaWrapper:not([refinement-enabled]) textarea,
#textareaWrapper:not([refinement-enabled]) #instructionsLoader {
  /* LINT.IfChange(textarea_without_refinement_height) */
  height: 215px;
  /* LINT.ThenChange(textarea_height, textarea_animation_height) */
}

textarea.has-overflow {
  -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
}

textarea::placeholder {
  color: var(--color-sys-state-disabled);
}

.textarea-actions {
  display: flex;
  gap: 4px;
  padding: 8px;
  background-color: transparent;
}

#instructionsLoader {
  display: block;
  width: 100%;
  /* LINT.IfChange(textarea_animation_height) */
  height: 175px;
  /* LINT.ThenChange(textarea_without_refinement_height) */
  box-sizing: border-box;
}

.refine-icon {
  margin: 0;
  --cr-icon-button-fill-color: var(--color-sys-on-surface-subtle);
  --cr-icon-button-icon-size: 20px;
  --cr-icon-button-size: 24px;
  --cr-icon-button-hover-background-color:
    var(--color-sys-state-hover-on-subtle);
}

.buttons-group {
  display: flex;
  justify-content: flex-end;
}

.buttons-group cr-button:first-child {
  margin-inline-end: auto;
}

#deleteButton {
  --cr-button-background-color: transparent;
  --cr-button-border-color: var(--color-sys-tonal-outline);
  --cr-button-text-color: var(--color-sys-primary);
}

.cancel-button {
  --cr-button-background-color: var(--color-sys-tonal-container);
  --cr-button-border-color: transparent;
  --cr-button-text-color: var(--color-sys-on-tonal-container);
}

.action-button {
  --cr-button-background-color: var(--color-sys-primary);
  --cr-button-border-color: transparent;
  --cr-button-text-color: var(--color-sys-on-primary);
  --cr-button-disabled-background-color:
    var(--color-sys-state-disabled-container);
  --cr-button-disabled-border-color: transparent;
  --cr-button-disabled-text-color: var(--color-sys-state-disabled);
}

.emoji-trigger {
  appearance: none;
  background: transparent;
  border: none;
  border-radius: 50%;
  padding: 4px;
  margin: 0;
  outline: none;
  box-shadow: none;
  width: 16px;
  height: 16px;
  align-self: center;
  margin-inline-start: -4px;
  margin-inline-end: 4px;
  font-family: 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  font-size: 12px;
  text-align: center;
  line-height: 16px;
  color: var(--cr-primary-text-color);
  cursor: pointer;
  caret-color: transparent;
  transition: background-color 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.placeholder-icon {
  opacity: 0.5;
}

.emoji-prefix-container {
  position: relative;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

#emojiPicker {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  z-index: 1;
}

#emojiZeroStateIcon {
  position: absolute;
  pointer-events: none;
  width: 16px;
  height: 16px;
  left: 0;
  color: var(--color-sys-state-disabled);
}

/* Hides the blue selection background if text gets selected */
.emoji-trigger::selection {
  background: transparent;
  color: var(--cr-primary-text-color);
}

.emoji-trigger:focus-visible {
  outline: 2px solid var(--cr-focus-outline-color);
  outline-offset: 2px;
}

.emoji-trigger:hover {
  background-color: var(--cr-hover-background-color);
}

.error-message {
  font-size: 11px;
  line-height: 16px;
  color: var(--color-sys-error);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding-left: 10px;
}

.error-message a {
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  outline: none;
}

#nameLoaderContainer {
  height: 38px;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--cr-fallback-color-neutral-outline);
  border-radius: 8px;
  background-color: var(--color-sys-surface);
  overflow: hidden;
  display: block;
  margin-bottom: 19px;
  padding-right: 10px;
}

#saveErrorContainer {
  align-items: center;
  display: flex;
  gap: 4px;
  height: 16px;
}

.icon-error {
  --iron-icon-fill-color: var(--color-sys-error);
  --iron-icon-width: 16px;
  --iron-icon-height: 16px;
}

[slot='footer'] {
  background-color: var(--color-sys-neutral-container);
  border-top: 1px solid var(--color-sys-neutral-outline);
  box-sizing: border-box;
  font-size: 13px;
  font-weight: 400;
  gap: 4px;
  line-height: 18px;
  padding: 15px 20px 20px 20px;
  color: var(--color-sys-on-surface);
}
