/* ===================== Base ===================== */
:root{
  --bg:#0b0f14;
  --text:#fff;
  --muted:rgba(255,255,255,.78);
  --border:rgba(255,255,255,.10);
  --glass:rgba(255,255,255,.06);
  --chipBorder:rgba(255,255,255,.14);
  --radius:16px;

  /* Font control */
  --amar-chat-font: 16px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: system-ui,-apple-system,"Segoe UI",Tahoma,Arial;
  color:var(--text);
  background:var(--bg);
}

/* ===================== Background ===================== */
.bg{ position:fixed; inset:0; z-index:-1; overflow:hidden; }
.orb{
  position:absolute;
  width:420px;height:420px;
  border-radius:50%;
  filter:blur(120px);
  opacity:.22;
}
.orb1{ background:#5aa9ff; top:-130px; right:-140px; }
.orb2{ background:#b25cff; bottom:-150px; left:-140px; }
.orb3{ background:#30ffd3; bottom:15%; right:10%; opacity:.14; }
.gridGlow{
  position:absolute; inset:0;
  background:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size:42px 42px;
  opacity:.12;
}

/* ===================== Top Bar ===================== */
.topBar{
  position:sticky;
  top:0;
  z-index:60;
  background:rgba(0,0,0,.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom:1px solid var(--border);
}
.topBar__inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 14px;
}
.menuBtn{
  width:42px;height:42px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.05);
  color:#fff;
  font-size:18px;
  cursor:pointer;
}
.topBar__logo img{ height:28px; display:block; }

/* ===================== Side Menu ===================== */
.menuOverlay{
  position:fixed; inset:0;
  background:rgba(0,0,0,.55);
  opacity:0;
  pointer-events:none;
  transition:.2s ease;
  z-index:70;
}
.menuOverlay.isOpen{ opacity:1; pointer-events:auto; }
.sideMenu{
  position:fixed;
  top:0; right:-290px;
  width:290px; height:100%;
  background:rgba(10,14,20,.98);
  border-left:1px solid var(--border);
  z-index:71;
  padding:16px;
  transition:.25s ease;
}
.sideMenu.isOpen{ right:0; }
.menuClose{
  border:0;
  background:transparent;
  color:#fff;
  font-size:26px;
  cursor:pointer;
}
.menuNav{ margin-top:10px; }
.menuNav a{
  display:block;
  padding:12px 10px;
  margin:6px 0;
  border:1px solid var(--border);
  border-radius:12px;
  text-decoration:none;
  color:#fff;
  background:rgba(255,255,255,.03);
}

/* ===================== Layout ===================== */
.wrap{
  max-width:1100px;
  margin:0 auto;
  padding:18px;
}

/* ===================== Panels ===================== */
.panel{
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:rgba(255,255,255,.06);
}
.glass{
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ===================== Chat Panel ===================== */
.chatPanel{
  display:flex;
  flex-direction:column;
  overflow:visible;
}

/* ===================== Chat Head ===================== */
.chatHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px;
  background:rgba(0,0,0,.22);
  border-bottom:1px solid var(--border);
}
.chatHead__text{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.chatHead__title{
  font-weight:900;
  font-size:16px;
  line-height:1.2;
}
.chatHead__hint{
  font-size:13px;
  color:var(--muted);
  line-height:1.3;
}

/* actions container (Tour + Font) */
.chatHead__actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
  white-space:nowrap;
}

/* ===================== Chat Body ===================== */
.chatBody{
  padding:16px;
  min-height:240px;
  max-height:52vh;
  overflow:auto;
  font-size: var(--amar-chat-font);
}

/* ===================== Suggest Chips ===================== */
.suggest{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  padding:0 16px 12px;
}

/* ===================== Form ===================== */
.chatForm{
  display:flex;
  gap:10px;
  align-items:center;
  padding:12px 16px;
  border-top:1px solid var(--border);
  background:rgba(0,0,0,.12);
}
.chatForm input[type="text"]{
  flex:1;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(0,0,0,.25);
  color:#fff;
  outline:none;
}
.btn{
  padding:11px 14px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.18);
  background:linear-gradient(135deg, rgba(140,90,255,.85), rgba(80,220,255,.85));
  color:#061018;
  font-weight:900;
  cursor:pointer;
}
.chatFooterTools{
  display:flex;
  gap:8px;
  margin-inline-start:auto;
}
.iconBtn{
  padding:9px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:#fff;
  cursor:pointer;
}

/* ===================== Chips ===================== */
.chip{
  border-radius:999px;
  border:1px solid var(--chipBorder);
  background:rgba(255,255,255,.05);
  color:#fff;
  padding:7px 12px;
  cursor:pointer;
}
.chipGhost{ background:transparent; }

/* ===================== Footer ===================== */
.footer{
  text-align:center;
  padding:18px 10px;
  color:var(--muted);
  font-size:12px;
}

/* =========================================================
   MODAL (Tour + Intro)
========================================================= */
.modal{ position:fixed; inset:0; display:none; z-index:200; }
.modal[aria-hidden="false"]{ display:block; }
.modal__overlay{ position:absolute; inset:0; background:rgba(0,0,0,.65); }
.modal__card{
  position:relative;
  width:min(920px, calc(100% - 24px));
  margin:60px auto;
  border-radius:18px;
  border:1px solid var(--border);
  background:rgba(10,14,20,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow:hidden;
}
.modal__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
}
.modal__head h3{ margin:0; font-size:16px; font-weight:900; }
.modal__x{
  width:38px;height:38px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:#fff;
  font-size:22px;
  cursor:pointer;
}
.modal__body{ padding:16px; }
.modal__foot{
  padding:14px 16px;
  border-top:1px solid var(--border);
  display:flex;
  justify-content:flex-end;
  gap:10px;
}
.btnGhost{
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:#fff;
  cursor:pointer;
}
.modal__tabs{
  display:flex;
  gap:8px;
  padding:12px 16px;
  border-bottom:1px solid var(--border);
  flex-wrap:wrap;
}
.tab{
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--chipBorder);
  background:rgba(255,255,255,.03);
  color:#fff;
  cursor:pointer;
  font-size:13px;
}
.tab.isActive{
  background:linear-gradient(135deg, rgba(140,90,255,.55), rgba(80,220,255,.35));
  border-color:rgba(255,255,255,.22);
}
.tabPane{ display:none; }
.tabPane.isActive{ display:block; }
.note{ display:block; margin-top:10px; color:var(--muted); font-size:12px; }

.videoWrap{
  width:100%;
  border-radius:14px;
  overflow:hidden;
  border:1px solid var(--border);
  background:#000;
}
.videoWrap video{ width:100%; height:auto; display:block; }

.prettyList{ margin:10px 0 0; padding:0 18px 0 0; }
.prettyList li{ margin:8px 0; }
.grid2{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap:12px;
  margin-top:10px;
}
.infoCard{
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(255,255,255,.04);
  padding:12px;
}
.infoCard h5{ margin:0 0 6px; }

/* =========================================================
   Chat Bubbles
========================================================= */
.chatBody .msgRow{
  display:flex;
  margin:10px 0;
  gap:10px;
}

/* المستخدم (يمين) */
.chatBody .msgRow.isUser{ justify-content:flex-end; }
/* البوت (يسار) */
.chatBody .msgRow.isBot{ justify-content:flex-start; }

/* الفقاعة */
.chatBody .msgBubble{
  max-width: min(680px, 85%);
  padding: 14px 16px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
  box-shadow: 0 8px 26px rgba(0,0,0,.35);
  line-height:1.9;
  word-break: break-word;
}

/* ألوان */
.chatBody .msgRow.isUser .msgBubble{
  background: linear-gradient(135deg, rgba(120,90,255,.30), rgba(80,220,255,.18));
  border-color: rgba(120,200,255,.35);
  text-align:right;
}
.chatBody .msgRow.isBot .msgBubble{
  background: rgba(255,255,255,.07);
  text-align:right;
}

/* ✅ Meta (تاريخ/وقت + المتحدث) — سطر مستقل داخل الفقاعة */
.chatBody .msgMeta{
  display:inline-flex;
  align-items:center;
  gap:8px;
  margin:0 0 10px 0;
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  line-height:1;
  color:rgba(255,255,255,.85);
  border:1px solid rgba(255,255,255,.14);
  background:rgba(10,12,18,.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space:nowrap;
}

/* ✅ عنوان السؤال المطابق من قاعدة البيانات (يظهر فقط مع رسائل أمار) */
.chatBody .msgTitle{
  margin:0 0 10px 0;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  font-weight:900;
  font-size:15px;
  line-height:1.8;
}

/* ✅ نص الرسالة */
.chatBody .msgText{
  white-space: pre-wrap;
  line-height: 1.9;
  word-break: break-word;
}

/* =========================================================
   Tour Hint (Star)
========================================================= */
#btnTour{ position:relative; }

#btnTour.tourHint::after{
  content: "★";
  position: absolute;
  top: -10px;
  left: -10px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
  color: #fff;
  background: rgba(255, 190, 0, .95);
  box-shadow: 0 10px 30px rgba(255, 190, 0, .25);
  animation: tourPulse 1.2s infinite ease-in-out;
  pointer-events: none;
}

#btnTour.tourHint::before{
  content:"";
  position:absolute;
  top:-13px;
  left:-13px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 190, 0, .22);
  animation: tourRing 1.2s infinite ease-out infinite;
  pointer-events:none;
}

@keyframes tourPulse{
  0%,100% { transform: translateY(0) scale(1); }
  50%     { transform: translateY(-1px) scale(1.08); }
}
@keyframes tourRing{
  0%   { transform: scale(.7); opacity: .9; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* زر الجولة */
#btnTour{
  border-radius:999px;
  border:1px solid rgba(255,255,255,.18);
  background:transparent;
  color:#fff;
  padding: 7px 14px;
  cursor:pointer;
}
#btnTour.tourHint{
  background: linear-gradient(135deg, #7b61ff 0%, #4a8cff 100%);
  box-shadow: 0 8px 22px rgba(123,97,255,.25);
}

/* زر تكبير الخط +A */
#btnFont{
  min-width:54px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.05);
  color:#fff;
  font-weight:900;
  cursor:pointer;
}

/* =========================================================
   Responsive
========================================================= */
@media (max-width: 720px){
  .chatBody{ max-height:54vh; }
  .grid2{ grid-template-columns:1fr; }
}
@media (max-width: 520px){
  .wrap{ padding:12px; }
  .chatHead{ flex-direction:column; align-items:flex-start; }
  .chatHead__actions{ width:100%; justify-content:flex-start; }
  .chatForm{ flex-wrap:wrap; }
  .chatFooterTools{
    width:100%;
    justify-content:flex-start;
    margin-inline-start:0;
  }
  .chatBody .msgBubble{ max-width:92%; }
}
/* =========================================================
   ✅ Answer Title (Top-Right) + Better Header Buttons
========================================================= */

/* ترتيب أزرار الهيدر */
.chatHead__actions{
  display:flex;
  gap:8px;
  align-items:center;
}

/* زر +A يكون صغير ومرتب */
#btnFont{
  min-width:52px;
  text-align:center;
  font-weight:900;
}

/* ===== داخل فقاعة الرسالة: مساحة للبادجات أعلى ===== */
.chatBody .msgBubble{
  position: relative;
  padding-top: 64px; /* زادت لأن صار عندنا ختم + عنوان */
}

/* ختم التاريخ/الوقت */
.chatBody .msgMeta{
  position: absolute;
  top: 12px;
  left: 14px;          /* أمار يسار */
  z-index: 10;

  display: inline-flex;
  align-items: center;

  padding: 8px 12px;
  border-radius: 14px;

  font-size: 12px;
  line-height: 1;
  white-space: nowrap;

  max-width: calc(100% - 28px);
  overflow: hidden;
  text-overflow: ellipsis;

  color: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(10,12,18,.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 22px rgba(0,0,0,.18);
}

/* ختم المستخدم يمين */
.chatBody .msgRow.isUser .msgMeta{
  left: auto;
  right: 14px;
}

/* ===== عنوان الإجابة (مكان الخط الأحمر) ===== */
.chatBody .msgTitleBadge{
  position: absolute;
  top: 12px;
  right: 14px;         /* ✅ يمين أعلى الفقاعة */
  z-index: 10;

  display: inline-flex;
  align-items: center;

  padding: 8px 12px;
  border-radius: 14px;

  font-size: 12px;
  line-height: 1;
  white-space: nowrap;

  color: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(10,12,18,.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* العنوان يظهر فقط مع رسائل البوت */
.chatBody .msgRow.isBot .msgTitleBadge{ display:inline-flex; }
.chatBody .msgRow.isUser .msgTitleBadge{ display:none; }
.footerRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}

.visitorCounter{
  padding:8px 12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.06);
  backdrop-filter: blur(10px);
  font-weight:700;
}
/* لا تجعل الـ overlay يمنع الضغط إلا عند الفتح */
.menuOverlay{ pointer-events:none; opacity:0; }
.menuOverlay.isOpen{ pointer-events:auto; opacity:1; }

/* المودالات وهي مخفية */
.modal[aria-hidden="true"]{ display:none !important; }
/* =========================================================
   FIX: Edge click freeze (overlays intercept clicks)
   ضع هذا آخر style.css
========================================================= */

/* Overlay القائمة: لا يلتقط الضغط إلا وهو مفتوح */
.menuOverlay{
  position:fixed; inset:0;
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transition:opacity .18s ease, visibility .18s ease;
  z-index:80; /* أقل من القائمة نفسها */
}
.menuOverlay.isOpen{
  opacity:1;
  visibility:visible;
  pointer-events:auto;
}

/* القائمة الجانبية فوق الـ overlay */
.sideMenu{
  position:fixed;
  z-index:90;
}

/* المودال: وهو مخفي لا يلتقط أي شيء ولا يظهر */
.modal{
  position:fixed; inset:0;
  display:none;           /* أهم سطر */
  pointer-events:none;    /* حماية إضافية */
  z-index:200;
}
.modal.isOpen{
  display:block;
  pointer-events:auto;
}

/* طبقة المودال */
.modal__overlay{
  position:absolute; inset:0;
  pointer-events:auto;
}

/* إذا كنت تستخدم aria-hidden بدل isOpen في بعض الحالات */
.modal[aria-hidden="true"]{
  display:none !important;
  pointer-events:none !important;
}
.videoWrap {
  width: 100%;
  max-width: 900px;
  margin: 15px auto;
  max-height: 45vh; /* مهم: لا يتجاوز نصف الشاشة */
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.videoWrap video {
  width: 100%;
  height: 100%;
  max-height: 45vh;
  object-fit: contain;
}
/* ===== Typing dots داخل فقاعة البوت ===== */
.chatBody .typingDots{
  display:inline-flex;
  gap:6px;
  align-items:center;
}
.chatBody .typingDots span{
  width:6px; height:6px;
  border-radius:50%;
  background: rgba(255,255,255,.75);
  opacity:.35;
  animation: amarDot 1.05s infinite ease-in-out;
}
.chatBody .typingDots span:nth-child(2){ animation-delay:.15s; opacity:.55; }
.chatBody .typingDots span:nth-child(3){ animation-delay:.30s; opacity:.75; }

@keyframes amarDot{
  0%,100%{ transform: translateY(0); opacity:.25; }
  50%    { transform: translateY(-3px); opacity:.95; }
}
/* ======================================================
   ChatGPT-like formatting for msgText (ضعها في style.css)
====================================================== */
.msgText{
  line-height: 1.75;
  font-size: 15.5px;
  white-space: normal;
  word-break: break-word;
}
.msgText p{
  margin: 0 0 10px 0;
}
.msgText .sp{
  height: 10px;
}
.msgText ul, .msgText ol{
  margin: 6px 18px 12px 0;
  padding: 0 18px 0 0;
}
.msgText li{
  margin: 4px 0;
}
.msgText a{
  text-decoration: underline;
}
.msgText{
  line-height: 1.75;
  font-size: 15.5px;
  white-space: normal;
  word-break: break-word;
}
.msgText p{ margin: 0 0 10px 0; }
.msgText .sp{ height: 10px; }
.msgText ul, .msgText ol{
  margin: 6px 18px 12px 0;
  padding: 0 18px 0 0;
}
.msgText li{ margin: 4px 0; }
.msgText a{ text-decoration: underline; }
