/* Assistant widget styles (Hatsune Miku) - Enhanced visibility */
#assistant-root {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 1200;
  pointer-events: none;
  transition: all 0.3s ease;
}

#assistant-root.resizing {
  cursor: nwse-resize;
}

#assistant-root .assistant-inner {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  position: relative;
}

/* Larger, more visible Miku sprite with resize handle */
#assistant-root img.assistant-sprite {
  width: 220px; /* Much larger for better visibility */
  height: auto;
  display: block;
  border-radius: 8px;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

#assistant-root img.assistant-sprite:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

/* Resize handle in bottom-right of sprite */
#assistant-root .resize-handle {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  background: rgba(37, 99, 235, 0.7);
  border-radius: 50%;
  cursor: nwse-resize;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#assistant-root:hover .resize-handle {
  opacity: 1;
}

/* Enhanced speech bubble with better visibility - always positioned relative to sprite */
#assistant-root .assistant-bubble {
  position: fixed;
  left: 0;
  top: 0;
  display: none;
  transform: translate3d(0,0,0);
  max-width: 450px;
  width: auto;
  min-width: 200px;
  background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(245,250,255,0.98) 100%);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 12px 48px rgba(16,24,40,0.18), 0 0 0 1px rgba(37, 99, 235, 0.1);
  font-size: 16px;
  font-weight: 500;
  color: #0f172a;
  border: 2px solid rgba(37, 99, 235, 0.2);
  pointer-events: auto;
  transition: opacity 200ms ease, transform 200ms ease;
  backdrop-filter: blur(8px);
  z-index: 1201;
}

#assistant-root .assistant-bubble.assistant-visible {
  display: block;
}

/* Enhanced triangle pointer */
#assistant-root .assistant-bubble:after {
  content: "";
  position: absolute;
  left: -14px;
  bottom: 20px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 14px solid rgba(255,255,255,0.98);
  filter: drop-shadow(-2px 0 2px rgba(16,24,40,0.1));
}

#assistant-root .assistant-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.6;
  letter-spacing: 0.3px;
  min-height: 1.6em;
}

/* Loading skeleton for message generation */
#assistant-root .assistant-text.loading {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#assistant-root .assistant-text.loading .skeleton-line {
  height: 1em;
  background: linear-gradient(90deg, 
    rgba(148, 163, 184, 0.2) 0%, 
    rgba(148, 163, 184, 0.4) 50%, 
    rgba(148, 163, 184, 0.2) 100%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Loading progress bar under Miku */
#assistant-root .loading-progress {
  position: absolute;
  bottom: -10px;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(100, 116, 139, 0.3);
  border-radius: 3px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#assistant-root .loading-progress.active {
  opacity: 1;
}

#assistant-root .loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, 
    rgba(59, 130, 246, 0.5) 0%, 
    rgba(96, 165, 250, 0.9) 50%, 
    rgba(59, 130, 246, 0.5) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite, progressFillRealistic 8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

@keyframes progressFillRealistic {
  0% { width: 0%; }
  20% { width: 15%; }
  40% { width: 35%; }
  60% { width: 58%; }
  80% { width: 78%; }
  95% { width: 92%; }
  100% { width: 94%; }
}

#assistant-root .assistant-text.loading .skeleton-line:nth-child(1) {
  width: 95%;
}

#assistant-root .assistant-text.loading .skeleton-line:nth-child(2) {
  width: 80%;
}

#assistant-root .assistant-text.loading .skeleton-line:nth-child(3) {
  width: 60%;
}

#assistant-root .assistant-hidden { 
  display: none !important; 
}

/* small clickable area for opening assistant options (if desired) */
#assistant-root .assistant-sprite:hover { transform: translateY(-2px); cursor: pointer; }

@media (max-width: 700px) {
  #assistant-root img.assistant-sprite { 
    width: 140px; /* Larger on mobile too */
  }
  #assistant-root .assistant-bubble { 
    max-width: 70vw; 
    font-size: 14px; 
    padding: 14px 16px;
  }
  #assistant-root {
    left: 10px;
    bottom: 10px;
  }
}
