/* invoice-send.css — the two dialogs that put an invoice in front of a customer.
 *
 * Its own tokens, defined on .crm-isd and redefined for dark, the same shape
 * every other overlay here uses. The dialog sits on <body> rather than inside
 * <main>, so it must not inherit anything from a screen it happens to open over.
 *
 * The three state colours are the whole point of the send dialog and were
 * measured rather than picked: each one is at least 4.5:1 on the surface it
 * sits on, in both themes, because "تحتاج قالب" being hard to read is the same
 * as not printing it.
 */
.crm-isd__back {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 18, 22, .55);
}

.crm-isd {
  --isd-ink: #1d1b1c;
  --isd-muted: #55606c;
  --isd-line: #e2e6dd;
  --isd-card: #ffffff;
  --isd-soft: #f7f9f4;
  --isd-good: #147a4a;
  --isd-warn: var(--crm-alert-ink, #c8243b);
  --isd-bad: #b42318;
  --isd-go: #d4fb08;
  --isd-goink: #1d1b1c;

  width: min(560px, 100%);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  background: var(--isd-card);
  color: var(--isd-ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  overflow: hidden;
  /* direction follows the reader — see html.crm-rtl below, and crm-i18n.js */
  text-align: start;
}

.crm-isd__back.is-wide .crm-isd { width: min(720px, 100%); }

:root.dark .crm-isd,
.dark .crm-isd,
[data-theme="dark"] .crm-isd {
  --isd-ink: #e8eaed;
  --isd-muted: #9aa3af;
  --isd-line: #2c3138;
  --isd-card: #1b1e23;
  --isd-soft: #15181c;
  --isd-good: #6ee7b7;
  --isd-warn: var(--crm-alert-ink, #c8243b);
  --isd-bad: #fca5a5;
  --isd-go: #d4fb08;
  --isd-goink: #1d1b1c;
}

.crm-isd * { box-sizing: border-box; }

.crm-isd__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--isd-line);
}

.crm-isd__title { margin: 0; font-size: 16px; font-weight: 700; flex: 1; }

.crm-isd__x {
  border: 0;
  background: transparent;
  color: var(--isd-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 8px;
}

.crm-isd__x:hover { background: var(--isd-soft); color: var(--isd-ink); }

.crm-isd__body { padding: 16px 18px; overflow: auto; flex: 1; }

.crm-isd__foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--isd-line);
  background: var(--isd-soft);
}

.crm-isd__go {
  border: 0;
  border-radius: 8px;
  padding: 8px 20px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  background: var(--isd-go);
  color: var(--isd-goink);
}

.crm-isd__go[disabled] { opacity: .5; cursor: default; }

.crm-isd__link {
  border: 0;
  background: transparent;
  color: var(--isd-muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.crm-isd__said { font-size: 12px; color: var(--isd-muted); }

.crm-isd__note { font-size: 12.5px; color: var(--isd-muted); margin-bottom: 12px; line-height: 1.6; }
.crm-isd__note.is-bad { color: var(--isd-bad); font-weight: 600; }
.crm-isd__note.is-warn { color: var(--isd-warn); }

/* ---------------------------------------------------------------- channels */

.crm-isd__channels { display: flex; flex-direction: column; gap: 8px; }

.crm-isd__channel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--isd-line);
  border-radius: 8px;
  cursor: pointer;
}

.crm-isd__channel:hover { background: var(--isd-soft); }
.crm-isd__channel.is-off { opacity: .55; cursor: default; }
.crm-isd__channel.is-off:hover { background: transparent; }

.crm-isd__channeltext { flex: 1; min-width: 0; }
.crm-isd__channelname { display: flex; align-items: baseline; gap: 8px; }
.crm-isd__chan { font-weight: 700; font-size: 13px; }
.crm-isd__inbox { font-size: 12px; color: var(--isd-muted); overflow: hidden; text-overflow: ellipsis; }
.crm-isd__ident { font-size: 12px; color: var(--isd-muted); direction: ltr; text-align: start; }
.crm-isd__why { font-size: 11.5px; color: var(--isd-warn); margin-top: 2px; }

.crm-isd__state {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.crm-isd__state.is-open { color: var(--isd-good); background: rgba(20, 122, 74, .12); }
.crm-isd__state.is-template { color: var(--isd-warn); background: rgba(163, 92, 15, .12); }
.crm-isd__state.is-closed { color: var(--isd-bad); background: rgba(180, 35, 24, .12); }

:root.dark .crm-isd__state.is-open,
.dark .crm-isd__state.is-open { background: rgba(110, 231, 183, .14); }
:root.dark .crm-isd__state.is-template,
.dark .crm-isd__state.is-template { background: rgba(251, 191, 36, .14); }
:root.dark .crm-isd__state.is-closed,
.dark .crm-isd__state.is-closed { background: rgba(252, 165, 165, .14); }

/* ------------------------------------------------------- preview and past */

.crm-isd__preview, .crm-isd__past { margin-top: 16px; }

.crm-isd__pre {
  margin: 6px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--isd-soft);
  border: 1px solid var(--isd-line);
  font: 12.5px/1.7 inherit;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--isd-ink);
}

.crm-isd__pastrow {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--isd-line);
}

.crm-isd__pastrow:last-child { border-bottom: 0; }
.crm-isd__pastwhen { color: var(--isd-muted); white-space: nowrap; }
.crm-isd__pastkind { flex: 1; }
.crm-isd__paststate { color: var(--isd-good); font-weight: 600; }
.crm-isd__pastrow.is-bad .crm-isd__paststate { color: var(--isd-bad); }

/* ---------------------------------------------------------------- settings */

.crm-isd__block {
  padding: 14px 0;
  border-bottom: 1px solid var(--isd-line);
}

.crm-isd__block:last-of-type { border-bottom: 0; }
.crm-isd__h3 { margin: 0 0 10px; font-size: 13px; font-weight: 700; }

.crm-isd__field { display: block; margin-bottom: 12px; }
.crm-isd__label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 3px; }
.crm-isd__hint { display: block; font-size: 11.5px; color: var(--isd-muted); line-height: 1.6; margin-bottom: 5px; }

.crm-isd input[type="text"],
.crm-isd input[type="number"],
.crm-isd select,
.crm-isd textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--isd-line);
  border-radius: 8px;
  background: var(--isd-card);
  color: var(--isd-ink);
  font: inherit;
  font-size: 13px;
}

.crm-isd textarea { resize: vertical; line-height: 1.7; }

/* flex-end, not stretch: one field in this row carries a hint line and the
   other does not, and aligning their tops put the two selects on different
   baselines with a gap under one of them. */
.crm-isd__row { display: flex; gap: 12px; align-items: flex-end; }

/* Saving the customer's number sits in the body, not the footer: the footer's
   Send is still disabled at this point, and two primary buttons a centimetre
   apart - one dead, one live - is a choice nobody should have to read twice. */
.crm-isd__saverow { display: flex; align-items: center; gap: 10px; margin-top: 4px; }

/* The country and the number are one field wearing two controls. Always
   left-to-right: a phone number is read the same way in either language, and
   the code belongs in front of it. */
.crm-isd__phone { display: flex; gap: 6px; direction: ltr; }

/* Wide enough for the flag and the code, not for "United Arab Emirates" - the
   name is there to find the row, and the code is what has to stay readable
   once it is chosen. */
.crm-isd__dial { flex: 0 0 132px; width: 132px; min-width: 0; }
.crm-isd__phone input { flex: 1 1 auto; min-width: 0; }
.crm-isd__row > .crm-isd__field { flex: 1; margin-bottom: 0; }

.crm-isd__switch {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  cursor: pointer;
}

.crm-isd__switchtext { flex: 1; }
.crm-isd__switchtext .crm-isd__hint { margin-bottom: 0; }

.crm-isd__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.crm-isd__chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: var(--isd-soft);
  border: 1px solid var(--isd-line);
}

.crm-isd__chipx {
  border: 0;
  background: transparent;
  color: var(--isd-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.crm-isd__chipx:hover { color: var(--isd-bad); }

/* stretch: the button is 29px of its own padding next to a 34px field, and
 * centring the difference left it visibly floating beside the input. The
 * margin is the platform's base rule for form controls - see the same note in
 * pipeline-board.css - and this row spaces itself with gap. */
.crm-isd__adder { display: flex; gap: 6px; align-items: stretch; }
/* !important, and not by preference: the platform writes this margin as
 * `input[type]:not([type="file"]):not([type="checkbox"])...` - six :not()s deep,
 * which outweighs any class selector we can reasonably write. */
.crm-isd__adder input { margin: 0 !important; }
.crm-isd__num { width: 110px !important; }

.crm-isd__add {
  border: 1px solid var(--isd-line);
  background: var(--isd-soft);
  color: var(--isd-ink);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.crm-isd__add[disabled] { opacity: .5; cursor: default; }

.crm-isd__keys { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }

.crm-isd__key {
  border: 1px solid var(--isd-line);
  background: var(--isd-soft);
  color: var(--isd-muted);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
  direction: ltr;
}

.crm-isd__key:hover { color: var(--isd-ink); border-color: var(--isd-muted); }

.crm-isd__vars { margin-top: 10px; }
.crm-isd__vars .crm-isd__field input { direction: ltr; text-align: left; }

/* Which of these is a thread the customer actually uses. */
.crm-isd__wrote { font-size: 11.5px; color: var(--isd-muted); margin-top: 2px; }

.crm-isd__latest {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--isd-good);
  background: rgba(20, 122, 74, .12);
  white-space: nowrap;
}

:root.dark .crm-isd__latest,
.dark .crm-isd__latest,
[data-theme="dark"] .crm-isd__latest { background: rgba(110, 231, 183, .14); }

/* Arabic reads the other way. The class is set by crm-i18n.js, which is the
   only thing on the page that knows: this installation leaves the document's
   own `dir` unset even in Arabic. */
html.crm-rtl .crm-isd { direction: rtl; }

/* Primary buttons are lime with black words, Facebook blue on hover (owner, 2026-10-04). */
.crm-isd__go:hover:not([disabled]) { background: #1877f2; color: #fff; }
