/* Price of the PRO ticket on the settings pages: partials/priceEditor.ejs, public/js/priceEditor.js.
   Hand-written like flight-card.css. Builds on the page's .form__input (tickets_v3.css /
   tickets_v2.css) and .segmented (new_landing.css); everything else is scoped under
   .price-editor (the block on the page) and .price-dialog (the dialog, moved to <body>).
   DESIGN.md: «Price block», «Modal (dialog)». */

/* ------------------------------------------------------------ the block on the page */

.price-editor {
  flex: 0 0 100%;
  width: 100%;
  margin-bottom: 16px;
}
.price-editor__fields,
.price-dialog__fields {
  display: flex;
}
.price-editor .form__input,
.price-dialog .form__input {
  margin-bottom: 0;
}
.price-editor .price-editor__amount,
.price-dialog .price-editor__amount {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}
.price-editor .price-editor__currency,
.price-dialog .price-editor__currency {
  flex: 0 0 148px; /* fits LIMITS.currencyMax characters: 'US Dollars' */
  max-width: none;
  margin-left: 16px;
}
/* the caption is a span (the script renames it): the label's grey, not the page's text colour */
.price-editor .price-editor__amount > span,
.price-dialog .price-dialog__caption,
.price-dialog .price-dialog__caption span {
  color: #9299A2;
}
/* the name of the base row (up to 32 characters) on one line: the field has room for one;
   the card under it shows the whole name */
.price-editor__fields .price-editor__amount > span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.price-editor .form__input.is-invalid,
.price-dialog .form__input.is-invalid {
  border-color: #FD3A57;
}
.price-editor .price-editor__hint,
.price-editor .price-editor__error,
.price-dialog .price-editor__error {
  margin: 6px 0 0;
  padding: 0 4px;
  font-size: 12px;
  line-height: 16px;
  color: #9299A2;
}
.price-editor .price-editor__error,
.price-dialog .price-editor__error {
  color: #FD3A57;
}
.price-editor [hidden],
.price-dialog [hidden] {
  display: none !important;
}

/* the card: the rows the ticket will print */
.price-editor .price-card {
  margin-top: 12px;
  padding: 14px 16px 16px;
  background: #F8F8F8;
  border-radius: 10px;
}
.price-editor .price-card__head {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}
.price-editor .price-card__title {
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}
.price-editor .price-card__badge {
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  color: #4450F2;
  background: #DAD9FB;
  border-radius: 6px;
}
.price-editor .price-card__edit {
  margin-left: auto;
  padding: 4px 0;
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #4450F2;
  background: none;
  border: 0;
  cursor: pointer;
}
.price-editor .price-card__edit:hover {
  color: #1D29C7;
  text-decoration: underline;
}
.price-editor .price-card__edit:focus-visible,
.price-dialog .price-dialog__reset:focus-visible {
  outline: 2px solid #4450F2;
  outline-offset: 2px;
  border-radius: 4px;
}
.price-editor .price-card__edit--inline {
  margin: 0;
  padding: 0;
  font-size: 12px;
  line-height: 16px;
}
.price-editor .price-card__rows {
  margin: 0;
  padding: 0;
  list-style: none;
}
.price-editor .price-card__rows li,
.price-editor .price-card__total {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 14px;
  line-height: 24px;
}
/* a long name wraps, as in the PDF; the amount keeps its line */
.price-editor .price-card__label {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}
.price-editor .price-card__amount {
  flex: none;
  margin-left: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.price-editor .price-card__total {
  margin-top: 6px;
  padding-top: 8px;
  font-size: 16px;
  font-weight: 700;
  border-top: 1px solid #E0E0E0;
}
.price-editor .price-card__total span {
  font-weight: 700;
}
.price-editor .price-card__total--only {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.price-editor .price-card__empty {
  margin: 2px 0 0;
  font-size: 14px;
  line-height: 20px;
  color: #9299A2;
}
.price-editor .price-card__note,
.price-editor .price-card__error {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 16px;
  color: #9299A2;
}
.price-editor .price-card__error {
  color: #FD3A57;
}

/* PNR converter, Simple tab: the price is Pro only; a click switches to Pro */
.price-editor--locked {
  cursor: pointer;
}
.price-editor--locked .form__input {
  background-color: #EEEEEE;
}
.price-editor--locked:hover .form__input {
  border-color: #BFC1CC;
}
.price-editor.price-editor--locked .form__input .input,
.price-editor.price-editor--locked .price-card * {
  color: #9299A2;
  cursor: pointer;
}
.price-editor.price-editor--locked .price-card .price-card__badge {
  color: #4450F2;
}

/* ------------------------------------------------------------ the dialog */

.price-dialog {
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: calc(100% - 48px);
  padding: 0;
  font-family: "Inter", Roboto, sans-serif;
  color: #141414;
  background: #fff;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}
/* the browser's own rule for <dialog>; kept for a browser without one (Safari < 15.4, the
   in-place panel), where a closed panel would stand under the card */
.price-dialog:not([open]) {
  display: none;
}
.price-dialog::backdrop {
  background: rgba(20, 20, 20, 0.5);
}
.price-dialog * {
  box-sizing: border-box;
  font-family: "Inter", Roboto, sans-serif;
}
/* only on html: overflow on body would make it a scroll container and break position: sticky
   of the sample ticket on the PNR converter */
html.price-dialog-open {
  overflow: hidden;
}
.price-dialog__wrap {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}
.price-dialog__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 8px;
}
.price-dialog .price-dialog__title {
  margin: 0;
  font-family: "Poppins", Roboto, sans-serif;
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  color: #141414;
}
.price-dialog__close {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  margin-right: -8px;
  padding: 0;
  color: #9299A2;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.price-dialog__close:hover {
  color: #141414;
  background: #EEEEEE;
}
.price-dialog__body {
  flex: 1 1 auto;
  padding: 8px 24px 16px;
  overflow: auto;
}
.price-dialog__foot {
  display: flex;
  justify-content: flex-end;
  padding: 16px 24px 20px;
  border-top: 1px solid #EEEEEE;
}
.price-dialog__btn {
  height: 48px;
  padding: 0 28px;
  font-size: 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color .2s ease-in;
}
.price-dialog__btn + .price-dialog__btn {
  margin-left: 12px;
}
.price-dialog__btn--primary {
  font-weight: 500;
  color: #fff;
  background: #4450F2;
  border: 0;
}
.price-dialog__btn--primary:hover {
  background: #1D29C7;
}
.price-dialog__btn--secondary {
  font-weight: 700;
  color: #141414;
  background: transparent;
  border: 2px solid #141414;
}
.price-dialog__btn:focus-visible,
.price-dialog__close:focus-visible,
.price-dialog .segmented__btn:focus-visible,
.price-line__remove:focus-visible,
.price-dialog__add:focus-visible {
  outline: 2px solid #4450F2;
  outline-offset: 2px;
}

/* the amount fields as on the page (label.input-big of a .form) */
.price-dialog .form__input .input {
  width: 100%;
  line-height: 23px;
  color: #141414;
}
.price-dialog .form__input.is-computed .input {
  color: #9299A2;
}
.price-dialog__computed {
  margin-left: 4px;
}
.price-dialog__computed::before {
  content: "· ";
}

.price-dialog__section {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 20px 0 4px;
}
.price-dialog__section-title {
  flex: none;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}
.price-dialog__section-sub {
  min-width: 0;
  margin-left: 12px;
  overflow: hidden;
  font-size: 12px;
  line-height: 16px;
  color: #9299A2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* the lines: name | % or Amount | value | on the ticket | remove; the first line (the base) has
   no type and no remove, its amount is an input over value and on the ticket */
.price-dialog__cols,
.price-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px 84px 92px 32px;
  column-gap: 8px;
  align-items: center;
}
.price-dialog__cols {
  padding: 6px 0 2px;
  font-size: 12px;
  line-height: 16px;
  color: #9299A2;
}
.price-dialog__cols span:nth-child(4) {
  padding-right: 13px;
  text-align: right;
}
.price-line {
  grid-template-areas: "label mode value amount remove";
  row-gap: 4px;
  padding: 5px 0;
}
.price-line--base {
  grid-template-areas: "label rest value value .";
}
/* "Calculated" while the base row is counted from the total */
.price-line--base:not(.is-computed) .price-line__rest {
  visibility: hidden;
}
.price-line__label { grid-area: label; }
.price-line__mode { grid-area: mode; }
.price-line__value { grid-area: value; }
.price-line__amount { grid-area: amount; }
.price-line__remove { grid-area: remove; }
.price-line__rest {
  grid-area: rest;
  font-size: 13px;
  line-height: 16px;
  color: #9299A2;
}
.price-line__error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0 4px;
  font-size: 12px;
  line-height: 16px;
  color: #FD3A57;
}
/* two rows, the name on its own: phones and the in-place panel (narrow form column);
   the same grid in @media (max-width: 599px) below: change both */
.price-dialog--inline .price-dialog__cols {
  display: none;
}
.price-dialog--inline .price-line {
  grid-template-columns: 112px minmax(0, 1fr) 88px 44px;
  grid-template-areas: "label label label label" "mode value amount remove";
}
.price-dialog--inline .price-line--base {
  grid-template-areas: "label label label label" "rest value value .";
}
.price-line__input {
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 500;
  color: #141414;
  background: #fff;
  border: 1px solid #D4D4D4;
  border-radius: 10px;
  outline: none;
}
.price-line__input::placeholder {
  color: #9299A2;
  font-weight: 400;
}
.price-line__input:hover {
  border-color: #BFC1CC;
}
.price-line__input:focus {
  border-color: #4356E9;
}
.price-line__input[aria-invalid="true"] {
  border-color: #FD3A57;
}
/* the datalist arrow takes room the name needs; the suggestions still open while typing */
.price-line__label::-webkit-calendar-picker-indicator {
  display: none !important;
}
.price-line__value {
  position: relative;
}
.price-line__value .price-line__input {
  padding-right: 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.price-line.is-amount .price-line__value .price-line__input,
.price-line__value--base .price-line__input {
  padding-right: 12px;
}
.price-line.is-amount .price-line__unit {
  display: none;
}
.price-line--base.is-computed .price-line__value .price-line__input {
  color: #9299A2;
}
.price-line__unit {
  position: absolute;
  top: 50%;
  right: 10px;
  font-size: 14px;
  color: #9299A2;
  transform: translateY(-50%);
  pointer-events: none;
}
.price-line__amount {
  padding-right: 13px;
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.price-line__amount.is-empty {
  color: #9299A2;
  font-weight: 400;
}
.price-line__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #9299A2;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.price-line__remove:hover {
  color: #EF4444;
  background: #FDECEC;
}
.price-dialog .segmented {
  display: flex;
  width: 100%;
}
/* "Amount" is wider than "%": buttons as wide as their text */
.price-dialog .segmented__btn {
  flex: 1 1 auto;
  height: 38px;
  padding: 0 6px;
  font-size: 14px;
  line-height: 38px;
}

.price-dialog__add {
  width: 100%;
  height: 48px;
  margin-top: 8px;
  font-size: 16px;
  color: #9299A2;
  background: transparent;
  border: 1px dashed #D4D4D4;
  border-radius: 10px;
  cursor: pointer;
}
.price-dialog__add:hover {
  color: #4356E9;
  border-color: #4356E9;
}
.price-dialog__note {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 16px;
  color: #9299A2;
}
.price-dialog__total {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 14px;
  font-size: 18px;
  line-height: 24px;
  font-weight: 700;
  border-top: 1px solid #E0E0E0;
}
.price-dialog__total span:last-child {
  margin-left: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.price-dialog__check {
  min-height: 16px;
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 16px;
  color: #9299A2;
}
.price-dialog__check.is-error {
  color: #FD3A57;
}
.price-dialog__reset {
  display: block;
  margin-top: 20px;
  padding: 0;
  font-size: 14px;
  line-height: 20px;
  color: #4450F2;
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.price-dialog__reset:hover {
  color: #1D29C7;
}

/* without showModal (Safari < 15.4): the same markup in place, under the card */
.price-dialog--inline {
  position: static;
  width: 100%;
  max-width: none;
  max-height: none;
  margin: 12px 0 0;
  border: 1px solid #D4D4D4;
  box-shadow: none;
}
.price-dialog--inline .price-dialog__wrap {
  max-height: none;
}

/* ------------------------------------------------------------ phones ($maxTabletScreenS) */

@media (max-width: 599px) {
  .price-editor .price-editor__currency,
  .price-dialog .price-editor__currency {
    flex-basis: 144px;
    margin-left: 12px;
  }
  /* 44 px touch targets around the small buttons (Edit in the head and in an error of the card,
     % | Amount, Reset to standard); the buttons keep their look. 44 px high around the middle
     of the text, whatever its line height (Edit in an error is 16 px) */
  .price-editor .price-card__edit,
  .price-dialog .segmented__btn,
  .price-dialog__reset {
    position: relative;
  }
  .price-editor .price-card__edit::after,
  .price-dialog__reset::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -16px;
    left: -16px;
    height: 44px;
    margin-top: -22px;
  }
  /* over the 3 px padding of the group, which is not a button */
  .price-dialog .segmented__btn::after {
    content: "";
    position: absolute;
    top: -3px;
    right: 0;
    bottom: -3px;
    left: 0;
  }
  .price-dialog .segmented__btn:first-child::after {
    left: -3px;
  }
  .price-dialog .segmented__btn:last-child::after {
    right: -3px;
  }
  .price-dialog .segmented__btn[data-mode="pct"] {
    min-width: 41px;
  }

  .price-dialog {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }
  .price-dialog__wrap {
    height: 100%;
    max-height: none;
  }
  /* the head and the buttons stay, the body scrolls */
  .price-dialog__head {
    padding: 10px 8px 10px 16px;
    border-bottom: 1px solid #EEEEEE;
  }
  .price-dialog__close {
    width: 44px;
    height: 44px;
    margin-right: 0;
  }
  .price-dialog__body {
    padding: 12px 16px 24px;
  }
  .price-dialog__foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }
  .price-dialog__btn {
    flex: 1 1 50%;
    padding: 0 12px;
  }
  .price-dialog__cols {
    display: none;
  }
  .price-line {
    grid-template-columns: 112px minmax(0, 1fr) 88px 44px;
    grid-template-areas: "label label label label" "mode value amount remove";
    row-gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid #EEEEEE;
  }
  .price-line--base {
    grid-template-areas: "label label label label" "rest value value .";
  }
  .price-line__remove {
    width: 44px;
    height: 44px;
  }
  .price-line__amount::before {
    content: "= ";
    color: #9299A2;
    font-weight: 400;
  }
  .price-line__input {
    font-size: 16px;
  }
  .price-dialog--inline {
    height: auto;
    margin: 12px 0 0;
    border-radius: 16px;
  }
}
