/**
 * NLWeb Chat Widget Styles
 * Clean, professional design with subtle animations
 */

/* === Container & Base Styles === */
.nlweb-widget-container {
  --nlweb-primary: #0078D4;
  --nlweb-primary-hover: #106EBE;
  --nlweb-secondary: #50E3C2;
  --nlweb-header-bg: #2D3748;
  --nlweb-text: #1A202C;
  --nlweb-text-secondary: #718096;
  --nlweb-background: #FFFFFF;
  --nlweb-border: #E2E8F0;
  --nlweb-hover: #F7FAFC;
  
  position: fixed;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.nlweb-widget-container *,
.nlweb-widget-container *::before,
.nlweb-widget-container *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* === Positioning === */
.nlweb-widget-container.nlweb-position-bottom-right {
  bottom: 20px;
  right: 20px;
}

.nlweb-widget-container.nlweb-position-bottom-left {
  bottom: 20px;
  left: 20px;
}

/* === Themes === */
/* Tech Community Theme */
.nlweb-widget-container.nlweb-theme-tech-community {
  --nlweb-primary: #5E5CE6;
  --nlweb-primary-hover: #4845D2;
  --nlweb-secondary: #50E3C2;
  --nlweb-header-bg: #2D3748;
  --nlweb-text: #1A202C;
  --nlweb-text-secondary: #718096;
  --nlweb-background: #FFFFFF;
  --nlweb-border: #E2E8F0;
  --nlweb-hover: #F7FAFC;
}

/* === Chat Button === */
.nlweb-chat-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  background: var(--nlweb-primary);
  color: #FFFFFF;
  border: none;
  border-radius: 28px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 120, 212, 0.3);
  transition: all 0.2s ease;
  outline: none;
}

.nlweb-chat-button:hover {
  background: var(--nlweb-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 120, 212, 0.4);
}

.nlweb-chat-button:active {
  transform: translateY(0);
}

.nlweb-chat-button-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nlweb-chat-button-icon svg {
  width: 100%;
  height: 100%;
}

.nlweb-chat-button.nlweb-open {
  border-radius: 50%;
  padding: 14px;
}

.nlweb-chat-button.nlweb-open .nlweb-chat-button-text {
  display: none;
}

/* === Chat Panel === */
.nlweb-chat-panel {
  display: none;
  flex-direction: column;
  width: 900px;
  max-width: calc(100vw - 40px);
  height: 85vh;
  max-height: 85vh;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.25), 
    0 0 1px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  border: 3px solid transparent;
  background-image: 
    linear-gradient(white, white),
    linear-gradient(135deg, #0078D4 0%, #106EBE 25%, #5E5CE6 50%, #0078D4 75%, #106EBE 100%);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  position: absolute;
  bottom: 80px;
  overflow: hidden;
  animation: nlweb-slide-up 0.3s ease;
}

/* Animated border gradient */
@keyframes nlweb-border-flow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.nlweb-chat-panel {
  background-size: 100% 100%, 200% 200%;
  animation: nlweb-slide-up 0.3s ease, nlweb-border-flow 4s ease infinite;
}

.nlweb-position-bottom-right .nlweb-chat-panel {
  right: 0;
}

.nlweb-position-bottom-left .nlweb-chat-panel {
  left: 0;
}

.nlweb-chat-panel.nlweb-visible {
  display: flex;
}

@keyframes nlweb-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* === Panel Header === */
.nlweb-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: var(--nlweb-header-bg);
  color: #FFFFFF;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

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

.nlweb-chat-header-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  flex-shrink: 0;
}

.nlweb-chat-header-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.nlweb-chat-header-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nlweb-chat-header-subtitle {
  font-size: 14px;
  opacity: 0.85;
  margin-top: 2px;
}

.nlweb-chat-close {
  background: transparent;
  border: none;
  color: #FFFFFF;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
  border-radius: 4px;
}

.nlweb-chat-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.nlweb-chat-close svg {
  width: 20px;
  height: 20px;
}

/* === Search Input === */
.nlweb-search-container {
  padding: 20px 24px;
  border-bottom: 1px solid var(--nlweb-border);
  background: #FAFAFA;
}

.nlweb-search-input-wrapper {
  position: relative;
  display: flex;
  gap: 12px;
}

.nlweb-search-input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid var(--nlweb-primary);
  border-radius: 8px;
  font-size: 15px;
  color: var(--nlweb-text);
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 120, 212, 0.08);
}

.nlweb-search-input:focus {
  border-color: var(--nlweb-primary);
  box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.15), 0 2px 12px rgba(0, 120, 212, 0.12);
}

.nlweb-search-input::placeholder {
  color: var(--nlweb-text-secondary);
}

.nlweb-search-button {
  padding: 14px 28px;
  background: var(--nlweb-primary);
  color: #FFFFFF;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: inherit;
}

.nlweb-search-button:hover:not(:disabled) {
  background: var(--nlweb-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 120, 212, 0.25);
}

.nlweb-search-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* === Results Container === */
.nlweb-results-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: #FAFAFA;
}

.nlweb-results-container::-webkit-scrollbar {
  width: 8px;
}

.nlweb-results-container::-webkit-scrollbar-track {
  background: transparent;
}

.nlweb-results-container::-webkit-scrollbar-thumb {
  background: #CBD5E0;
  border-radius: 4px;
}

.nlweb-results-container::-webkit-scrollbar-thumb:hover {
  background: #A0AEC0;
}

/* === Empty State === */
.nlweb-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--nlweb-text-secondary);
  padding: 40px 20px;
}

.nlweb-empty-state-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  background: var(--nlweb-primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 120, 212, 0.2);
}

.nlweb-empty-state-icon svg {
  width: 32px;
  height: 32px;
  color: white;
  stroke-width: 2;
}

.nlweb-empty-state-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--nlweb-text);
}

.nlweb-empty-state-subtitle {
  font-size: 15px;
  color: var(--nlweb-text-secondary);
}

/* === Loading State === */
.nlweb-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 16px;
}

.nlweb-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #E2E8F0;
  border-top-color: var(--nlweb-primary);
  border-radius: 50%;
  animation: nlweb-spin 0.8s linear infinite;
}

@keyframes nlweb-spin {
  to { transform: rotate(360deg); }
}

.nlweb-loading-text {
  color: var(--nlweb-text-secondary);
  font-size: 15px;
}

/* Typing indicator */
.nlweb-typing-indicator {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  width: fit-content;
}

.nlweb-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--nlweb-primary);
  border-radius: 50%;
  animation: nlweb-typing 1.4s ease-in-out infinite;
}

.nlweb-typing-dot:nth-child(1) { animation-delay: 0s; }
.nlweb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.nlweb-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes nlweb-typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* === Results List === */
.nlweb-results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nlweb-results-count {
  font-size: 14px;
  color: var(--nlweb-text-secondary);
  margin-bottom: 8px;
  padding: 8px 12px;
  background: white;
  border-radius: 6px;
  font-weight: 500;
  border: 1px solid var(--nlweb-border);
}

/* === Result Item === */
.nlweb-result-item {
  background: white;
  border: 1px solid var(--nlweb-border);
  border-radius: 8px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: inherit;
  display: block;
  opacity: 0;
  animation: nlweb-fade-in 0.2s ease forwards;
}

@keyframes nlweb-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Remove stagger animation delays to prevent flickering during progressive rendering */
/* Results are now added progressively via JavaScript, so no CSS delays needed */

.nlweb-result-item:hover {
  border-color: var(--nlweb-primary);
  box-shadow: 0 4px 12px rgba(0, 120, 212, 0.12);
  transform: translateY(-2px);
}

.nlweb-result-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--nlweb-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}

.nlweb-result-title-text {
  flex: 1;
  line-height: 1.4;
}

.nlweb-result-item:hover .nlweb-result-title-text {
  text-decoration: underline;
}

.nlweb-result-icon {
  flex-shrink: 0;
  color: var(--nlweb-primary);
  margin-top: 2px;
  width: 16px;
  height: 16px;
}

.nlweb-result-description {
  font-size: 15px;
  color: var(--nlweb-text);
  line-height: 1.5;
  margin-bottom: 10px;
}

.nlweb-result-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--nlweb-text-secondary);
  flex-wrap: wrap;
}

.nlweb-result-site {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--nlweb-border);
  padding: 4px 8px;
  border-radius: 4px;
}

.nlweb-result-site-icon {
  width: 13px;
  height: 13px;
}

.nlweb-result-url {
  color: var(--nlweb-primary);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Error State === */
.nlweb-error {
  background: #FFF5F5;
  border: 1px solid #FC8181;
  border-radius: 6px;
  padding: 14px 16px;
  color: #C53030;
}

.nlweb-error-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}

.nlweb-error-message {
  font-size: 13px;
}

/* === Footer === */
.nlweb-chat-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--nlweb-border);
  text-align: center;
  font-size: 12px;
  color: var(--nlweb-text-secondary);
  background: #FAFAFA;
}

.nlweb-chat-footer a {
  color: var(--nlweb-primary);
  text-decoration: none;
  font-weight: 500;
}

.nlweb-chat-footer a:hover {
  text-decoration: underline;
}

/* === Mobile Responsive === */
@media (max-width: 480px) {
  .nlweb-widget-container.nlweb-position-bottom-right,
  .nlweb-widget-container.nlweb-position-bottom-left {
    bottom: 10px;
    right: 10px;
    left: 10px;
  }
  
  .nlweb-chat-panel {
    width: 100%;
    height: calc(100vh - 80px);
    max-height: calc(100vh - 80px);
    bottom: 60px;
  }
  
  .nlweb-chat-button {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  .nlweb-search-input-wrapper {
    flex-direction: column;
  }
  
  .nlweb-search-button {
    width: 100%;
  }
}

/* === Accessibility === */
.nlweb-widget-container button:focus-visible {
  outline: 2px solid var(--nlweb-primary);
  outline-offset: 2px;
}

.nlweb-widget-container a:focus-visible {
  outline: 2px solid var(--nlweb-primary);
  outline-offset: 2px;
}

/* === Print === */
@media print {
  .nlweb-widget-container {
    display: none !important;
  }
}