/* LMail 2.0 — compose window: address fields, suggestions, drop zone.
   Owned by package C (SPEC-UI 3.6, 2.3 and the "by analogy" table of 2.4).
   Shared pieces live in components.css (.lm-chip, .lm-field, .lm-banner, .attach-picker__*, .chat-upload*). */

/* ── the window (a dialog by the recipe of 2.4) ── */
.lm-compose-layer { padding: clamp(8px, 2vw, 24px); }
/* a flex column instead of the grid rows of 3.6: hidden banners do not generate boxes, and with
   explicit grid rows the text area would land in the wrong track */
.lm-compose { position: relative; width: min(880px, calc(100vw - 48px)); height: min(86dvh, 860px); display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent-primary) 38%, var(--border-color)); border-radius: var(--r-xl);
  background: var(--bg-secondary); box-shadow: var(--shadow); animation: lm-dialog-in 180ms ease-out; }
.lm-compose[data-max="true"] { width: calc(100vw - 32px); height: calc(100dvh - 32px); }
.lm-compose[aria-busy="true"] .lm-compose__fields { opacity: .6; }

/* ── head ── */
.lm-compose__head { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 10px 14px 10px 20px; border-bottom: 1px solid var(--border-color); }
.lm-compose__head h2 { min-width: 0; font: 700 19px/1.2 var(--lm-font-heading); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lm-compose__status { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 12.5px; }
.lm-compose__back, .lm-compose__send-head { display: none; }
.lm-compose__head .chat-tool { width: 40px; height: 40px; }

/* ── fields ── */
.lm-compose__fields { display: grid; }
.lm-compose__row { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto auto; align-items: start; gap: 8px; padding: 8px 20px; border-bottom: 1px solid var(--border-color); }
.lm-compose__row:focus-within { box-shadow: inset 2px 0 0 var(--accent-primary); }
.lm-compose__row > .lm-field__label { align-self: center; padding-top: 0; line-height: 36px; }
.lm-compose__row--from { color: var(--text-secondary); }
.lm-compose__from, .lm-compose__subject { font-size: 14.5px; color: var(--text-primary); }
.lm-compose__from { align-self: center; line-height: 36px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm-compose__subject { width: 100%; min-width: 0; height: 36px; padding: 0 4px; border: 0; border-radius: var(--r-xs); background: transparent; color: var(--text-primary); font: 14.5px/36px var(--font-sans); }
.lm-compose__toggles { display: flex; gap: 4px; align-self: center; grid-column: 3 / span 2; }
.lm-compose__toggle { min-height: 32px; padding: 0 8px; border-radius: var(--r-xs); color: var(--lm-accent-ink); font-size: 13px; font-weight: 650; }
.lm-compose__toggle:hover { background: color-mix(in srgb, var(--accent-primary) 10%, transparent); }
.lm-compose__toggle--both { display: none; }

/* address field: chips + the input itself (SPEC-UI 3.6: no border, flex: 1 0 140px) */
.lm-addr { position: relative; display: flex; flex-wrap: wrap; gap: 6px; min-height: 36px; align-items: center; }
.lm-addr__chips { display: contents; }
.lm-addr__input { flex: 1 0 140px; min-width: 0; height: 32px; padding: 0 4px; border: 0; border-radius: var(--r-xs); background: transparent; color: var(--text-primary); font: 14.5px/32px var(--font-sans); }
.lm-addr__input:disabled { opacity: .55; }
.lm-chip[data-active="true"] > span { color: var(--lm-accent-ink); }

/* suggestions: by the menu recipe */
.lm-suggest { position: absolute; top: 100%; left: 0; z-index: 2; min-width: 260px; max-width: min(420px, 100%); max-height: 300px; overflow-y: auto; margin-top: 4px;
  padding: 6px; border: 1px solid color-mix(in srgb, var(--accent-primary) 30%, var(--border-color)); border-radius: var(--r-md);
  background: var(--lm-popover-bg); box-shadow: var(--lm-popover-shadow); list-style: none; }
.lm-suggest__item { display: grid; gap: 2px; min-height: 40px; padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer; }
.lm-suggest__item strong { color: var(--text-primary); font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm-suggest__item small { color: var(--text-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm-suggest__item:hover, .lm-suggest__item[aria-selected="true"] { background: color-mix(in srgb, var(--accent-primary) 10%, transparent); }
.lm-suggest__item[aria-selected="true"] strong { color: var(--lm-accent-ink); }

/* ── banners inside the window ── */
.lm-compose > .lm-banner { margin: 10px 20px 0; border-radius: var(--r-sm); }
.lm-compose > .lm-banner > span:last-child { min-width: 0; flex: 1; overflow-wrap: anywhere; }

/* ── text ── */
.lm-compose__head, .lm-compose__fields, .lm-compose > .lm-banner, .lm-compose-attach, .lm-compose__progress, .lm-compose__foot { flex: none; }
.lm-compose__body { position: relative; flex: 1; min-height: 0; display: grid; }
.lm-addr__input:focus-visible { outline-width: 2px; outline-offset: -2px; }
.lm-compose__subject:focus-visible { outline-width: 2px; outline-offset: -2px; }
.lm-compose__text { width: 100%; height: 100%; min-height: 0; padding: 16px 20px; border: 0; resize: none; background: transparent; color: var(--text-primary); font: 15px/1.6 var(--font-sans); }
.lm-compose__text:focus-visible { outline-offset: -3px; }
.lm-compose__loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent-primary); }

/* ── attachments ── */
.lm-compose-attach { padding: 8px 20px 0; }
.lm-compose-attach li { border-radius: var(--r-sm); color: var(--text-primary); }
.lm-compose-attach li > svg { color: var(--accent-primary); }
.lm-compose-attach li[data-state="error"] { border-color: color-mix(in srgb, var(--danger) 55%, var(--border-color)); color: var(--lm-danger-ink); }
.lm-compose-attach li[data-state="error"] > svg { color: var(--lm-danger-ink); }
.lm-compose-attach__err { color: var(--lm-danger-ink); }
.lm-compose__progress { margin: 8px 20px 0; }

/* ── foot ── */
.lm-compose__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border-color); }
.lm-compose__attach { border-radius: var(--r-md); }
.lm-compose__attach:focus-within { outline: 3px solid var(--lm-focus); outline-offset: 3px; }
.lm-compose__limit { color: var(--text-muted); font-size: 12.5px; }
.lm-compose__spacer { flex: 1; }
.lm-compose__foot .chat-tool { width: 36px; height: 36px; }

/* ── drop zone ── */
.lm-dropzone { position: absolute; inset: 8px; z-index: 3; display: grid; place-items: center; align-content: center; gap: 10px; border: 2px dashed var(--accent-primary); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--accent-primary) 10%, var(--bg-secondary)); color: var(--accent-primary); font-weight: 700; pointer-events: none; }

/* ── widths ── */
@media (max-width: 1199px) { .lm-compose { width: calc(100vw - 32px); } }
@media (max-width: 820px), (max-height: 500px) {
  .lm-compose-layer { padding: 0; }
  .lm-compose, .lm-compose[data-max="true"] { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .lm-compose__head { gap: 6px; min-height: 56px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; }
  .lm-compose__head h2 { font-size: 17px; }
  .lm-compose__back, .lm-compose__send-head { display: inline-flex; }
  .lm-compose__back { width: 44px; height: 44px; display: grid; place-items: center; flex: none; border-radius: var(--r-sm); color: var(--text-secondary); }
  .lm-compose__max, .lm-compose__x, .lm-compose__send-foot { display: none; }
  .lm-compose__send-head { flex: none; min-height: 44px; }
  .lm-compose__row { grid-template-columns: 64px minmax(0, 1fr) auto; padding: 8px 14px; }
  .lm-compose__toggles { grid-column: 3; }
  .lm-compose__toggle { display: none; min-height: 44px; }
  .lm-compose__toggle--both { display: inline-flex; align-items: center; }
  .lm-compose__toggle--both[hidden] { display: none; }
  .lm-compose__from, .lm-compose__subject, .lm-addr__input { font-size: 16px; }
  .lm-addr__input { height: 36px; }
  .lm-compose > .lm-banner { margin: 8px 14px 0; }
  .lm-compose__text { padding: 14px; font-size: 16px; }
  .lm-compose-attach { padding: 8px 14px 0; }
  .lm-compose__foot { position: sticky; bottom: 0; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--bg-secondary); }
  .lm-compose__attach { min-height: 44px; width: 44px; padding: 0; justify-content: center; }
  .lm-compose__attach > span { display: none; }
  .lm-compose__limit { display: none; }
  .lm-compose__save { width: 44px; min-height: 44px; padding: 0; justify-content: center; }
  .lm-compose__save > span { display: none; }
  .lm-compose__foot .chat-tool { width: 44px; height: 44px; }
  .lm-suggest { max-width: calc(100vw - 28px); }
}
