/* ============================================================================
   NabGol — CHAT COMPOSER  (the bottom bar: attach preview + input + send)
   ----------------------------------------------------------------------------
   Owns EXACTLY one thing: `.chat-input` and everything inside it (including
   the attachment preview, `.file-preview`). Does not touch `#messages` or
   `.chat-header` — those are chat-canvas.css's and chat-header.css's, by the
   same one-owner-per-region rule.

   Why this file exists: same story as chat-header.css. The message area and
   the header now speak one visual language (chat-canvas.css / chat-header.css:
   hairline instead of frame, a three-level ink scale, green spent once). The
   composer still spoke the old one — a solid/gradient bar, a saturated green
   focus glow on the input pill, icon buttons in raw `#a1a1aa`/`#8b949e`.

   Scope decision — same exclusions as chat-header.css, plus one more:
     - size, padding, gap, the safe-area math, `--nabgol-composer-offset`
       (script.js measures this composer's real height and the typing
       indicator overlay positions off it — retinting colours never touches
       height, so this is safe by construction, not by carefulness).
     - `.voice-btn.recording`: a real state (the mic is live), no --nbgc-*
       equivalent, excluded below with `:not(.recording)` rather than left to
       specificity luck.
     - any self-painted CTA chip class (`.nabgol-live-tutor-cta`,
       `.suggestion-chip--live-power`) — those paint their own surface already
       (chip ink, not canvas ink); this file never touches those class names.
       `.live-call-btn--tutor`'s ring WAS on that list too, on the grounds that
       this file sets no box-shadow. Section 4b now does, for one declaration
       and one reason: the ring was a hard-coded accent that no theme switch
       could reach, and it is the composer's second accent element. It is
       re-tinted, never removed.

   The specificity problem — found by grepping "chat-input|input-wrapper|
   composer-" in chat-flagship-polish.css BEFORE writing a rule here (the
   lesson chat-header.css left in docs/CHAT_CANVAS_HANDOFF.md): that file
   already ships a light-theme unification pass for several of these exact
   selectors (`html[data-theme="light"] body:is(...) .chat-input .input-wrapper
   {...}`, `.composer-hint {...}`, `.composer-ai-disclaimer {...}`, a
   mobile-only `.input-wrapper` variant). Each carries an extra
   `[data-theme="light"]` attribute selector — one more specificity "class"
   than an equivalent plain rule here, so for any property BOTH files claim,
   a same-depth selector here LOSES even though this file loads later (a
   loss, not a tie load order could settle). Section 7 below duplicates each
   of those exact selector shapes to force a genuine tie, which this file's
   later load order then wins. Properties with no such competing rule (the
   bar itself, the attachment preview, the toolbar icons, send) don't need a
   duplicate — this file's own `.chat-input`-scoped selector already carries
   more classes than anything currently fighting it.

   Load order: after chat-canvas.css AND chat-header.css, in both templates.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1) THE BAR ITSELF — hairline instead of a filled/gradient slab.
   --------------------------------------------------------------------------- */
body:is(.desktop-chat, .mobile-chat) .chat-input {
  background: none !important;
  background-image: none !important;
  border-top: 1px solid var(--nbgc-hairline) !important;
}
/* 2026-09-05, work 8 of docs/CHAT_REDESIGN_MASTER_PLAN.md §21.
   ON DESKTOP THERE IS NO LINE. The hairline above is right for the phone, where
   the bar spans the same width as the conversation and the rule reads as the
   edge of one column. On a 1440px desktop the bar spans the window while the
   conversation is 820px, so the same hairline drew a full-bleed rule under a
   narrow column — the "فوترِ تمام‌عرض" the owner reported. What separates the
   composer from the canvas there is the fade at the column's own width
   (chat-desktop-shell.css, .chat-input::before), not a line across the screen.
   Mobile is deliberately untouched: it has its own document and its own gate. */
body.desktop-chat .chat-input {
  border-top: none !important;
  /* AND IT PAINTS ITSELF, AT THE COLUMN'S WIDTH, NOT THE WINDOW'S.
     The bar has to stay a full-track grid item (it shares the column's centring
     with #messages), so the paint is narrowed with background-size instead of
     the element: the band starts and ends exactly where the reading column
     does, at every viewport width and with the dossier panel open.

     OPAQUE UNDER THE BAR, ON PURPOSE. «شفاف» in §21 means "no slab across the
     window", not "see through to the conversation". A translucent composer
     leaves the input pill's own controls legible on top of moving text, and a
     message's ویرایش/حذف chips legible and unclickable underneath — readable and
     dead, which test_controls_always_reachable.js treats as worse than an
     honest cover, and which it caught in this change's first draft. Only the
     top 24px fade, so an answer scrolling up dims into the band instead of
     meeting a hard edge.

     background-COLOR stays transparent and the gradient is a background-IMAGE:
     that is also what makes the reachability audit read this bar as a real
     cover (it counts an image as fully painted and cannot sample one), which a
     ::before pseudo-element could never do — the audit walks DOM ancestors. */
  background-color: transparent !important;
  background-image: linear-gradient(
    to bottom,
    transparent 0,
    var(--nbgc-canvas-face, #0d1117) 24px,
    var(--nbgc-canvas-face, #0d1117) 100%) !important;
  background-repeat: no-repeat !important;
  background-position: center bottom !important;
  background-size: var(--stage-col-width, 100%) 100% !important;
}

/* One font-family line, one token, owner's call: what the reader types is set in
   the same face as what they get back. Defined once, in chat-canvas.css.
   The selector has to name the field itself, not just the bar: a <textarea> does
   not inherit font-family — form controls start from the UA's own font — so
   putting this on `.chat-input` alone would restyle the placeholder row and the
   hint while leaving the reader's actual sentence in the browser default. */
body:is(.desktop-chat, .mobile-chat) .chat-input,
body:is(.desktop-chat, .mobile-chat) .chat-input #input,
body:is(.desktop-chat, .mobile-chat) .chat-input textarea {
  font-family: var(--nbgc-font) !important;
}

/* ---------------------------------------------------------------------------
   2) THE INPUT PILL — the one surface this region keeps (same idea as the
   user bubble: a quiet, self-contained field, not a slab under everything).
   --------------------------------------------------------------------------- */
body:is(.desktop-chat, .mobile-chat) .chat-input .input-wrapper {
  background: var(--nbgc-surface) !important;
  border-color: var(--nbgc-hairline) !important;
}
body:is(.desktop-chat, .mobile-chat) .chat-input .input-wrapper:focus-within {
  border-color: var(--nbgc-accent-edge) !important;
  /* The focus ring moves OUT here from the field it used to sit inside (see
     the `:focus` rule below). A wash, not a fill: a keyboard user still gets
     an unmistakable halo, and it costs the accent budget nothing because a
     7-10% alpha never lands near the accent itself. */
  box-shadow: 0 0 0 3px var(--nbgc-accent-wash) !important;
}
body:is(.desktop-chat, .mobile-chat) .chat-input #input,
body:is(.desktop-chat, .mobile-chat) .chat-input textarea {
  color: var(--nbgc-ink) !important;
  background: transparent !important;
}
/* style-common.css:457 rings the focused field with `0 0 0 3px
   rgba(66,133,244,.2)` — Google blue, from the era before this product had a
   colour. It sat INSIDE the pill whose border already says "focused", so the
   composer showed two focus rings in two different hues, one of them not the
   brand's. Found by the accent-budget harness: a blue box in a green product
   is invisible to a contrast check and obvious in a screenshot. */
body:is(.desktop-chat, .mobile-chat) .chat-input #input:focus,
body:is(.desktop-chat, .mobile-chat) .chat-input textarea:focus {
  box-shadow: none !important;
  border-color: transparent !important;
  outline: none !important;
}
body:is(.desktop-chat, .mobile-chat) .chat-input textarea::placeholder,
body:is(.desktop-chat, .mobile-chat) .chat-input #input::placeholder {
  color: var(--nbgc-ink-faint) !important;
}

/* ---------------------------------------------------------------------------
   3) ATTACHMENT PREVIEW — same neutral surface as the input pill so a photo
   about to be sent doesn't sit in a differently-toned box right above it.
   --------------------------------------------------------------------------- */
body:is(.desktop-chat, .mobile-chat) .chat-input.composer-has-attach {
  background: var(--nbgc-surface) !important;
  border-color: var(--nbgc-hairline) !important;
}
body:is(.desktop-chat, .mobile-chat) .file-preview .file-name {
  color: var(--nbgc-ink) !important;
}
body:is(.desktop-chat, .mobile-chat) .file-preview .file-meta,
body:is(.desktop-chat, .mobile-chat) .file-preview .fp-caption-hint {
  color: var(--nbgc-ink-soft) !important;
}

/* ---------------------------------------------------------------------------
   4) TOOLBAR ICONS — voice/attach/camera/live-call. Same ink scale as the
   header. `.recording` is a live state with no --nbgc-* equivalent (and a
   meaningful one: the mic is on) — excluded on purpose, not left to chance;
   its own `.chat-input .composer-action-btn` ancestor chain plus the
   `.recording` class already out-classes this file's `:not(.recording)`
   selector, so it is never a specificity coin-flip either.
   --------------------------------------------------------------------------- */
body:is(.desktop-chat, .mobile-chat) .chat-input .composer-action-btn:not(.recording),
body:is(.desktop-chat, .mobile-chat) .chat-input .composer-action-btn:not(.recording) .ico {
  background: none !important;
  background-image: none !important;
  color: var(--nbgc-ink-soft) !important;
}
body:is(.desktop-chat, .mobile-chat) .chat-input .composer-action-btn:not(.recording):hover,
body:is(.desktop-chat, .mobile-chat) .chat-input .composer-action-btn:not(.recording):focus-visible,
body:is(.desktop-chat, .mobile-chat) .chat-input .composer-action-btn:not(.recording):hover .ico,
body:is(.desktop-chat, .mobile-chat) .chat-input .composer-action-btn:not(.recording):focus-visible .ico {
  background: var(--nbgc-surface-2) !important;
  color: var(--nbgc-ink-strong) !important;
}

/* ---------------------------------------------------------------------------
   4b) THE LIVE-CALL RING — the composer's second accent element.
   chat-flagship-polish.css rings `.live-call-btn--tutor` with a hard-coded
   `0 0 0 2px rgba(52,211,153,.35)`. The file header above said this file never
   sets box-shadow; that stance was written when the only question was colour.
   The question now is weight, and a ring at .35 alpha next to a solid accent
   send button gives the composer two things competing to be "the action".
   It is NOT removed — the ring is how a tutor robot says "you can call me from
   right here", a real capability, and the product wall forbids taking that
   away. It moves onto --nbgc-accent-edge: the same edge weight the canvas
   spends on its closing question, one step below send, and a token instead of
   a hex that no theme switch could ever reach (that .35 mint was identical in
   day and night, on two completely different backgrounds).
   --------------------------------------------------------------------------- */
body:is(.desktop-chat, .mobile-chat) .chat-input .live-call-btn--tutor {
  box-shadow: 0 0 0 2px var(--nbgc-accent-edge) !important;
}

/* ---------------------------------------------------------------------------
   5) SEND — the one legitimate accent use in this region (the primary
   action), same as the message area reserves its accent for the closing
   question. The old raw `color:#fff` on the icon measured only 1.92:1 on
   this theme's bright mint accent (test_chat_composer_gate.js caught it, not
   inspection) — --nbgc-ink-on-accent replaces it. Same token family, same
   file that already owns every other --nbgc-* value; not a parallel set.
   --------------------------------------------------------------------------- */
body:is(.desktop-chat, .mobile-chat) .chat-input .send-btn {
  background: var(--nbgc-accent) !important;
  background-image: none !important;
  color: var(--nbgc-ink-on-accent) !important;
}
body:is(.desktop-chat, .mobile-chat) .chat-input .send-btn .ico {
  color: var(--nbgc-ink-on-accent) !important;
  stroke: currentColor !important;
}

/* ---------------------------------------------------------------------------
   6) HINT + DISCLAIMER — quiet chrome under the field.
   --------------------------------------------------------------------------- */
body:is(.desktop-chat, .mobile-chat) .chat-input .composer-hint {
  color: var(--nbgc-ink-faint) !important;
}
body:is(.desktop-chat, .mobile-chat) .chat-input .composer-ai-disclaimer {
  color: var(--nbgc-ink-faint) !important;
}

/* ---------------------------------------------------------------------------
   6b) THE CHROME LINE — one row, on desktop only (work 8, §21.3).

   Two stacked <p> elements under the field cost 47px of reading height and
   still said less than one sentence: "Enter ارسال · Shift+Enter خط جدید" on
   one row, the AI disclaimer on the next. They are one row now, separated by
   the same «·» the hint already uses between its own two halves.

   THE INK CHANGES, AND THAT IS NOT COSMETIC. Section 6 above paints both lines
   --nbgc-ink-faint, whose own token comment in chat-canvas.css reads «4.0:1 —
   hairline labels only, never prose». §21.3 sets the floor for this line at
   4.5:1 in BOTH themes, so on desktop it moves to --nbgc-ink-soft (7.1:1 night,
   6.4:1 day). It also now sits on a soft pill instead of on the bare canvas —
   the line has to stay readable while an answer scrolls behind the fade — and
   the pill is sized to the text, never to the window: a full-width strip here
   would be the full-bleed footer coming back wearing a different colour.

   Mobile keeps section 6 exactly as it was: mobile.php has no .composer-chrome
   and no hint line, and this file's mobile branch is not what §21 is about. */
body.desktop-chat .chat-input .composer-chrome {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: baseline !important;
  justify-content: center !important;
  gap: 0 8px !important;
  width: fit-content !important;
  max-width: var(--stage-col-width, 100%) !important;
  margin: 6px auto 0 !important;
  padding: 2px 12px !important;
  border-radius: 999px !important;
  background: var(--nbgc-surface) !important;
  box-sizing: border-box !important;
}
body.desktop-chat .chat-input .composer-chrome .composer-hint,
body.desktop-chat .chat-input .composer-chrome .composer-ai-disclaimer,
html[data-theme="light"] body.desktop-chat .chat-input .composer-chrome .composer-hint,
html[data-theme="light"] body.desktop-chat .chat-input .composer-chrome .composer-ai-disclaimer {
  color: var(--nbgc-ink-soft) !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.5 !important;
  white-space: normal !important;
  /* style-desktop.css:361 stretches .composer-hint to --composer-max (the whole
     820px column) with !important. Inside a fit-content pill that is not a
     shorter line, it is the full-bleed strip again — so the two sentences give
     the width back and let the row size to the text. */
  width: auto !important;
  max-width: none !important;
}
/* The separator belongs to the row, not to either sentence: putting it in the
   markup would have made assistant-local.js's rewrite of the disclaimer
   responsible for a punctuation mark it knows nothing about. */
body.desktop-chat .chat-input .composer-chrome .composer-ai-disclaimer::before {
  content: '·';
  margin-inline-end: 8px;
  opacity: 0.7;
}

/* ---------------------------------------------------------------------------
   7) LIGHT-THEME TIE-BREAKS — see the file header. Same selector shape as
   the chat-flagship-polish.css rules being out-specificity'd, so this is a
   real tie that this file's later load order settles.
   --------------------------------------------------------------------------- */
html[data-theme="light"] body:is(.desktop-chat, .mobile-chat) .chat-input .input-wrapper {
  background: var(--nbgc-surface) !important;
  border-color: var(--nbgc-hairline) !important;
  color: var(--nbgc-ink) !important;
}
html[data-theme="light"] body.mobile-chat .input-wrapper {
  background: var(--nbgc-surface) !important;
  border-color: var(--nbgc-hairline) !important;
  box-shadow: none !important;
}
html[data-theme="light"] body:is(.desktop-chat, .mobile-chat) .chat-input #input {
  color: var(--nbgc-ink) !important;
}
html[data-theme="light"] body:is(.desktop-chat, .mobile-chat) .composer-hint {
  color: var(--nbgc-ink-faint) !important;
}
html[data-theme="light"] body:is(.desktop-chat, .mobile-chat) .composer-ai-disclaimer {
  color: var(--nbgc-ink-faint) !important;
}

/* ---------------------------------------------------------------------------
   9) THE PHONE DISCLAIMER NEVER GETS CLIPPED (owner, 1405-07-03).
   style-controls.css sets it nowrap + overflow:hidden at 10px, and the phone
   copy had been trimmed to a fragment («… اگر درست نبود ⟳ بازتولید») just to
   squeeze into that one line — still exactly as wide as a 390px screen and
   cut on anything narrower. It is a whole sentence now («… ⟳ را بزنید»), and
   on a narrow screen it wraps into two balanced lines instead of losing its end.
   --------------------------------------------------------------------------- */
body.mobile-chat .chat-input .composer-ai-disclaimer {
  display: block !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  text-wrap: balance;
  font-size: 11px !important;
  line-height: 1.45 !important;
}
body.mobile-chat .chat-input .composer-ai-disclaimer .composer-ai-regen-ico {
  vertical-align: -4px;
  margin: 0 2px;
}
