﻿/* Enhanced Chatbot Styles with Professional Site Integration */

.chatbot-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: var(--z-toast);
  font-family: 'Tajawal', sans-serif;
}

/* Floating toggle */
.chatbot-toggle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0, 188, 212, 0.24) 0%, rgba(30, 136, 229, 0.18) 100%);
  border: 1px solid rgba(0, 188, 212, 0.25);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35), 0 0 18px rgba(0, 188, 212, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  animation: float 3s ease-in-out infinite;
}

.chatbot-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 188, 212, 0.22), transparent);
  transition: left 0.8s ease;
}

.chatbot-toggle::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  background: var(--success-color, #4caf50);
  border: 2px solid rgba(8, 12, 20, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.6);
  animation: statusPulse 2.6s infinite;
}

@keyframes statusPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.55);
  }

  70% {
    box-shadow: 0 0 0 8px rgba(76, 175, 80, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
  }
}

.chatbot-toggle:hover::before {
  left: 100%;
}

.chatbot-toggle:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.4), 0 0 26px rgba(0, 188, 212, 0.35);
  border-color: var(--accent-color);
  animation-play-state: paused;
}

.chatbot-toggle:active {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.chatbot-icon {
  width: 46px;
  height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(0, 188, 212, 0.35));
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

.chatbot-toggle:hover .chatbot-icon {
  transform: scale(1.12) rotate(4deg);
  filter: drop-shadow(0 6px 14px rgba(0, 188, 212, 0.45));
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

/* Chat window */
.chatbot-window {
  position: absolute;
  bottom: 90px;
  right: 0;
  width: 380px;
  height: 600px;
  max-width: calc(100vw - 40px);
  max-height: calc(100dvh - 140px);
  background: linear-gradient(165deg, rgba(8, 12, 20, 0.96) 0%, rgba(10, 15, 25, 0.94) 55%, rgba(0, 188, 212, 0.08) 100%);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 25px rgba(0, 188, 212, 0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 188, 212, 0.18);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.chatbot-window.active {
  display: flex;
  animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
.chatbot-header {
  background: linear-gradient(135deg, rgba(0, 188, 212, 0.16) 0%, rgba(30, 136, 229, 0.16) 40%, rgba(8, 12, 20, 0.95) 100%);
  border-bottom: 1px solid rgba(0, 188, 212, 0.35);
  color: var(--text-main-light);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
}

.chatbot-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary-color);
}

.chatbot-title .chatbot-header-icon {
  width: 24px;
  height: 24px;
  animation: headerRobotBounce 2.5s infinite;
  filter: drop-shadow(0 0 5px rgba(0, 188, 212, 0.4));
}

@keyframes headerRobotBounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }
}

.chatbot-header-actions {
  display: flex;
  gap: 8px;
}

.chatbot-lang-toggle,
.chatbot-close {
  background: rgba(0, 188, 212, 0.08);
  border: 1px solid rgba(0, 188, 212, 0.2);
  color: var(--text-main-light);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.chatbot-lang-toggle:hover,
.chatbot-close:hover {
  background: rgba(0, 188, 212, 0.16);
  color: var(--primary-color);
  border-color: rgba(0, 188, 212, 0.4);
}

.chatbot-lang-toggle span {
  font-size: 0.8rem;
  font-weight: 700;
}

.chatbot-lang-toggle img {
  width: 16px;
  height: 12px;
  object-fit: cover;
  margin-left: 4px;
}

/* Messages */
.chatbot-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(6, 10, 20, 0.96) 0%, rgba(8, 13, 22, 0.96) 60%, rgba(0, 188, 212, 0.06) 100%);
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: var(--bg-dark-primary);
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

.message {
  display: flex;
  animation: messageSlideIn 0.3s ease-out;
  max-width: 85%;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bot-message {
  align-self: flex-start;
}

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

.message-content {
  padding: 12px 16px;
  border-radius: 18px;
  position: relative;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  font-size: 0.95rem;
}

.bot-message .message-content {
  background: var(--bg-dark-secondary);
  color: var(--text-main-light);
  border: 1px solid var(--border-dark);
  border-radius: 18px 18px 18px 4px;
  border-left: 3px solid var(--primary-color);
}

.user-message .message-content {
  background: linear-gradient(135deg, #1e88e5 0%, #00bcd4 100%);
  color: white;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 15px rgba(0, 188, 212, 0.3);
}

.message-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: inherit;
  line-height: 1.6;
}

.message-text p {
  margin: 0;
}

/* Typing Indicator */
.typing-indicator .message-content {
  padding: 15px;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--primary-color);
  animation: typing 1.4s infinite ease-in-out;
  opacity: 0.6;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Input area */
.chatbot-input {
  padding: 14px 16px;
  background: rgba(8, 12, 20, 0.95);
  border-top: 1px solid rgba(0, 188, 212, 0.15);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  /* Align to bottom for multiline textarea */
}

.chat-input-wrapper {
  flex: 1;
  display: flex;
  position: relative;
}

.chatbot-input input,
.chatbot-input textarea {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 188, 212, 0.18);
  border-radius: 16px;
  padding: 10px 15px;
  color: var(--text-main-light);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s ease;
  resize: none;
  /* For textarea */
  min-height: 44px;
  /* Ensure sufficient height */
  box-sizing: border-box;
}

.chatbot-input input:focus,
.chatbot-input textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 188, 212, 0.12);
  background: rgba(255, 255, 255, 0.07);
}

.chatbot-input input::placeholder,
.chatbot-input textarea::placeholder {
  color: var(--text-secondary-light);
}

.chatbot-input button {
  background: linear-gradient(135deg, #00bcd4 0%, #1e88e5 100%);
  border: none;
  color: #ffffff;
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(0, 188, 212, 0.25);
}

.chatbot-input button:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 26px rgba(0, 188, 212, 0.35);
}

.chatbot-input button:active {
  transform: translateY(-1px) scale(1.02);
}

.chatbot-input .voice-btn,
.chatbot-input .tts-btn {
  background: rgba(0, 188, 212, 0.08);
  border: 1px solid rgba(0, 188, 212, 0.2);
  color: var(--text-main-light);
  border-radius: 12px;
  box-shadow: none;
}

.chatbot-input .voice-btn:hover,
.chatbot-input .tts-btn:hover {
  background: rgba(0, 188, 212, 0.16);
  color: var(--primary-color);
  border-color: rgba(0, 188, 212, 0.35);
  box-shadow: 0 8px 20px rgba(0, 188, 212, 0.25);
}

.chatbot-input button#chatbotSend {
  background: linear-gradient(135deg, #1e88e5 0%, #00bcd4 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 10px 24px rgba(0, 188, 212, 0.35);
}

.chatbot-input button#chatbotSend:hover {
  transform: translateY(-2px) scale(1.07);
  box-shadow: 0 14px 30px rgba(0, 188, 212, 0.45);
}

/* RTL positioning (desktop/tablet) */
[dir="rtl"] .chatbot-container {
  right: auto;
  left: 20px;
}

[dir="rtl"] .chatbot-window {
  right: auto;
  left: 0;
}

/* CTA Buttons & Chips */
.cta-row,
.track-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cta-btn,
.track-chip {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Tajawal', sans-serif;
  border: 1px solid var(--primary-color);
  background: rgba(0, 188, 212, 0.05);
  color: var(--primary-color);
  font-weight: 600;
}

.cta-btn:hover,
.track-chip:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 188, 212, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
  .chatbot-window {
    width: min(380px, calc(100vw - 40px));
    height: min(540px, calc(100dvh - 190px));
  }
}

@media (max-width: 480px) {
  .chatbot-window {
    position: fixed;
    left: 18px;
    right: 18px;
    top: 18px;
    top: calc(18px + env(safe-area-inset-top));
    bottom: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    margin: 0;
    border-radius: 14px;
  }

  .chatbot-messages {
    padding: 14px;
    gap: 10px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .message {
    max-width: 90%;
  }

  .message-content {
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .chatbot-header {
    padding: 10px 12px;
  }

  .chatbot-title {
    font-size: 0.95rem;
  }

  .chatbot-title .chatbot-header-icon {
    width: 20px;
    height: 20px;
  }

  .chatbot-input {
    padding: 8px;
    gap: 6px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .chatbot-input input,
  .chatbot-input textarea {
    font-size: 16px;
    padding: 8px 12px;
    min-height: 38px;
    border-radius: 12px;
  }

  .chatbot-input button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .chatbot-input button i {
    font-size: 14px;
  }

  .chatbot-container {
    bottom: 10px;
    right: 10px;
  }

  .chatbot-toggle {
    width: 60px;
    height: 60px;
  }

  .chatbot-icon {
    width: 40px;
    height: 40px;
  }

  [dir="rtl"] .chatbot-container {
    right: auto;
    left: 10px;
  }
}