/**
 * Phase 3 Rendering Styles
 * 
 * Styles for thinking bubbles, placeholders, and messages
 * rendered by the new RenderingManager system.
 */

/* ========================================
   CSS VARIABLES
   ======================================== */

:root {
  --checkmark-size: 16px;
  --checkmark-container-width: 24px;
}

/* ========================================
   THINKING BUBBLES
   ======================================== */

.thinking-bubble {
  padding: 12px 16px;
  margin: 8px 0;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.1);
  border-left: 3px solid rgba(99, 102, 241, 0.5);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.thinking-bubble.fading-out {
  opacity: 0;
}

.thinking-content {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 28px;
}

.thinking-text {
  color: rgba(99, 102, 241, 1);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  flex-shrink: 0;
}

.thinking-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px; /* ✨ CLOSER - reduced from 2px */
  margin-left: 8px;
  margin-top: 4px; /* Move dots 4px lower */
  min-width: var(--checkmark-container-width);
  width: var(--checkmark-container-width);
}

/* Checkmark icon standardization */
.thinking-dots img {
  width: var(--checkmark-size);
  height: var(--checkmark-size);
  display: block;
}

.thinking-dot {
  width: 5px; /* ✨ BIGGER - increased from 3px */
  height: 5px; /* ✨ BIGGER - increased from 3px */
  min-width: 5px;
  min-height: 5px;
  background: rgba(200, 200, 200, 0.6);
  border-radius: 50%;
  animation: thinking-pulse 1.4s ease-in-out infinite;
  display: block;
  flex-shrink: 0;
}

.thinking-dot:nth-child(1) {
  animation-delay: 0s;
  animation-name: thinking-pulse-left; /* ✨ Separate animation for left dot */
}

.thinking-dot:nth-child(2) {
  animation-delay: 0.2s;
  animation-name: thinking-pulse; /* ✨ Center stays in place */
}

.thinking-dot:nth-child(3) {
  animation-delay: 0.4s;
  animation-name: thinking-pulse-right; /* ✨ Separate animation for right dot */
}

/* Center dot - stays in place */
@keyframes thinking-pulse {
  0%, 80%, 100% { 
    transform: scale(1) translateY(0); 
    opacity: 0.4;
    filter: brightness(1);
  }
  40% { 
    transform: scale(1.76) translateY(-2px); /* ✨ 20% smaller - was 2.2, now 1.76 */
    opacity: 0.95; /* ✨ More visible at peak */
    filter: brightness(1.6); /* ✨✨ WHITE SHINE when BIG! */
  }
}

/* Left dot - spreads left when pulsing */
@keyframes thinking-pulse-left {
  0%, 80%, 100% { 
    transform: scale(1) translate(0, 0); 
    opacity: 0.4;
    filter: brightness(1);
  }
  40% { 
    transform: scale(1.76) translate(-3px, -2px); /* ✨ 20% smaller - was 2.2, now 1.76 */
    opacity: 0.95;
    filter: brightness(1.6); /* ✨✨ WHITE SHINE when BIG! */
  }
}

/* Right dot - spreads right when pulsing */
@keyframes thinking-pulse-right {
  0%, 80%, 100% { 
    transform: scale(1) translate(0, 0); 
    opacity: 0.4;
    filter: brightness(1);
  }
  40% { 
    transform: scale(1.76) translate(3px, -2px); /* ✨ 20% smaller - was 2.2, now 1.76 */
    opacity: 0.95;
    filter: brightness(1.6); /* ✨✨ WHITE SHINE when BIG! */
  }
}

/* ========================================
   PLACEHOLDER BUBBLES
   ======================================== */

.placeholder-bubble {
  padding: 16px;
  margin: 8px 0;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.05);
  border: 1px dashed rgba(59, 130, 246, 0.3);
  opacity: 1;
  transition: opacity 0.3s ease;
  position: relative;
}

/* 🆕 PHASE 3 VISUAL INDICATOR - Blue border to distinguish from old system */
.placeholder-bubble::before {
  content: 'PHASE 3';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 8px;
  font-weight: 700;
  color: rgba(59, 130, 246, 0.4);
  letter-spacing: 0.5px;
  pointer-events: none;
}

.placeholder-bubble.fading-out {
  opacity: 0;
}

.placeholder-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.placeholder-visual {
  width: 100%;
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent; /* Transparent for plasma */
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

.placeholder-visual.animated {
  animation: none; /* Remove simple animation - plasma will handle it */
}

@keyframes placeholder-pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.05); opacity: 1; }
}

.placeholder-icon {
  width: 48px;
  height: 48px;
  color: rgba(59, 130, 246, 0.6);
}

.placeholder-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.generating-text {
  color: rgba(59, 130, 246, 1);
  font-size: 14px;
  font-weight: 500;
}

.placeholder-progress {
  width: 100%;
  max-width: 200px;
  height: 4px;
  background: rgba(59, 130, 246, 0.2);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.6), rgba(99, 102, 241, 0.8));
  border-radius: 2px;
  transition: width 0.3s ease;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 600;
  color: white;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* ========================================
   MESSAGES
   ======================================== */

.chat-bubble.fading-in {
  animation: fade-in 0.3s ease;
}

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

.chat-bubble.streaming .streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: currentColor;
  margin-left: 2px;
  animation: cursor-blink 1s infinite;
}

@keyframes cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.bubble-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  opacity: 0.7;
  font-size: 12px;
}

.assistant-icon {
  font-size: 16px;
}

.message-time {
  color: rgba(100, 100, 100, 0.8);
}

.message-media {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.media-item {
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
}

.media-item img,
.media-item video {
  max-width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
}

.media-item img:hover {
  opacity: 0.9;
}

.bubble-footer {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.bubble-action {
  background: none;
  border: none;
  padding: 4px 8px;
  font-size: 12px;
  color: rgba(100, 100, 100, 0.8);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.bubble-action:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* ========================================
   PROGRESS CAPSULE/PILL
   ======================================== */

.plasma-progress-capsule {
  position: absolute;
  bottom: 12px;
  left: 20px;
  right: 20px;
  height: 8.5px; /* 15% thinner: 10px * 0.85 = 8.5px */
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4.25px; /* Half of height for full pill shape */
  overflow: hidden;
  backdrop-filter: blur(4px);
  z-index: 10;
}

.plasma-progress-fill {
  height: 100%;
  /* Dynamic color - will be updated via style attribute based on progress */
  /* Default: blue at 0% */
  background: linear-gradient(90deg, 
    rgba(30, 64, 175, 0.8) 0%,    /* Dark blue (blue-800) */
    rgba(37, 99, 235, 0.95) 50%,  /* Medium blue (blue-600) */
    rgba(30, 64, 175, 0.8) 100%   /* Dark blue (blue-800) */
  );
  width: 0%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1), background 0.6s ease, box-shadow 0.6s ease; /* Smooth transitions */
  border-radius: 4.25px;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.6); /* Blue glow */
}

/* ========================================
   LEGACY SPINNING WHEEL OVERLAY
   ======================================== */

/* Spinner overlay container - centered on plasma */
.plasma-spinner-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  z-index: 5;
  pointer-events: none;
}

/* Legacy spinning wheel with 85% opacity */
.plasma-spinner {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  opacity: 0.85; /* 85% opacity as requested */
  background: conic-gradient(
    rgba(255, 255, 255, 0.9) 0turn, 
    rgba(255, 255, 255, 0.9) 0.75turn, 
    rgba(255, 255, 255, 0) 0.75turn 1turn
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 8px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 8px));
  animation: spin360 1s linear infinite;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

@keyframes spin360 { 
  to { transform: rotate(360deg); } 
}

/* Pulsing effect for progress fill */
@keyframes progress-pulse {
  0%, 100% {
    opacity: 0.8;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.6), 0 0 16px rgba(37, 99, 235, 0.3); /* Blue glow */
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 16px rgba(37, 99, 235, 0.8), 0 0 24px rgba(37, 99, 235, 0.4); /* Stronger blue glow */
  }
}

.plasma-progress-fill.animating {
  animation: progress-pulse 1.5s ease-in-out infinite;
}

/* ========================================
   SKELETON SHIMMER (while image loads)
   ======================================== */

.skeleton-shimmer {
  position: relative;
  background: linear-gradient(90deg, 
    rgba(240, 240, 240, 0.1) 0%, 
    rgba(240, 240, 240, 0.2) 50%, 
    rgba(240, 240, 240, 0.1) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
  overflow: hidden;
}

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

.skeleton-shimmer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(255, 255, 255, 0.3) 50%, 
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer-shine 2s ease-in-out infinite;
}

@keyframes shimmer-shine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .placeholder-visual {
    width: 60px;
    height: 60px;
  }
  
  .placeholder-icon {
    width: 36px;
    height: 36px;
  }
  
  .plasma-progress-capsule {
    height: 7px;
    border-radius: 3.5px;
    left: 15px;
    right: 15px;
  }
}

