/* =============================================================================
   صفحات العملاء: عملاء السوشيال ميديا (#socialClientsSubView) وعملاء القنوات المختلفة (#otherClientsSubView)
   وقوائم الحملات (#campaignListsSubView): طيّ اللوحات، كروت المؤشرات القابلة للضغط، شريط التحديدات،
   وتخطيط الصفحات الثلاث على الجوال (<=700px). الكمبيوتر لا يتأثر إلا بالقسم الأول.
   ملاحظة: تحت 900px تفرض 03-header-quotation-selector.css على الأزرار والحقول قيمًا بـ !important،
   وقواعد الجوال العامة في 02 كذلك؛ لذلك قواعد الجوال هنا بـ !important.
   ============================================================================= */

/* ---------- كل المقاسات ---------- */
/* أزرار طيّ اللوحات للجوال فقط؛ على الكمبيوتر يعرض .filter-panel عناصره كأنها داخل الشريط مباشرة */
.panel-toggle{display:none}
.filter-panel{display:contents}

/* كروت المؤشرات قابلة للضغط لعرض العملاء تحت التصنيف */
#clientsView .analytics-dashboard .dash-card,
#otherClientsSubView .analytics-dashboard .dash-card,
#clCards .dash-card{cursor:pointer}
.dash-card.card-active{outline:2px solid #d4af37;outline-offset:-2px;box-shadow:0 0 0 3px rgba(212,175,55,.25)}

/* شريط التحديدات: قائمة منسدلة (details) مطويّة افتراضيًا */
.bulk-actions-bar{margin:10px 0;border:1px solid #334155;border-radius:12px;background:#111827}
body.theme-light .bulk-actions-bar{background:#f8fafc;border-color:#cbd5e1}
.bulk-actions-bar[hidden]{display:none !important}
.bulk-actions-bar > summary{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 14px;cursor:pointer;font-weight:800;list-style:none}
.bulk-actions-bar > summary::-webkit-details-marker{display:none}
.bulk-actions-bar > summary::after{content:"▾";margin-inline-start:auto;padding-inline-start:10px}
.bulk-actions-bar[open] > summary::after{content:"▴"}
.bulk-selected-count{font-weight:900}
.bulk-actions-panel{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:2px 14px 12px}
.bulk-actions-panel select{min-width:145px}

/* ---------- الجوال ---------- */
@media (max-width:700px){
  /* ---- الصفحة والتبويبات ---- */
  #socialClientsSubView{width:100%;max-width:100%;overflow-x:hidden}
  #socialClientsSubView > .page{width:100%;max-width:100%;box-sizing:border-box;padding:0 8px 16px !important}
  /* الشريط اللاصق يغطي أول 12px من المحتوى عند أعلى الصفحة: مسافة تعوّضها لكل الأقسام الفرعية */
  #clientsView .clients-subview{padding-top:20px}
  #clientsView .clients-subnav{padding:8px !important;gap:6px !important;overflow-x:auto;flex-wrap:nowrap !important;-webkit-overflow-scrolling:touch}
  #clientsView .clients-subnav .clients-subtab{flex:0 0 auto;width:auto !important;white-space:nowrap;font-size:11.5px !important;padding:8px 10px !important}

  /* ---- رأس عملاء القنوات المختلفة وقوائم الحملات ---- */
  :is(#otherClientsSubView,#campaignListsSubView) .other-clients-head p{font-size:12px !important;line-height:1.6 !important;margin-top:3px !important}
  :is(#otherClientsSubView,#campaignListsSubView) .other-clients-head > div:last-child{
    display:grid !important;grid-template-columns:1fr 1fr !important;gap:6px !important;width:100% !important}
  :is(#otherClientsSubView,#campaignListsSubView) .other-clients-head button{min-height:40px !important;font-size:12.5px !important;padding:6px 8px !important}

  /* ---- شريط الأدوات (عمودان) ---- */
  #socialClientsSubView .toolbar{display:grid !important;margin-bottom:10px !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .toolbar{grid-template-columns:1fr 1fr !important;gap:6px !important;padding:8px !important}
  /* في السوشيال كل عناصر الشريط بعرض خانتها وبلا هوامش، ومنها زر طيّ البحث */
  #socialClientsSubView .toolbar :is(button,input,select){width:100% !important;min-width:0 !important;box-sizing:border-box;margin:0 !important}
  #socialClientsSubView .toolbar .status-bar{width:100% !important;margin:0 !important;box-sizing:border-box}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .toolbar .status-bar,
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .toolbar .range-hint,
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) #nameSearch{grid-column:1 / -1 !important}
  :is(#otherClientsSubView,#campaignListsSubView) .toolbar button:not(.panel-toggle){grid-column:1 / -1 !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .toolbar button:not(.panel-toggle){min-height:36px !important;font-size:12.5px !important;padding:4px 6px !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .toolbar input,
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .toolbar select{min-height:38px !important;font-size:13px !important;min-width:0 !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .toolbar .status-bar,
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .toolbar .range-hint{font-size:11px !important;text-align:start !important}

  /* ---- المؤشرات ---- */
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .analytics-dashboard{gap:6px !important}
  :is(#otherClientsSubView,#campaignListsSubView) .dash-card{padding:7px 10px !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .dash-value{font-size:20px !important}
  :is(#otherClientsSubView,#campaignListsSubView) .dash-card .dash-percent{display:none !important}
  /* السوشيال: كرتان في الصف، الإجمالي بعرض كامل، والنسبة بجانب الرقم */
  #socialClientsSubView .analytics-dashboard{
    display:grid !important;grid-template-columns:repeat(2,minmax(0,1fr)) !important;
    width:100%;box-sizing:border-box;margin-bottom:10px !important}
  #socialClientsSubView .analytics-dashboard .dash-card{
    min-width:0 !important;width:100% !important;box-sizing:border-box;padding:11px 9px !important;border-radius:13px !important}
  #socialClientsSubView .analytics-dashboard .dash-card.total-card{grid-column:1 / -1}
  #socialClientsSubView .dash-card{
    display:grid !important;grid-template-columns:1fr auto !important;align-items:center !important;
    column-gap:6px !important;row-gap:0 !important;min-height:0 !important}
  #socialClientsSubView .dash-label{font-size:11px !important;line-height:1.4;white-space:normal !important;overflow-wrap:anywhere}
  #socialClientsSubView .dash-card .dash-label{grid-column:1 / -1 !important}
  #socialClientsSubView .dash-value{line-height:1.2;margin-top:5px;overflow-wrap:anywhere}
  #socialClientsSubView .dash-card .dash-percent{margin:0 !important;justify-self:end;font-size:11px !important;padding:2px 8px !important}

  /* ---- التقرير وترقيم الصفحات (السوشيال) ---- */
  #socialClientsSubView .report-info{font-size:11px !important;padding:8px !important;overflow-wrap:anywhere}
  #socialClientsSubView .client-pagination{width:100%;box-sizing:border-box;overflow-x:auto}

  /* ---- التبويبات السريعة (عملاء القنوات المختلفة) ---- */
  :is(#otherClientsSubView,#campaignListsSubView) .other-quick-tabs{
    display:flex !important;flex-wrap:nowrap !important;overflow-x:auto !important;gap:8px !important;
    padding-bottom:4px !important;-webkit-overflow-scrolling:touch}
  :is(#otherClientsSubView,#campaignListsSubView) .other-quick-tabs button{
    flex:0 0 auto !important;width:auto !important;min-height:36px !important;white-space:nowrap !important;padding:6px 12px !important;font-size:12.5px !important}

  /* ---- أزرار طيّ اللوحات (المؤشرات التحليلية + البحث والتصفية) ---- */
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .panel-toggle{
    display:flex !important;justify-content:space-between;align-items:center;width:100% !important;grid-column:1 / -1;
    min-height:44px !important;margin:8px 0 !important;padding:8px 14px !important;border-radius:12px !important;
    background:rgba(148,163,184,.12) !important;border:1px solid rgba(148,163,184,.32) !important;
    color:inherit !important;font-size:14px !important;font-weight:800 !important;text-align:start}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .panel-toggle::after{content:"▾";font-size:16px}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) .panel-toggle[aria-expanded="true"]::after{content:"▴"}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) :is(.analytics-dashboard,.filter-panel):not(.panel-open){display:none !important}

  /* ---- بطاقة العميل: الاسم والهاتف ثم عمودان، ولون الحالة/التصنيف فوق خلفية البطاقة ---- */
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards tr{
    display:grid !important;grid-template-columns:1fr 1fr !important;position:relative !important;
    --td-tint:transparent !important;
    background:linear-gradient(var(--row-tint,transparent),var(--row-tint,transparent)) var(--bt-card-bg) !important;
    background-clip:padding-box !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td{
    display:flex !important;flex-direction:column !important;align-items:stretch !important;gap:2px !important;
    padding:6px 10px !important;border-bottom:0 !important;grid-template-columns:none !important;background:transparent}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td::before{font-size:10px !important}
  /* م: مخفي — التحديد: زاوية البطاقة بلا خلفية */
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td:nth-child(1){display:none !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td[data-label="تحديد"]{
    position:absolute !important;top:8px !important;left:8px !important;width:auto !important;padding:0 !important;z-index:1;
    background:transparent !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td[data-label="تحديد"]::before{display:none !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td[data-label="تحديد"] input{width:24px !important;height:24px !important}
  /* خانات النص القابلة للتعديل تظهر دائمًا ككتابة حتى لو فاضية */
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td[contenteditable="true"]{
    min-height:40px !important;border-radius:8px !important;
    background:rgba(255,255,255,.08) !important;outline:1px dashed rgba(148,163,184,.45) !important;outline-offset:-3px !important;
    margin:2px 6px !important;width:auto !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td[contenteditable="true"]::before{pointer-events:none}
  /* الاسم والهاتف بعرض كامل بلا عنوان ولا إطار كتابة */
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td[data-label="اسم العميل"]{
    grid-column:1 / -1 !important;font-size:16px !important;font-weight:800 !important;padding:10px 44px 2px 10px !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td[data-label*="هاتف"]{
    grid-column:1 / -1 !important;padding-top:0 !important;direction:rtl !important;text-align:right !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards :is(td[data-label="اسم العميل"],td[data-label*="هاتف"]){
    background:transparent !important;outline:none !important;margin:0 !important;min-height:0 !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards :is(td[data-label="اسم العميل"],td[data-label*="هاتف"])::before{display:none !important}
  /* الحقول الطويلة والحذف بعرض كامل */
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards :is(td[data-label="ملاحظات"],td[data-label="الحملة"],td:last-child){grid-column:1 / -1 !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td:last-child .delete-btn{min-height:34px !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td select{min-height:36px !important;font-size:13px !important}
  :is(#otherClientsSubView,#socialClientsSubView,#campaignListsSubView) table.ayan-mobile-cards td[colspan]{display:block !important}
  /* خلية الحذف تختفي كلها لمن لا يملك صلاحية الحذف (لا تبقى كلمة "حذف" وحدها) */
  body.m3-no-client-delete #socialClientsSubView table.ayan-mobile-cards td:last-child,
  body.m3-no-other-delete #otherClientsSubView table.ayan-mobile-cards td:last-child,
  body.m3-no-client-delete #campaignListsSubView #clBody td:last-child{display:none !important}

  /* ---- شريط التحديدات ---- */
  .bulk-actions-panel{display:grid;grid-template-columns:1fr 1fr;gap:6px}
  .bulk-actions-panel > label,.bulk-actions-panel > button.red{grid-column:1 / -1}
  .bulk-actions-panel select,.bulk-actions-panel button{width:100%;min-width:0;min-height:38px;font-size:12.5px;box-sizing:border-box}
}
