/* Canonical chat window layout shared by factory and dealer pages. */
.chat-window-shell,.chat-window-shell *{box-sizing:border-box}
.chat-window-shell{height:100%;display:flex;flex-direction:column}
.chat-window-shell .sticky-header{height:52px;padding:6px 10px;background:#fff;border-bottom:1px solid #e4e9ed}
.chat-window-shell .header-row{height:40px;display:flex;align-items:center;gap:8px}
.chat-window-shell .page-title{flex:1;min-width:0;text-align:center;font-size:14px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#0f172a}
.chat-window-shell .top-spacer{width:48px;flex:0 0 48px}
.chat-window-shell .chat-main{padding:14px 14px 0;min-height:0}
.chat-window-shell .thread-main{position:relative;height:calc(100vh - 52px);display:flex;flex-direction:column;min-width:0}
.chat-window-shell #chatView{position:relative;min-width:0}
.chat-window-shell #chatView .emoji-panel{left:8px;right:8px;width:auto;max-width:100%;box-sizing:border-box}
.chat-window-shell .chat-thread{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:12px 0 8px}
.chat-window-shell .message-row{display:flex;flex-direction:row;align-items:flex-end;gap:10px;max-width:min(82%,560px)}
.chat-window-shell .message-row.me{align-self:flex-end;flex-direction:row-reverse;align-items:flex-end}.chat-window-shell .message-row.other{align-self:flex-start;flex-direction:row;align-items:flex-end}
.chat-window-shell .message-avatar-wrap{display:flex;flex:0 0 38px;align-items:center;justify-content:center}.chat-window-shell .message-avatar{width:38px;height:38px;flex:0 0 38px;border-radius:50%;object-fit:cover;background:#eef2f7;border:1px solid #dbe3ea;padding:5px}
.chat-window-shell .message-meta,.chat-window-shell .message-read-state{font-size:12px;font-weight:500;color:#94a3b8;margin:2px 6px 0;line-height:1.4}
.chat-window-shell .message-bubble{padding:10px 12px;border-radius:16px;line-height:1.55;font-size:16px;word-break:break-word;white-space:pre-wrap;box-shadow:none}
.chat-window-shell .message-row.me .message-bubble{background:var(--accent,#ff9500);color:#fff;border-bottom-right-radius:4px}.chat-window-shell .message-row.other .message-bubble{background:#fff;border:1px solid #e5e7eb;border-bottom-left-radius:4px}
.chat-window-shell .product-context-card{display:flex;align-items:center;gap:8px;min-width:180px;max-width:100%;background:transparent;color:#17212b;text-decoration:none}
.chat-window-shell .product-context-card img,.chat-window-shell .product-thumb-placeholder{width:44px;height:44px;flex:0 0 44px;object-fit:cover;border-radius:7px;display:block}
.chat-window-shell #messageList img{width:200px!important;height:auto!important;max-width:100%!important;max-height:none!important;aspect-ratio:auto!important;object-fit:contain;border-radius:8px;display:block}.chat-window-shell #messageList .attach-img{width:200px!important;height:auto!important;max-width:100%!important;max-height:none!important;aspect-ratio:auto!important;object-fit:contain}.chat-window-shell #messageList .product-context-card img{width:44px!important;height:44px!important;max-width:44px!important;aspect-ratio:1!important;border-radius:7px}
.chat-window-shell #messageList img.message-avatar{display:block!important;width:38px!important;height:38px!important;max-width:38px!important;min-width:38px!important;border-radius:50%;object-fit:cover}.chat-window-shell #messageList .message-avatar-wrap{display:flex!important;width:38px!important;height:38px!important;max-width:38px!important;min-width:38px!important;overflow:hidden;flex:0 0 38px}
.chat-window-shell .product-context-card span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:700}
.chat-window-shell .message-attachment-video{display:block;width:100%;max-width:320px;height:auto;max-height:none;aspect-ratio:auto;object-fit:contain;border-radius:8px;background:#111}
.chat-window-shell #chatView .composer{display:flex;align-items:center;gap:4px;min-height:58px;flex:0 0 auto;margin-left:calc(-14px - var(--paw-safe-left));margin-right:calc(-14px - var(--paw-safe-right));width:calc(100% + 28px + var(--paw-safe-left) + var(--paw-safe-right));max-width:none;padding:10px 10px max(10px,calc(10px + var(--paw-safe-bottom)));background:#fff;border:0;border-top:1px solid #e5e7eb;border-radius:0;box-shadow:0 -1px 0 rgba(15,23,42,.03);overflow:visible}
.chat-window-shell #chatView .message-input-wrap{position:relative;flex:1;min-width:0}
.chat-window-shell #chatView .msg-input{display:block;width:100%;height:40px;min-height:40px;max-height:320px;padding:8px 12px 8px 40px;border:1px solid #cbd5e1;border-radius:9px;outline:0;background:#fff;font-size:14px;line-height:24px;resize:none;overflow-y:hidden}
.chat-window-shell #chatView .btn-attach,.chat-window-shell #chatView .btn-emoji{position:relative;display:inline-flex;align-items:center;justify-content:center;height:40px;min-height:40px;padding:0;border:0;border-radius:0;background:transparent;color:#475569;box-shadow:none}
.chat-window-shell #chatView .btn-attach{width:30px;flex:0 0 30px}.chat-window-shell #chatView .btn-emoji{width:32px;flex:0 0 32px}
.chat-window-shell #chatView .btn-attach img{position:absolute;top:50%;left:50%;width:24px;height:24px;display:block;transform:translate(-50%,-50%)}
.chat-window-shell #chatView .btn-voice{position:absolute;z-index:1;top:50%;left:8px;width:24px;height:24px;padding:0;border:0;border-radius:0;background:transparent;color:#475569;transform:translateY(-50%)}
.chat-window-shell #chatView .btn-voice span{position:absolute;top:50%;left:50%;width:13px;height:13px;border-radius:50%;background:#ef4444;box-shadow:0 0 0 3px rgba(239,68,68,.14);transform:translate(-50%,-50%)}
.chat-window-shell #chatView .btn-emoji{cursor:pointer}.chat-window-shell #chatView .btn-emoji .emoji-glyph{position:absolute;top:48%;left:50%;font-size:30px;line-height:30px;transform:translate(-50%,-50%)}
.chat-window-shell #chatView .btn-send{height:40px;min-height:40px;padding:0 14px;border:0;border-radius:10px;background:#1d4ed8;color:#fff;font-size:14px;flex:0 0 auto}
@media (max-width:390px){.chat-window-shell #chatView .composer{margin-left:calc(-12px - var(--paw-safe-left));margin-right:calc(-12px - var(--paw-safe-right));width:calc(100% + 24px + var(--paw-safe-left) + var(--paw-safe-right));max-width:none;padding-bottom:max(10px,calc(10px + var(--paw-safe-bottom)))}.chat-window-shell .chat-main{padding:12px 12px 0}.chat-window-shell .page-title{font-size:14px}.chat-window-shell .top-spacer{width:40px;flex-basis:40px}.chat-window-shell .btn-send{padding:0 14px}}

/* iOS PAW standalone: lift the factory/dealer chat composer above the
   home-indicator area. Use the runtime .is-standalone class instead of only
   display-mode so iOS installed web apps are covered consistently. */
@media (max-width:768px) {
  html.keyboard-visible .chat-window-shell #chatView .composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--mobile-keyboard-offset, var(--mobile-keyboard-height, 0px));
    z-index: 1200;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    max-width: none;
    min-height: 58px;
    padding: 8px 10px;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
  html.keyboard-visible .chat-window-shell #chatView .chat-thread {
    padding-bottom: 76px;
  }
  .is-standalone.is-factory-dealer .chat-window-shell #chatView .composer {
    padding-bottom: 8px;
  }
  .is-standalone.is-factory-dealer .chat-window-shell #chatView .chat-thread {
    padding-bottom: 18px;
  }
  .is-standalone.is-factory-dealer .chat-window-shell #chatView .emoji-panel {
    bottom: calc(88px + var(--paw-safe-bottom, 0px));
  }
  html.keyboard-visible.is-standalone.is-factory-dealer .chat-window-shell #chatView .composer {
    padding-bottom: 8px;
  }
}

/* Canonical message presentation: both roles use the same transparent timeline. */
.chat-window-shell #messageList .message-row{display:flex!important;flex-direction:row!important;align-items:flex-end!important;gap:10px!important;max-width:min(82%,560px)!important}
.chat-window-shell #messageList .message-row.me{flex-direction:row-reverse!important;align-self:flex-end!important}
.chat-window-shell #messageList .message-row.other{flex-direction:row!important;align-self:flex-start!important}
.chat-window-shell #messageList .message-avatar{display:block!important;width:38px!important;height:38px!important;min-width:38px!important;max-width:38px!important;flex:0 0 38px!important;border-radius:50%!important;object-fit:cover!important}
.chat-window-shell #messageList .message-avatar-wrap{display:flex!important;width:38px!important;height:38px!important;min-width:38px!important;max-width:38px!important;flex:0 0 38px!important}
.chat-window-shell #messageList .message-bubble{border:1px solid transparent!important;border-radius:16px!important;box-shadow:none!important;padding:6px!important;min-height:32px!important;line-height:20px!important}
.chat-window-shell #messageList .message-row.me .message-bubble{background:#e6edf6!important;color:#111827!important;border-bottom-right-radius:4px!important;order:1!important;position:relative!important}
.chat-window-shell #messageList .message-row.other .message-bubble{background:#f8dfe7!important;color:#111827!important;border-bottom-left-radius:4px!important;order:1!important;position:relative!important}
.chat-window-shell #messageList .message-bubble .message-body{color:#111827!important}
.chat-window-shell #messageList .message-row.me .message-avatar{order:0!important}
.chat-window-shell #messageList .message-row.me .message-read-state{order:2!important}
.chat-window-shell #messageList .message-row.me .message-read-state:not([hidden])::before{content:none}
.chat-window-shell #messageList .message-row.me .message-read-state:not([hidden])::after{content:'·';display:inline-block;margin-left:4px;color:#7890aa}
.chat-window-shell #messageList .message-row.me .message-bubble::after{content:'';position:absolute;right:-6px;top:50%;width:0;height:0;transform:translateY(-50%);border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:7px solid #e6edf6}
.chat-window-shell #messageList .message-row.other .message-bubble::after{content:'';position:absolute;left:-6px;top:50%;width:0;height:0;transform:translateY(-50%);border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:7px solid #f8dfe7}
.chat-window-shell #messageList .message-body{font-size:14px!important;line-height:1.45!important}
.chat-window-shell #messageList .message-meta,.chat-window-shell #messageList .message-read-state{font-size:12px!important;color:#64748b!important;margin:2px 0 0!important;line-height:1.4!important}
.chat-window-shell #messageList .message-meta,.chat-window-shell #messageList .message-read-state{display:inline!important;white-space:nowrap!important}
.chat-window-shell #messageList .message-read-state[hidden]{display:none!important}
.chat-window-shell #messageList .chat-product-card{padding:0!important;gap:8px!important;align-items:center!important}
.chat-window-shell #messageList .chat-product-card-thumb{width:110px!important;height:82px!important;max-width:110px!important;flex:0 0 110px!important;padding:4px!important;border:1px solid #e5c9d3!important;border-radius:8px!important;background:#fff!important;object-fit:contain!important}
.chat-window-shell #messageList .message-read-state:before{content:none;}
.chat-window-shell .chat-menu-button{width:36px;height:36px;flex:0 0 36px;border:0;background:transparent;padding:7px;display:inline-flex;align-items:center;justify-content:center}
.chat-window-shell .chat-menu-button .nav-icon-img{width:22px;height:22px;display:block}
.chat-window-shell .chat-menu-button.has-unread{animation:chat-menu-unread-pulse 1.1s ease-in-out infinite}
.chat-window-shell .chat-menu-button.has-unread .nav-icon-img{filter:drop-shadow(0 0 4px rgba(239,68,68,.8))}
.chat-window-shell .chat-menu-button{position:relative}
.chat-window-shell .chat-menu-unread-badge{position:absolute;top:-2px;right:-4px;min-width:18px;height:18px;padding:0 4px;border-radius:999px;background:#ef4444;color:#fff;font-size:11px;font-weight:700;line-height:18px;text-align:center;box-shadow:0 0 0 2px #fff;pointer-events:none}
@keyframes chat-menu-unread-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.12)}}
.chat-window-shell .conv-list{display:flex;flex-direction:column;gap:0;min-width:0}
.chat-window-shell .conv-list .inbox-item{width:100%;min-width:0;display:flex;align-items:center;gap:10px;padding:10px 8px 10px 10px;margin:0;border:0;border-bottom:1px solid #f0f2f5;border-radius:0;background:#fff;box-shadow:0 8px 20px rgba(15,23,42,.08);cursor:pointer}
.chat-window-shell .conv-list .inbox-item-avatar{display:block;width:38px;height:38px;min-width:38px;max-width:38px;flex:0 0 38px;border-radius:50%;object-fit:cover;background:#eef2f7;border:1px solid #dbe3ea;padding:4px}
.chat-window-shell .conv-list .inbox-item-avatar{display:none!important}
.chat-window-shell .conv-list .inbox-item-avatar[hidden]{display:none!important}
.chat-window-shell .conv-list .inbox-item-body{min-width:0;flex:1;display:flex;flex-direction:column;overflow:hidden}
.chat-window-shell .conv-list .inbox-item-body strong,.chat-window-shell .conv-list .inbox-item-body span{display:block;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-window-shell .conv-list .inbox-item-body strong{font-size:14px;font-weight:600;color:#172033}
.chat-window-shell .conv-list .inbox-item-body span{font-size:12px;color:#64748b;margin-top:2px}
.chat-window-shell .conv-list .inbox-item-close{margin-left:auto;flex:0 0 22px;width:22px;height:22px;border:0;border-radius:50%;background:transparent;color:#dc2626;font-size:20px;line-height:20px;font-weight:700;padding:0;cursor:pointer}
.chat-window-shell .conv-list .inbox-item.is-unread .inbox-item-body strong{font-weight:700;color:#b91c1c}
.chat-window-shell #conversationListView.chat-menu-drawer{position:absolute;top:54px;right:8px;left:auto;width:min(300px,calc(100vw - 16px));height:auto;z-index:30;overflow:visible;background:transparent;pointer-events:none}
.chat-window-shell #conversationListView.chat-menu-drawer>.sticky-header{display:none}
.chat-window-shell #conversationListView.chat-menu-drawer>.chat-main{display:block;max-height:min(52vh,420px);overflow-y:auto;padding:6px;background:#fff;border:1px solid #e5e7eb;border-radius:12px;box-shadow:0 10px 26px rgba(15,23,42,.18);pointer-events:auto}
.chat-window-shell #conversationListView.chat-menu-drawer #permissionDenied,.chat-window-shell #conversationListView.chat-menu-drawer #feedback{display:none!important}
.chat-window-shell #conversationListView.chat-menu-drawer .conv-list{gap:2px}
.chat-window-shell #conversationListView.chat-menu-drawer .inbox-item{padding:7px 6px;border-bottom:1px solid #f0f2f5;box-shadow:none;border-radius:8px}
.chat-window-shell #conversationListView.chat-menu-drawer .loading,.chat-window-shell #conversationListView.chat-menu-drawer .empty-state{padding:14px 8px;margin:0}

/* Guest conversations use the same window geometry and message presentation.
   Identity and API selection remain page-specific; visual metrics are shared. */
.guest-chat-shell{height:100%;display:flex;flex-direction:column;background:var(--bg,#f5f7fb);color:#172033}
.guest-chat-shell .chat-header{height:52px;min-height:52px;padding:6px 10px;background:#fff;border-bottom:1px solid #e4e9ed}
.guest-chat-shell .chat-header button{width:36px;height:36px;padding:7px;display:inline-flex;align-items:center;justify-content:center}
.guest-chat-shell .chat-header .nav-icon-img,.guest-chat-shell .inbox-menu-icon{width:22px;height:22px}
.guest-chat-shell .header-conversation-title{font-size:14px;font-weight:700;color:#0f172a}
.guest-chat-shell .chat-main{padding:14px 14px 0;min-height:0;background:var(--bg,#f5f7fb)}
.guest-chat-shell .messages{gap:10px;padding:12px 0 8px}
.guest-chat-shell .message-row{max-width:min(82%,560px);gap:10px}
.guest-chat-shell .message-row.guest{align-self:flex-end;flex-direction:row-reverse}
.guest-chat-shell .message-row.dealer,.guest-chat-shell .message-row.incoming{align-self:flex-start;flex-direction:row}
.guest-chat-shell .message-avatar{width:38px;height:38px;flex:0 0 38px;border:1px solid #dbe3ea;padding:4px;background:#eef2f7}
.guest-chat-shell .message-bubble{max-width:calc(100% - 48px);padding:0;border:0;border-radius:0;background:transparent!important;color:#172033!important;font-size:14px;line-height:1.45}
.guest-chat-shell .message-meta,.guest-chat-shell .message-read-state{display:inline!important;white-space:nowrap;font-size:12px;color:#64748b;margin:2px 0 0;line-height:1.4}
.guest-chat-shell .message-read-state:before{content:' · '}
.guest-chat-shell .composer{height:58px;min-height:58px;margin-left:calc(-14px - var(--paw-safe-left));margin-right:calc(-14px - var(--paw-safe-right));width:calc(100% + 28px + var(--paw-safe-left) + var(--paw-safe-right));max-width:none;padding:10px 10px max(10px,calc(10px + var(--paw-safe-bottom)));gap:8px;border:0;border-top:1px solid #e5e7eb;border-radius:0;background:#fff;box-shadow:0 -1px 0 rgba(15,23,42,.03)}
.guest-chat-shell .composer-tool{width:38px;height:38px;min-width:38px;padding:0;border:1px solid #d5dce5;border-radius:999px;background:#fff;display:inline-flex;align-items:center;justify-content:center}
.guest-chat-shell .composer-tool img{width:20px;height:20px;display:block}
.guest-chat-shell .composer input{height:38px;border:1px solid #cbd5e1;border-radius:9px;background:#fff;padding:0 12px}
.guest-chat-shell .composer button[type="submit"]{height:38px;min-width:auto;padding:0 14px;border-radius:10px;background:#1d4ed8}
.guest-chat-shell .inbox-toggle{width:36px;height:36px;padding:7px;gap:0}.guest-chat-shell .inbox-toggle-avatar{display:none!important}
.guest-chat-shell .inbox-badge{position:absolute;right:-3px;top:-2px}.guest-chat-shell .product-prompt{margin:0 -14px;padding:8px 14px 4px}
