/* =====================================================
   AI CHAT WIDGET (مشترک بین صفحاتی که دستیار هوشمند دارند)
===================================================== */

.ai-chat {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 9998;
  font-family: var(--font-family);
}

.ai-chat-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  padding: 15px 22px;
  border-radius: 50px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 15px 30px rgba(15, 23, 42, 0.25);
  transition: transform 0.3s ease;
}

.ai-chat-launcher i {
  color: var(--secondary);
  font-size: 18px;
}

.ai-chat-launcher:hover {
  transform: translateY(-3px);
}

.ai-chat.is-open .ai-chat-launcher {
  display: none;
}

.ai-chat-window {
  position: fixed;
  left: 22px;
  bottom: 22px;
  width: 340px;
  max-width: calc(100vw - 44px);
  height: 460px;
  max-height: calc(100vh - 100px);
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
}

.ai-chat-window[hidden] {
  display: none;
}

.ai-chat-head {
  background: var(--primary);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.ai-chat-head strong {
  display: block;
  font-size: 15px;
}

.ai-chat-head span {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 3px;
}

.ai-chat-close {
  background: none;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 16px;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--gray-50);
}

.ai-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.8;
}

.ai-msg--bot {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--gray-200);
  color: var(--gray-800, #1f2937);
  border-bottom-left-radius: 4px;
}

.ai-msg--user {
  align-self: flex-end;
  background: var(--secondary);
  color: #111827;
  border-bottom-right-radius: 4px;
}

.ai-msg--typing {
  align-self: flex-start;
  color: var(--gray-400);
  font-size: 13px;
}

.ai-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

.ai-chat-form input {
  flex: 1;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}

.ai-chat-form input:focus {
  border-color: var(--secondary);
}

.ai-chat-form button {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: var(--secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.ai-chat-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 560px) {
  .ai-chat {
    left: 14px;
    bottom: 14px;
    right: 14px;
  }
  .ai-chat-window {
    left: 14px;
    bottom: 14px;
    width: 100%;
    max-width: calc(100vw - 28px);
  }
  .ai-chat-launcher span {
    display: none;
  }
}
