# Mobile sheet

Vùng chat riêng trên mobile: khung, lớp nền chặn trang và composer khi bàn phím mở, theo từng surface đang chạy.

## Key rules

- AI Mode: mobile khi viewport tối đa 899px; sheet chừa 12px phía trên và lớp scrim chặn trang phía sau khi mở.
- AI Mode: composer dock nâng theo `--aimode-kb-inset` do hook đọc visualViewport; box nút header trên mobile là 32px, vùng chạm mở rộng qua pseudo-element.
- Classic: mobile khi width tối đa 899px; popup đặt top 12px, cao hết phần còn lại và nút đóng tối thiểu 44px.
- Mỗi surface có composition riêng; không trộn class của AI Mode vào Classic.

## Use when / Avoid

Dùng khi chat chiếm gần hết màn hình điện thoại. Giá trị của hai surface khác nhau, đọc đúng tab.

### Use instead

| Component | Use when |
| --- | --- |
| `Overlay` | AI Mode: scrim đứng sau panel đang mở. |
| `SearchBar` | AI Mode: composer dock giữ trên bàn phím và safe area. |

## Entry points

| Surface | Owner |
| --- | --- |
| AI Mode | Panel dưới PanelLazy mở bằng launcher; `Overlay` mount cùng panel |
| Classic | Popup Avada-Faqs_Popup nhận class mobile từ WidgetFAQ |

## Flow

| Surface | Step | Trigger | UI shown | Component | Copy + i18n key | Timing |
| --- | --- | --- | --- | --- | --- | --- |
| AI Mode | Mở | Panel mở | Scrim hiện, trang phía sau không nhận tương tác | Overlay | Không có chữ | opacity 400ms khi mở |
| AI Mode | Bàn phím mở | visualViewport resize hoặc scroll | Composer dock dịch lên theo --aimode-kb-inset | SearchBar | Không có chữ | Theo sự kiện viewport |
| AI Mode | Đóng | Click ngoài panel | Panel thu lại | Panel | Không có chữ | Theo sự kiện click |
| Classic | Mở trên mobile | width tối đa 899px | Popup phủ từ top 12px tới đáy | Popup sheet | Không có chữ | Tính khi render |

## Edge cases

| Surface | Case | Behaviour |
| --- | --- | --- |
| AI Mode | Composer đặt ở slot trên | Không theo bàn phím; hook chỉ bật cho composer dock |
| AI Mode | Chế độ preview của admin | Hook không bật; --aimode-kb-inset về 0px |
| Classic | Preview admin | Rule top 12px chỉ áp khi popup không có class admin |
| Classic | Voice input | Composer tải control ghi âm riêng khi không phải preview hoặc merchant test AI. |
| AI Mode | Voice input | Composer tải control ghi âm khi ở chế độ hỏi, panel không nghỉ, không bị gate hay preview. |

## Live preview

AI Mode scrim và trang phía sau là fixture trong shell; Keyboard open chỉ đặt footer inset fixture, bàn phím thật: N/A trong preview. Classic không dùng AI scrim.

Classic: bubble thu gọn là fixture từ chatty-icon-button; Current: FloatButtonWidget, chưa có element. Bag và menu (…) ở header: N/A trong preview.

AI Mode: SignIn, EmailContinue, Reset và Bag ở header: N/A trong preview.

### Standard

Example (Standard) — Widget thread Standard; tương tác bằng dữ liệu fixture.

```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import {IconClose, IconMessage} from '@avada/chatty-ui/elements/icon-glyphs.js';
import '@avada/chatty-ui/elements/surface.js';
import '@avada/chatty-ui/elements/avatar.js';
import '@avada/chatty-ui/elements/badge.js';
import '@avada/chatty-ui/elements/icon-button.js';
import '@avada/chatty-ui/elements/launcher.js';
import '@avada/chatty-ui/elements/button.js';
import {sameGroup} from '@avada/chatty-ui/behaviors/messages.js';

// Reference viewport: 1280 × 900 desktop, 390 × 900 mobile.
const sizes = {
  classic: {width: 400, height: 700},
  'ai-mode': {width: 820, height: 657},
  admin: {width: 527, height: 842}
};
const question = {
  id: 'question',
  senderType: 'customer',
  text: 'Can you help me?',
  createdAt: '2026-01-15T10:00:00Z'
};

/** Viewport-relative sizing survives the initial hidden iframe layout. */
function widgetSize(surface) {
  const mode = new URLSearchParams(location.search).get('mobile');
  const isMobile = mode === null ? innerWidth < 900 : mode === 'true';
  const width = `min(${sizes[surface].width}px, max(0px, 100vw - 40px))`;
  const height = isMobile
    ? `min(${surface === 'admin' ? 848 : 888}px, round(down, calc(${width} * 2.2), 1px))`
    : `${sizes[surface].height}px`;
  return {...sizes[surface], height, mobile: isMobile};
}

/** Local immutable message state with real subscriptions for live previews. */
function fixtureStore(initial) {
  let state = {messages: initial};
  const listeners = new Set();
  return {
    getState: () => state,
    subscribe(listener) {
      listeners.add(listener);
      return () => listeners.delete(listener);
    },
    setMessages(messages) {
      state = {messages};
      listeners.forEach(listener => listener());
    }
  };
}

/** Appends the viewer message without replacing the existing conversation. */
function appendViewer(store, surface, text) {
  const message = {
    id: `viewer-${store.getState().messages.length}`,
    senderType: surface === 'admin' ? 'agent' : 'customer',
    senderMeta: {name: surface === 'admin' ? 'Alex' : 'You'},
    text,
    createdAt: new Date().toISOString()
  };
  store.setMessages([...store.getState().messages, message]);
}

/**
 * One shell owns surface sizing, header, thread and composer for every pattern.
 * @param {string} surface
 * @param {Object} store
 * @param {Object} strings
 * @param {Object} content
 * @param {Function} renderMessage
 * @param {Function} onSend
 * @param {Object} registry
 * @param {boolean} composerHidden
 * @param {string} title
 * @param {Object} headerStart
 * @param {Object} headerActions
 * @param {boolean} sheet
 * @param {string | null} status
 * @returns {Object}
 */
function patternShell({
  surface,
  store,
  strings = {header: 'Store assistant', message: 'Message', send: 'Send'},
  content,
  renderMessage,
  onSend,
  registry,
  title,
  headerStart,
  headerActions,
  status = 'online',
  sheet = false,
  composerHidden = false
}) {
  const size = widgetSize(surface);
  const mobileSheet = sheet && size.mobile;
  if (mobileSheet) {
    size.width = 'none';
    size.height = 'calc(100dvh - 12px)';
  }
  const toggle = (event, closed) => {
    const frame = event.currentTarget.closest('[data-pattern-frame]');
    const panel = frame.querySelector('chatty-surface');
    const launcher = frame.querySelector('[data-pattern-launcher]');
    panel.hidden = closed;
    frame.dataset.closed = String(closed);
    const background = frame.querySelector('[data-sheet-page]');
    if (background) background.inert = !closed && surface === 'ai-mode';
    launcher.hidden = !closed;
    if (closed) {
      launcher.style.insetBlockEnd = `${Math.max(surface === 'ai-mode' ? 40 : 16, frame.getBoundingClientRect().bottom - innerHeight + 20)}px`;
      launcher.focus({preventScroll: true});
    } else {
      const composer = panel.querySelector('chatty-composer');
      const input = !composer.hidden
        ? composer.renderRoot.querySelector('textarea')
        : (panel
            .querySelector('chatty-contact-form:not([hidden])')
            ?.renderRoot.querySelector('chatty-text-field') ??
          panel.querySelector('form chatty-text-field') ??
          panel.querySelector('[data-welcome-invitation]:not([hidden]) chatty-button') ??
          panel
            .querySelector('chatty-pre-chat:not([hidden])')
            ?.renderRoot.querySelector('chatty-button'));
      input?.focus({preventScroll: true});
    }
  };
  const sender = message => {
    const content = renderMessage?.(message) ?? {};
    const messages = store.getState().messages;
    const previous = messages[messages.indexOf(message) - 1];
    if (message.senderType !== 'bot' || sameGroup(message, previous)) return content;
    return {
      ...content,
      sender: html`<span style="display:inline-flex;align-items:center;gap:6px"
        ><chatty-avatar size="sm" label="Assistant">A</chatty-avatar
        >${content.sender ?? message.senderName ?? message.senderMeta?.name ?? 'Assistant'}</span
      >`
    };
  };
  return html`<style>
      [data-pattern-frame] {
        display: flex;
        position: relative;
        justify-content: center;
        inline-size: 100%;
        min-inline-size: 0;
      }
      [data-pattern-frame='classic'] {
        justify-content: flex-end;
      }
      [data-pattern-frame] chatty-surface::part(header) {
        padding: 0;
      }
      [data-pattern-frame='classic'] chatty-surface::part(header),
      [data-pattern-frame='ai-mode'] chatty-surface::part(header) {
        border-bottom-width: 0;
      }
      [data-pattern-frame] [hidden] {
        display: none !important;
      }
      [data-pattern-header] {
        display: flex;
        align-items: center;
        gap: 10px;
        box-sizing: border-box;
        min-inline-size: 0;
        block-size: 52px;
        padding: 0 16px;
      }
      [data-pattern-frame='classic'] [data-pattern-header] {
        block-size: 56px;
        background: var(--chatty-color-accent);
        color: var(--chatty-color-on-accent);
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-icon-button {
        --chatty-color-border-focus: var(--chatty-color-on-accent);
      }
      [data-pattern-frame='admin'] [data-pattern-header] {
        block-size: 68px;
        padding: 8px 12px;
      }
      [data-pattern-header] chatty-avatar {
        --chatty-avatar-size: 32px;
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-avatar {
        --chatty-avatar-background: #fff;
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-avatar::part(base) {
        color: #303030;
        border: 1px solid #767676;
      }
      [data-pattern-actions] {
        display: flex;
        align-items: center;
        gap: 8px;
      }
      [data-pattern-title] {
        flex: 1;
        min-inline-size: 0;
        display: flex;
        flex-direction: column;
      }
      [data-pattern-frame='admin'] [data-pattern-title] {
        gap: 4px;
      }
      [data-pattern-frame='admin'] [data-pattern-title] strong {
        display: flex;
        align-items: center;
        min-block-size: 28px;
        font: var(--p-font-weight-semibold, 650) var(--p-text-heading-md-font-size, 14px) /
          var(--p-text-heading-md-font-line-height, 20px) var(--p-font-family-sans, system-ui);
      }
      [data-pattern-title] strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      [data-pattern-header] chatty-icon-button {
        --chatty-icon-button-size: 32px;
        --chatty-icon-button-color: currentColor;
      }
      @media (max-width: 899px), (pointer: coarse) {
        [data-pattern-header] chatty-icon-button {
          --chatty-icon-button-size: 44px;
        }
      }
      [data-pattern-launcher] {
        position: absolute;
        inset-inline-end: 0;
        inset-block-end: 0;
      }
      [data-pattern-frame='ai-mode'] [data-pattern-launcher] {
        inset-inline-end: auto;
        inset-inline-start: 50%;
        transform: translateX(-50%);
      }
      [data-pattern-frame='classic'] [data-pattern-launcher] {
        --chatty-icon-button-size: 56px;
        border-radius: 50%;
        background: var(--chatty-color-accent);
        --chatty-icon-button-color: var(--chatty-color-on-accent);
      }
      [data-sheet-mobile='true'] {
        position: fixed;
        inset: 0;
        inline-size: 100vw;
      }
      [data-sheet-mobile='true'] chatty-surface::part(base) {
        border-radius: 16px 16px 0 0;
      }
      [data-sheet-mobile='true'] chatty-surface {
        position: relative;
        z-index: 2;
        margin-block-start: 12px;
      }
      [data-sheet-page],
      [data-sheet-scrim] {
        position: absolute;
        inset: 0;
        box-sizing: border-box;
      }
      [data-sheet-page] {
        padding: 20px;
        background: var(--chatty-color-bg-surface);
        color: var(--chatty-color-text);
      }
      [data-sheet-scrim] {
        z-index: 1;
        border: 0;
        background: rgb(0 0 0 / 40%);
        animation: sheet-scrim 400ms ease;
      }
      [data-sheet-mobile='true'][data-closed='true'] [data-sheet-scrim] {
        display: none;
      }
      [data-sheet-mobile='true'] [data-pattern-launcher] {
        z-index: 3;
      }
      @keyframes sheet-scrim {
        from {
          opacity: 0;
        }
        to {
          opacity: 1;
        }
      }
      @media (prefers-reduced-motion: reduce) {
        [data-sheet-scrim] {
          animation: none;
        }
      }
    </style>
    <div
      data-pattern-frame=${surface}
      data-sheet-mobile=${String(mobileSheet)}
      data-closed="false"
      style=${`block-size:calc(${size.height} + ${mobileSheet ? 12 : 0}px)`}
    >
      ${
        mobileSheet
          ? html`<div data-sheet-page .inert=${surface === 'ai-mode'}>
                <p>Example storefront</p>
                <chatty-button
                  variant="secondary"
                  type="button"
                  @click=${event => {
                    event.currentTarget.textContent = 'Products opened';
                  }}
                >
                  Browse products
                </chatty-button>
              </div>
              ${surface === 'ai-mode' ? html`<button type="button" data-sheet-scrim tabindex="-1" aria-label="Close chat background" @click=${event => toggle(event, true)}></button>` : ''}`
          : ''
      }
      <chatty-surface
        data-chatty-surface=${surface}
        data-chatty-theme=${surface === 'admin' ? 'light' : (document.documentElement.dataset.chattyTheme ?? document.documentElement.dataset.theme ?? 'light')}
        style=${`inline-size:100%;max-inline-size:${mobileSheet ? 'none' : `${size.width}px`};--chatty-surface-height:${size.height}`}
        .store=${store}
        .registry=${registry ?? null}
        viewer-type=${surface === 'admin' ? 'agent' : 'customer'}
        .selfTypes=${surface === 'admin' ? ['agent', 'bot'] : null}
        .renderMessage=${sender}
      >
        <div slot="header" data-pattern-header>
          ${headerStart ?? ''}
          ${surface === 'admin' ? '' : html`<chatty-avatar label="Store" .status=${status}>S</chatty-avatar>`}
          <span data-pattern-title
            ><strong
              >${title ?? (surface === 'admin' ? 'Customer conversation' : strings.header)}</strong
            >${surface === 'admin' ? html`<chatty-badge size="sm" variant="secondary" style="align-self:flex-start">Customer</chatty-badge>` : status == null ? '' : html`<small data-pattern-status>${status === 'online' ? 'Open' : 'Closed'}</small>`}</span
          >
          <span data-pattern-actions>${headerActions ?? ''}</span>
          ${
            surface === 'admin'
              ? ''
              : html`<chatty-icon-button label="Close panel" @click=${event => toggle(event, true)}
                  >${IconClose()}</chatty-icon-button
                >`
          }
        </div>
        <chatty-thread .strings=${{bot: 'Assistant', ...strings}}></chatty-thread>${content ?? ''}
        <chatty-composer
          slot="footer"
          ?hidden=${composerHidden}
          .label=${strings.message}
          .sendLabel=${strings.send}
          @chatty-send=${event => {
            appendViewer(store, surface, event.detail.text);
            if (onSend) onSend(event.detail.text, event.currentTarget);
            else if (surface !== 'admin')
              store.setMessages([
                ...store.getState().messages,
                {
                  id: `fixture-${store.getState().messages.length}`,
                  senderType: 'bot',
                  text: `You asked: “${event.detail.text}”. I can help with that.`,
                  hasEventTime: false
                }
              ]);
          }}
        ></chatty-composer> </chatty-surface
      >${
        surface === 'admin'
          ? ''
          : surface === 'ai-mode'
            ? html`<chatty-launcher
                data-pattern-launcher
                hidden
                label="Open chat"
                @chatty-open=${event => toggle(event, false)}
                >${IconMessage({size: 20, slot: 'icon'})}Ask a question</chatty-launcher
              >`
            : html`<chatty-icon-button
                data-pattern-launcher
                hidden
                size="lg"
                label="Open chat"
                @click=${event => toggle(event, false)}
                >${IconMessage({size: 24})}</chatty-icon-button
              >`
      }
    </div>`;
}

export function Standard({surface}) {
  const store = fixtureStore([
    question,
    {id: 'answer', senderType: 'bot', text: 'Of course. What would you like to know?'}
  ]);
  return patternShell({surface, store, title: 'Example store', sheet: true});
}
```

### Current

Example (Current (React), being replaced) — Nút đóng của header Classic; dùng toggle mobile để thấy 44px. JSX lấy từ caller Header.

```jsx
import {MoreHorizIcon, CloseIcon, ArrowBackIcon, MailOutlineIcon} from '@assets/components/icons';

            <button
              onClick={() => handleCloseModal()}
              aria-label={i18n('Close')}
              className="Avada-Faqs_HeaderClose Avada-Faqs_HeaderClose-button"
              style={{
                background: 'none',
                border: 'none',
                cursor: 'pointer',
                display: 'flex',
                color: 'var(--faqsActionColor)',
                zIndex: 2
              }}
            >
              <CloseIcon size={20} />
            </button>
```

## AI Mode

### Import / element

#### Overlay

| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Overlay` | @scripttag/v2/components/Overlay.jsx | Mount cạnh root widget, ngoài .chatty-ai-mode |

#### Panel sheet

| Component / element | Import / file | Scope root |
| --- | --- | --- |
| Panel sheet (class aimode-panel) |  | .chatty-ai-mode.is-mobile |

#### Docked composer

| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `SearchBar` | @scripttag/v2/components/SearchBar/SearchBar.jsx | .chatty-ai-mode .aimode-sbar-dock |

### Anatomy

#### Overlay

| Part | Element |
| --- | --- |
| 1 | Một div fixed phủ viewport, tạo bằng DOM; chỉ giữ một scrim. |

#### Panel sheet

| Part | Element |
| --- | --- |
| 1 | Panel với header, split và body. |

#### Docked composer

| Part | Element |
| --- | --- |
| 1 | Dock chứa composer pill. |

### Placement / order

#### Overlay

| Context | Order |
| --- | --- |
| Page | Nằm ngay dưới root của widget về z-index. |

#### Panel sheet

| Context | Order |
| --- | --- |
| Mobile | Panel phủ chiều ngang viewport; sidebar thành overlay. |

#### Docked composer

| Context | Order |
| --- | --- |
| Mobile | Đáy sheet, full-bleed; dịch lên theo bàn phím khi focus. |

### Props

#### Overlay

| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `open` | boolean | true / false | Caller | Bật class is-open. |
| `theme` | string | light / dark | dark | Đặt data-theme cho scrim. |

#### Panel sheet

| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `--aimode-panel-height` | CSS custom property | `calc(var(--aimode-vh, 100svh) - 12px)` | min(73svh, calc(100svh - 200px)) | Mobile ghi đè chiều cao desktop. |

#### Docked composer

| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `enabled` | boolean | true / false | Caller | Hook chỉ bật cho composer dock khi mobile focused. |

### Sizes

#### Overlay

| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Scrim | Phủ viewport (top, right, bottom, left 0) | — | — | — | — | Chặn trang phía sau khi mở | Không có override theo viewport |

#### Panel sheet

| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Mobile sheet | `calc(var(--aimode-vh, 100svh) - 12px)` | `--chatty-layout-inset-mobile` | — | — | — | Box header 32px; vùng chạm mở rộng | Media max-width 899px; JS class is-mobile |
| Sign-in pill | 44px | — | — | — | — | 44px | Class is-mobile |

#### Docked composer

| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Dock mobile | — | `var(--chatty-space-300) var(--chatty-layout-inset) calc(var(--chatty-space-300) + env(safe-area-inset-bottom, 0px))` | — | 0 | — | — | Class is-mobile, không ở state resting |

### Tokens

#### Overlay

| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Tint | `--chatty-scrim-tint` | rgba(232, 234, 240, 0.22) | rgba(9, 8, 12, 0.5) |
| Blur | `--chatty-scrim-blur` | 2px | 3px |

#### Panel sheet

| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Chiều rộng mở | `--aimode-open-width` | 100vw | Same |

#### Docked composer

| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Bàn phím | `--aimode-kb-inset` | 0px khi đóng | Same |

### States

#### Overlay

| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Đóng | Mặc định | opacity 0, visibility hidden, pointer-events none | Không thêm ARIA |
| Mở | Class is-open | opacity 1, pointer-events auto, thời gian 400ms | Không thêm ARIA |

#### Panel sheet

| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Mobile | Viewport tối đa 899px | Chiều rộng 100vw; chiều cao trừ 12px | Không thêm ARIA |

#### Docked composer

| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Bàn phím mở | visualViewport resize hoặc scroll | translateY âm bằng --aimode-kb-inset; inset line phía trên | Không thêm ARIA |

### Behaviour

#### Overlay

| Interaction | Result |
| --- | --- |
| Chặn trang | Khi mở, scrim nhận pointer; trang phía sau không nhận tương tác. |
| Cuộn | useScrollLock chạy khi panel mở và không phải preview. |

#### Panel sheet

| Interaction | Result |
| --- | --- |
| Svh | Dùng svh để thanh URL không đổi chiều cao sheet giữa chừng. |
| Click ngoài | Thu panel (collapse click_outside), trừ khi đang preview. |

#### Docked composer

| Interaction | Result |
| --- | --- |
| Tính inset | Chiều cao document trừ chiều cao và offsetTop của visualViewport, tối thiểu 0. |
| Viewport đọc | Padding đáy viewport cộng --aimode-kb-inset để tin không bị che. |

### Copy

#### Overlay

| String | i18n key | Where |
| --- | --- | --- |
| Not available | — | Scrim không có chữ. |

#### Panel sheet

| String | i18n key | Where |
| --- | --- | --- |
| Not available | — | Panel không có chữ riêng ở lớp này. |

#### Docked composer

| String | i18n key | Where |
| --- | --- | --- |
| Not available | — | Dock không có chữ riêng. |

### Source

#### Overlay

| File | Evidence |
| --- | --- |
|  | Mount và class |
|  | Scrim CSS |

#### Panel sheet

| File | Evidence |
| --- | --- |
|  | Mobile sheet |
|  | Header button và vùng chạm |

#### Docked composer

| File | Evidence |
| --- | --- |
|  | Hook |
|  | CSS mobile dock |

## Classic

### Import / element

#### Popup sheet

| Component / element | Import / file | Scope root |
| --- | --- | --- |
| Popup sheet (class Avada-Faqs_Popup) |  | .Avada-Faqs_Popup.mobile |

#### Close target

| Component / element | Import / file | Scope root |
| --- | --- | --- |
| Close target (class Avada-Faqs_HeaderClose) |  | .Avada-Faqs_Popup.mobile |

### Anatomy

#### Popup sheet

| Part | Element |
| --- | --- |
| 1 | Popup phủ từ top tới đáy viewport. |

#### Close target

| Part | Element |
| --- | --- |
| 1 | Native button chứa CloseIcon. |

### Placement / order

#### Popup sheet

| Context | Order |
| --- | --- |
| Mobile | Popup top 12px, bottom 0; không áp cho class admin. |

#### Close target

| Context | Order |
| --- | --- |
| Header | Cuối hàng header, sau tiêu đề. |

### Props

#### Popup sheet

| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `mobileMaxWidth` | number | 899 | Caller | Ngưỡng JS bật class mobile. |

#### Close target

| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `aria-label` | string | Close theo i18n | Caller | Tên truy cập của nút. |

### Sizes

#### Popup sheet

| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Mobile sheet | auto; top/bottom theo viewport | `--chatty-layout-inset-mobile` | — | — | — | — | JS mobileMaxWidth 899px |

#### Close target

| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Mobile | 44px | 44px | — | — | — | 44px | Class mobile |

### Tokens

#### Popup sheet

| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Inset ngang | `--chatty-layout-inset` | `--chatty-layout-inset-mobile` | Same |

#### Close target

| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Màu icon | `--faqsActionColor` | Màu merchant | Theo merchant |

### States

#### Popup sheet

| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Mobile | width tối đa 899px | box-shadow none; top calc(var(--chatty-classic-viewport-top, 0px) + 12px); bottom var(--chatty-classic-viewport-bottom, 0px); height auto | Không thêm ARIA |

#### Close target

| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Mặc định | Hiển thị | Nền none, border none, cursor pointer | aria-label |

### Behaviour

#### Popup sheet

| Interaction | Result |
| --- | --- |
| Class mobile | WidgetFAQ gán mobile hay desktop từ isMobile. |

#### Close target

| Interaction | Result |
| --- | --- |
| Bấm | Gọi handleCloseModal. |

### Copy

#### Popup sheet

| String | i18n key | Where |
| --- | --- | --- |
| Not available | — | Popup không có chữ riêng. |

#### Close target

| String | i18n key | Where |
| --- | --- | --- |
| Close | Close | aria-label của nút đóng (i18n) |

### Source

#### Popup sheet

| File | Evidence |
| --- | --- |
|  | Mobile geometry |
|  | Breakpoint |

#### Close target

| File | Evidence |
| --- | --- |
|  | Caller |
|  | Hit target mobile |

## Do / Don't

Do: giữ composer trên bàn phím và trong vùng an toàn của AI Mode bằng hook và biến CSS có sẵn.

Don't: để trang phía sau nhận thao tác khi panel AI Mode đang mở.

## Accessibility

| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| AI Mode | Scrim là div không có role; nút header có tên theo caller | Click ngoài thu panel; không có focus trap trong Overlay | Không có live region riêng | Không khai báo cặp màu trong cell |
| Classic | Nút đóng là button có aria-label | Native button; nhận focus theo thứ tự DOM | Không có live region riêng | Không khai báo cặp màu trong cell |

