/*
 * Creation Progress Indicator
 * ===========================
 * Shows step number, step name, and completion percentage during character creation.
 * Displays persistently at the top of the narrative panel.
 */

/* ========================================
 * Progress Container
 * ======================================== */

.creation-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 8px);
  padding: var(--space-3, 12px) var(--space-4, 16px);
  background: var(--color-bg-secondary, rgba(20, 25, 35, 0.95));
  border: 1px solid var(--color-border-default, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-md, 6px);
  margin-bottom: var(--space-3, 12px);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

/* ========================================
 * Progress Bar
 * ======================================== */

.creation-progress__bar {
  height: 6px;
  background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.05));
  border-radius: var(--radius-full, 9999px);
  overflow: hidden;
}

.creation-progress__fill {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--color-accent-primary, #3b82f6),
    var(--color-accent-success, #22c55e)
  );
  border-radius: var(--radius-full, 9999px);
  transition: width 0.4s ease-out;
  min-width: 2%;
}

/* Pulse animation when progress changes */
.creation-progress__fill.pulse {
  animation: progress-pulse 0.6s ease-out;
}

@keyframes progress-pulse {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
  100% { filter: brightness(1); }
}

/* ========================================
 * Progress Info Row
 * ======================================== */

.creation-progress__info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3, 12px);
  font-family: var(--font-mono, monospace);
  font-size: var(--font-size-sm, 0.85rem);
}

.creation-progress__step {
  color: var(--color-text-muted, #888);
  white-space: nowrap;
}

.creation-progress__label {
  flex: 1;
  color: var(--color-text-primary, #e0e0e0);
  font-weight: 500;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.creation-progress__percent {
  color: var(--color-accent-success, #22c55e);
  font-weight: 600;
  white-space: nowrap;
}

/* Completed state */
.creation-progress.complete .creation-progress__fill {
  background: var(--color-accent-success, #22c55e);
}

.creation-progress.complete .creation-progress__percent {
  color: var(--color-accent-success, #22c55e);
}

.creation-progress.complete .creation-progress__label {
  color: var(--color-accent-success, #22c55e);
}

/* ========================================
 * Pick For Me Button
 * Consistent styling for all selection panel headers
 * ======================================== */

.selection-pick-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1, 4px);
  padding: var(--space-1, 4px) var(--space-2, 8px);
  background: transparent;
  border: 1px solid var(--color-accent-warning, #f59e0b);
  border-radius: var(--radius-sm, 4px);
  color: var(--color-accent-warning, #f59e0b);
  font-family: var(--font-mono, monospace);
  font-size: var(--font-size-xs, 0.75rem);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  margin-left: auto;
}

.selection-pick-btn:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--color-accent-warning, #f59e0b);
  transform: translateY(-1px);
}

.selection-pick-btn:active:not(:disabled) {
  transform: translateY(0);
}

.selection-pick-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.selection-pick-btn .pick-icon {
  font-size: 1em;
}

.selection-pick-btn .pick-text {
  font-size: inherit;
}

/* Suggesting state - animated while waiting for AI response */
.selection-pick-btn.suggesting {
  pointer-events: none;
  animation: pick-pulse 1s ease-in-out infinite;
}

.selection-pick-btn.suggesting .pick-icon {
  animation: pick-spin 0.8s linear infinite;
}

@keyframes pick-pulse {
  0%, 100% {
    opacity: 1;
    background: rgba(245, 158, 11, 0.1);
  }
  50% {
    opacity: 0.7;
    background: rgba(245, 158, 11, 0.2);
  }
}

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

/* ========================================
 * Selection Header Layout Adjustment
 * Ensure header can accommodate the pick button
 * ======================================== */

.selection-panel .selection-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2, 8px);
}

/* When using with spell panels */
.spell-selection-panel .spell-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2, 8px);
}

/* Equipment panel header */
.equipment-selection-panel .selection-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2, 8px);
}

/* ========================================
 * Responsive Adjustments
 * ======================================== */

@media (max-width: 480px) {
  .creation-progress {
    padding: var(--space-2, 8px) var(--space-3, 12px);
  }

  .creation-progress__info {
    flex-wrap: wrap;
    gap: var(--space-2, 8px);
  }

  .creation-progress__label {
    order: -1;
    width: 100%;
    text-align: left;
  }

  .selection-pick-btn {
    padding: var(--space-1, 4px) var(--space-1, 4px);
  }

  .selection-pick-btn .pick-text {
    display: none;
  }
}

/* ========================================
 * Step Breadcrumb Trail
 * ======================================== */

.creation-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-1, 4px);
  padding: var(--space-2, 8px) 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.creation-breadcrumb::-webkit-scrollbar {
  display: none;
}

.creation-breadcrumb__step {
  display: flex;
  align-items: center;
  gap: var(--space-1, 4px);
  font-family: var(--font-mono, monospace);
  font-size: var(--font-size-xs, 0.75rem);
  white-space: nowrap;
  transition: all var(--transition-fast, 0.15s);
}

.creation-breadcrumb__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-bg-tertiary, #333);
  border: 1px solid var(--color-border-default, #444);
  transition: all var(--transition-fast, 0.15s);
  flex-shrink: 0;
}

.creation-breadcrumb__label {
  color: var(--color-text-muted, #888);
  transition: color var(--transition-fast, 0.15s);
}

/* Completed step */
.creation-breadcrumb__step--completed .creation-breadcrumb__dot {
  background: var(--color-accent-success, #22c55e);
  border-color: var(--color-accent-success, #22c55e);
}

.creation-breadcrumb__step--completed .creation-breadcrumb__label {
  color: var(--color-accent-success, #22c55e);
}

/* Current step */
.creation-breadcrumb__step--current .creation-breadcrumb__dot {
  background: var(--color-accent-primary, #3b82f6);
  border-color: var(--color-accent-primary, #3b82f6);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
  animation: breadcrumb-pulse 2s ease-in-out infinite;
}

.creation-breadcrumb__step--current .creation-breadcrumb__label {
  color: var(--color-text-primary, #e0e0e0);
  font-weight: 600;
}

/* Pending step */
.creation-breadcrumb__step--pending .creation-breadcrumb__dot {
  background: transparent;
}

.creation-breadcrumb__step--pending .creation-breadcrumb__label {
  color: var(--color-text-disabled, #666);
}

/* Connector between steps */
.creation-breadcrumb__connector {
  width: 12px;
  height: 1px;
  background: var(--color-border-default, #444);
  flex-shrink: 0;
}

.creation-breadcrumb__step--completed + .creation-breadcrumb__connector {
  background: var(--color-accent-success, #22c55e);
}

@keyframes breadcrumb-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(59, 130, 246, 0.5); }
  50% { box-shadow: 0 0 16px rgba(59, 130, 246, 0.8); }
}

/* Compact mode - show only dots */
.creation-breadcrumb--compact .creation-breadcrumb__label {
  display: none;
}

.creation-breadcrumb--compact .creation-breadcrumb__connector {
  width: 8px;
}

/* ========================================
 * Inline Help Tooltip (on field labels)
 * ======================================== */

.creation-help-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: var(--space-1, 4px);
  background: transparent;
  border: 1px solid var(--color-text-muted, #888);
  border-radius: 50%;
  color: var(--color-text-muted, #888);
  font-size: 10px;
  font-weight: 600;
  cursor: help;
  transition: all var(--transition-fast, 0.15s);
  vertical-align: middle;
}

.creation-help-trigger:hover {
  background: var(--color-accent-primary, #3b82f6);
  border-color: var(--color-accent-primary, #3b82f6);
  color: var(--color-bg-primary, #1a1a1a);
}

.creation-help-tooltip {
  position: absolute;
  z-index: var(--z-tooltip, 500);
  max-width: 280px;
  padding: var(--space-2, 8px) var(--space-3, 12px);
  background: var(--color-bg-elevated, #404040);
  border: 1px solid var(--color-border-default, #555);
  border-radius: var(--radius-md, 4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  font-family: var(--font-mono, monospace);
  font-size: var(--font-size-sm, 0.85rem);
  color: var(--color-text-primary, #e0e0e0);
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: all var(--transition-fast, 0.15s);
}

.creation-help-tooltip--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.creation-help-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 16px;
  width: 10px;
  height: 10px;
  background: var(--color-bg-elevated, #404040);
  border-left: 1px solid var(--color-border-default, #555);
  border-top: 1px solid var(--color-border-default, #555);
  transform: rotate(45deg);
}

.creation-help-tooltip__title {
  font-weight: 600;
  color: var(--color-accent-primary, #3b82f6);
  margin-bottom: var(--space-1, 4px);
}

/* ========================================
 * Step Saved Confirmation (inline)
 * ======================================== */

.creation-step-saved {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1, 4px);
  padding: var(--space-1, 4px) var(--space-2, 8px);
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid var(--color-accent-success, #22c55e);
  border-radius: var(--radius-md, 4px);
  font-family: var(--font-mono, monospace);
  font-size: var(--font-size-xs, 0.75rem);
  color: var(--color-accent-success, #22c55e);
  animation: step-saved-appear 0.3s ease-out;
}

.creation-step-saved__icon {
  font-size: 1em;
}

@keyframes step-saved-appear {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Auto-hide after appearing */
.creation-step-saved--auto-hide {
  animation: step-saved-appear 0.3s ease-out, step-saved-fade-out 0.3s ease-in 2s forwards;
}

@keyframes step-saved-fade-out {
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ========================================
 * Loading State for Selections
 * ======================================== */

.selection-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 26, 0.8);
  backdrop-filter: blur(2px);
  z-index: 10;
  animation: fade-in var(--transition-fast, 0.15s);
}

.selection-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2, 8px);
  color: var(--color-text-primary, #e0e0e0);
  font-family: var(--font-mono, monospace);
  font-size: var(--font-size-sm, 0.85rem);
}

.selection-loading-spinner__icon {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-bg-tertiary, #333);
  border-top-color: var(--color-accent-primary, #3b82f6);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ========================================
 * Reduced Motion
 * ======================================== */

@media (prefers-reduced-motion: reduce) {
  .creation-progress__fill {
    transition: none;
  }

  .selection-pick-btn.suggesting,
  .selection-pick-btn.suggesting .pick-icon {
    animation: none;
  }

  .creation-breadcrumb__step--current .creation-breadcrumb__dot {
    animation: none;
  }

  .creation-step-saved,
  .creation-step-saved--auto-hide {
    animation: none;
  }

  .selection-loading-spinner__icon {
    animation: none;
  }
}
