/* =========================
   CHAT LAUNCHER BUTTON
========================= */

#chatLauncher {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: linear-gradient(135deg, #0f8f70, #0b6b54);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-family: Inter, Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  z-index: 10000;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

#chatLauncher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.26);
}

/* =========================
   CHAT BOX
========================= */

#chatBox {
  position: fixed;
  bottom: 82px;
  right: 22px;
  width: 360px;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.24);
  overflow: hidden;
  z-index: 9999;
  font-family: Inter, Arial, sans-serif;
  display: none;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

#chatBox.show {
  display: block;
}

/* =========================
   HEADER
========================= */

.chat-header {
  background: linear-gradient(135deg, #0f8f70, #0b6b54);
  color: white;
  padding: 15px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-header-title strong {
  font-size: 15px;
  font-weight: 700;
}

.chat-header-title span {
  font-size: 12px;
  opacity: 0.9;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-minimize,
.chat-close {
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  opacity: 0.95;
  user-select: none;
}

.chat-minimize:hover,
.chat-close:hover {
  opacity: 1;
}

/* =========================
   MESSAGES
========================= */

#chatMessages {
  height: 320px;
  overflow-y: auto;
  padding: 14px;
  background: #f7f8fa;
}

.chat-welcome {
  background: white;
  border: 1px solid #e7ebef;
  border-radius: 14px;
  padding: 12px 13px;
  color: #444;
  font-size: 13px;
  line-height: 1.8;
  margin-bottom: 12px;

  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg-row {
  margin-bottom: 10px;
  display: flex;
}

.chat-msg-row.user {
  justify-content: flex-end;
}

.chat-msg-row.ai {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 85%;
  border-radius: 14px;
  padding: 11px 13px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

/* USER MESSAGE */
.chat-msg-row.user .chat-bubble {
  background: #e60023;
  color: white;
  border-bottom-right-radius: 6px;
}

/* AI MESSAGE */
.chat-msg-row.ai .chat-bubble {
  background: white;
  color: #222;
  border: 1px solid #e7ebef;
  border-bottom-left-radius: 6px;
}

/* =========================
   INPUT
========================= */

.chat-input-row {
  display: flex;
  align-items: stretch;
  border-top: 1px solid #e4e7eb;
  background: white;
}

.chat-input-row input {
  flex: 1;
  padding: 13px 14px;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: Inter, Arial, sans-serif;
  color: #222;
}

.chat-input-row input::placeholder {
  color: #9aa3ad;
}

.chat-input-row button {
  background: #e60023;
  color: white;
  border: none;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 700;
  font-family: Inter, Arial, sans-serif;
  font-size: 14px;
}

.chat-input-row button:hover {
  opacity: 0.95;
}

/* =========================
   MOBILE
========================= */

@media (max-width: 600px) {
  #chatBox {
    width: calc(100% - 20px);
    right: 10px;
    bottom: 72px;
  }

  #chatLauncher {
    right: 10px;
    bottom: 10px;
  }
}

/* =========================
   FONT CUSTOMIZATION
========================= */

.ai-msg-fa {
  font-family: "B Koodak", Tahoma, "Times New Roman", serif !important;
  direction: rtl;
  text-align: right;
}

.ai-msg-en {
  font-family: Calibri, Arial, Helvetica, sans-serif !important;
  direction: ltr;
  text-align: left;
}

.chat-welcome.ai-msg-fa,
.chat-welcome.ai-msg-en {
  font-size: 13px;
  line-height: 1.8;
}

/* =========================
   FIX POSITION VS FLOATING CONTACT
========================= */

@media (max-width: 768px) {
  #chatLauncher {
       right: 90px !important;
    z-index: 10000;
  }
}

#chatLauncher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* آیکون */
#chatLauncher .ai-icon img {
  width: 20px;
  height: 20px;
  display: block;
}

/* متن */
#chatLauncher .ai-label {
  display: inline;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {

  #chatLauncher {
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
    right: 12px !important;
  }

  #chatLauncher .ai-icon img {
    width: 22px;
    height: 22px;
  }

  #chatLauncher .ai-label {
    display: none;
  }
}
/* ===== CLEAN AI ICON ON MOBILE: NO GREEN BACKGROUND ===== */
@media (max-width: 768px) {
  #chatLauncher {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    right: 12px !important;
    bottom: 22px !important;
  }

  #chatLauncher .ai-icon {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  #chatLauncher .ai-icon img {
    width: 34px !important;
    height: 34px !important;
    display: block !important;
    object-fit: contain;
  }

  #chatLauncher .ai-label {
    display: none !important;
  }
}

/* Hide AI chat on vertical mobile screens */
@media (max-width: 768px) and (orientation: portrait) {
  #chatLauncher,
  #chatBox {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

.chat-bubble.ai-msg-en,
.chat-welcome.ai-msg-en {
  direction: ltr !important;
  text-align: left !important;
  unicode-bidi: plaintext;
}

.chat-bubble.ai-msg-fa,
.chat-welcome.ai-msg-fa {
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: plaintext;
}