/* ===== Select-to-ask tooltip (يظهر لما الطالب يحدد نص بالدرس) ===== */
#fislab-select-tip {
  position: fixed;
  transform: translateX(-50%);
  background: #012116;
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: bold;
  font-family: "Inter", "Tahoma", sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  display: none;
  white-space: nowrap;
}
#fislab-select-tip.show { display: block; }
#fislab-select-tip:hover { background: #00573f; }

/* ===== Fislab AI chat widget ===== */
#fislab-chat-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 999;
  height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #00573f, #012116);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: "Inter", "Tahoma", sans-serif;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 87, 63, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s ease;
}
#fislab-chat-btn:hover { transform: scale(1.04); }
#fislab-chat-btn-icon,
.fislab-chat-btn-icon { font-size: 20px; }

@media (max-width: 480px) {
  #fislab-chat-btn { font-size: 12px; padding: 0 14px; height: 46px; }
  .fislab-chat-btn-icon { font-size: 17px; }
}

#fislab-chat-panel {
  position: fixed;
  bottom: 92px;
  left: 24px;
  z-index: 999;
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 140px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: "Inter", "Tahoma", sans-serif;
  direction: rtl;
}
#fislab-chat-panel.open { display: flex; }

#fislab-chat-header {
  background: linear-gradient(135deg, #00573f, #012116);
  color: #fff;
  padding: 14px 16px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#fislab-chat-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.8;
}
#fislab-chat-header button:hover { opacity: 1; }

#fislab-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f6f3f2;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fislab-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.fislab-msg.user {
  align-self: flex-end;
  background: #00573f;
  color: #fff;
  border-bottom-left-radius: 4px;
}
.fislab-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: #1c1b1b;
  border: 1px solid #e3ede8;
  border-bottom-right-radius: 4px;
}
.fislab-msg.error {
  align-self: center;
  background: #fbe9ea;
  color: #7a0013;
  border: 1px solid #f3c9cc;
  font-size: 13px;
}
.fislab-msg.typing { color: #6b7a74; font-style: italic; }

#fislab-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #eee;
  background: #fff;
}
#fislab-chat-input {
  flex: 1;
  border: 1px solid #dcece3;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  resize: none;
  font-family: inherit;
}
#fislab-chat-input:focus { outline: none; border-color: #00573f; }
#fislab-chat-send {
  background: #00573f;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: bold;
  cursor: pointer;
}
#fislab-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 480px) {
  #fislab-chat-panel { left: 12px; bottom: 84px; }
  #fislab-chat-btn { left: 12px; }
}
