/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

:host {
  overflow: hidden;

  --reveal-checkbox-opacity: 0.8;
  --reveal-checkbox-opacity-hover: 0.6;
  --reveal-checkbox-opacity-active: 1;
}

/* Only overwrite the deemphasized text color in non-dark mode. */
@media not (prefers-color-scheme: dark) {
  :host {
    --text-color-deemphasized: #737373;
  }
}

@media (prefers-color-scheme: dark) {
  :host {
    --reveal-checkbox-opacity: 0.8;
    --reveal-checkbox-opacity-hover: 1;
    --reveal-checkbox-opacity-active: 0.6;
  }
}

.container {
  overflow: auto;
  padding: 0 40px;
  box-sizing: border-box;
  height: 100%;
}

@media (max-width: 830px) {
  .container {
    padding-inline: 20px;
  }
}

.column {
  min-height: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
}

button {
  min-width: 100px;
}

form {
  flex-grow: 1;
}

:host([data-editing]) edit-button,
:host([data-editing]) :is(.copy-button, .copied-button),
:host([data-is-new-login]) delete-button,
:host([data-is-new-login]) .origin-saved-value,
:host([data-is-new-login]) login-timeline,
:host([data-is-new-login]) .login-item-title,
:host(:not([data-is-new-login])) .new-login-title,
:host(:not([data-editing])) .form-actions-row {
  display: none;
}

:host(:not([data-editing])) input[type="password"]:read-only,
input[type="text"]:read-only,
input[type="url"]:read-only {
  all: unset;
  font-size: 1.1em;
  display: inline-block;
  background-color: transparent !important; /* override common.inc.css */
  text-overflow: ellipsis;
  overflow: hidden;
  width: 100%;
}

input:is([type="password"], [type="text"], [type="url"]) {
  /* Override all: unset above */
  appearance: textfield !important;
  text-align: match-parent !important;
}

input.password-display,
input[name="password"] {
  font-family: monospace !important; /* Override all: unset above */
}

/* We can't use `margin-inline-start` here because we force
 * the input to have dir="ltr", so we set the margin manually
 * using the parent element's directionality. */
.detail-cell:dir(ltr) input:not([type="checkbox"]) {
  margin-left: 0;
}

.detail-cell:dir(rtl) input:not([type="checkbox"]) {
  margin-right: 0;
}

.save-changes-button {
  margin-inline-start: 0; /* Align the button on the start side */
}

.header {
  display: flex;
  align-items: center;
  margin-bottom: 40px;
  margin-top: 5px;
}

.title {
  margin-block: 0;
  flex-grow: 1;
}

origin-warning,
password-warning {
  display: none;
}

input[type="url"]:focus:not(:user-invalid):invalid ~ origin-warning,
input[type="url"]:focus:user-invalid:not(:placeholder-shown) ~ origin-warning {
  display: block;
}

input[name="password"]:focus ~ password-warning {
  display: block;
}

.reveal-password-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(240px, max-content) auto;
  grid-template-rows: auto;
  column-gap: 20px;
  row-gap: 40px;
  justify-content: start;
}

:host([data-editing]) .detail-grid {
  grid-template-columns: auto;
}

:host([data-editing]) .detail-grid > .detail-row {
  display: flex;
}

.detail-grid > .detail-row:not([hidden]) {
  display: contents;
}

.detail-grid > .detail-row > .detail-cell {
  grid-column: 1;
}

.detail-grid > .detail-row > :is(.copy-button, .copied-button) {
  grid-column: 2;
  margin-inline-start: 0; /* Reset button's margin so it doesn't affect the overall grid's width */
  justify-self: start;
  align-self: end;
}

.detail-row {
  display: flex;
  position: relative; /* Allows for the hint message to be positioned correctly */
}

.detail-grid,
.detail-row {
  margin-bottom: 40px;
}

.detail-cell {
  flex-grow: 1;
  min-width: 0; /* Allow long passwords to collapse down to flex item width */
}

.field-label {
  display: block;
  margin-bottom: 8px;
}

moz-button-group,
:host([data-editing]) .detail-cell input:read-write:not([type="checkbox"]),
:host([data-editing]) input[type="password"]:read-only {
  width: 298px;
  box-sizing: border-box;
}

.copy-button,
.copied-button {
  margin-bottom: 0; /* Align button at the bottom of the row */
}

.copied-button[data-copied]:focus-visible {
  outline-width: 0;
  box-shadow: none;
}

.reveal-password-checkbox {
  appearance: none;
  background-image: url("chrome://global/skin/icons/eye.svg");
  margin-inline: 10px 0;
  cursor: pointer;
  -moz-context-properties: fill;
  fill: currentColor;
  color: inherit;
  opacity: var(--reveal-checkbox-opacity);

  &:hover {
    opacity: var(--reveal-checkbox-opacity-hover);

    &:active {
      opacity: var(--reveal-checkbox-opacity-active);
    }
  }

  &:checked {
    background-image: url("chrome://global/skin/icons/eye-slash.svg");
  }
}

.login-item-favicon {
  margin-inline-end: 12px;
  height: var(--icon-size-large);
  width: var(--icon-size-large);
  flex-shrink: 0;
  -moz-context-properties: fill, fill-opacity;
  fill: currentColor;
  fill-opacity: 0.75;
}

login-breach-alert,
login-vulnerable-password-alert {
  margin-block-end: 40px;
}

login-command-button {
  margin-block-start: 4px; /* Focus did not display entirely on edit and remove with margin:0 */
}

.alert-title {
  font-size: var(--font-size-xlarge);
  font-weight: var(--font-weight);
  line-height: 1em;
  margin-block: 0 12px;
}

.alert-date {
  display: block;
  font-weight: var(--font-weight-bold);
}

.alert-link:visited,
.alert-link {
  font-weight: var(--font-weight-bold);
  overflow-wrap: anywhere;
}

.breach-alert > .alert-link:visited,
.breach-alert > .alert-link {
  color: inherit;
  text-decoration: underline;
}

.alert-icon {
  position: absolute;
  inset-block-start: 16px;
  inset-inline-start: 32px;
  -moz-context-properties: fill;
  fill: currentColor;
  width: var(--icon-size-large);
}

.alert-learn-more-link:hover,
.alert-learn-more-link:visited,
.alert-learn-more-link {
  position: absolute;
  inset-block-start: 16px;
  inset-inline-end: 32px;
  color: inherit;
  font-size: var(--font-size-small);
}

.vulnerable-alert > .alert-learn-more-link {
  color: var(--text-color-deemphasized);
}

.error-message {
  color: #fff;
  background-color: var(--red-60);
  border: 1px solid transparent;
  padding-block: 6px;
  display: inline-block;
  padding-inline: 32px 16px;
  background-image: url("chrome://global/skin/icons/warning.svg");
  background-repeat: no-repeat;
  background-position: left 10px center;
  -moz-context-properties: fill;
  fill: currentColor;
  margin-bottom: 38px;
}

.error-message:dir(rtl) {
  background-position-x: right 10px;
}

.error-message-link > a,
.error-message-link > a:hover,
.error-message-link > a:hover:active {
  color: currentColor;
  text-decoration: underline;
  font-weight: var(--font-weight-bold);
}

.action-buttons {
  display: flex;
  flex-direction: row;
}

.action-buttons .form-actions-row {
  margin-inline: 0 5px;
}
