/**
 * HRDe Archive - Mobile Chatbot Widget Styles
 * 
 * Purpose: Mobile-optimized frame-based design for chatbot
 * Scope: DESIGN ONLY - Same logic as desktop, optimized for mobile UX
 * Note: All colors kept identical to desktop, only sizing adjusted
 */

/* ========================================
   MOBILE CHATBOT - FRAME-BASED DESIGN
   Same colors, mobile-optimized dimensions
   ======================================== */

/* Floating Chatbot Button - Mobile Touch Optimized */
.chatbot-toggle {
  position: fixed !important;
  bottom: 1.5rem !important;
  right: 1.5rem !important;
  width: 56px !important;
  height: 56px !important;
  background: transparent !important;
  border: none !important;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 119, 0, 0.4);
  transition: all 0.3s ease;
  display: flex !important;
  align-items: center;
  justify-content: center;
  color: transparent !important;
  font-size: 0 !important;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding: 0;
  overflow: visible !important;
  background-color: transparent !important;
  background-image: none !important;
  visibility: visible !important;
  opacity: 1 !important;
}
1
/* Force visibility - highest priority */
#chatbot-toggle {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: fixed !important;
  bottom: 1.5rem !important;
  right: 1.5rem !important;
}

/* Ensure image inside button is always visible */
.chatbot-toggle img.chatbot-icon-img {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 100% !important;
  object-fit: contain !important;
  height: 100% !important;
}

/* Fallback: If image doesn't load, show colored circle */
.chatbot-toggle:not(:has(img[src*="chatbot-icon"]))::after,
.chatbot-toggle img[src=""]::after {
  content: "💬";
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}


.chatbot-icon-img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  padding: 4px !important;
  position: relative !important;
  z-index: 100 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  background: transparent !important;
  filter: none !important;
  -webkit-filter: none !important;
  mix-blend-mode: normal !important;
  pointer-events: none;
  max-width: 100% !important;
  max-height: 100% !important;
  image-rendering: auto !important;
  -webkit-image-rendering: auto !important;
}

.chatbot-icon-img[alt] {
  text-indent: -9999px;
  overflow: hidden;
}

.chatbot-toggle:active {
  transform: scale(0.92);
  box-shadow: 0 6px 24px rgba(255, 119, 0, 0.5);
}



/* Tooltip for mobile - shown on larger mobile screens */
.chatbot-toggle::after {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 6px);
  bottom: 50%;
  transform: translateY(50%);
  background: rgba(255, 255, 255, 0.98);
  color: #1f2937;
  padding: 0.5rem 0.625rem;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(255, 119, 0, 0.25);
  font-size: 0.6875rem;
  line-height: 1.25;
  max-width: 140px;
  width: auto;
  min-width: 100px;
  pointer-events: none;
  opacity: 1 !important;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: pre-line;
  font-weight: 500;
  text-align: center;
  animation: chatbotToggleGlow 2.5s ease-in-out infinite;
  background-image: url('/m_images/chatbot-icon.png');
  background-repeat: no-repeat;
  background-size: 20px 20px;
  background-position: 0.5rem center;
  padding-left: 2.5rem;
  /* z-index: 10000; */
  display: block !important;
  visibility: visible !important;
}

.chatbot-toggle::before {
  content: "";
  position: absolute;
  right: calc(100% + 4px);
  bottom: 50%;
  transform: translateY(50%);
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 25px rgba(255, 119, 0, 0.15);
  border-radius: 3px;
  opacity: 1 !important;
  transition: opacity 0.3s ease, transform 0.3s ease;
  clip-path: polygon(0% 50%, 100% 0%, 100% 100%);
  /* z-index: 10000; */
  display: block !important;
  visibility: visible !important;
  pointer-events: none;
}


.chatbot-toggle:hover::after,
.chatbot-toggle:hover::before,
.chatbot-toggle:focus-visible::after,
.chatbot-toggle:focus-visible::before {
  transform: translateY(50%) translateX(-4px);
}

.chatbot-toggle.active::after,
.chatbot-toggle.active::before {
  opacity: 0;
  animation: none;
}

@keyframes chatbotToggleGlow {
  0%, 100% {
    box-shadow: 0 10px 25px rgba(255, 119, 0, 0.15);
  }
  50% {
    box-shadow: 0 12px 30px rgba(255, 119, 0, 0.35);
  }
}

.chatbot-toggle.is-tooltip-bouncing::after {
  animation: chatbotToggleGlow 2.5s ease-in-out infinite, chatbotTooltipBounce 1s ease-out 0s 5;
}

/* Only hide tooltip if explicitly marked as hidden */
.chatbot-toggle.is-tooltip-hidden::after,
.chatbot-toggle.is-tooltip-hidden::before {
  opacity: 0 !important;
  animation: none !important;
  transform: translateY(50%);
  pointer-events: none;
  visibility: hidden !important;
}

/* Ensure tooltip is ALWAYS visible by default */
.chatbot-toggle::after,
.chatbot-toggle::before {
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
}

/* Only hide if explicitly marked as hidden */
.chatbot-toggle.is-tooltip-hidden::after,
.chatbot-toggle.is-tooltip-hidden::before {
  opacity: 0 !important;
  visibility: hidden !important;
  display: none !important;
}

@keyframes chatbotTooltipBounce {
  0% {
    transform: translateY(50%) translateX(0);
  }
  30% {
    transform: translateY(40%) translateX(-4px);
  }
  55% {
    transform: translateY(50%) translateX(0);
  }
  70% {
    transform: translateY(44%) translateX(-2px);
  }
  100% {
    transform: translateY(50%) translateX(0);
  }
}

/* Hide tooltip on very small screens */
@media (max-width: 480px) {
  .chatbot-toggle::after,
  .chatbot-toggle::before {
    display: none;
  }
}

/* Chatbot Panel - Smaller Width Mobile Frame */
.chatbot-panel {
  position: fixed;
  bottom: calc(1.5rem + 56px + 40px); /* Button bottom (1.5rem) + button height (56px) + gap (40px) */
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 420px;
  height: 75vh;
  max-height: 75vh;
  background: white;
  border-radius: 20px;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
  z-index: 10001;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.chatbot-panel.active {
  display: flex;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Chatbot Header - Same colors, mobile-friendly spacing */
.chatbot-header {
  background: linear-gradient(135deg,#FF7700, #FF7200);
  color: white;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  border-radius: 20px 20px 0 0;
}

.chatbot-close {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-width: 40px;
  min-height: 40px;
}

.chatbot-close:hover,
.chatbot-close:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.chatbot-close svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

.chatbot-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.chatbot-subtitle {
  color: #fff;
  font-size: 0.8125rem;
  opacity: 0.9;
  margin: 0.25rem 0 0 0;
}


/* Chat Messages Area - Mobile-optimized scrolling */
.chatbot-messages {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #f9fafb;
  -webkit-overflow-scrolling: touch;
}

.chatbot-message-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  border-radius: 15px;
}

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

.chatbot-message-wrapper.assistant {
  align-self: flex-start;
}

.chatbot-message-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 500px;
  background: linear-gradient(180deg, #AFC7FF 0%, #2351A6 100%);
  box-shadow: 0 4px 15px 1px rgba(58, 58, 58, 0.25);
}

.chatbot-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chatbot-message {
  padding: 1rem 1.25rem;
  border-radius: 12px;
  font-size: 1rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chatbot-message.user {
  background: white;
  color: #374151;
}

.chatbot-message.assistant {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

.chatbot-message.system {
  background: #f3f4f6;
  color: #6b7280;
  align-self: center;
  text-align: center;
  font-size: 0.875rem;
  font-style: italic;
  max-width: 90%;
}

/* Typing Indicator */
.chatbot-typing {
  display: none;
  align-self: flex-start;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  max-width: 80px;
}

.chatbot-typing.active {
  display: flex;
}

.chatbot-typing-dots {
  display: flex;
  gap: 4px;
}

.chatbot-typing-dot {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typingDot 1.4s infinite ease-in-out;
}

.chatbot-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chatbot-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDot {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Input Area - Mobile touch-optimized */
.chatbot-input-area {
  padding: 0.75rem 1rem;
  padding-bottom: 0.75rem;
  background: white;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  min-height: 70px;
  border-radius: 0 0 20px 20px;
}

.chatbot-input {
  flex: 1;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-size: 1rem;
  resize: none;
  max-height: 120px;
  min-height: 48px;
  transition: border-color 0.3s ease;
  font-family: inherit;
  background: white;
  color: #374151 !important; /* Ensure text is visible */
}

.chatbot-input:focus {
  outline: none;
  border-color:#FF7700;
}

.chatbot-send {
  background: linear-gradient(135deg,#FF7700, #FF7200);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.875rem;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  width: 48px;
  height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chatbot-send svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
}

.chatbot-send:active {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 119, 0, 0.3);
}

.chatbot-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Welcome Message */
.chatbot-welcome {
  padding: 0;
  background: transparent;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chatbot-welcome-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.chatbot-welcome-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-welcome-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.chatbot-welcome-greeting {
  margin: 0;
  color: #374151;
  font-size: 1rem;
  line-height: 1.5;
}

.chatbot-user-name {
  font-weight: 600;
}

.chatbot-welcome-intro {
  margin: 0;
  color: #374151;
  font-size: 1rem;
  line-height: 1.5;
}

/* Quick Actions - Mobile-friendly touch targets */
.chatbot-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-top: 0.75rem;
  justify-content: center;
}

.chatbot-quick-btn {
  background: white;
  border: 1px solid #e5e7eb;
  color: #6b7280;
  padding: 0.625rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chatbot-quick-btn:hover,
.chatbot-quick-btn:active {
  background:#FF7700;
  color: white;
  border-color:#FF7700;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(255, 119, 0, 0.2);
}

/* Error States */
.chatbot-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 0.875rem;
  border-radius: 8px;
  font-size: 0.9375rem;
  margin: 0.5rem 0;
}

/* Loading States */
.chatbot-loading {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: #6b7280;
  font-size: 0.9375rem;
}

.chatbot-loading.active {
  display: flex;
}

.chatbot-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e5e7eb;
  border-top: 2px solid#FF7700;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========================================
   MOBILE RESPONSIVE BREAKPOINTS
   ======================================== */

/* Smaller mobile devices */
@media (max-width: 375px) {
  .chatbot-toggle {
    bottom: 1rem;
    right: 1rem;
    width: 52px;
    height: 52px;
    font-size: 1.5rem;
  }
  
  .chatbot-panel {
    width: 95%;
    height: 80vh;
    max-height: 80vh;
    bottom: calc(1rem + 52px + 40px); /* Button bottom (1rem) + button height (52px) + gap (40px) */
  }
  
  .chatbot-message {
    max-width: 88%;
    font-size: 0.9375rem;
  }
  
  .chatbot-quick-btn {
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
  }
}

/* Very small devices */
@media (max-width: 320px) {
  .chatbot-toggle {
    width: 48px;
    height: 48px;
    font-size: 1.375rem;
  }
  
  .chatbot-panel {
    bottom: calc(1rem + 48px + 40px); /* Button bottom (1rem) + button height (48px) + gap (40px) */
  }
  
  .chatbot-header {
    padding: 1rem;
  }
  
  .chatbot-title {
    font-size: 1.125rem;
  }
  
  .chatbot-subtitle {
    font-size: 0.75rem;
  }
  
  .chatbot-messages {
    padding: 1rem;
  }
  
  .chatbot-input-area {
    padding: 0.875rem;
  }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .chatbot-panel {
    height: 95vh;
    max-height: 95vh;
  }
  
  .chatbot-welcome {
    padding: 0.75rem;
  }
  
  .chatbot-welcome h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }
  
  .chatbot-welcome p {
    font-size: 0.875rem;
  }
  
  .chatbot-quick-actions {
    gap: 0.5rem;
    margin-top: 0.5rem;
  }
}

/* Larger mobile devices and small tablets */
@media (min-width: 480px) {
  .chatbot-panel {
    width: 85%;
    max-width: 450px;
    height: 70vh;
    max-height: 70vh;
    bottom: calc(2rem + 56px + 40px); /* Button bottom (2rem) + button height (56px) + gap (40px) */
  }
  
  .chatbot-toggle {
    bottom: 2rem;
    right: 2rem;
  }
}

/* Tablet in portrait */
@media (min-width: 600px) {
  .chatbot-panel {
    width: 85%;
    max-width: 450px;
    height: 650px;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(2rem + 56px + 40px); /* Button bottom (2rem) + button height (56px) + gap (40px) */
    border-radius: 20px;
    border: 1px solid #e5e7eb;
  }
  
  .chatbot-toggle {
    bottom: 2rem;
    right: 2rem;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.chatbot-toggle:focus,
.chatbot-send:focus,
.chatbot-input:focus {
  outline: 2px solid#FF7700;
  outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================
   ANIMATIONS
   ======================================== */

.chatbot-message {
  animation: messageSlide 0.3s ease-out;
}

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

/* Smooth scroll for messages */
.chatbot-messages {
  scroll-behavior: smooth;
}

/* ========================================
   PERFORMANCE & UX OPTIMIZATIONS
   ======================================== */

/* Prevent text selection on interactive elements */
.chatbot-toggle,
.chatbot-send,
.chatbot-quick-btn {
  -webkit-user-select: none;
  user-select: none;
}

/* Prevent pull-to-refresh interference */
.chatbot-panel {
  overscroll-behavior: contain;
}

.chatbot-messages {
  overscroll-behavior: contain;
}

/* iOS safe area support */
@supports (padding: env(safe-area-inset-bottom)) {
  .chatbot-input-area {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
  }
}

/* ========================================
   DARK MODE SUPPORT (Future)
   ======================================== */

@media (prefers-color-scheme: dark) {
  .chatbot-panel {
    background: #1f2937;
    border-color: #374151;
  }
  
  .chatbot-messages {
    background: #111827;
  }
  
  .chatbot-message.assistant {
    background: #374151;
    color: #f9fafb;
    border-color: #4b5563;
  }
  
  .chatbot-input-area {
    background: #1f2937;
    border-color: #374151;
  }
  
  .chatbot-input {
    background: #374151;
    color: #f9fafb;
    border-color: #4b5563;
  }
  
  .chatbot-input:focus {
    border-color:#FF7700;
  }
}
