/**
 * H Tower Chatbot Styles
 * Premium styling with RTL support
 */

/* Root container */
#htower-chatbot-root {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 10000;
}

/* Chat window */
.htower-chatbot-window {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  right: max(40px, env(safe-area-inset-right, 0px) + 40px);
  width: 360px;
  max-width: calc(100vw - 80px);
  height: 490px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}

.htower-chatbot-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* RTL support */
.htower-chatbot-window.rtl {
  right: auto;
  left: max(40px, env(safe-area-inset-left, 0px) + 40px);
  direction: rtl;
}

/* Header */
.htower-chatbot-header {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  color: #ffffff;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 20px 20px 0 0;
  flex-shrink: 0;
}

.htower-chatbot-header-content {
  flex: 1;
}

.htower-chatbot-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Poppins', sans-serif;
}

.htower-chatbot-subtitle {
  font-size: 13px;
  opacity: 0.85;
  font-weight: 400;
  line-height: 1.4;
}

.htower-chatbot-close {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
  margin-left: 16px;
  flex-shrink: 0;
}

.htower-chatbot-window.rtl .htower-chatbot-close {
  margin-left: 0;
  margin-right: 16px;
}

.htower-chatbot-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.htower-chatbot-close:active {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Messages container */
.htower-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8f9fa;
  scroll-behavior: smooth;
}

.htower-chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.htower-chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.htower-chatbot-messages::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 3px;
}

.htower-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #b0b0b0;
}

/* Message bubbles */
.htower-chatbot-message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
  animation: messageSlideIn 0.4s ease;
  opacity: 0;
  animation-fill-mode: forwards;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Message heading (from **text** markdown) */
.htower-chatbot-message-heading {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
  color: inherit;
}

.htower-chatbot-message-bot {
  background: #ffffff;
  color: #333333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.htower-chatbot-window.rtl .htower-chatbot-message-bot {
  align-self: flex-end;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 4px;
}

.htower-chatbot-message-user {
  background: linear-gradient(135deg, #25D366 0%, #20BA5A 100%);
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.htower-chatbot-window.rtl .htower-chatbot-message-user {
  align-self: flex-start;
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 4px;
}

.htower-chatbot-message-bot > div {
  margin-bottom: 6px;
}

.htower-chatbot-message-bot > div:last-child {
  margin-bottom: 0;
}

/* Typing indicator with animation */
.htower-chatbot-typing {
  opacity: 0.7;
  font-style: italic;
  position: relative;
  padding-left: 20px;
}

.htower-chatbot-typing::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  animation: typingDot 1.4s infinite;
}

.htower-chatbot-window.rtl .htower-chatbot-typing {
  padding-left: 0;
  padding-right: 20px;
}

.htower-chatbot-window.rtl .htower-chatbot-typing::before {
  left: auto;
  right: 0;
}

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(-50%) scale(1);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-50%) scale(1.2);
    opacity: 1;
  }
}

/* Suggestions container */
.htower-chatbot-suggestions {
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #ffffff;
  border-top: 1px solid #e9ecef;
  flex-shrink: 0;
}

.htower-chatbot-window.rtl .htower-chatbot-suggestions {
  direction: rtl;
}

/* Suggestion chips with enhanced interactions */
.htower-chatbot-suggestion-chip {
  background: #f1f3f5;
  border: 1px solid #e9ecef;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  color: #495057;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.htower-chatbot-suggestion-chip::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(37, 211, 102, 0.1);
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.htower-chatbot-suggestion-chip:hover {
  background: #e9ecef;
  border-color: #dee2e6;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.htower-chatbot-suggestion-chip:hover::before {
  width: 100px;
  height: 100px;
}

.htower-chatbot-suggestion-chip:active {
  transform: translateY(0) scale(0.98);
  transition: transform 0.1s ease;
}

.htower-chatbot-suggestion-chip:focus {
  outline: 2px solid #25D366;
  outline-offset: 2px;
}

/* Input container */
.htower-chatbot-input-container {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  background: #ffffff;
  border-top: 1px solid #e9ecef;
  gap: 12px;
  flex-shrink: 0;
}

.htower-chatbot-window.rtl .htower-chatbot-input-container {
  direction: rtl;
}

/* Input field */
.htower-chatbot-input {
  flex: 1;
  border: 1px solid #dee2e6;
  border-radius: 24px;
  padding: 12px 18px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #f8f9fa;
}

.htower-chatbot-input:focus {
  border-color: #25D366;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
  background: #ffffff;
}

.htower-chatbot-input::placeholder {
  color: #adb5bd;
}

/* Send button */
.htower-chatbot-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366 0%, #20BA5A 100%);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.htower-chatbot-send:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.htower-chatbot-send:active {
  transform: scale(0.95);
}

.htower-chatbot-send svg {
  width: 20px;
  height: 20px;
}

/* WhatsApp button */
.htower-chatbot-whatsapp-button-container {
  padding: 12px 0;
  display: flex;
  justify-content: flex-end;
}

.htower-chatbot-window.rtl .htower-chatbot-whatsapp-button-container {
  justify-content: flex-start;
}

.htower-chatbot-whatsapp-button {
  background: linear-gradient(135deg, #25D366 0%, #20BA5A 100%);
  color: #ffffff;
  border: none;
  border-radius: 24px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
  font-family: inherit;
}

.htower-chatbot-whatsapp-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.htower-chatbot-whatsapp-button:active {
  transform: translateY(0);
}

/* Mobile responsive */
@media (max-width: 600px) {
  .htower-chatbot-window {
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 32px;
    left: 32px;
    width: calc(100vw - 64px);
    max-width: calc(100vw - 64px);
    height: calc(100vh - 200px);
    max-height: calc(100vh - 200px);
    border-radius: 20px;
  }

  .htower-chatbot-window.rtl {
    left: 32px;
    right: 32px;
  }

  .htower-chatbot-window.open {
    transform: translateY(0) scale(1);
  }

  .htower-chatbot-message {
    max-width: 85%;
  }

  /* Ensure proper spacing on mobile */
  .htower-chatbot-header {
    padding: 16px 20px;
    border-radius: 20px 20px 0 0;
  }

  .htower-chatbot-messages {
    padding: 16px 20px;
  }

  .htower-chatbot-input-container {
    padding: 12px 20px;
  }

  .htower-chatbot-suggestions {
    padding: 10px 20px;
  }
}

/* Tablet responsive */
@media (min-width: 601px) and (max-width: 1024px) {
  .htower-chatbot-window {
    width: 340px;
    height: 475px;
  }
}

/* Accessibility */
.htower-chatbot-send:focus,
.htower-chatbot-close:focus,
.htower-chatbot-suggestion-chip:focus,
.htower-chatbot-whatsapp-button:focus {
  outline: 2px solid #25D366;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  #htower-chatbot-root {
    display: none;
  }
}

