/* ===============================
   الملف الديناميكي من الإعدادات
   =============================== */

.my-buttons-bar a {
  margin-right: var(--my-buttons-gap);
  background: var(--my-button-bg2);
  color: var(--my-button-text);
  border-radius: var(--my-button-radius);
  font-size: var(--my-button-siz);
  height: var(--button-hi);
  width: var(--button-wdth);
  min-height: var(--button-hi);
  font-weight: var(--button-wet);
  line-height: var(--button-hi);
}

.my-buttons-bar a img {
  height: var(--button-hi);
  width: var(--button-wdth);
  max-height: var(--button-hi);
}

/*
 * المسافة العلوية أصبحت على الغلاف المشترك.
 * لذلك الشريط + الإعجاب + الترس يرتفعون وينخفضون معًا.
 */
.my-buttons-shell {
  top: var(--my-buttons-top-desktop);
}

.my-buttons-container {
  background: var(--my-buttons-bg1);
}

.scroll-arrow {
  top: calc(10px + (var(--button-hi) / 2));
}

@media (max-width: 767px) {
  .my-buttons-shell {
    top: var(--my-buttons-top-mobile) !important;
  }

  .scroll-arrow {
    top: calc(10px + (var(--button-hi_mob) / 2)) !important;
  }

  .my-buttons-bar a {
    font-size: var(--my-button-siz_mob);
    height: var(--button-hi_mob);
    width: var(--button-wdth_mob);
    min-height: var(--button-hi_mob);
    line-height: var(--button-hi_mob);
    margin-right: var(--my-buttons-gap_mob);
  }

  .my-buttons-bar a img {
    height: var(--button-hi_mob);
    max-height: var(--button-hi_mob);
  }
}


/* ===============================
   الغلاف المشترك
   =============================== */

.my-buttons-shell {
  position: relative;
  left: 0;
  right: 0;
  z-index: 999;
}

/*
 * هذه الحاوية فوق يسار الشريط.
 * هي التي تستقبل أزرار الإعجاب والترس.
 */
.mybb-linked-controls {
  position: absolute;
  left: 20px;
  bottom: calc(100% + 7px);
  z-index: 1002;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 52px;
  pointer-events: none;
}

.mybb-linked-controls > * {
  pointer-events: auto;
}

.mybb-linked-controls:empty {
  display: none;
}


/* ===============================
   تصميم الشريط الأصلي
   =============================== */

.my-buttons-bar a img {
  width: auto;
  object-fit: contain;
  vertical-align: middle;
  display: block;
}

.my-buttons-bar a {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  line-height: normal;
  vertical-align: middle;
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.15),
    inset 0 2px 3px rgba(255, 255, 255, 1),
    inset 0 -3px 6px rgba(0, 0, 0, 1);
}

.my-buttons-bar a:hover {
  background: #333;
  color: #fff;
  border-color: #000;
  transform: translateY(-2px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.my-buttons-container {
  position: relative;
  left: 0;
  right: 0;
  padding: 5px;
}

.my-buttons-bar {
  overflow-x: hidden;
  white-space: nowrap;
  cursor: grab;
}

.scroll-arrow {
  position: absolute;
  width: 1px;
  height: 1px;
  background: #eee;
  border-radius: 50%;
  text-align: center;
  line-height: 30px;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0;
}

.scroll-arrow-left {
  left: 10px;
}

.scroll-arrow-right {
  right: 10px;
}


/* ===============================
   الهاتف
   =============================== */

@media (max-width: 767px) {
  html,
  body {
    overflow-x: hidden;
    touch-action: pan-y;
    overscroll-behavior-x: none;
  }

  .mybb-linked-controls {
    left: 10px;
    bottom: calc(100% + 5px);
    min-height: 46px;
  }

  .my-buttons-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
  }

  .my-buttons-bar {
    overflow-x: visible !important;
  }
}

/* ==========================================================
   إصلاح صف الترس والإعجاب على الهاتف فقط
   ========================================================== */
@media (max-width: 767px) {

  /*
   * جعل عناصر الغلاف في تدفق طبيعي:
   * صف التفاعل أولاً، ثم شريط الأزرار.
   * بهذا لا تتداخل الأزرار مع البحث أو المحتوى التالي.
   */
  .my-buttons-shell {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }

  .mybb-linked-controls {
    position: relative !important;
    inset: auto !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;

    order: 1;
    width: 100%;
    min-height: 48px;
    padding: 4px 12px 5px;
    margin: 0;

    display: flex;
    align-items: center;
    justify-content: flex-end;

    background: transparent;
    box-sizing: border-box;
    overflow: visible;
  }

  .my-buttons-container {
    order: 2;
    width: 100%;
  }

  /*
   * ترتيب حاوية التقييم من دون فراغات أو انتقال لأسطر متعددة.
   */
  #mybb-linked-controls .feedback-buttons-container {
    width: auto !important;
    max-width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    align-items: flex-start !important;
  }

  #mybb-linked-controls .main-buttons-row {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    gap: 7px !important;
    width: auto;
    max-width: 100%;
  }

  /*
   * تصغير أزرار الإعجاب والعدادات على الهاتف.
   */
  #mybb-linked-controls .feedback-button {
    min-width: auto !important;
    min-height: 34px !important;
    height: 34px !important;
    padding: 5px 10px !important;
    border-radius: 7px !important;
    font-size: 12px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  #mybb-linked-controls .feedback-count {
    min-width: 30px !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 13px !important;
    line-height: 34px !important;
    text-align: center !important;
    white-space: nowrap !important;
  }

  /*
   * تصغير صورة الترس لتناسب صف الهاتف.
   */
  #mybb-linked-controls #gmcgm-root {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    margin: 0 2px 0 0 !important;
    visibility: visible !important;
  }

  #mybb-linked-controls .gmcgm-button {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
  }

  #mybb-linked-controls .gmcgm-button img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
  }

  /*
   * الملاحظة تظهر تحت صف الأزرار من دون توسيع الشريط.
   */
  #mybb-linked-controls .note-container {
    width: auto !important;
    margin-top: 5px !important;
    justify-content: flex-start !important;
  }

  #mybb-linked-controls .note-action-button {
    min-height: 32px !important;
    padding: 5px 9px !important;
    font-size: 11px !important;
  }
}

