/**
 * Styles for the shared UnitsChip.
 * Pair with shared/js/units_chip.js.
 *
 * An unconfirmed guess is marked with a dotted underline rather than a warning colour:
 * the chip is optional, the result is already on screen, and nothing is wrong.
 */

.units-chip {
  position: relative;
  display: inline-block;
  margin-left: 0.4em;
}

.units-chip__toggle {
  padding: 0.1em 0.6em;
  min-height: 1.6em;
  font: inherit;
  /* After the shorthand, and text-transform / letter-spacing are not in it at all.
     Without these the chip turns bold and uppercase inside a table header. */
  font-size: 0.8em;
  font-weight: 500;
  font-style: normal;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--app-muted, #5f6b7a);
  background: transparent;
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 999px;
  cursor: pointer;
}

.units-chip__toggle--unconfirmed {
  color: var(--app-accent-dark, #1a5fb4);
  border-style: dashed;
}

.units-chip__toggle:hover {
  background: #eef4fc;
  border-color: var(--app-accent, #2a7de1);
}

.units-chip__toggle:focus-visible,
.units-chip__select:focus-visible,
.units-chip__symbol:focus-visible,
.units-chip__save:focus-visible {
  outline: 2px solid var(--app-accent, #2a7de1);
  outline-offset: 2px;
}

.units-chip__panel {
  position: absolute;
  z-index: 97000;
  top: calc(100% + 0.35em);
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: max-content;
  min-width: 14rem;
  padding: 0.7rem 0.8rem;
  /* Same inheritance trap as the toggle: the panel sits wherever the chip was mounted. */
  font-size: 1rem;
  font-weight: 400;
  font-style: normal;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.5;
  text-align: left;
  background: var(--app-card-bg, #ffffff);
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(31, 42, 55, 0.18);
}

.units-chip__panel[hidden] {
  display: none;
}

.units-chip__label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--app-muted, #5f6b7a);
}

.units-chip__select,
.units-chip__symbol {
  padding: 0.3rem 0.4rem;
  font: inherit;
  font-size: 0.86rem;
  color: var(--app-text, #1f2a37);
  background: var(--app-card-bg, #ffffff);
  border: 1px solid var(--app-border, #d6dfea);
  border-radius: 6px;
}

.units-chip__symbol[hidden] {
  display: none;
}

.units-chip__save {
  align-self: flex-end;
  padding: 0.25rem 0.9rem;
  font: inherit;
  font-size: 0.84rem;
  color: #ffffff;
  background: var(--app-accent, #2a7de1);
  border: 1px solid var(--app-accent-dark, #1a5fb4);
  border-radius: 6px;
  cursor: pointer;
}

.units-chip__save:hover {
  background: var(--app-accent-dark, #1a5fb4);
}

@media (max-width: 40rem) {
  .units-chip__panel {
    left: auto;
    right: 0;
  }
}

@media print {
  .units-chip {
    display: none !important;
  }
}
