/**
 * PRG Chat Widget Styles - ENHANCED VERSION
 */
:root {
  --prg-chat-primary: #3b82f6;
  --prg-chat-primary-hover: #2563eb;
  --prg-chat-primary-light: #dbeafe;
  --prg-chat-secondary: #6b7280;
  --prg-chat-success: #10b981;
  --prg-chat-white: #ffffff;
  --prg-chat-gray-50: #f9fafb;
  --prg-chat-gray-100: #f3f4f6;
  --prg-chat-gray-200: #e5e7eb;
  --prg-chat-gray-300: #d1d5db;
  --prg-chat-gray-400: #9ca3af;
  --prg-chat-gray-500: #6b7280;
  --prg-chat-gray-600: #4b5563;
  --prg-chat-gray-700: #374151;
  --prg-chat-gray-800: #1f2937;
  --prg-chat-border-radius: 18px;
  --prg-chat-border-radius-sm: 12px;
  --prg-chat-shadow: 0 20px 45px rgba(15, 23, 42, 0.2);
  --prg-chat-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --prg-chat-transition-fast: all 0.2s ease;
  --prg-chat-z-index: 9990;
}

.prg-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--prg-chat-z-index);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--prg-chat-gray-800);
}

.prg-chat-widget.prg-chat-bottom-left {
  right: auto;
  left: 24px;
}

.prg-chat-widget.prg-chat-top-right,
.prg-chat-widget.prg-chat-top-left {
  top: 24px;
  bottom: auto;
}

.prg-chat-toggle {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: none;
  background: var(--prg-chat-primary);
  color: var(--prg-chat-white);
  box-shadow: 0 12px 25px rgba(59, 130, 246, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--prg-chat-transition-fast);
  position: relative;
}

.prg-chat-toggle svg {
  width: 24px;
  height: 24px;
}

.prg-chat-toggle:hover {
  transform: translateY(-2px) scale(1.03);
  background: var(--prg-chat-primary-hover);
}

.prg-chat-toggle:focus {
  outline: 2px solid var(--prg-chat-primary-light);
  outline-offset: 3px;
}

.prg-chat-notification {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f97316;
  border: 2px solid var(--prg-chat-white);
}

.prg-chat-window {
  position: absolute;
  right: 0;
  bottom: 80px;
  width: 370px;
  max-height: 560px;
  background: var(--prg-chat-white);
  border-radius: var(--prg-chat-border-radius);
  box-shadow: var(--prg-chat-shadow);
  border: 1px solid var(--prg-chat-gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--prg-chat-z-index);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: var(--prg-chat-transition);
  background-clip: padding-box;
}

.prg-chat-window.prg-chat-window-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.prg-chat-bottom-left .prg-chat-window {
  right: auto;
  left: 0;
}

.prg-chat-top-right .prg-chat-window,
.prg-chat-top-left .prg-chat-window {
  top: 80px;
  bottom: auto;
}

/* Chat Header */
.prg-chat-header {
  background: var(--prg-chat-primary);
  color: var(--prg-chat-white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.prg-chat-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.prg-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.prg-chat-header-text {
  min-width: 0;
}

.prg-chat-title {
  font-weight: 600;
  font-size: 16px;
  margin: 0;
  line-height: 1.2;
}

.prg-chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.9;
  margin-top: 2px;
}

.prg-chat-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--prg-chat-success);
  animation: prg-chat-pulse 2s infinite;
}

@keyframes prg-chat-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.prg-chat-minimize {
  background: none;
  border: none;
  color: var(--prg-chat-white);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  opacity: 0.8;
  transition: var(--prg-chat-transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.prg-chat-minimize:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

/* Chat Messages - Enhanced */
.prg-chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.prg-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.prg-chat-messages::-webkit-scrollbar-track {
  background: var(--prg-chat-gray-100);
  border-radius: 3px;
}

.prg-chat-messages::-webkit-scrollbar-thumb {
  background: var(--prg-chat-gray-300);
  border-radius: 3px;
  transition: var(--prg-chat-transition-fast);
}

.prg-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--prg-chat-gray-400);
}

/* Message Bubbles - Enhanced */
.prg-chat-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: prg-chat-message-in 0.3s ease-out;
}

@keyframes prg-chat-message-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.prg-chat-message-user {
  flex-direction: row-reverse;
}

.prg-chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--prg-chat-primary-light);
  color: var(--prg-chat-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 4px;
}

.prg-chat-message-user .prg-chat-message-avatar {
  background: var(--prg-chat-primary);
  color: var(--prg-chat-white);
}

.prg-chat-message-content {
  max-width: 75%;
  min-width: 60px;
}

.prg-chat-message-text {
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--prg-chat-gray-100);
  color: var(--prg-chat-gray-800);
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  font-size: 15px;
}

.prg-chat-message-user .prg-chat-message-text {
  background: var(--prg-chat-primary);
  color: var(--prg-chat-white);
}

.prg-chat-message-text strong {
  font-weight: 600;
}

.prg-chat-message-text em {
  font-style: italic;
}

.prg-chat-message-time {
  font-size: 11px;
  color: var(--prg-chat-secondary);
  margin-top: 4px;
  padding: 0 6px;
}

.prg-chat-message-user .prg-chat-message-time {
  text-align: right;
}

/* Typing Indicator - Enhanced */
.prg-chat-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.prg-chat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--prg-chat-secondary);
  animation: prg-chat-typing-pulse 1.4s infinite both;
}

.prg-chat-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.prg-chat-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes prg-chat-typing-pulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* System Messages */
.prg-chat-message-system {
  justify-content: center;
  margin: 12px 0;
}

.prg-chat-message-system .prg-chat-message-content {
  max-width: 90%;
}

.prg-chat-system-text {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fbbf24;
  text-align: center;
  font-size: 13px;
  border-radius: 12px;
  padding: 8px 12px;
}

/* Product Recommendations - FIXED COLORS */
.prg-chat-recommendation {
  background: var(--prg-chat-gray-50);
  border: 1px solid var(--prg-chat-gray-200);
  border-radius: var(--prg-chat-border-radius-sm);
  padding: 12px;
  margin: 8px 0;
  transition: var(--prg-chat-transition-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prg-chat-recommendation:hover {
  border-color: var(--prg-chat-primary);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.prg-chat-rec-image {
  width: 100%;
  height: 120px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--prg-chat-gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.prg-chat-rec-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.prg-chat-rec-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
  gap: 8px;
}

.prg-chat-rec-header strong {
  font-weight: 600;
  color: var(--prg-chat-gray-800);
  flex: 1;
  line-height: 1.3;
  font-size: 14px;
}

.prg-chat-rec-price {
  color: var(--prg-chat-primary);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.prg-chat-rec-reason {
  font-size: 13px;
  color: var(--prg-chat-gray-600);
  margin-bottom: 8px;
  line-height: 1.4;
}

.prg-chat-rec-benefits {
  list-style-type: none;
  margin: 0 0 8px 0;
  padding: 0;
}

.prg-chat-rec-benefits li {
  font-size: 12px;
  color: var(--prg-chat-gray-700);
  margin-bottom: 4px;
  padding-left: 20px;
  position: relative;
  line-height: 1.4;
}

.prg-chat-rec-benefits li:before {
  content: "✓";
  color: var(--prg-chat-success);
  position: absolute;
  left: 0;
  top: 0;
  font-weight: bold;
}

.prg-chat-rec-link {
  display: inline-block;
  background: var(--prg-chat-primary);
  color: var(--prg-chat-white) !important;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: var(--prg-chat-transition-fast);
  border: none;
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.2);
}

.prg-chat-rec-link:hover {
  background: var(--prg-chat-primary-hover) !important;
  color: var(--prg-chat-white) !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
  text-decoration: none;
}

.prg-chat-rec-link:visited {
  color: var(--prg-chat-white) !important;
}

.prg-chat-rec-link:focus {
  outline: 2px solid var(--prg-chat-primary-light);
  outline-offset: 2px;
}

/* Product Link Styles - Enhanced for chat responses */
.prg-chat-product-link {
  color: var(--prg-chat-primary) !important;
  text-decoration: none;
  font-weight: 600;
  transition: var(--prg-chat-transition-fast);
  border-bottom: 1px solid transparent;
}

.prg-chat-product-link:hover {
  color: var(--prg-chat-primary-hover) !important;
  border-bottom-color: var(--prg-chat-primary-hover);
  text-decoration: none;
}

.prg-chat-product-link:visited {
  color: var(--prg-chat-primary) !important;
}

.prg-chat-product-link:focus {
  outline: 2px solid var(--prg-chat-primary-light);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Regular Link Styles */
.prg-chat-link {
  color: var(--prg-chat-primary);
  text-decoration: underline;
  transition: var(--prg-chat-transition-fast);
}

.prg-chat-link:hover {
  color: var(--prg-chat-primary-hover);
  text-decoration: none;
}

/* Ranking Link Styles - For internal page navigation */
.prg-chat-ranking-link {
  color: var(--prg-chat-primary);
  text-decoration: none;
  font-size: 0.9em;
  padding: 2px 4px;
  border-radius: 3px;
  background: var(--prg-chat-gray-100);
  transition: var(--prg-chat-transition-fast);
  font-weight: 600;
}

.prg-chat-ranking-link:hover {
  color: var(--prg-chat-primary);
  background: var(--prg-chat-primary-light);
  text-decoration: none;
}

/* Chat Input - Enhanced */
.prg-chat-input-container {
  border-top: 1px solid var(--prg-chat-gray-200);
  padding: 16px 20px;
  background: var(--prg-chat-white);
  flex-shrink: 0;
}

.prg-chat-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.prg-chat-input {
  flex: 1;
  border: 1px solid var(--prg-chat-gray-300);
  border-radius: 24px;
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  transition: var(--prg-chat-transition-fast);
  resize: none;
  font-family: inherit;
  background: var(--prg-chat-white);
}

.prg-chat-input:focus {
  border-color: var(--prg-chat-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.prg-chat-input:disabled {
  background: var(--prg-chat-gray-50);
  color: var(--prg-chat-gray-400);
  cursor: not-allowed;
}

.prg-chat-input::placeholder {
  color: var(--prg-chat-gray-400);
}

.prg-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--prg-chat-primary);
  border: none;
  color: var(--prg-chat-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--prg-chat-transition-fast);
  flex-shrink: 0;
  outline: none;
  padding: 14px;
}

.prg-chat-send:hover:not(:disabled) {
  background: var(--prg-chat-primary-hover);
  transform: scale(1.05);
}

.prg-chat-send:focus {
  outline: 2px solid var(--prg-chat-primary-light);
  outline-offset: 2px;
}

.prg-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.prg-chat-send svg {
  width: 24px;
  height: 24px;
}

.prg-chat-loading-icon {
  animation: prg-chat-spin 1s linear infinite;
}

@keyframes prg-chat-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Mobile Responsiveness - Enhanced */
@media (max-width: 480px) {
  .prg-chat-widget {
    bottom: 16px;
    right: 16px;
  }
  
  .prg-chat-toggle {
    width: 56px;
    height: 56px;
  }
  
  .prg-chat-toggle svg {
    width: 22px;
    height: 22px;
  }
  
  .prg-chat-window {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-width: 100vw;
    border-radius: 0;
    box-shadow: none;
  }
  
  .prg-chat-window.prg-chat-window-open {
    transform: translateY(0) scale(1);
  }
  
  .prg-chat-messages {
    padding: 16px;
  }
  
  .prg-chat-input-container {
    padding: 16px;
  }
  
  .prg-chat-message-content {
    max-width: 85%;
  }
  
  /* Mobile responsive recommendations */
  .prg-chat-recommendation {
    padding: 10px;
  }
  
  .prg-chat-rec-image {
    height: 100px;
    margin-bottom: 6px;
  }
  
  .prg-chat-rec-header strong {
    font-size: 13px;
  }
  
  .prg-chat-rec-price {
    font-size: 13px;
  }
}

/* Tablet Responsiveness */
@media (max-width: 768px) and (min-width: 481px) {
  .prg-chat-window {
    width: 320px;
    height: 450px;
  }
  
  .prg-chat-message-content {
    max-width: 80%;
  }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .prg-chat-widget {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .prg-chat-widget *,
  .prg-chat-widget *::before,
  .prg-chat-widget *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .prg-chat-messages {
    scroll-behavior: auto;
  }
}


/* Focus Trap for Accessibility */
.prg-chat-window[aria-hidden="false"] {
  visibility: visible;
}

.prg-chat-window[aria-hidden="true"] {
  visibility: hidden;
}

/* Screen Reader Only */
.prg-chat-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;
}

/* =============================================================================
   PROACTIVE GREETING POPUP STYLES
   ============================================================================= */

.prg-proactive-greeting {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: calc(var(--prg-chat-z-index) + 10);
  max-width: 320px;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: var(--prg-chat-transition);
  pointer-events: none;
}

.prg-proactive-greeting.prg-proactive-show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.prg-proactive-content {
  background: var(--prg-chat-white);
  border-radius: var(--prg-chat-border-radius);
  box-shadow: var(--prg-chat-shadow);
  padding: 16px;
  border: 1px solid var(--prg-chat-gray-200);
  position: relative;
}

.prg-proactive-content::before {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 32px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--prg-chat-white);
}

.prg-proactive-content::after {
  content: '';
  position: absolute;
  bottom: -9px;
  right: 32px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--prg-chat-gray-200);
  z-index: -1;
}

.prg-proactive-message {
  font-size: 14px;
  line-height: 1.5;
  color: var(--prg-chat-gray-700);
  margin-bottom: 12px;
  font-weight: 400;
}

.prg-proactive-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.prg-proactive-actions button {
  padding: 6px 12px;
  border-radius: var(--prg-chat-border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--prg-chat-transition-fast);
  border: none;
  outline: none;
}

.prg-proactive-chat {
  background: var(--prg-chat-primary);
  color: var(--prg-chat-white);
}

.prg-proactive-chat:hover {
  background: var(--prg-chat-primary-hover);
  transform: translateY(-1px);
}

.prg-proactive-dismiss {
  background: transparent;
  color: var(--prg-chat-gray-500);
  border: 1px solid var(--prg-chat-gray-300);
}

.prg-proactive-dismiss:hover {
  background: var(--prg-chat-gray-50);
  color: var(--prg-chat-gray-700);
}

/* Left-positioned proactive greeting */
.prg-chat-widget.prg-chat-bottom-left ~ .prg-proactive-greeting {
  left: 24px;
  right: auto;
}

.prg-chat-widget.prg-chat-bottom-left ~ .prg-proactive-greeting .prg-proactive-content::before {
  left: 32px;
  right: auto;
}

.prg-chat-widget.prg-chat-bottom-left ~ .prg-proactive-greeting .prg-proactive-content::after {
  left: 32px;
  right: auto;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .prg-proactive-greeting {
    left: 16px;
    right: 16px;
    bottom: 80px;
    max-width: none;
  }

  .prg-proactive-content::before,
  .prg-proactive-content::after {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }

  .prg-proactive-message {
    font-size: 13px;
  }

  .prg-proactive-actions {
    flex-direction: column;
  }

  .prg-proactive-actions button {
    width: 100%;
    padding: 8px 12px;
  }
}

/* Animation for smooth entrance */
@keyframes proactiveSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.prg-proactive-greeting.prg-proactive-show {
  animation: proactiveSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
