/* ========================================
   FLOATING BUTTONS - Back to Top & Chatbox
   ======================================== */

.floating-buttons {
  position: fixed;
  bottom: 30px;
  right: 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
}

.floating-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  position: relative;
  font-size: 1.4rem;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.floating-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.4);
}

.floating-btn:active {
  transform: scale(0.95);
}

/* Chat Button */
.chat-btn {
  background: linear-gradient(135deg, #5364f7, #8ab4f8);
  color: #ffffff;
  order: 1;
  z-index: 10000;
  position: relative;
}

.chat-btn:hover {
  background: linear-gradient(135deg, #6a7af7, #9ac4f8);
}

.chat-btn .chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f87171;
  color: #ffffff;
  font-size: 0.6rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #000828;
  animation: pulse-badge 2s infinite;
  z-index: 10001;
}

@keyframes pulse-badge {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

/* Back to Top Button */
.top-btn {
  background: rgba(10, 17, 49, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #8ab4f8;
  border: 1px solid rgba(255, 255, 255, 0.1);
  order: 2;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
}

.top-btn:hover {
  background: rgba(26, 74, 138, 0.85);
  color: #ffffff;
  border-color: rgba(138, 180, 248, 0.3);
  transform: scale(1.1);
}

.top-btn.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
}

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

/* ========================================
   CHATBOX OVERLAY - LEFT SIDE OF ICON
   ======================================== */

.chatbox-overlay {
  position: fixed;
  bottom: 30px;
  right: 110px; /* Position to the left of the chat icon (56px + 24px gap + 30px) */
  width: 380px;
  max-height: 520px;
  background: rgba(10, 17, 49, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: chatSlideLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}

.chatbox-overlay.active {
  display: flex;
}

@keyframes chatSlideLeft {
  from {
    opacity: 0;
    transform: translateX(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Chat Header */
.chatbox-header {
  padding: 16px 20px;
  background: rgba(138, 180, 248, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chatbox-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5364f7, #8ab4f8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.2rem;
}

.chat-header-info h5 {
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
}

.chat-status {
  color: #4ade80;
  font-size: 0.7rem;
  font-weight: 500;
}

.chat-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.chat-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

/* Chat Messages */
.chatbox-messages {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 340px;
  -webkit-overflow-scrolling: touch;
}

.chatbox-messages::-webkit-scrollbar {
  width: 4px;
}

.chatbox-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}

.chatbox-messages::-webkit-scrollbar-thumb {
  background: rgba(138, 180, 248, 0.3);
  border-radius: 10px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.chat-message.received {
  align-self: flex-start;
}

.chat-message.sent {
  align-self: flex-end;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  position: relative;
  word-wrap: break-word;
}

.chat-message.received .message-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom-left-radius: 4px;
}

.chat-message.sent .message-bubble {
  background: linear-gradient(135deg, #5364f7, #8ab4f8);
  border-bottom-right-radius: 4px;
}

.message-bubble p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0;
}

.message-bubble .message-time {
  display: block;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.6rem;
  margin-top: 4px;
}

.chat-options {
  list-style: none;
  padding: 0;
  margin: 6px 0 0 0;
}

.chat-options li {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  padding: 3px 0;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 4px;
  padding: 2px 6px;
  -webkit-tap-highlight-color: transparent;
}

.chat-options li:hover {
  color: #8ab4f8;
  background: rgba(138, 180, 248, 0.08);
}

.chat-options li:active {
  background: rgba(138, 180, 248, 0.15);
}

/* ===== CHAT INPUT ===== */
.chatbox-input {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  background: rgba(10, 17, 49, 0.95);
}

.chat-input-field {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 30px;
  padding: 10px 18px;
  color: #ffffff;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.3s;
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
}

.chat-input-field::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.chat-input-field:focus {
  border-color: rgba(138, 180, 248, 0.4);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(83, 100, 247, 0.1);
}

.chat-input-field:focus {
  outline: none;
}

/* ===== SEND BUTTON ===== */
.chat-send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #5364f7, #8ab4f8);
  color: #ffffff;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 4px 16px rgba(83, 100, 247, 0.3);
  position: relative;
}

.chat-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(83, 100, 247, 0.4);
  background: linear-gradient(135deg, #6a7af7, #9ac4f8);
}

.chat-send-btn:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(83, 100, 247, 0.2);
}

.chat-send-btn i {
  font-size: 1.3rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.chat-send-btn::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5364f7, #8ab4f8);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s;
}

.chat-send-btn:hover::after {
  opacity: 0.3;
  animation: sendPulse 1.5s ease-in-out infinite;
}

@keyframes sendPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.15);
    opacity: 0;
  }
}

/* ========================================
   RESPONSIVE - CHATBOX LEFT OF ICON
   ======================================== */

@media (max-width: 768px) {
  .chatbox-overlay {
    right: 75px; /* 48px (button) + 12px (gap) + 15px */
    bottom: 20px;
    width: 300px;
    max-height: 450px;
  }
}

@media (max-width: 576px) {
  .floating-buttons {
    bottom: 13%;
    right: 20px;
    gap: 10px;
  }
  
  .floating-btn {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
  
  /* Chatbox positioned to the left of icon on mobile */
  .chatbox-overlay {
    right: 70px; /* 48px (button) + 12px (gap) + 10px */
    bottom: 20px;
    left: 10px;
    width: auto;
    max-height: 450px;
    border-radius: 16px;
  }
  
  .chatbox-messages {
    max-height: 280px;
    padding: 12px 16px;
  }
  
  .chatbox-header {
    padding: 12px 16px;
  }
  
  .chatbox-input {
    padding: 10px 14px;
    gap: 8px;
  }
  
  .chat-input-field {
    font-size: 16px;
    padding: 8px 14px;
    min-height: 40px;
  }
  
  .chat-send-btn {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
    box-shadow: 0 4px 16px rgba(83, 100, 247, 0.4);
  }
  
  .chat-send-btn i {
    font-size: 1.2rem;
  }
  
  .chat-btn {
    z-index: 10000;
  }
}

@media (max-width: 380px) {
  .chatbox-overlay {
    max-height: 400px;
    right: 65px;
    bottom: 20px;
    left: 10px;
  }
  
  .chatbox-messages {
    max-height: 240px;
    padding: 10px 14px;
  }
  
  .message-bubble p {
    font-size: 0.8rem;
  }
  
  .chat-options li {
    font-size: 0.75rem;
  }
  
  .chat-send-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  
  .chat-send-btn i {
    font-size: 1rem;
  }
}

/* ========================================
   PREVENT ZOOM ON FOCUS (Mobile)
   ======================================== */
@media (max-width: 768px) {
  input, textarea, select {
    font-size: 16px !important;
  }
  
  body.chat-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }
}

/* ========================================
   BACKDROP OVERLAY FOR CHAT
   ======================================== */
.chatbox-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 9997;
  display: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.chatbox-backdrop.active {
  display: block;
}