/* ============================================================
   سيف الخروصي — مساعد سجل بنو خروص
   منقول عن الكابتن سيف (dronesuae) بهيئته نفسها، ومربوط
   بمفردات تصميم هذا الموقع: النحاس والحجر والورق والسعف.
   كل الخصائص منطقية الاتجاه، فتنعكس مع RTL تلقائيًّا.
   ============================================================ */

/* ---------- الزر العائم ---------- */
.saifwrap {
  position: fixed; inset-block-end: 20px; inset-inline-start: 20px;
  z-index: 200; display: flex; align-items: center; gap: 8px;
  transition: opacity .2s ease, transform .2s ease;
}
.saifwrap.hid { opacity: 0; pointer-events: none; transform: scale(.9); }

.saifbtn {
  position: relative; width: 60px; height: 60px; padding: 0; cursor: pointer;
  border-radius: 50%; border: 2px solid var(--paper); background: var(--paper);
  box-shadow: 0 6px 20px rgba(20, 16, 11, .3);
  transition: transform .2s ease, box-shadow .2s ease;
  animation: saifBob 3.4s ease-in-out infinite;
}
.saifbtn img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.saifbtn:hover { transform: scale(1.08); box-shadow: 0 10px 26px rgba(20, 16, 11, .36); }
.saifbtn:focus-visible { outline: 3px solid var(--copper); outline-offset: 3px; }
@keyframes saifBob { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-5px) } }
@media (prefers-reduced-motion: reduce) { .saifbtn { animation: none } }

.saifdot {
  position: absolute; inset-block-end: 3px; inset-inline-end: 3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--palm); border: 2px solid var(--paper);
}

.saiftip {
  background: var(--night); color: var(--sand); font-size: .74rem; font-weight: 500;
  font-family: var(--body); padding: 7px 12px; border-radius: 999px; white-space: nowrap;
  opacity: 0; transform: translateX(-6px); transition: opacity .3s ease, transform .3s ease;
  box-shadow: 0 4px 12px rgba(20, 16, 11, .24); order: 2;
}
.saiftip.go { opacity: 1; transform: translateX(0); }

/* ---------- لوحة المحادثة ---------- */
.saifpanel {
  position: fixed; inset-block-end: 20px; inset-inline-start: 20px;
  width: min(392px, calc(100vw - 40px)); height: min(600px, calc(100vh - 40px));
  z-index: 210; display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper-lt); border: 1px solid var(--rule-light);
  border-radius: 4px; box-shadow: 0 22px 60px rgba(20, 16, 11, .34);
  opacity: 0; visibility: hidden; transform: translateY(14px) scale(.98);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
  font-family: var(--body);
}
.saifpanel.on { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.saifhead {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-block-end: 1px solid var(--rule-light); background: var(--sand);
  flex: 0 0 auto;
}
.saifhead > img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.saifwho { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.saifwho b { font-family: var(--display); font-size: 1rem; font-weight: 400; color: var(--basalt); }
.saifwho small { font-size: .68rem; color: var(--palm); }
.saifx {
  width: 30px; height: 30px; flex: 0 0 auto; cursor: pointer; font-size: .95rem;
  border-radius: 3px; border: 1px solid var(--rule-light);
  background: var(--paper); color: var(--stone);
  display: grid; place-items: center; transition: background .14s, color .14s;
}
.saifx:hover { background: var(--canvas); color: var(--basalt); }

.saifbody {
  flex: 1 1 auto; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--paper-lt);
}
.saifmsg {
  max-width: 88%; padding: 10px 13px; border-radius: 12px;
  font-size: .85rem; line-height: 1.85; word-wrap: break-word;
}
.saifmsg.bot {
  align-self: flex-start; background: var(--canvas); color: var(--basalt);
  border: 1px solid var(--rule-light); border-start-start-radius: 3px;
}
.saifmsg.me {
  align-self: flex-end; background: var(--copper); color: #17110A;
  border-end-end-radius: 3px;
}
.saifdots { display: inline-flex; gap: 4px; padding: 2px 0; }
.saifdots i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--stone);
  animation: saifPulse 1.2s ease-in-out infinite;
}
.saifdots i:nth-child(2) { animation-delay: .18s }
.saifdots i:nth-child(3) { animation-delay: .36s }
@keyframes saifPulse { 0%, 60%, 100% { opacity: .3; transform: translateY(0) } 30% { opacity: 1; transform: translateY(-3px) } }

/* حالة البطاقة: موثق / رواية محلية — لا يُقدَّم المشكوك فيه كالمثبت */
.saifstat {
  display: inline-block; font-size: .66rem; padding: .16rem .5rem; border-radius: 2px;
  border: 1px solid; margin-inline-end: .4rem; vertical-align: 1px;
}
.saifstat--verified { color: #3E6B3B; border-color: rgba(62,107,59,.4); background: rgba(62,107,59,.09); }
.saifstat--local { color: #9A6321; border-color: rgba(154,99,33,.4); background: rgba(154,99,33,.09); }
.saifstat--research { color: #6A5B49; border-color: rgba(106,91,73,.4); background: rgba(106,91,73,.08); }

.saiflinks { display: flex; flex-direction: column; gap: 5px; margin-block-start: 10px; }
.saifpage {
  display: inline-block; font-size: .78rem; font-weight: 500; text-decoration: none;
  padding: 7px 11px; border-radius: 3px; color: var(--rust);
  background: var(--paper); border: 1px solid var(--rule-light);
  transition: background .14s, transform .14s;
}
.saifpage:hover { background: var(--sand); transform: translateX(-2px); }

.saifws {
  margin-block-start: 11px; padding: 11px; border-radius: 3px;
  background: var(--paper); border: 1px dashed var(--stone);
}
.saifwsq { font-size: .76rem; color: var(--stone); margin-block-end: 8px; font-style: italic; }
.saifwsgo {
  display: block; text-align: center; text-decoration: none; font-weight: 500; font-size: .82rem;
  padding: 9px 12px; border-radius: 3px; color: #17110A; background: var(--copper);
  transition: transform .14s ease;
}
.saifwsgo:hover { transform: translateY(-1px); background: var(--copper-lt); }
.saifwshint { font-size: .68rem; color: var(--stone); margin: 7px 0 0; text-align: center; }

/* تقييم الإجابة — عليه يقوم التعلّم */
.saifrate { display: flex; align-items: center; gap: 6px; margin-block-start: 9px; font-size: .7rem; color: var(--stone); }
.saifrate button {
  cursor: pointer; font: inherit; font-size: .7rem; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--rule-light); background: var(--paper); color: var(--stone);
  transition: background .14s, color .14s, border-color .14s;
}
.saifrate button:hover { background: var(--sand); color: var(--basalt); }
.saifrate.done { color: var(--palm); }
.saifrate.done button { display: none; }

.saifquick {
  display: flex; gap: 6px; padding: 9px 12px; overflow-x: auto; flex: 0 0 auto;
  border-block-start: 1px solid var(--rule-light); background: var(--paper);
  scrollbar-width: none;
}
.saifquick::-webkit-scrollbar { display: none }
.saifquick button {
  white-space: nowrap; cursor: pointer; font: inherit; font-size: .74rem;
  padding: 6px 11px; border-radius: 999px; color: var(--stone);
  border: 1px solid var(--rule-light); background: var(--paper-lt);
  transition: background .14s, color .14s;
}
.saifquick button:hover { background: var(--copper); color: #17110A; border-color: transparent; }

.saifinput {
  display: flex; gap: 7px; padding: 11px 12px; flex: 0 0 auto;
  border-block-start: 1px solid var(--rule-light); background: var(--paper);
}
.saifinput input {
  flex: 1 1 auto; min-width: 0; font: inherit; font-size: .85rem;
  padding: 9px 13px; border-radius: 999px; color: var(--basalt);
  border: 1px solid var(--stone); background: var(--paper-lt);
}
.saifinput input:focus { outline: none; border-color: var(--copper); }
.saifinput button {
  width: 40px; height: 40px; flex: 0 0 auto; cursor: pointer; font-size: 1rem;
  border-radius: 50%; border: none; color: #17110A; background: var(--copper);
  display: grid; place-items: center; transition: transform .14s ease;
}
.saifinput button:hover { transform: scale(1.07); }
[dir="rtl"] .saifinput button { transform: scaleX(-1); }
[dir="rtl"] .saifinput button:hover { transform: scaleX(-1) scale(1.07); }

@media (max-width: 480px) {
  .saifwrap { inset-block-end: 14px; inset-inline-start: 14px; }
  .saifbtn { width: 52px; height: 52px; }
  .saifpanel { inset-block-end: 0; inset-inline-start: 0; width: 100vw; height: 100dvh; border-radius: 0; border: none; }
  .saiftip { display: none; }
}

@media print { .saifwrap, .saifpanel { display: none !important; } }
