/* ======================================================================
   mobile.css — تصميم الهاتف المستقل لصندوق الرسائل (V34.2)
   يُحمَّل فقط على الشاشات ≤ 820px وبعد app.css، فلا يتأثر به الحاسوب.
   ====================================================================== */

/* ---------- الإطار: يملأ الشاشة بالضبط، ويتبع الكيبورد ---------- */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body { background: var(--wa-head, #f0f2f5); }
:root[data-theme="dark"] body { background: #202c33; }
html body #app.app {
  position: fixed !important; left: 0; right: 0; top: var(--app-top, 0px) !important;
  height: var(--app-h, 100dvh) !important; max-height: none !important; min-height: 0 !important;
  display: block !important; overflow: hidden !important; box-shadow: none !important; border-radius: 0 !important;
}
html body #app .sidebar { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; display: flex !important; flex-direction: column !important; overflow: hidden !important; }
html body #app .sidebar .conv-list { flex: 1 1 auto !important; min-height: 0 !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch; padding-bottom: env(safe-area-inset-bottom) !important; }
html body #app .chat { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; display: none; flex-direction: column; overflow: hidden !important; z-index: 5; }
html body #app.chat-open .chat { display: flex !important; }
html body #app.chat-open .sidebar { visibility: hidden; }
html body #app .chat-inner { flex: 1 1 auto; min-height: 0; display: flex !important; flex-direction: column !important; height: 100% !important; }
html body #app .chat-inner.hidden { display: none !important; }

/* ---------- رأس القائمة ---------- */
html body #app .side-head { padding: calc(env(safe-area-inset-top) + 8px) 10px 8px 14px !important; min-height: 0 !important; flex: none; }

/* ---------- رأس المحادثة: رجوع · صورة · الاسم + المنتج والسعر · مُباع · تفاصيل · ⋮ ---------- */
html body #app .chat-head {
  flex: none !important; display: flex !important; align-items: center !important; gap: 6px !important;
  padding: calc(env(safe-area-inset-top) + 6px) 4px 6px 4px !important; min-height: 0 !important; height: auto !important;
  background: var(--wa-head) !important; border: 0 !important; box-shadow: 0 1px 0 var(--wa-line) !important; position: relative; z-index: 10;
}
html body #app .chat-head .back { display: inline-flex !important; width: 36px !important; height: 40px !important; flex: none; color: var(--wa-text) !important; }
html body #app .chat-head .avatar { width: 38px !important; height: 38px !important; flex: none; font-size: 14px !important; }
html body #app .chat-title { flex: 1 1 auto !important; min-width: 0 !important; display: flex; flex-direction: column; gap: 2px; }
html body #app .chat-title .name { font-size: 16px !important; font-weight: 600 !important; color: var(--wa-text) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
html body #app .chat-title .sub { display: flex !important; align-items: center; gap: 5px; flex-wrap: nowrap !important; overflow: hidden; white-space: nowrap; font-size: 12.5px; color: var(--wa-muted); min-width: 0; }
html body #app .chat-title .sub > * { flex: none; }
html body #app .chat-title .sub .lt { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--wa-muted); }
html body #app .chat-title .sub .acc { display: none !important; }
html body #app .chat-actions { flex: none !important; display: flex !important; align-items: center; gap: 0 !important; }
html body #app .chat-actions > .icon-btn, html body #app .chat-actions > .v34-more { width: 38px !important; height: 40px !important; min-width: 0 !important; display: inline-flex !important; border-radius: 50% !important; color: var(--wa-muted) !important; background: transparent !important; }
html body #app .chat-actions .icon-btn svg { width: 21px; height: 21px; }
html body #app .chat-actions #btnSold.on { color: var(--wa-green) !important; }

/* قائمة ⋮ */
html body #app .v34-ovf { display: none !important; position: absolute; top: calc(100% + 4px); inset-inline-end: 6px; z-index: 60; min-width: 220px; flex-direction: column; background: var(--wa-list); border-radius: 12px; box-shadow: 0 12px 32px rgba(11,20,26,.28); padding: 6px 0; }
html body #app .chat-actions.ovf-open .v34-ovf { display: flex !important; }
html body #app .v34-ovf .icon-btn { display: flex !important; width: 100% !important; height: auto !important; border-radius: 0 !important; justify-content: flex-start; gap: 14px; padding: 12px 18px !important; color: var(--wa-text) !important; font: inherit; font-size: 15px; background: transparent !important; }
html body #app .v34-ovf .icon-btn::after { content: attr(data-label); }
html body #app .v34-ovf .icon-btn svg { width: 20px; height: 20px; color: var(--wa-muted); }

/* ---------- الرسائل ---------- */
html body #app .sync-bar { flex: none; }
html body #app .messages { flex: 1 1 auto !important; min-height: 0 !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 8px 8px 6px !important; }
html body #app .bubble { max-width: 84% !important; font-size: 15px !important; padding: 6px 9px 5px !important; }
html body #app .bubble .text { display: block !important; white-space: pre-wrap; }
html body #app .bubble .meta { float: none !important; position: static !important; display: flex !important; justify-content: flex-end !important; align-items: center; gap: 3px; margin: 2px 0 0 !important; top: auto !important; font-size: 11px !important; line-height: 1 !important; height: 14px; }
html body #app .msg.out .bubble .meta { justify-content: flex-start !important; }
html body #app .day-sep span { font-size: 12px !important; }

/* ---------- خانة الكتابة: ثابتة في الأسفل بدون فراغ ---------- */
html body #app .composer { flex: none !important; position: relative !important; bottom: auto !important; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)) !important; margin: 0 !important; }
html.kb-open body #app .composer { padding-bottom: 6px !important; }
html body #app .ext-warning { margin: 0 0 6px !important; font-size: 11.5px !important; }
html body #app .composer textarea, html body #app #input { font-size: 16px !important; /* يمنع تكبير الصفحة في iOS */ max-height: 120px; }

/* ---------- لوحة تفاصيل العميل ---------- */
html body #app .info-panel:not(.hidden) { position: absolute !important; inset: 0 !important; z-index: 30 !important; width: 100% !important; height: 100% !important; display: flex !important; flex-direction: column !important; }
html body #app .info-panel > header { flex: none; padding-top: calc(env(safe-area-inset-top) + 8px) !important; }
html body #app .info-panel .info-body { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important; }

/* ---------- نافذة الحسابات: شاشة كاملة وقائمة مرتبة ---------- */
html body #modalAccounts { position: fixed !important; inset: 0 !important; padding: 0 !important; display: block !important; background: var(--bg) !important; }
html body #modalAccounts.hidden { display: none !important; }
html body #modalAccounts .modal-card { position: absolute !important; inset: 0 !important; width: 100% !important; max-width: none !important; height: 100% !important; max-height: none !important; margin: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; display: flex !important; flex-direction: column !important; overflow: hidden !important; transform: none !important; }
html body #modalAccounts .modal-card > header { flex: none; display: grid !important; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 10px) 14px 10px !important; border-bottom: 1px solid var(--border); background: var(--panel); }
html body #modalAccounts .modal-card > header h3 { margin: 0; font-size: 19px; }
html body #modalAccounts .acc-head-actions { grid-column: 1 / -1; grid-row: 2; display: flex !important; gap: 8px; width: 100%; }
html body #modalAccounts .acc-head-actions .btn { flex: 1; justify-content: center; padding: 10px 8px !important; font-size: 13.5px !important; }
html body #modalAccounts .acc-head-actions #accTplBtn { display: none !important; }
html body #modalAccounts .acc-head-actions [data-close] { position: absolute; top: calc(env(safe-area-inset-top) + 8px); inset-inline-end: 10px; flex: none !important; width: 40px; height: 40px; }
html body #modalAccounts .setup-summary { flex: none; padding: 10px 14px !important; margin: 0 !important; }
html body #modalAccounts .acc-panel { flex: none; padding: 10px 14px !important; }
html body #modalAccounts .acc-list { flex: 1 1 auto !important; min-height: 0 !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch; padding: 4px 12px calc(16px + env(safe-area-inset-bottom)) !important; margin: 0 !important; }
html body #modalAccounts .acc-item { display: block !important; width: 100% !important; max-width: 100% !important; margin: 0 0 8px !important; padding: 0 !important; box-sizing: border-box !important; background: var(--panel) !important; border: 1px solid var(--border) !important; border-radius: 12px !important; overflow: hidden; transform: none !important; }
html body #modalAccounts .acc-item .acc-row { display: grid !important; grid-template-columns: 40px minmax(0, 1fr) auto !important; grid-template-areas: "num info chip" "actions actions actions" !important; align-items: center !important; gap: 4px 10px !important; padding: 10px 12px !important; margin: 0 !important; min-height: 0 !important; width: 100% !important; box-sizing: border-box !important; border: 0 !important; }
html body #modalAccounts .acc-item .acc-num { grid-area: num; width: 40px !important; height: 40px !important; border-radius: 50% !important; font-size: 15px !important; margin: 0 !important; }
html body #modalAccounts .acc-item .acc-row .info { grid-area: info; min-width: 0 !important; margin: 0 !important; }
html body #modalAccounts .acc-item .acc-row .info .n { font-size: 15px !important; font-weight: 700 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; line-height: 1.3 !important; }
html body #modalAccounts .acc-item .acc-row .info .s { font-size: 12px !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
html body #modalAccounts .acc-item .setup-chip { grid-area: chip !important; margin: 0 !important; max-width: 104px !important; justify-self: end !important; font-size: 11px !important; padding: 3px 9px !important; min-height: 0 !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html body #modalAccounts .acc-item .acc-actions { grid-area: actions !important; display: none !important; gap: 6px !important; margin: 6px 0 0 !important; padding-top: 8px !important; border-top: 1px dashed var(--border); justify-content: flex-start !important; }
html body #modalAccounts .acc-item.open .acc-actions { display: flex !important; }
html body #modalAccounts .acc-item .acc-actions .icon-btn { width: 40px !important; height: 40px !important; border-radius: 10px !important; background: var(--panel-2) !important; }
html body #modalAccounts .acc-detail { padding: 0 12px 12px !important; }
html body #modalAccounts .acc-form-grid { grid-template-columns: 1fr !important; }

/* ---------- قائمة المزيد: رقم النسخة ---------- */
.v34-ver { padding: 8px 14px 4px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 4px; }
/* الصفوف العلوية في القائمة لا تنضغط */
html body #app .sidebar > *:not(.conv-list) { flex: none !important; }
html body #app .sidebar .accounts, html body #app .sidebar .v30-seg { min-height: 36px; align-items: center; }
/* زر الإغلاق في نافذة الحسابات بجانب العنوان */
html body #modalAccounts .modal-card > header { position: relative !important; }
html body #modalAccounts .acc-head-actions { position: static !important; }
html body #modalAccounts .acc-head-actions [data-close] { position: absolute !important; top: calc(env(safe-area-inset-top) + 6px) !important; left: 10px; right: auto; }
/* رأس الحسابات: العنوان + ✕ في السطر الأول، الزران في الثاني */
html body #modalAccounts .modal-card > header { display: grid !important; grid-template-columns: 1fr 1fr 44px !important; grid-auto-rows: auto; gap: 10px 8px !important; }
html body #modalAccounts .modal-card > header h3 { grid-column: 1 / 3; grid-row: 1; align-self: center; }
html body #modalAccounts .acc-head-actions { display: contents !important; }
html body #modalAccounts .acc-head-actions [data-close] { position: static !important; grid-column: 3; grid-row: 1; justify-self: end; align-self: center; }
html body #modalAccounts #accAddBtn { grid-column: 1; grid-row: 2; }
html body #modalAccounts #accImportBtn { grid-column: 2 / 4; grid-row: 2; }
/* V34.3: بدون كيبورد → التطبيق مثبت على حواف الشاشة كاملة (لا فراغ أسفل في آيفون) */
html body #app.app { top: var(--app-top, 0px) !important; bottom: 0 !important; height: auto !important; min-height: 0 !important; }
html.kb-open body #app.app { bottom: auto !important; height: var(--app-h, 100%) !important; }
/* V37 */
#composer.recording .composer-row{display:none!important}
.v37-rec{padding:6px 6px calc(6px + env(safe-area-inset-bottom))}
.v37-voice{min-width:220px;max-width:78vw}
#publishingApp .pub-nav.hidden{display:none!important}
