/* =========================================================
   Almaarefa Institute - Back to Top & Smart Chatbot Widget
   ========================================================= */

/* --- Back to Top Button (Right Side) --- */
.back-to-top-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #022d38;
  color: #cdb180;
  border: 2px solid #cdb180;
  box-shadow: 0 8px 25px rgba(2, 45, 56, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 998;
}

.back-to-top-btn.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top-btn:hover {
  background: #c7953b;
  color: #ffffff;
  border-color: #c7953b;
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(199, 149, 59, 0.45);
}

.back-to-top-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
  transition: transform 0.2s;
}

.back-to-top-btn:hover svg {
  transform: translateY(-2px);
}

/* --- Smart Chatbot (Left Side) --- */
.chatbot-widget {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 999;
  font-family: var(--type-font, "Almaarefa", sans-serif);
  direction: rtl;
}

/* Floating Chat Toggle Button */
.chatbot-toggle-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #022d38 0%, #205b68 100%);
  color: #ffffff;
  border: 2px solid #cdb180;
  box-shadow: 0 10px 30px rgba(2, 45, 56, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.chatbot-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 14px 35px rgba(2, 45, 56, 0.5);
  border-color: #c7953b;
}

.chatbot-toggle-btn .pulse-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #cdb180;
  animation: chatPulse 2.4s infinite;
  opacity: 0.6;
  pointer-events: none;
}

@keyframes chatPulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

.chatbot-toggle-btn svg {
  width: 28px;
  height: 28px;
}

.chatbot-toggle-btn .close-icon {
  display: none;
}

.chatbot-widget.is-open .chatbot-toggle-btn .chat-icon {
  display: none;
}

.chatbot-widget.is-open .chatbot-toggle-btn .close-icon {
  display: block;
}

/* Chatbot Popup Window */
.chatbot-window {
  position: absolute;
  bottom: 74px;
  left: 0;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(2, 45, 56, 0.25);
  border: 1px solid rgba(2, 45, 56, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom left;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.chatbot-widget.is-open .chatbot-window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chatbot Header */
.chatbot-header {
  background: linear-gradient(135deg, #022d38 0%, #205b68 100%);
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #cdb180;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(205, 177, 128, 0.2);
  border: 1.5px solid #cdb180;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cdb180;
}

.chatbot-avatar svg {
  width: 22px;
  height: 22px;
}

.chatbot-title-wrap h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.chatbot-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: #cdb180;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
}

.chatbot-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.chatbot-close-btn svg {
  width: 18px;
  height: 18px;
}

/* Chat Messages Body */
.chatbot-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #f8f9f9;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chatbot-body::-webkit-scrollbar {
  width: 5px;
}
.chatbot-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

/* Message Bubbles */
.chat-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: msgFade 0.25s ease-out;
}

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

.chat-msg.bot {
  align-self: flex-start;
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-bubble {
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
}

.chat-msg.bot .chat-bubble {
  background: #ffffff;
  color: #022d38;
  border: 1px solid #e2e8f0;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
}

.chat-msg.user .chat-bubble {
  background: #022d38;
  color: #ffffff;
  border-bottom-left-radius: 4px;
}

.chat-bubble a.chat-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 14px;
  border-radius: 8px;
  background: #205b68;
  color: #ffffff !important;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s;
}

.chat-bubble a.chat-link-btn:hover {
  background: #c7953b;
}

/* Quick Topic Chips */
.quick-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #022d38;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.chip-btn:hover {
  background: #022d38;
  color: #ffffff;
  border-color: #022d38;
}

/* Embedded In-Chat Support Form */
.chat-support-form {
  background: #fbfcfc;
  border: 1px solid #dfe6e8;
  border-radius: 14px;
  padding: 14px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-support-form input,
.chat-support-form textarea,
.chat-support-form select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 12.5px;
  outline: none;
  background: #ffffff;
  font-family: inherit;
  color: #022d38;
}

.chat-support-form input:focus,
.chat-support-form textarea:focus,
.chat-support-form select:focus {
  border-color: #205b68;
  box-shadow: 0 0 0 2px rgba(32, 91, 104, 0.15);
}

.chat-support-form textarea {
  resize: vertical;
  min-height: 60px;
}

.chat-support-submit-btn {
  background: #022d38;
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.chat-support-submit-btn:hover {
  background: #c7953b;
}

/* Chat Input Footer */
.chatbot-footer {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-input {
  flex: 1;
  height: 42px;
  border: 1.5px solid #dfe6e8;
  border-radius: 25px;
  padding: 0 16px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  background: #fbfcfc;
  color: #022d38;
}

.chatbot-input:focus {
  border-color: #205b68;
  background: #ffffff;
}

.chatbot-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #022d38;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chatbot-send-btn:hover {
  background: #c7953b;
  transform: scale(1.06);
}

.chatbot-send-btn svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 480px) {
  .chatbot-widget {
    bottom: 18px;
    left: 18px;
  }
  .back-to-top-btn {
    bottom: 18px;
    right: 18px;
    width: 44px;
    height: 44px;
  }
  .chatbot-window {
    bottom: 68px;
    left: 0;
    width: calc(100vw - 36px);
    height: 500px;
  }
}
