/* الزر العائم */
#chat-toggle {
  position: fixed;
  bottom: 25px;
  right: 25px;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 15px 20px;
  cursor: pointer;
  font-size: 16px;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
  z-index: 1000;
  transition: all 0.3s ease;
  font-weight: 600;
}

#chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.5);
}

[dir="ltr"] #chat-toggle {
  left: 30px;
  right: auto;
}

/* نافذة المحادثة */
#chat-container {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 25px;
  width: 360px;
  height: 500px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  flex-direction: column;
  z-index: 999;
  animation: slideIn 0.3s ease-out;
}

[dir="ltr"] #chat-container {
  left: 30px;
  right: auto;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#chat-header {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  text-align: center;
  padding: 15px;
  font-weight: bold;
  font-size: 17px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#chat-box {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background: #f5f7fa;
  font-family: "Tajawal", "Segoe UI", sans-serif;
  scroll-behavior: smooth;
}

/* تحسين شريط التمرير */
#chat-box::-webkit-scrollbar {
  width: 6px;
}

#chat-box::-webkit-scrollbar-track {
  background: #f1f1f1;
}

#chat-box::-webkit-scrollbar-thumb {
  background: #007bff;
  border-radius: 3px;
}

#chat-box::-webkit-scrollbar-thumb:hover {
  background: #0056b3;
}

.msg {
  margin: 8px 0;
  padding: 12px 15px;
  border-radius: 18px;
  max-width: 80%;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user {
  background: linear-gradient(135deg, #dcf8c6 0%, #c8e6c9 100%);
  align-self: flex-end;
  margin-left: auto;
  text-align: right;
  color: #1b5e20;
  border-bottom-right-radius: 4px;
}

.bot {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  align-self: flex-start;
  margin-right: auto;
  text-align: right;
  color: #333;
  border-bottom-left-radius: 4px;
}

[dir="ltr"] .bot,
[dir="ltr"] .user {
  text-align: left;
}

/* رسالة التحميل */
.msg.loading {
  opacity: 0.7;
  animation: pulse 1.5s infinite;
  font-style: italic;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

/* رسالة الخطأ */
.msg.error {
  background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
  color: #721c24;
  border-right: 3px solid #f5c6cb;
  border-bottom-left-radius: 4px;
}

/* الروابط داخل الرسائل */
.msg a {
  color: #007bff;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.msg a:hover {
  color: #0056b3;
  text-decoration: underline;
}

#chat-input {
  display: flex;
  border-top: 1px solid #e0e0e0;
  background: #fff;
  padding: 10px;
  gap: 10px;
}

#msg {
  flex: 1;
  border: 1px solid #e0e0e0;
  padding: 12px;
  font-size: 14px;
  outline: none;
  border-radius: 25px;
  font-family: "Tajawal", "Segoe UI", sans-serif;
  transition: border-color 0.3s;
}

#msg:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#msg:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
  opacity: 0.6;
}

#send-btn {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border: none;
  padding: 12px 20px;
  cursor: pointer;
  font-weight: bold;
  border-radius: 25px;
  transition: all 0.3s ease;
  min-width: 80px;
}

#send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
}

#send-btn:active:not(:disabled) {
  transform: translateY(0);
}

#send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

/* استجابة للشاشات الصغيرة */
@media (max-width: 480px) {
  #chat-container {
    width: calc(100vw - 20px);
    height: calc(100vh - 120px);
    right: 10px;
    left: 10px;
    bottom: 70px;
  }

  #chat-toggle {
    bottom: 15px;
    right: 15px;
  }

}

.msg a {
  color: #007bff;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s;
  border-bottom: 1px dashed #007bff;
}

.msg a:hover {
  color: #0056b3;
  border-bottom-style: solid;
}

.msg .phone-link {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  border: none;
  display: inline-block;
  margin: 0 2px;
}

.msg .phone-link:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}