/* Azkiyar Chatbot Widget — premium UI refresh
   Design-only update: no structural or data-flow changes */

:root {
  --azkiyar-bg: #030817;
  --azkiyar-panel: rgba(10, 18, 40, 0.94);
  --azkiyar-panel-soft: rgba(12, 22, 52, 0.84);
  --azkiyar-border: rgba(101, 153, 255, 0.22);
  --azkiyar-border-strong: rgba(101, 153, 255, 0.34);
  --azkiyar-text: #f4f7ff;
  --azkiyar-text-soft: rgba(228, 234, 255, 0.78);
  --azkiyar-muted: rgba(168, 185, 227, 0.62);
  --azkiyar-accent: #2fd0ff;
  --azkiyar-accent-2: #8b5cf6;
  --azkiyar-accent-3: #ff8b24;
  --azkiyar-success: #4dd289;
  --azkiyar-shadow: 0 24px 70px rgba(1, 8, 24, 0.48);
  --azkiyar-shadow-soft: 0 10px 30px rgba(3, 12, 38, 0.34);
  --azkiyar-ease: cubic-bezier(.22,1,.36,1);
}

/* Floating launcher */
.azkiyar-chat-button {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 74px;
  height: 74px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.18);
  cursor: pointer;
  padding: 0;
  z-index: 9998;
  overflow: visible;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.30), transparent 26%),
    linear-gradient(145deg, rgba(21, 34, 75, 0.98), rgba(5, 11, 28, 0.96));
  box-shadow:
    0 0 0 1px rgba(47, 208, 255, 0.18),
    0 12px 28px rgba(4, 14, 42, 0.5),
    0 0 34px rgba(47, 208, 255, 0.24);
  transition:
    transform .35s var(--azkiyar-ease),
    box-shadow .35s var(--azkiyar-ease),
    filter .35s var(--azkiyar-ease);
  will-change: transform;
}

.azkiyar-chat-button::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: inherit;
  background: conic-gradient(from 220deg, rgba(47, 208, 255, 0.2), rgba(139, 92, 246, 0.28), rgba(255, 139, 36, 0.18), rgba(47, 208, 255, 0.2));
  filter: blur(14px);
  z-index: -1;
  opacity: .8;
  animation: azkiyarHalo 4.8s linear infinite;
}

.azkiyar-chat-button::after {
  content: "ازکیار · دستیار هوشمند";
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(7, 14, 36, 0.88);
  color: #f7f9ff;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 12px 28px rgba(2, 9, 24, 0.38);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.azkiyar-chat-button:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow:
    0 0 0 1px rgba(47, 208, 255, 0.28),
    0 18px 34px rgba(4, 14, 42, 0.54),
    0 0 42px rgba(47, 208, 255, 0.32);
}

.azkiyar-chat-button:active {
  transform: scale(0.97);
}

.azkiyar-chat-button img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.02));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 8px 20px rgba(0,0,0,0.18);
}

.azkiyar-notification-badge {
  position: absolute;
  top: 0;
  left: 2px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #ff6b6b, #ff3d7f);
  border: 2px solid rgba(7, 14, 36, 0.86);
  box-shadow: 0 8px 18px rgba(255, 61, 127, 0.34);
  font-size: 11px;
  font-weight: 800;
  animation: azkiyarBadgePulse 1.8s ease infinite;
}

/* Chat window */
.azkiyar-chat-window {
  position: fixed;
  right: 22px;
  bottom: 108px;
  width: min(400px, calc(100vw - 28px));
  height: min(680px, calc(100vh - 128px));
  max-height: calc(100vh - 128px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  color: var(--azkiyar-text);
  border-radius: 28px;
  border: 1px solid var(--azkiyar-border);
  background:
    radial-gradient(circle at 16% 8%, rgba(47, 208, 255, 0.10), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(139, 92, 246, 0.12), transparent 30%),
    linear-gradient(180deg, rgba(7, 14, 36, 0.96), rgba(4, 8, 22, 0.98));
  box-shadow: var(--azkiyar-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: azkiyarWindowUp .35s var(--azkiyar-ease);
}

.azkiyar-chat-window::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(transparent 96%, rgba(255,255,255,0.03) 96%),
    linear-gradient(90deg, transparent 96%, rgba(255,255,255,0.03) 96%);
  background-size: 24px 24px;
  opacity: .18;
}

.azkiyar-chat-window::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -1px 0 rgba(255,255,255,0.02);
}

.azkiyar-chat-window.open {
  display: flex;
}

/* Header */
.azkiyar-chat-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  background:
    linear-gradient(135deg, rgba(47, 208, 255, 0.14), rgba(139, 92, 246, 0.12) 48%, rgba(4, 8, 22, 0.06)),
    rgba(9, 16, 40, 0.78);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.azkiyar-chat-header::after {
  content: "";
  position: absolute;
  inset-inline: 20px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(47,208,255,0), rgba(47,208,255,0.48), rgba(139,92,246,0.48), rgba(47,208,255,0));
}

.azkiyar-chat-header img {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  object-fit: cover;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 10px 22px rgba(1, 8, 24, 0.32);
}

.azkiyar-chat-header-info {
  flex: 1;
  min-width: 0;
}

.azkiyar-chat-header-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .01em;
  color: #ffffff;
}

.azkiyar-chat-header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--azkiyar-text-soft);
}

.azkiyar-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--azkiyar-success);
  box-shadow: 0 0 0 5px rgba(77, 210, 137, 0.12), 0 0 16px rgba(77, 210, 137, 0.4);
  animation: azkiyarBlink 2s ease infinite;
}

.azkiyar-chat-close {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: transform .25s ease, background .25s ease, border-color .25s ease;
}

.azkiyar-chat-close:hover {
  transform: rotate(90deg);
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.16);
}

/* Body */
.azkiyar-chat-body {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 10px;
  background: linear-gradient(180deg, rgba(8, 15, 38, 0.72), rgba(3, 8, 22, 0.84));
  scroll-behavior: smooth;
}

.azkiyar-chat-body::-webkit-scrollbar {
  width: 6px;
}

.azkiyar-chat-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(47,208,255,.65), rgba(139,92,246,.65));
  border-radius: 999px;
}

/* Messages */
.azkiyar-message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  animation: azkiyarFadeIn .28s ease;
}

.azkiyar-message.bot {
  flex-direction: row;
}

.azkiyar-message.user {
  flex-direction: row-reverse;
}

.azkiyar-message-avatar {
  display: block !important;
  width: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  aspect-ratio: 1 / 1;
  object-fit: cover !important;
  object-position: center;
  border-radius: 12px;
  flex: 0 0 34px !important;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}

.azkiyar-message-content {
  max-width: min(80%, 280px);
}

.azkiyar-message-bubble {
  position: relative;
  padding: 13px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.azkiyar-message.bot .azkiyar-message-bubble {
  color: #eef3ff;
  background: linear-gradient(180deg, rgba(18, 28, 64, 0.94), rgba(9, 17, 42, 0.96));
  border: 1px solid rgba(255,255,255,0.06);
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 6px;
  box-shadow: 0 12px 20px rgba(2, 10, 27, 0.26);
}

.azkiyar-message.user .azkiyar-message-bubble {
  color: #fff;
  background: linear-gradient(135deg, var(--azkiyar-accent), #2688ff 46%, var(--azkiyar-accent-2));
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 6px;
  box-shadow: 0 12px 24px rgba(38, 136, 255, 0.24);
}

.azkiyar-message-time {
  padding: 0 4px;
  margin-top: 6px;
  color: var(--azkiyar-muted);
  font-size: 11px;
}

.azkiyar-feedback {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.azkiyar-feedback-btn {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}

.azkiyar-feedback-btn:hover,
.azkiyar-feedback-btn.active {
  transform: translateY(-2px);
  background: rgba(47,208,255,0.14);
  border-color: rgba(47,208,255,0.34);
}

.azkiyar-feedback-btn:disabled {
  opacity: .55;
  cursor: default;
}

/* Quick replies */
.azkiyar-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.azkiyar-quick-reply {
  border-radius: 999px;
  border: 1px solid rgba(47,208,255,0.24);
  background: rgba(255,255,255,0.03);
  color: #cce6ff;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: transform .24s ease, background .24s ease, border-color .24s ease, color .24s ease;
}

.azkiyar-quick-reply:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(47,208,255,.16), rgba(139,92,246,.16));
  color: #fff;
  border-color: rgba(47,208,255,0.42);
}

/* Typing */
.azkiyar-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  padding: 12px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(18, 28, 64, 0.94), rgba(9, 17, 42, 0.96));
  border: 1px solid rgba(255,255,255,0.06);
}

.azkiyar-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(47,208,255,0.94), rgba(139,92,246,0.88));
  animation: azkiyarTyping 1.4s infinite ease-in-out;
}

.azkiyar-typing-dot:nth-child(2) { animation-delay: .2s; }
.azkiyar-typing-dot:nth-child(3) { animation-delay: .4s; }

/* Footer / input */
.azkiyar-chat-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 16px;
  background: rgba(5, 10, 26, 0.96);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.azkiyar-chat-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #fff;
  padding: 0 16px;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.azkiyar-chat-input::placeholder {
  color: rgba(220, 228, 252, 0.48);
}

.azkiyar-chat-input:focus {
  border-color: rgba(47,208,255,0.44);
  background: rgba(255,255,255,0.06);
  box-shadow: 0 0 0 4px rgba(47,208,255,0.10);
}

.azkiyar-chat-send {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(135deg, var(--azkiyar-accent), #2688ff 46%, var(--azkiyar-accent-2));
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .24s ease, box-shadow .24s ease, opacity .24s ease;
  box-shadow: 0 14px 22px rgba(38, 136, 255, 0.22);
}

.azkiyar-chat-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(38, 136, 255, 0.28);
}

.azkiyar-chat-send:disabled {
  opacity: .46;
  cursor: not-allowed;
  box-shadow: none;
}

/* Action buttons */
.azkiyar-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.azkiyar-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: right;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #e9f0ff;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 12px 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}

.azkiyar-action-btn .btn-icon {
  flex-shrink: 0;
  font-size: 16px;
}

.azkiyar-action-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(47,208,255,0.26);
  background: rgba(47,208,255,0.10);
}

.azkiyar-action-btn.azkiyar-end-chat {
  border-color: rgba(77,210,137,0.24);
  color: #d9ffea;
}

.azkiyar-action-btn.azkiyar-end-chat:hover {
  background: rgba(77,210,137,0.12);
  border-color: rgba(77,210,137,0.36);
}

.azkiyar-action-btn.azkiyar-human-support {
  border-color: rgba(255,139,36,0.22);
  color: #ffe5cc;
}

.azkiyar-action-btn.azkiyar-human-support:hover {
  background: rgba(255,139,36,0.10);
  border-color: rgba(255,139,36,0.32);
}

/* Utility */
.azkiyar-hidden {
  display: none !important;
}

/* Motion */
@keyframes azkiyarHalo {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes azkiyarBadgePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 18px rgba(255, 61, 127, 0.34); }
  50% { transform: scale(1.06); box-shadow: 0 12px 22px rgba(255, 61, 127, 0.45); }
}

@keyframes azkiyarWindowUp {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes azkiyarFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes azkiyarBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

@keyframes azkiyarTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: .58; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Responsive */
@media (max-width: 992px) {
  .azkiyar-chat-button::after {
    font-size: 12px;
    padding: 8px 12px;
  }
}

@media (max-width: 768px) {
  .azkiyar-chat-button {
    right: 14px;
    bottom: 14px;
    width: 66px;
    height: 66px;
  }

  .azkiyar-chat-button img {
    width: 48px;
    height: 48px;
  }

  .azkiyar-chat-button::after {
    display: none;
  }

  .azkiyar-chat-window {
    inset: auto 0 0 0;
    width: 100%;
    height: min(100vh, 100dvh);
    max-height: min(100vh, 100dvh);
    bottom: 0;
    right: 0;
    border-radius: 26px 26px 0 0;
  }

  .azkiyar-chat-header {
    padding: 16px 16px 14px;
  }

  .azkiyar-chat-body {
    padding: 16px 14px 10px;
  }

  .azkiyar-message-content {
    max-width: 84%;
  }

  .azkiyar-chat-footer {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .azkiyar-chat-window {
    border-radius: 22px 22px 0 0;
  }

  .azkiyar-chat-header-title {
    font-size: 15px;
  }

  .azkiyar-message-bubble,
  .azkiyar-chat-input {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .azkiyar-chat-button,
  .azkiyar-chat-window,
  .azkiyar-message,
  .azkiyar-chat-send,
  .azkiyar-action-btn,
  .azkiyar-quick-reply,
  .azkiyar-chat-close,
  .azkiyar-feedback-btn {
    transition: none !important;
    animation: none !important;
  }

  .azkiyar-chat-button::before,
  .azkiyar-status-dot,
  .azkiyar-notification-badge,
  .azkiyar-typing-dot {
    animation: none !important;
  }
}


/* =========================================================
   Blog / Projects shell isolation
   Keeps the same premium Azkiyar appearance even when older
   listing-page CSS contains !important geometry overrides.
   ========================================================= */
.az-listing-shell .azkiyar-chat-button {
  right: 22px !important;
  bottom: 22px !important;
  width: 74px !important;
  min-width: 74px !important;
  max-width: 74px !important;
  height: 74px !important;
  min-height: 74px !important;
  max-height: 74px !important;
  padding: 0 !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  border-radius: 999px !important;
  overflow: visible !important;
}

.az-listing-shell .azkiyar-chat-button img {
  width: 54px !important;
  min-width: 54px !important;
  max-width: 54px !important;
  height: 54px !important;
  min-height: 54px !important;
  max-height: 54px !important;
  padding: 0 !important;
  border-radius: 50% !important;
}

.az-listing-shell .azkiyar-chat-window {
  right: 22px !important;
  bottom: 108px !important;
  width: min(400px, calc(100vw - 28px)) !important;
  max-width: calc(100vw - 28px) !important;
  height: min(680px, calc(100vh - 128px)) !important;
  max-height: calc(100vh - 128px) !important;
  padding: 0 !important;
  border-radius: 28px !important;
  border: 1px solid var(--azkiyar-border) !important;
  overflow: hidden !important;
}

@media (max-width: 768px) {
  .az-listing-shell .azkiyar-chat-button {
    right: 14px !important;
    bottom: 14px !important;
    width: 66px !important;
    min-width: 66px !important;
    max-width: 66px !important;
    height: 66px !important;
    min-height: 66px !important;
    max-height: 66px !important;
  }

  .az-listing-shell .azkiyar-chat-button img {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
  }

  .az-listing-shell .azkiyar-chat-window {
    inset: auto 0 0 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: min(100vh, 100dvh) !important;
    max-height: min(100vh, 100dvh) !important;
    border-radius: 26px 26px 0 0 !important;
  }
}


@media (max-width: 768px) {
  .azkiyar-message.bot > img.azkiyar-message-avatar,
  #azkiyar-typing > img.azkiyar-message-avatar {
    display: block !important;
    width: 34px !important;
    min-width: 34px !important;
    max-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: cover !important;
    object-position: center !important;
    flex: 0 0 34px !important;
  }
}
