/* ======= Reset and base styles ======= */
#chatbot {
  position: fixed;
  bottom: 15px;
  right: 15px;
  width: 400px;
  max-height: 400px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 12px 35px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  color: #333;
  z-index: 1500;
  transition: all 0.3s ease;
  padding: 1.5rem; /* لإضافة padding يناسب التصميم الجديد */
}

#chatbot.show {
  display: flex;
}

#chatbot.fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-height: none !important;
  bottom: 0 !important;
  right: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 2rem !important;
}

/* ======= Header ======= */
#chatbotHeader, #chatbot > div:first-child {
  background: transparent;
  color: #061135; /* بدل الأبيض إلى أزرق يناسب شعارك */
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 16px;
  user-select: none;
  cursor: default;
  margin-bottom: 1rem;
  border-bottom: 1px solid #bfdbfe; /* خط سفلي فاتح */
  padding-bottom: 0.75rem;
}

#chatbotHeader .controls, #chatbot > div:first-child > div {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* عنوان الشات مع الصورة */
#chatbotTitle {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 700;
  font-size: 1rem;
  color: #133c6b;
  flex-direction: row;
  flex-wrap: nowrap;
}

#chatbotTitle img {
  height: 48px;
  width: auto;
  object-fit: contain;
}

/* أضف هذا لضبط النص ومنعه من الكسر */
#chatbotTitle span {
  white-space: nowrap;
}


/* ======= Back Button ======= */
#backButton {
  background: transparent;
  border: none;
  color: #0284c7; /* sky-600 */
  font-size: 0.875rem; /* 14px تقريباً */
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  margin-right: 10px;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  display: none; /* مخفي افتراضياً */
  align-items: center;
  gap: 0.25rem;
  transition: color 0.3s ease, background-color 0.3s ease;
}

#backButton.visible {
  display: inline-flex;
}

#backButton:hover {
  color: white;
  background-color: #0284c7;
}

#backButton i {
  font-size: 1.2rem;
  margin-right: 0.25rem;
}

/* ======= Fullscreen Toggle ======= */
#fullscreenToggle {
  color: #2563eb;
  font-size: 1.25rem;
  cursor: pointer;
  transition: color 0.3s ease;
  user-select: none;
  background: transparent;
  border: none;
}

#fullscreenToggle:hover {
  color: #1e40af;
}

/* ======= Content area ======= */
#chatbotContent {
  flex-grow: 1;
  padding-left: 0.25rem;
  overflow-y: auto;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  font-size: 14px;
  color: #374151; /* رمادي متوسط */
  word-wrap: break-word;
}

/* ======= Messages ======= */
.msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 15px;
  line-height: 1.3;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.1);
  user-select: text;
}

.bot-msg {
  background: #e0e7ff;
  color: #090450;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.user-msg {
  background: #05356b;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

/* ======= Typing effect ======= */
.typing-text {
  display: inline-block;
  white-space: pre-wrap;
}

.cursor {
  display: inline-block;
  animation: blink 1.1s steps(2, start) infinite;
  font-weight: 600;
  color: #060f5f;
  margin-left: 2px;
  user-select: none;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ======= Buttons in chat ======= */
#options button {
  width: 100%;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.1);
  margin-bottom: 8px; /* زيادة مسافة بين الأزرار */
}

#options button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(12, 7, 97, 0.5);
}

.bg-indigo-100 {
  background-color: #e0e7ff;
  color: #110b5a;
}

.bg-indigo-100:hover {
  background-color: #c7d2fe;
}

.bg-green-100 {
  background-color: #d1fae5;
  color: #065f46;
}

.bg-green-100:hover {
  background-color: #a7f3d0;
}

.bg-gray-100 {
  background-color: #f3f4f6;
  color: #374151;
}

.bg-gray-100:hover {
  background-color: #e5e7eb;
}

.bg-blue-100 {
  background-color: #dbeafe;
  color: #0b1f63;
}

.bg-blue-100:hover {
  background-color: #bfdbfe;
}

.bg-blue-600 {
  background-color: #102450;
  color: white;
  border-radius: 8px;
  user-select: none;
}

.bg-blue-600:hover {
  background-color: #0b1f57;
}

/* ======= Loading dots ======= */
.typing-dots {
  display: flex;
  justify-content: flex-start;
  gap: 4px;
  margin: 12px 0;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #0d0864;
  border-radius: 50%;
  opacity: 0.3;
  animation: typing-dots 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
  animation-delay: 0s;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-dots {
  0%, 80%, 100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}

/* ======= Scrollbar ======= */
#chatbotContent::-webkit-scrollbar {
  width: 8px;
}

#chatbotContent::-webkit-scrollbar-track {
  background: transparent;
}

#chatbotContent::-webkit-scrollbar-thumb {
  background-color: rgba(14, 10, 102, 0.4);
  border-radius: 4px;
}

#chatbotContent:hover::-webkit-scrollbar-thumb {
  background-color: rgba(8, 4, 82, 0.7);
}

/* ======= Toggle button ======= */
#chatbotToggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #cfced3;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 8px 15px rgba(12, 7, 107, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  transition: background-color 0.3s ease;
  user-select: none;
  padding: 0;
}

#chatbotToggle:hover {
  background-color: #b5b1ee;
}

#chatbotToggle img {
  height: 40px;
  width: 40px;
  object-fit: contain;
}

/* ======= Tilt animation for first message ======= */
.msg.tilt {
  animation: tilt 0.5s ease forwards;
}

@keyframes tilt {
  0% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
  100% { transform: rotate(0deg); }
}

/* ======= Responsive ======= */
@media (max-width: 400px) {
  #chatbot {
    width: 90vw;
    max-height: 60vh;
    padding: 1rem;
    font-size: 13px;
  }
  #chatbotToggle {
    width: 48px;
    height: 48px;
  }
  #chatbotToggle img {
    height: 32px;
    width: 32px;
  }
  #chatbotTitle {
    font-size: 1.25rem;
  }
  #chatbotContent {
    font-size: 12px;
    gap: 6px;
  }
}

/* ======= تحسين التباعد داخل محتوى الشات ======= */
#chatbotContent > * {
  margin-bottom: 0.5rem;
}

/* ======= تحسين زر الرجوع لتناسق أكبر ======= */
#backButton {
  display: inline-flex;
    font-size: 0.875rem;
  padding: 0.3rem 0.6rem;
  border-radius: 0.375rem;
}

/* ======= تحسين أزرار الخيارات لمزيد من التباعد والوضوح ======= */
#options button {
  margin-bottom: 10px;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 0.75rem;
}

/* ======= إضافة تأثير hover أفضل للأزرار ======= */
#options button:hover {
  filter: brightness(0.9);
  transition: filter 0.3s ease;
}
/* صندوق الحاسبة */
#calculator {
  transition: all 0.3s ease-in-out;
}

/* تسميات الحقول */
#calculator label {
  font-weight: 500;
  color: #374151; /* gray-700 */
}

/* الحقول */
#calculator input,
#calculator select {
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 0.75rem; /* rounded-xl */
  padding: 0.5rem 0.75rem;
  width: 100%;
  transition: 0.2s;
  font-size: 0.9rem;
}

#calculator input:focus,
#calculator select:focus {
  border-color: #6366f1; /* indigo-500 */
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25); /* glow */
  outline: none;
}

/* الأزرار */
#calculator button {
  border-radius: 0.75rem;
  padding: 0.6rem 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

#calculator button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* زر حساب */
#calculator button:first-child {
  background-color: #4f46e5; /* indigo-600 */
  color: white;
  border: none;
}

#calculator button:first-child:hover {
  background-color: #4338ca; /* indigo-700 */
}

/* زر اللغة */
#calculator button:last-child {
  background-color: #e5e7eb; /* gray-200 */
  color: #374151; /* gray-700 */
  border: none;
}

#calculator button:last-child:hover {
  background-color: #d1d5db; /* gray-300 */
}

/* النتائج */
#results {
  background: #f9fafb; /* gray-50 */
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #111827; /* gray-900 */
}
#calculator.lang-ar {
  font-family: "Cairo", sans-serif;
}

#calculator.lang-en {
  font-family: "Roboto", sans-serif;
}
.bot-msg button {
  margin-top: 8px;
  padding: 6px 14px;
  background: #4f46e5; /* Indigo-600 */
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: background 0.3s ease, transform 0.2s ease;
}

.bot-msg button:hover {
  background: #4338ca; /* Indigo-700 */
  transform: translateY(-2px);
}

.bot-msg button:active {
  background: #3730a3; /* Indigo-800 */
  transform: translateY(0);
}
#chatbotFooter {
  margin-top: 8px;
  padding-top: 6px;
  font-size: 12px;
  color: #6b7280; /* رمادي هادئ */
  text-align: center;
  border-top: 1px solid #e5e7eb; /* خط فاصل فاتح */
  line-height: 1.4;
}

#chatbotFooter span {
  color: #1e40af; /* أزرق غامق */
  font-weight: 600;
}
