/**
 * Generation Status Pill
 * Shows AI thinking status during image generation
 * Small frosted pill anchored bottom-right, expands left with text
 */

/* Container - zero-size anchor at bottom-right corner of generation area.
   Positioned purely via translate3d (no width/height changes = no layout thrash). */
.generation-status-pill-container {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 1000;
  overflow: visible;

  /* GPU acceleration for smooth pan/zoom */
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

/* The status pill - anchored right, expands left */
.generation-status-pill {
  --gs-pill-scale: 1;
  --gs-pill-opacity: 1;
  
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  
  /* 70% transparent frosted background */
  background: rgba(255, 255, 255, 0.70);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  
  /* Subtle border for definition */
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50px;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 1px 3px rgba(0, 0, 0, 0.06);
  
  /* Tight sizing - auto width based on content, compact base size */
  padding: 5px 8px 5px 12px;
  height: 24px;
  white-space: nowrap;
  
  /* Text styling - smaller base for proportional scaling */
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1px;
  color: rgba(0, 0, 0, 0.8);
  text-align: center;
  
  /* Anchor at bottom-right of container (which is at bottom-right of crop area) */
  /* translate moves pill up-left from anchor with 8px inset padding */
  transform-origin: right bottom;
  transform: translate(calc(-100% - 8px), calc(-100% - 8px)) scale(var(--gs-pill-scale));
  opacity: var(--gs-pill-opacity);
  
  /* GPU acceleration for smooth updates */
  will-change: transform, opacity;
  backface-visibility: hidden;
  
  /* Prevent text selection */
  user-select: none;
  -webkit-user-select: none;
}

/* Subtle breathing animation */
.generation-status-pill.active {
  animation: pill-breathe 2.5s ease-in-out infinite;
}

@keyframes pill-breathe {
  0%, 100% {
    opacity: calc(var(--gs-pill-opacity) * 0.85);
  }
  50% {
    opacity: var(--gs-pill-opacity);
  }
}

/* Status text with fade transition */
.generation-status-pill .status-text {
  display: inline-block;
  line-height: 1;
  text-align: center;
  transition: opacity 0.25s ease-out;
}

.generation-status-pill .status-text.fading {
  opacity: 0;
}

/* Progress bar container */
.generation-status-pill .status-progress {
  position: relative;
  width: 60px;
  height: 4px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

/* Progress bar fill */
.generation-status-pill .status-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(74, 74, 74, 0.78), rgba(36, 36, 36, 0.86));
  border-radius: 2px;
  transition: width 0.15s ease-out;
}

/* Spinning wheel - first on the left, before the text */
.generation-status-pill .status-spinner {
  width: 10px;
  height: 10px;
  min-width: 10px;
  flex-shrink: 0;
  border: 1.5px solid rgba(42, 42, 42, 0.18);
  border-top-color: rgba(36, 36, 36, 0.86);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}

.generation-status-pill .status-cancel {
  position: relative;
  width: 14px;
  height: 14px;
  min-width: 14px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  color: rgba(36, 36, 36, 0.86);
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.generation-status-pill .status-cancel svg {
  width: 6px;
  height: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.generation-status-pill .status-cancel:hover {
  background: #ff4444;
  color: #fff;
  transform: scale(1.15);
}

.generation-status-pill .status-cancel::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 7px);
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(20, 20, 20, 0.92);
  color: #fff;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.2px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.generation-status-pill .status-cancel:hover::after {
  opacity: 1;
  transform: translateY(0);
}

/* Context On tab (below the pill, anchored bottom-right) */
.generation-context-tab {
  position: absolute;
  right: 8px;
  bottom: -6px;
  height: 14px;
  padding: 0 6px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 0;
  color: rgba(255, 255, 255, 0.9);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  transform-origin: right bottom;
  transform: scale(var(--gs-pill-scale, 1));
  opacity: var(--gs-pill-opacity, 1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Cancel Confirmation Dialog - sleek pill style */
.generation-cancel-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1001;
  
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.08);
  
  padding: 16px 24px;
  
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  pointer-events: auto;
  
  animation: dialog-enter 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dialog-enter {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.generation-cancel-dialog.exiting {
  animation: dialog-exit 0.2s ease-out forwards;
}

@keyframes dialog-exit {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
}

.generation-cancel-dialog-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.85);
  text-align: center;
  margin: 0;
}

.generation-cancel-dialog-buttons {
  display: flex;
  gap: 10px;
}

.generation-cancel-dialog-btn {
  padding: 8px 18px;
  border-radius: 20px;
  border: none;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.generation-cancel-dialog-btn.cancel {
  background: #ff4444;
  color: white;
}

.generation-cancel-dialog-btn.cancel:hover {
  background: #e63333;
  transform: scale(1.02);
}

.generation-cancel-dialog-btn.continue {
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.75);
}

.generation-cancel-dialog-btn.continue:hover {
  background: rgba(0, 0, 0, 0.12);
  transform: scale(1.02);
}

@keyframes spinner-rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Entry animation - from right */
.generation-status-pill.entering {
  animation: pill-enter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes pill-enter {
  0% {
    opacity: 0;
    transform: translate(calc(-100% - 8px), calc(-100% - 8px)) scale(0.85) translateX(8px);
  }
  100% {
    opacity: var(--gs-pill-opacity, 1);
    transform: translate(calc(-100% - 8px), calc(-100% - 8px)) scale(var(--gs-pill-scale, 1)) translateX(0);
  }
}

/* Exit animation */
.generation-status-pill.exiting {
  animation: pill-exit 0.25s ease-out forwards;
}

@keyframes pill-exit {
  0% {
    opacity: var(--gs-pill-opacity, 1);
    transform: translate(calc(-100% - 8px), calc(-100% - 8px)) scale(var(--gs-pill-scale, 1));
  }
  100% {
    opacity: 0;
    transform: translate(calc(-100% - 8px), calc(-100% - 8px)) scale(0.9) translateX(6px);
  }
}

/* Hidden state */
.generation-status-pill.hidden {
  display: none;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .generation-status-pill {
    font-size: 10px;
    padding: 5px 8px 5px 12px;
    height: 24px;
    gap: 6px;
  }
  
  .generation-status-pill .status-spinner {
    width: 10px;
    height: 10px;
    min-width: 10px;
    border-width: 1.5px;
  }
  
  .generation-status-pill {
    transform: translate(calc(-100% - 6px), calc(-100% - 6px)) scale(var(--gs-pill-scale));
  }
}
