/* ==========================================================================
   Telkini v145 — الشريط السفلي في كل نصوص Lesen (Teil 1 · Teile 2 · Teile 3 · Sprach 1 · Sprach 2)
   نفس تصميم الصورة المرجعية: زر «تصحيح» أزرق متدرج يساراً، كبسولة «Ask AI» بيضاء في الوسط
   مع كرة Telkini، وزر الجزء التالي أزرق متدرج يميناً. لا تغيير على أي وظيفة (onclick كما هي).
   يُحمَّل بعد telkini-chat.css و ui-responsive.css حتى يتغلب عليهما داخل هذا الشريط فقط.
   ========================================================================== */

/* ---------- الشريط نفسه: زجاجي أبيض، خط علوي رفيع وظل ناعم ---------- */
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) {
  min-height: 61px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom)) !important;
  background: rgba(255, 255, 255, .9) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
          backdrop-filter: blur(24px) saturate(1.4);
  border-top: 1px solid rgba(226, 232, 240, .8) !important;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, .06);
  align-items: center;
}
.dark :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) {
  background: rgba(2, 6, 23, .9) !important;
  border-top-color: rgba(30, 41, 59, .6) !important;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, .4);
}
@media (min-width: 1024px) {
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) { padding-left: 24px !important; padding-right: 24px !important; }
}
.ex-bottom-bar > div { width: 100%; max-width: 1920px; margin: 0 auto; }

/* ---------- الأزرار الرئيسية (تصحيح / الجزء التالي / النتيجة) ---------- */
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button:is(.bg-blue-600, .bg-blue-700, .bg-\[\#1d4ed8\], .bg-green-600) {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px !important; min-height: 44px;
  padding: 10px 24px !important;
  border: 0 !important; border-radius: 8px !important;
  background-color: #1d4ed8 !important;
  background-image: linear-gradient(to top right, #3b82f6, #1d4ed8, #1e40af) !important;
  color: #fff !important;
  font-family: Cairo, Tajawal, Inter, sans-serif !important;
  font-size: 15px !important; font-weight: 700 !important; line-height: 24px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(59, 130, 246, .1);
  transition: transform .2s cubic-bezier(.4, 0, .2, 1), box-shadow .2s cubic-bezier(.4, 0, .2, 1), filter .2s cubic-bezier(.4, 0, .2, 1) !important;
  -webkit-tap-highlight-color: transparent;
}
/* «النتيجة» يبقى أخضر (نهاية الامتحان) لكن بنفس الشكل والحركة */
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button.bg-green-600 {
  background-color: #16a34a !important;
  background-image: linear-gradient(to top right, #22c55e, #16a34a, #15803d) !important;
  box-shadow: 0 1px 2px rgba(34, 197, 94, .12);
}
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button:is(.bg-blue-600, .bg-blue-700, .bg-\[\#1d4ed8\], .bg-green-600) svg {
  width: 18px !important; height: 18px !important; flex-shrink: 0;
}
@media (hover: hover) {
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button:is(.bg-blue-600, .bg-blue-700, .bg-\[\#1d4ed8\]):hover {
    filter: brightness(1.08) saturate(1.05);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px -8px rgba(29, 78, 216, .55);
  }
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button.bg-green-600:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px -8px rgba(22, 163, 74, .55);
  }
}
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button:is(.bg-blue-600, .bg-blue-700, .bg-\[\#1d4ed8\], .bg-green-600):active {
  transform: scale(.96) !important; filter: brightness(.96);
  box-shadow: 0 1px 2px rgba(29, 78, 216, .2);
  transition-duration: .08s !important;
}
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button:focus-visible {
  outline: 2px solid #93c5fd !important; outline-offset: 2px;
}

/* ---------- زر الإعادة (أيقونة): رمادي فاتح 40×44 ---------- */
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button[aria-label="إعادة"] {
  width: 40px !important; height: 44px !important; padding: 0 !important;
  border: 0 !important; border-radius: 8px !important;
  background: #f1f5f9 !important; color: #334155 !important;
  transition: background-color .15s ease, transform .15s ease !important;
}
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button[aria-label="إعادة"] svg { width: 20px !important; height: 20px !important; }
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button[aria-label="إعادة"]:hover { background: #e2e8f0 !important; }
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button[aria-label="إعادة"]:active { transform: scale(.94); }
.dark :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button[aria-label="إعادة"] { background: #1e293b !important; color: #cbd5e1 !important; }
.dark :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button[aria-label="إعادة"]:hover { background: #334155 !important; }

/* ---------- كبسولة «Ask AI»: بيضاء، إطار رمادي رفيع، كرة Telkini + النص ---------- */
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn {
  display: inline-flex !important; align-items: center; gap: 12px !important;
  min-height: 0; padding: 10px 20px !important;
  border-radius: 999px !important;
  background: #fff !important;
  border: 1px solid #e5e7eb !important;
  color: #000 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05) !important;
  animation: none !important;
  transition: box-shadow .25s ease, border-color .25s ease, transform .2s cubic-bezier(.2, .8, .2, 1) !important;
  -webkit-tap-highlight-color: transparent;
}
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn::before,
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn::after { display: none !important; }
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn:hover {
  background: #fff !important;
  border-color: rgba(34, 197, 94, .35) !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1), 0 0 0 4px rgba(34, 197, 94, .08) !important;
}
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn:focus-visible { outline: 2px solid #4ade80 !important; outline-offset: 2px; }
.dark :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn { background: #0a0a0a !important; border-color: #1f2937 !important; color: #fff !important; }
.dark :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn:hover { background: #0a0a0a !important; border-color: rgba(74, 222, 128, .4) !important; box-shadow: 0 4px 14px -4px rgba(0, 0, 0, .6), 0 0 0 4px rgba(34, 197, 94, .12) !important; }

:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-label {
  display: inline-flex !important; gap: .25em;
  font: 600 15px/24px Inter, Poppins, system-ui, sans-serif !important; letter-spacing: 0;
}
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) :is(.ask-ai-a, .ask-ai-b) { color: inherit !important; }

/* حاوية الكرة: بدون الأيقونة المربعة القديمة */
.ask-ai-orb, button[onclick="runLesenAICorrection()"] .ask-ai-orb {
  background: none !important; box-shadow: none !important; animation: none !important;
  border-radius: 50% !important; overflow: visible;
}
:is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-orb { width: 22px !important; height: 22px !important; }
.ask-ai-btn:hover .ask-ai-orb { animation: none !important; }
button[onclick="runLesenAICorrection()"] .ask-ai-orb { width: 18px !important; height: 18px !important; }

/* الكمبيوتر والتابلت: الكبسولة في منتصف الشريط تماماً مهما اختلف عرض الزرين */
@media (min-width: 768px) {
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn {
    position: absolute !important; left: 50%; top: 50%;
    transform: translate(-50%, calc(-50% - env(safe-area-inset-bottom) / 2));
  }
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn:active {
    transform: translate(-50%, calc(-50% - env(safe-area-inset-bottom) / 2)) scale(.95) !important;
  }
}
@media (max-width: 767px) {
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn { transform: none; }
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn:active { transform: scale(.95) !important; }
}

/* ---------- الهاتف ---------- */
@media (max-width: 767px) {
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) {
    min-height: 58px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) !important;
  }
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button:is(.bg-blue-600, .bg-blue-700, .bg-\[\#1d4ed8\], .bg-green-600) {
    min-height: 42px; padding: 9px 16px !important; font-size: 14px !important; gap: 6px !important;
  }
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn { padding: 9px 14px !important; gap: 8px !important; min-height: 42px; }
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-label { font-size: 14px !important; }
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button[aria-label="إعادة"] { width: 40px !important; height: 42px !important; }
}
@media (max-width: 400px) {
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button:is(.bg-blue-600, .bg-blue-700, .bg-\[\#1d4ed8\], .bg-green-600) {
    padding: 9px 12px !important; font-size: 13.5px !important;
  }
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn { padding: 9px 12px !important; gap: 7px !important; }
}
/* شاشات صغيرة جداً، أو الشريط الذي فيه 4 أزرار (Sprach 2): الكرة فقط بدون كلمة Ask AI حتى لا يتداخل شيء */
@media (max-width: 359px) {
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn > .ask-ai-label { display: none !important; }
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) .ask-ai-btn { padding: 9px !important; }
}
@media (max-width: 420px) {
  [id^="exercise"][id$="-view"] > .fixed.bottom-0:has(button[aria-label="إعادة"]) .ask-ai-btn > .ask-ai-label { display: none !important; }
  [id^="exercise"][id$="-view"] > .fixed.bottom-0:has(button[aria-label="إعادة"]) .ask-ai-btn { padding: 9px !important; }
}

@media (prefers-reduced-motion: reduce) {
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button { transition: none !important; }
  :is(.ex-bottom-bar, [id^="exercise"][id$="-view"] > .fixed.bottom-0) button:hover { transform: none; }
}
