/* chat.css — شاشة المحادثة (العميل + الإدارة): الرسايل بتسكرول لوحدها وخانة الرد ثابتة في آخر الشاشة */
:root{--z:1}
@media (min-width:2200px){:root{--z:1.25}}
@media (min-width:3000px){:root{--z:1.7}}
@media (min-width:3600px){:root{--z:2}}

.ch-back{display:none;align-items:center;gap:6px;align-self:flex-start;min-height:40px;padding:0;background:none;border:0;color:var(--ink);font:inherit;font-weight:700;cursor:pointer}
.ch-back svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
[dir=rtl] .ch-back svg{transform:scaleX(-1)}

.ch-card{display:flex;flex-direction:column;min-height:0;margin:0;scroll-margin-top:calc(var(--hdr) + 10px)}
.ch-card>*{flex:none}
.ch-card>.sp-thread{flex:1 1 0;min-height:0;max-height:none;align-content:start;overflow-y:auto;overscroll-behavior:contain;scroll-behavior:auto}
.ch-card .sp-comp{max-height:calc(42dvh / var(--z));overflow-y:auto}

@media (min-width:1001px){
  .ch-card{height:calc(100dvh / var(--z) - var(--hdr) - 24px);min-height:520px;scroll-margin-bottom:12px}
}

@media (max-width:1000px){
  body.chat-full{overflow:hidden}
  body.chat-full :is(.colm,main.wrap,#v-support,#v-admin,#support-body,#admin-body){animation:none!important;transform:none!important;filter:none!important;contain:none!important}
  body.chat-full :is(#ox-bar,#tabs,.k4-dock,#kz-top,.pn-bar,header,#ban){display:none!important}
  body.chat-full #toasts{top:calc(64px + env(safe-area-inset-top));bottom:auto}
  body.chat-full :is(#sp-main,#sa-main){position:fixed;z-index:60;left:0;right:0;top:var(--vvt,0px);height:var(--vvh,100dvh);display:flex;flex-direction:column;background:var(--bg);
    padding:env(safe-area-inset-top) 0 0}
  body.chat-full .ch-back{display:inline-flex;flex:none}
  body.chat-full .ch-card{flex:1;border:0;border-radius:0;background:var(--bg);padding:6px 14px calc(10px + env(safe-area-inset-bottom))}
  /* تذكرة جديدة: الفورم هو اللي بيسكرول */
  body.chat-full #sp-main>.ch-back{margin:6px 14px}
  body.chat-full #sp-main>.card:not(.ch-card){flex:1;min-height:0;overflow-y:auto;margin:0;border:0;border-radius:0;background:var(--bg);padding-bottom:calc(24px + env(safe-area-inset-bottom))}

  body.chat-full .sp-head{margin:0;flex-wrap:nowrap}
  body.chat-full .sp-head h2{font-size:17px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  body.chat-full .sp-head [data-s=dl]{display:none}
  body.chat-full .sp-steps{margin:10px 0 6px}
  body.chat-full .sp-thread{border-top:1px solid var(--line);padding-top:12px}
  body.chat-full .sp-b{max-width:78vw;font-size:15px}
  body.chat-full .sp-comp{margin:0;padding-top:10px;gap:8px}
  body.chat-full .sp-comp textarea{min-height:48px;height:64px;resize:none;font-size:16px}
  body.chat-full .sp-comp .tools .sp-cnt{visibility:hidden;font-size:0}
  body.chat-full .sp-comp .tools .btn{min-height:42px}
  /* الشاشة قصيرة (الكيبورد مفتوح): نخلي المساحة للرسايل */
  body.chat-short :is(.sp-steps,#sa-h .sp-tools){display:none}
}
