/* =============================================================================
   الأزرار العائمة: زر جي ولوحته، وزر «لوحة المدير».
   المصدر الوحيد لمواضعها ومقاساتها وحالاتها (شكل الزر واللوحة الداخلي في 05 وexecutive.css).
   الحالات يضعها js/41-ayan-floating-widgets.js على <html>:
   ayan-g-open: اللوحة مفتوحة · ayan-g-docked: جي مرسى خلف الحافة (كمبيوتر)
   ayan-fw-idle / ayan-fw-scrolling / ayan-fw-awake: خمول / تمرير / اقتراب (كمبيوتر).
   على الجوال لا توجد حالات خمول أو إرساء؛ جي نصفه خلف الحافة دائمًا ويظهر كاملًا باللمس أو بالفتح.
   ============================================================================= */

html,body{max-width:100%;overflow-x:hidden}

/* ---------- جي: الكمبيوتر ---------- */
#opsGlobalG{
  display:block;position:fixed;inset:auto 14px 24px auto;z-index:10040;
  transform-origin:bottom center;transition:transform .25s ease,opacity .25s ease;
}
/* اللوحة فوق زر جي بمسافة 32px من الأسفل ومحاذية لحافته */
#opsGlobalGPanel{
  position:fixed;inset:auto 32px 120px auto;
  width:min(410px,calc(100vw - 36px));max-width:calc(100vw - 36px);
  height:min(640px,calc(100vh - 150px));max-height:calc(100vh - 36px);
  box-sizing:border-box;z-index:10050;
}
/* الترتيب يحدد الأولوية: الخمول ثم التمرير ثم الاقتراب ثم الإرساء، والمرور بالماوس والفتح فوق الكل */
html.ayan-fw-idle #opsGlobalG{opacity:.38;transform:scale(.72)}
html.ayan-fw-scrolling #opsGlobalG{opacity:.22;transform:scale(.55);pointer-events:none}
html.ayan-fw-awake #opsGlobalG{opacity:1;transform:none;pointer-events:auto}
html.ayan-g-docked #opsGlobalG{opacity:.55;transform:translateX(58%)}
html #opsGlobalG:is(:hover,:focus-within),
html.ayan-g-open #opsGlobalG{opacity:1;transform:none;pointer-events:auto}

/* ---------- زر «لوحة المدير»: الكمبيوتر ---------- */
#ayanExecutiveReturnBtn{
  position:fixed;inset:auto auto 18px 16px;z-index:8500;
  padding:8px 14px;font-size:12.5px;border-radius:999px;
  transform-origin:bottom center;transition:transform .22s ease,opacity .22s ease;
}
html.ayan-fw-idle #ayanExecutiveReturnBtn{opacity:.38;transform:scale(.72)}
html.ayan-fw-scrolling #ayanExecutiveReturnBtn{opacity:.22;transform:scale(.55);pointer-events:none}
html.ayan-fw-awake #ayanExecutiveReturnBtn,
#ayanExecutiveReturnBtn:is(:hover,:focus){opacity:1;transform:none;pointer-events:auto}

/* مساحة أسفل الصفحات حتى يمكن تمرير آخر صف فوق الأزرار العائمة (الجوال له قيمته أدناه) */
.ayan-system-shell,
.ops-shell{padding-bottom:72px}

/* ---------- التابلت (701–900px): جي دائرة 58px بلا نص ---------- */
@media (min-width:701px) and (max-width:900px){
  #opsGlobalG{width:58px;height:58px}
  #opsGlobalGButton{
    width:58px;min-width:58px;max-width:58px;height:58px;min-height:58px;
    padding:4px;border-radius:50%;justify-content:center;overflow:hidden;
  }
  #opsGlobalGButton .ops-global-g-button-text{display:none}
  #opsGlobalGButton img{width:48px;height:48px;min-width:48px;max-width:48px;min-height:48px}
}
/* الحبة بعرض محتواها حتى لا تمدها قواعد أزرار الشاشات الصغيرة على عرض الصفحة */
@media (max-width:900px){
  #ayanExecutiveReturnBtn{width:auto;max-width:none;min-height:0}
}

/* ---------- الجوال (<=700px) ---------- */
@media (max-width:700px){
  /* جي 44px ملتصق بالحافة ونصفه تقريبًا خلفها، يظهر كاملًا باللمس أو بفتح اللوحة */
  #opsGlobalG{
    inset:auto 0 calc(76px + env(safe-area-inset-bottom,0px)) auto;
    width:44px;height:44px;z-index:999999;
    opacity:.78;transform:translateX(40%);transition:transform .18s ease,opacity .18s ease;
  }
  html #opsGlobalG:active,
  html.ayan-g-open #opsGlobalG{opacity:1;transform:none}
  #opsGlobalGButton{
    width:44px;min-width:44px;max-width:44px;height:44px;min-height:44px;
    padding:2px;border-radius:50%;justify-content:center;overflow:hidden;
    box-shadow:0 8px 24px rgba(15,23,42,.22);
  }
  #opsGlobalGButton:hover{transform:none}
  #opsGlobalGButton .ops-global-g-button-text{display:none}
  #opsGlobalGButton img{width:38px;height:38px;min-width:38px;max-width:38px;min-height:38px}

  /* اللوحة منقولة إلى body؛ ارتفاعها من الشاشة المرئية (--ayan-vvh يكتبه السكربت) */
  #opsGlobalGPanel{
    inset:auto 8px 8px 8px;width:auto;max-width:none;
    height:max(320px,min(calc(var(--ayan-vvh,100vh) * .78),700px));
    min-height:340px;max-height:max(300px,calc(var(--ayan-vvh,100vh) - 16px));
    margin:0;padding:0;overflow:hidden;border-radius:18px;z-index:2000000;
  }

  /* «لوحة المدير»: دائرة 46px بأيقونة فقط */
  #ayanExecutiveReturnBtn{
    inset:auto auto 10px 16px;width:46px;height:46px;max-width:46px;min-height:46px;
    padding:7px 12px;font-size:11.5px;justify-content:center;overflow:hidden;z-index:9200;
  }
  #ayanExecutiveReturnBtn span{display:none}

  /* مساحة أسفل الصفحات حتى لا تغطي الأزرار العائمة آخر الصفوف */
  .ayan-system-shell,
  .ops-shell{padding-bottom:84px}
  #controlView,
  #operationsView,
  #socialClientsSubView{padding-bottom:100px}
}
@media (max-width:380px){
  #opsGlobalGPanel{
    inset:auto 5px 5px 5px;
    height:max(320px,min(calc(var(--ayan-vvh,100vh) * .82),700px));
    min-height:320px;max-height:max(300px,calc(var(--ayan-vvh,100vh) - 10px));
  }
}
