/* فاهيم v3 — أيقونة عائمة قابلة للسحب + شاشة محادثة تفاعلية (نقرة تفتح ونقرة تغلق) + شاشة الإقلاع */
#fahim-root { --fh-a: #12b886; --fh-b: #0b7285; --fh-ink: #13293f; --fh-line: #e3e8ec; --fh-soft: #f5f8fa; }
#fahim-root, #fahim-root * { box-sizing: border-box; }

/* الأيقونة العائمة */
#fahim-btn { position: fixed; inset-inline-end: 18px; bottom: 18px; z-index: 1060; width: 58px; height: 58px; padding: 0; margin: 0;
  border: 0; border-radius: 50%; display: grid; place-items: center; cursor: grab; color: #fff;
  background: linear-gradient(135deg, var(--fh-a), var(--fh-b));
  box-shadow: 0 10px 26px rgba(11, 114, 133, .38), inset 0 1px 0 rgba(255, 255, 255, .35);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  transition: transform .18s ease, box-shadow .18s ease; }
#fahim-btn:hover { transform: scale(1.06); box-shadow: 0 14px 32px rgba(11, 114, 133, .45); }
#fahim-btn:focus-visible { outline: 3px solid #ffd43b; outline-offset: 3px; }
#fahim-root.fh-placed #fahim-btn { inset: auto; }
#fahim-root.fh-dragging #fahim-btn { cursor: grabbing; transform: scale(1.12); box-shadow: 0 20px 44px rgba(11, 114, 133, .5); transition: none; }
#fahim-btn .fh-ico { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; transition: transform .22s ease, opacity .22s ease; }
#fahim-btn .fh-ico-bot svg { width: 34px; height: 34px; }
#fahim-btn .fh-ico-x svg { width: 24px; height: 24px; }
#fahim-btn .fh-ico-x { opacity: 0; transform: rotate(-90deg) scale(.6); }
#fahim-root.fh-open #fahim-btn .fh-ico-bot { opacity: 0; transform: rotate(90deg) scale(.6); }
#fahim-root.fh-open #fahim-btn .fh-ico-x { opacity: 1; transform: none; }
#fahim-btn .fh-pulse { position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--fh-a); opacity: 0; pointer-events: none; animation: fhPulse 2.4s ease-out infinite; }
#fahim-root.fh-seen .fh-pulse, #fahim-root.fh-open .fh-pulse { display: none; }
@keyframes fhPulse { 0% { transform: scale(.88); opacity: .75; } 80%, 100% { transform: scale(1.38); opacity: 0; } }

/* تلميح أول زيارة (لا يفتح المحادثة) */
#fahim-hint { position: fixed; z-index: 1061; max-width: 240px; padding: 8px 12px; border-radius: 12px; background: var(--fh-ink); color: #fff;
  font-size: 12.5px; line-height: 1.6; box-shadow: 0 10px 28px rgba(0, 0, 0, .25); pointer-events: none; animation: fhIn .25s ease-out; }
#fahim-hint[hidden] { display: none !important; }

/* شاشة المحادثة */
#fahim-panel { position: fixed; z-index: 1059; inset-inline-end: 18px; bottom: 88px; width: min(380px, calc(100vw - 16px)); height: min(540px, calc(100vh - 110px));
  display: flex; flex-direction: column; overflow: hidden; background: #fff; color: var(--fh-ink); font-size: 14px; line-height: 1.6;
  border: 1px solid var(--fh-line); border-radius: 18px; box-shadow: 0 22px 60px rgba(16, 19, 24, .26); animation: fhIn .18s ease-out; }
#fahim-panel[hidden] { display: none !important; }
@keyframes fhIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
#fahim-panel[data-side="below"] { animation-name: fhInDown; }
@keyframes fhInDown { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
.fh-head { display: flex; align-items: center; gap: 9px; padding: 10px 12px; background: linear-gradient(135deg, #13293f, #0b4f63); color: #fff; flex: 0 0 auto; }
.fh-avatar { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--fh-a), var(--fh-b)); }
.fh-avatar svg { width: 25px; height: 25px; }
.fh-title { flex: 1; min-width: 0; line-height: 1.35; }
.fh-title b { display: block; font-size: 15px; }
.fh-title small { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: #b8d8de; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fh-title small::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #51cf66; }
.fh-tool { width: 30px; height: 30px; flex: 0 0 30px; padding: 0; border: 0; border-radius: 9px; background: rgba(255, 255, 255, .1); color: #fff; display: grid; place-items: center; cursor: pointer; }
.fh-tool:hover, .fh-tool:focus-visible { background: rgba(255, 255, 255, .22); outline: none; }
.fh-tool svg { width: 16px; height: 16px; }
#fahim-chat { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--fh-soft); overscroll-behavior: contain; }
.fh-msg { max-width: 86%; padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.75; white-space: pre-line; overflow-wrap: anywhere; animation: fhMsg .2s ease-out; }
.fh-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--fh-line); border-start-start-radius: 4px; }
.fh-msg.user { align-self: flex-end; background: var(--fh-b); color: #fff; border-start-end-radius: 4px; }
@keyframes fhMsg { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.fh-link { display: inline-flex; margin-top: 6px; padding: 4px 11px; border-radius: 999px; background: #e6fcf5; color: #087f5b; font-weight: 700; font-size: 12.5px; text-decoration: none; }
.fh-link:hover { background: #c3fae8; }
.fh-typing { display: inline-flex; gap: 4px; align-items: center; padding: 13px 14px; }
.fh-typing i { width: 7px; height: 7px; border-radius: 50%; background: #9aa9b3; animation: fhDot 1.1s infinite ease-in-out; }
.fh-typing i:nth-child(2) { animation-delay: .15s; }
.fh-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes fhDot { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-5px); opacity: 1; } }
.fh-chips { display: flex; flex-wrap: wrap; gap: 6px; align-self: stretch; padding-top: 2px; }
.fh-chip { border: 1px solid #b9e4d8; background: #f0fbf7; color: #0b6b55; border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12.5px; line-height: 1.5; cursor: pointer; transition: background .15s ease, transform .15s ease; }
.fh-chip:hover, .fh-chip:focus-visible { background: #d3f9ea; transform: translateY(-1px); outline: none; }
#fahim-form { display: flex; gap: 6px; padding: 10px 10px 6px; border-top: 1px solid var(--fh-line); background: #fff; flex: 0 0 auto; margin: 0; }
#fahim-input { flex: 1; min-width: 0; height: 42px; border: 1px solid #d6dde3; border-radius: 12px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--fh-ink); background: #fbfcfd; }
#fahim-input:focus { outline: none; border-color: var(--fh-a); box-shadow: 0 0 0 3px rgba(18, 184, 134, .18); }
#fahim-send { width: 42px; height: 42px; flex: 0 0 42px; padding: 0; border: 0; border-radius: 12px; background: var(--fh-a); color: #fff; display: grid; place-items: center; cursor: pointer; transition: background .15s ease; }
#fahim-send:disabled { background: #c5d3d8; cursor: default; }
#fahim-send svg { width: 19px; height: 19px; }
#fahim-root[dir="rtl"] #fahim-send svg { transform: scaleX(-1); }
.fh-foot { flex: 0 0 auto; padding: 0 12px 8px; background: #fff; color: #8a99a3; font-size: 11px; text-align: center; }
@media (max-width: 420px) { #fahim-btn { width: 54px; height: 54px; } .fh-msg { max-width: 92%; } }
@media print { #fahim-root { display: none !important; } }
@media (prefers-reduced-motion: reduce) { #fahim-root, #fahim-root * { animation: none !important; transition: none !important; } }

/* شاشة إقلاع تفاعلية ثلاثية الأبعاد */
#splash-host { position: fixed; inset: 0; z-index: 2000; background: linear-gradient(160deg, #f8fbfa, #eef7f4);
  display: grid; place-items: center; transition: opacity .55s ease; perspective: 900px; }
#splash-host.done { opacity: 0; pointer-events: none; }
.sp-card { text-align: center; transform-style: preserve-3d; animation: sp3d 5s ease-in-out infinite; }
@keyframes sp3d { 0%,100% { transform: rotateX(6deg) rotateY(-8deg); } 50% { transform: rotateX(-4deg) rotateY(8deg) translateY(-6px); } }
.sp-card img { width: 150px; margin: 0 auto 10px; filter: drop-shadow(0 14px 24px rgba(18, 184, 134, .35)); }
.sp-bar { width: 220px; height: 6px; margin: 18px auto 10px; background: #dfe9e6; border-radius: 99px; overflow: hidden; }
.sp-bar i { display: block; height: 100%; width: 20%; border-radius: 99px; background: linear-gradient(90deg, #12b886, #0b7285); transition: width .8s ease; }
.sp-label { color: #5b6a72; font-size: 13.5px; }
.sp-ring { width: 120px; height: 120px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(#12b886 0 25%, #e4efec 0); animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sp-card { animation: none; } }
