/* ============================================================
   أوتاد كنانة — مساعد الموقع الذكي (Chatbot Widget)
   Rule-based FAQ assistant. No backend, no external API, no cost.
   ============================================================ */

.ak-chat-fab {
  position: fixed;
  bottom: 26px;
  inset-inline-start: 26px;
  z-index: 260;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  border: none;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}
.ak-chat-fab:hover { transform: scale(1.08); background: var(--navy-dark); }
.ak-chat-fab svg { width: 27px; height: 27px; }
.ak-chat-fab__dot {
  position: absolute; top: 4px; inset-inline-end: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--cyan); border: 2px solid var(--navy);
}
.ak-chat-fab[data-open="true"] .ak-chat-fab__icon--chat { display: none; }
.ak-chat-fab[data-open="true"] .ak-chat-fab__icon--close { display: block; }
.ak-chat-fab .ak-chat-fab__icon--close { display: none; }

.ak-chat-panel {
  position: fixed;
  bottom: 96px;
  inset-inline-start: 26px;
  z-index: 260;
  width: min(360px, calc(100vw - 40px));
  height: min(500px, calc(100vh - 150px));
  background: var(--white);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ak-chat-panel[data-open="true"] {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ak-chat-panel__header {
  background: var(--navy);
  color: var(--white);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.ak-chat-panel__avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--navy-panel);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ak-chat-panel__avatar svg { width: 20px; height: 20px; }
.ak-chat-panel__title { font-weight: 700; font-size: 14.5px; line-height: 1.3; }
.ak-chat-panel__subtitle { font-size: 12px; color: #AEB9DA; display: flex; align-items: center; gap: 5px; }
.ak-chat-panel__subtitle::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3ECF6F; display: inline-block;
}
.ak-chat-panel__close {
  margin-inline-start: auto;
  background: transparent; border: none; color: #AEB9DA;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.ak-chat-panel__close:hover { background: rgba(255,255,255,0.1); color: var(--white); }

.ak-chat-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

.ak-msg { max-width: 86%; font-size: 13.5px; line-height: 1.6; }
.ak-msg--bot {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-start-start-radius: 4px;
  padding: 10px 13px;
  color: var(--text);
}
[dir="rtl"] .ak-msg--bot { border-start-start-radius: 14px; border-start-end-radius: 4px; }
.ak-msg--user {
  align-self: flex-end;
  background: var(--navy);
  color: var(--white);
  border-radius: 14px;
  border-end-end-radius: 4px;
  padding: 10px 13px;
}
[dir="rtl"] .ak-msg--user { align-self: flex-start; border-end-end-radius: 14px; border-end-start-radius: 4px; }
[dir="rtl"] .ak-msg--bot { align-self: flex-end; }

.ak-msg--user a { color: var(--white); }

.ak-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}
.ak-chip {
  background: var(--white);
  border: 1.3px solid var(--cyan);
  color: var(--navy-dark);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ak-chip:hover { background: var(--cyan); color: var(--navy-dark); }

.ak-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #25D366;
  color: #fff !important;
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  margin-top: 8px;
}
.ak-wa-btn svg { width: 15px; height: 15px; }

.ak-chat-panel__footer {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--white);
}
.ak-chat-panel__input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 10px 15px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  min-width: 0;
}
.ak-chat-panel__input:focus { border-color: var(--cyan); }
.ak-chat-panel__send {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--cyan); border: none; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.ak-chat-panel__send svg { width: 18px; height: 18px; }
[dir="rtl"] .ak-chat-panel__send svg { transform: scaleX(-1); }
.ak-chat-panel__send:hover { background: #3ec0f2; }

.ak-typing { display: flex; gap: 4px; padding: 4px 2px; }
.ak-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
  animation: ak-bounce 1.1s infinite ease-in-out;
}
.ak-typing span:nth-child(2) { animation-delay: 0.15s; }
.ak-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ak-bounce { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 480px) {
  .ak-chat-fab { bottom: 20px; inset-inline-start: 20px; }
  .ak-chat-panel { bottom: 90px; inset-inline-start: 16px; width: calc(100vw - 32px); }
}
