/**
 * Testpan India Chatbot Widget Styles
 * Updated Brand Aesthetic - Primary Dark Blue (#0F2C59), Accent Light Blue (#3B82F6)
 */

/* Widget Container */
.testpan-widget-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Launcher Button - Testpan Blue */
.testpan-launcher {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0052A3 0%, #003D7A 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 82, 163, 0.4);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.testpan-launcher:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 82, 163, 0.5);
}

.testpan-launcher.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0);
}

/* Chat Window - Glassmorphic Design */
.testpan-chat-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  height: 500px;
  max-height: calc(100vh - 120px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 82, 163, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: all 0.3s ease;
}

.testpan-chat-window.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* Header - Dark Blue Background */
.testpan-chat-header {
  background: linear-gradient(135deg, #0052A3 0%, #003D7A 100%);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.testpan-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Header only. Message avatars deliberately use their own sizing rules below. */
.testpan-logo {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  padding: 5px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Only BMTC and ManpowerX assets need a white circular plate on the blue header. */
.testpan-logo[data-logo-background="white"] {
  background: #FFFFFF !important;
}

.testpan-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent !important;
}

.testpan-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: white;
  font-family: 'Inter', 'Roboto', sans-serif;
}

.testpan-status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4CAF50;
  margin-right: 4px;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.testpan-status-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.testpan-minimize-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.testpan-minimize-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: rotate(90deg);
}

/* Messages Container - Soft Background */
.testpan-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #F8FAFC;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.testpan-messages-container::-webkit-scrollbar-track {
  background: rgba(15, 44, 89, 0.05);
}

.testpan-messages-container::-webkit-scrollbar-thumb {
  background: rgba(15, 44, 89, 0.2);
  border-radius: 3px;
}

.testpan-messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 44, 89, 0.3);
}

/* Messages */
.testpan-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  word-wrap: break-word;
  font-family: 'Inter', 'Roboto', sans-serif;
  display: flex;
  gap: 8px;
}

.testpan-user-message {
  align-self: flex-end;
  background: linear-gradient(135deg, #0052A3 0%, #003D7A 100%);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 82, 163, 0.2);
  flex-direction: row-reverse;
}

.testpan-bot-message {
  align-self: flex-start;
  background: white;
  color: #1E293B;
  border: 1px solid rgba(15, 44, 89, 0.1);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  flex-direction: row;
}

/* FIXED: Transparent bot avatar container next to messages */
.testpan-bot-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: transparent !important; /* Removes background color fill */
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  box-shadow: none;
  margin-top: 2px;
}

.testpan-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Ensures proper scaling without cropping */
  background: transparent !important;
}

.testpan-avatar-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.testpan-message-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.testpan-system-message {
  align-self: center;
  background: rgba(15, 44, 89, 0.05);
  color: #64748B;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  text-align: center;
  font-weight: 500;
}

.testpan-message-text {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.testpan-message-text:last-child {
  margin-bottom: 0;
}

.testpan-message-text p {
  margin-bottom: 12px;
}

.testpan-message-text p:last-child {
  margin-bottom: 0;
}

.testpan-message-text h1,
.testpan-message-text h2,
.testpan-message-text h3,
.testpan-message-text h4,
.testpan-message-text h5,
.testpan-message-text h6 {
  margin: 12px 0 8px 0;
  font-weight: 600;
  color: #0052A3;
}

.testpan-message-text ul,
.testpan-message-text ol {
  margin: 12px 0;
  padding-left: 24px;
}

.testpan-message-text li {
  margin: 6px 0;
  line-height: 1.5;
}

.testpan-message-text strong {
  font-weight: 600;
  color: #0052A3;
}

.testpan-message-text em {
  font-style: italic;
  color: #0052A3;
}

.testpan-message-text code {
  background: rgba(0, 82, 163, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #0052A3;
}

.testpan-message-text a {
  color: #FF9500;
  text-decoration: none;
  border-bottom: 1px solid #FF9500;
  font-weight: 500;
  transition: all 0.2s ease;
}

.testpan-message-text a:hover {
  color: #FF8C00;
  border-bottom-style: solid;
  text-decoration: underline;
}

/* Contact information styling */
.testpan-message-text a[href^="tel:"],
.testpan-message-text a[href^="mailto:"] {
  font-family: 'Courier New', monospace;
  background: rgba(255, 149, 0, 0.05);
  padding: 3px 8px;
  border-radius: 4px;
  border: none;
}

.testpan-message-text blockquote {
  border-left: 4px solid #FF9500;
  padding-left: 12px;
  margin-left: 0;
  margin-right: 0;
  margin-top: 8px;
  margin-bottom: 8px;
  color: #64748B;
  font-style: italic;
}

/* Quick Reply Buttons - Pill Style */
.testpan-message-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  animation: fadeIn 0.3s ease-in;
}

/* Typing Indicator Animation */
.testpan-typing-indicator .typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-right: 8px;
}

.testpan-typing-indicator .typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0052A3;
  animation: typingBounce 1.4s infinite;
}

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

.testpan-typing-indicator .typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

.testpan-typing-indicator .typing-text {
  font-size: 13px;
  color: #0052A3;
  font-weight: 500;
}

/* Animations */
@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

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

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.testpan-bot-message {
  animation: slideInLeft 0.3s ease-out;
}

.testpan-quick-reply-btn {
  background: white;
  border: 2px solid #FF9500;
  color: #0052A3;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  font-family: 'Inter', 'Roboto', sans-serif;
  box-shadow: 0 2px 4px rgba(255, 149, 0, 0.15);
}

.testpan-quick-reply-btn:hover {
  background: #FF9500;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 149, 0, 0.3);
  border-color: #FF9500;
}

.testpan-quick-reply-btn:active {
  transform: translateY(0);
}

/* Input Area */
.testpan-input-area {
  padding: 16px;
  background: white;
  border-top: 1px solid rgba(15, 44, 89, 0.1);
  display: flex;
  gap: 8px;
  align-items: center;
}

.testpan-message-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid rgba(15, 44, 89, 0.2);
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  font-family: 'Inter', 'Roboto', sans-serif;
  background: #F8FAFC;
}

.testpan-message-input:focus {
  border-color: #3B82F6;
  background: white;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.testpan-message-input::placeholder {
  color: #94A3B8;
}

.testpan-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF9500 0%, #FF8C00 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(255, 149, 0, 0.3);
}

.testpan-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 149, 0, 0.4);
}

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

/* Responsive Design */
@media (max-width: 480px) {
  .testpan-widget-container {
    bottom: 10px;
    right: 10px;
    left: 10px;
  }

  .testpan-launcher {
    width: 50px;
    height: 50px;
  }

  .testpan-chat-window {
    width: 100%;
    right: 0;
    bottom: 70px;
    height: calc(100vh - 100px);
    max-height: none;
    border-radius: 16px;
  }

  .testpan-message {
    max-width: 90%;
  }
}

@media (max-width: 360px) {
  .testpan-chat-window {
    border-radius: 12px;
  }

  .testpan-chat-header {
    padding: 12px;
  }

  .testpan-header-info h3 {
    font-size: 14px;
  }

  .testpan-messages-container {
    padding: 12px;
  }

  .testpan-input-area {
    padding: 12px;
  }
}

/* Animation for new messages */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.testpan-message {
  animation: slideIn 0.3s ease;
}

/* Loading indicator */
.testpan-loading {
  display: flex;
  gap: 4px;
  padding: 8px;
}

.testpan-loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3B82F6;
  animation: bounce 1.4s infinite ease-in-out both;
}

.testpan-loading-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.testpan-loading-dot:nth-child(2) {
  animation-delay: -0.16s;
}

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