/**
 * 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(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.12);
  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(234, 237, 244, 0.92);
  font-size: 14px;
  font-weight: 400;
  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(255, 255, 255, 0.62);
  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;
  }
  40% { 
    transform: scale(1.76) translateY(-2px); /* ✨ 20% smaller - was 2.2, now 1.76 */
    opacity: 0.95;
  }
}

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

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

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

.placeholder-bubble {
  padding: 16px;
  margin: 8px 0;
  border-radius: 12px;
  background: rgba(24, 24, 27, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 1;
  transition: opacity 0.3s ease;
  position: relative;
}

.placeholder-bubble::before {
  content: 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(229, 231, 235, 0.95);
  font-size: 14px;
  font-weight: 500;
}

.placeholder-progress {
  width: 100%;
  max-width: 200px;
  height: 3px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(242, 242, 242, 0.94), rgba(255, 255, 255, 1), rgba(242, 242, 242, 0.94));
  border-radius: 999px;
  transition: width 0.3s ease;
  box-shadow: 0 0 7px rgba(255, 255, 255, 0.32);
}

.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: 5px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.32);
  z-index: 10;
}

.plasma-progress-fill {
  height: 100%;
  /* Dynamic color is still supported from JS updates; default is monochrome */
  background: linear-gradient(90deg, 
    rgba(242, 242, 242, 0.96) 0%,
    rgba(255, 255, 255, 1) 50%,
    rgba(242, 242, 242, 0.96) 100%
  );
  width: 0%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1), background 0.6s ease, box-shadow 0.6s ease;
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}

/* ========================================
   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.82;
    box-shadow: 0 0 7px rgba(255, 255, 255, 0.32), 0 0 14px rgba(255, 255, 255, 0.14);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.44), 0 0 18px rgba(255, 255, 255, 0.2);
  }
}

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

/* ========================================
   PLASMA META PILLS (TYPE + RES + ASPECT + ENGINE)
   ======================================== */

.plasma-meta-pills {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 12;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  max-width: calc(100% - 20px);
  overflow: hidden;
  pointer-events: auto;
}

.plasma-meta-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 16px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  white-space: nowrap;
  min-width: 0;
  max-width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  color: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: default;
  user-select: none;
  transition: transform 140ms ease, background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.plasma-meta-pill.pill-aspect {
  border-color: rgba(255, 255, 255, 0.72);
}

.plasma-meta-pill.pill-resolution,
.plasma-meta-pill.pill-engine,
.plasma-meta-pill.pill-model,
.plasma-meta-pill.pill-type,
.plasma-meta-pill.pill-quality {
  border-color: rgba(255, 255, 255, 0.72);
}

.plasma-meta-pill.pill-model {
  max-width: 116px;
  letter-spacing: 0.02em;
}

.plasma-meta-pill:hover {
  transform: scale(1.12);
  background: rgba(255, 255, 255, 0.98);
  color: rgba(0, 0, 0, 0.95);
  border-color: rgba(255, 255, 255, 0.98);
  box-shadow: 0 3px 10px rgba(255, 255, 255, 0.25);
}

/* ========================================
   RESULT MEDIA META PILLS (ON FINAL GENERATED MEDIA)
   ======================================== */

.result-meta-pills {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 12;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  max-width: calc(100% - 28px);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.chat-img-wrapper:hover .result-meta-pills,
.chat-model-wrapper:hover .result-meta-pills,
.chat-model-wrapper-clean:hover .result-meta-pills,
.chat-pointcloud-wrapper:hover .result-meta-pills {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.result-meta-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 16px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  white-space: nowrap;
  min-width: 0;
  max-width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  color: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: default;
  user-select: none;
  transition: transform 140ms ease, background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.result-meta-pill.pill-model {
  max-width: 116px;
  letter-spacing: 0.02em;
}

.result-meta-pill:hover {
  transform: scale(1.12);
  background: rgba(255, 255, 255, 0.98);
  color: rgba(0, 0, 0, 0.95);
  border-color: rgba(255, 255, 255, 0.98);
  box-shadow: 0 3px 10px rgba(255, 255, 255, 0.25);
}

/* ========================================
   SKELETON SHIMMER (while image loads)
   Disabled — gallery skeletons now use a subtle opacity pulse
   defined in combined.css on .skeleton-image
   ======================================== */

.skeleton-shimmer {
  display: none;
}

.skeleton-shimmer::before {
  content: none;
}

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

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

  .plasma-meta-pills {
    top: 10px;
    right: 10px;
    gap: 3px;
    max-width: calc(100% - 20px);
  }

  .plasma-meta-pill {
    min-height: 15px;
    padding: 3px 6px;
    font-size: 8px;
    max-width: 96px;
  }

  .plasma-meta-pill.pill-model {
    max-width: 82px;
  }

  .result-meta-pills {
    top: 12px;
    right: 12px;
    gap: 3px;
    max-width: calc(100% - 24px);
  }

  .result-meta-pill {
    min-height: 15px;
    padding: 3px 6px;
    font-size: 8px;
    max-width: 96px;
  }

  .result-meta-pill.pill-model {
    max-width: 82px;
  }
}
