/**
 * 進捗インジケーター スタイル
 * ISSUE #63: 処理の進捗を可視化（フロー図形式）
 */

/* =============================
   メインコンテナ
   ============================= */
.progress-indicator {
  background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
  border-radius: 20px;
  padding: 32px 40px;
  margin: 24px auto;
  max-width: 800px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: none;
}

.progress-indicator.active {
  display: block;
  animation: progressFadeIn 0.4s ease-out;
}

@keyframes progressFadeIn {
  from {
    opacity: 0;
    transform: translateY(-15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================
   ヘッダー
   ============================= */
.progress-header {
  text-align: center;
  margin-bottom: 32px;
}

.progress-title {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 600;
  color: #f8f8f2;
}

.progress-title i {
  font-size: 1.4rem;
  color: #8be9fd;
}

.progress-counter {
  display: none; /* フロー図では非表示 */
}

/* =============================
   フロー図コンテナ
   ============================= */
.progress-flow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  margin-bottom: 32px;
  padding: 0 10px;
}

/* ステップ間のコネクターライン（背景） */
.progress-flow::before {
  content: '';
  position: absolute;
  top: 32px;
  left: 60px;
  right: 60px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  z-index: 0;
}

/* =============================
   フローステップ
   ============================= */
.flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  flex: 1;
  max-width: 140px;
}

/* ステップアイコン（円） */
.flow-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 12px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  background: #2d2d44;
  border: 3px solid rgba(255, 255, 255, 0.15);
  color: #6272a4;
}

/* ステップラベル */
.flow-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #6272a4;
  text-align: center;
  transition: color 0.3s ease;
  line-height: 1.3;
}

/* =============================
   ステップ状態：Pending（待機中）
   ============================= */
.flow-step.pending .flow-icon {
  background: #2d2d44;
  border-color: rgba(255, 255, 255, 0.15);
  color: #6272a4;
}

.flow-step.pending .flow-label {
  color: #6272a4;
}

/* =============================
   ステップ状態：Active（処理中）
   ============================= */
.flow-step.active .flow-icon {
  background: linear-gradient(135deg, #8be9fd 0%, #bd93f9 100%);
  border-color: #8be9fd;
  color: #1e1e2e;
  box-shadow: 0 0 30px rgba(139, 233, 253, 0.5),
              0 0 60px rgba(189, 147, 249, 0.3);
  animation: activeGlow 2s ease-in-out infinite;
}

.flow-step.active .flow-label {
  color: #f8f8f2;
  font-weight: 600;
}

@keyframes activeGlow {
  0%, 100% {
    box-shadow: 0 0 30px rgba(139, 233, 253, 0.5),
                0 0 60px rgba(189, 147, 249, 0.3);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 40px rgba(139, 233, 253, 0.7),
                0 0 80px rgba(189, 147, 249, 0.5);
    transform: scale(1.05);
  }
}

/* 処理中のスピナー */
.flow-step.active .flow-icon::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #8be9fd;
  border-right-color: #bd93f9;
  animation: spinRing 1.2s linear infinite;
}

@keyframes spinRing {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* =============================
   ステップ状態：Completed（完了）
   ============================= */
.flow-step.completed .flow-icon {
  background: linear-gradient(135deg, #50fa7b 0%, #8be9fd 100%);
  border-color: #50fa7b;
  color: #1e1e2e;
  box-shadow: 0 4px 20px rgba(80, 250, 123, 0.4);
}

.flow-step.completed .flow-label {
  color: #50fa7b;
}

/* 完了チェックマークのポップアニメーション */
.flow-step.completed .flow-icon {
  animation: completePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes completePop {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* =============================
   ステップ状態：Error（エラー）
   ============================= */
.flow-step.error .flow-icon {
  background: linear-gradient(135deg, #ff5555 0%, #ff79c6 100%);
  border-color: #ff5555;
  color: #1e1e2e;
  box-shadow: 0 4px 20px rgba(255, 85, 85, 0.4);
  animation: errorShake 0.5s ease-in-out;
}

.flow-step.error .flow-label {
  color: #ff5555;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* =============================
   コネクターの進捗表示
   ============================= */
.flow-connector {
  position: absolute;
  top: 32px;
  height: 4px;
  background: linear-gradient(90deg, #50fa7b, #8be9fd);
  border-radius: 2px;
  z-index: 0;
  transition: width 0.5s ease-out;
}

/* コネクター1: ステップ1→2 */
.flow-connector[data-connector="1"] {
  left: 60px;
  width: 0;
}

/* コネクター2: ステップ2→3 */
.flow-connector[data-connector="2"] {
  left: calc(25% + 35px);
  width: 0;
}

/* コネクター3: ステップ3→4 */
.flow-connector[data-connector="3"] {
  left: calc(50% + 10px);
  width: 0;
}

/* コネクター完了状態 */
.flow-connector.completed {
  width: calc(25% - 45px) !important;
}

/* =============================
   詳細情報エリア
   ============================= */
.progress-detail-area {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 20px 24px;
  margin-top: 8px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.detail-main {
  font-size: 1.1rem;
  font-weight: 500;
  color: #f8f8f2;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-main i {
  color: #8be9fd;
}

.detail-sub {
  font-size: 0.9rem;
  color: #6272a4;
}

/* =============================
   検出カウンター（リアルタイム）
   ============================= */
.detection-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(80, 250, 123, 0.2), rgba(80, 250, 123, 0.1));
  border: 2px solid rgba(80, 250, 123, 0.5);
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 1rem;
  color: #50fa7b;
  font-weight: 700;
  margin-top: 12px;
  animation: badgeAppear 0.4s ease-out;
}

.detection-badge i {
  font-size: 1.1rem;
}

@keyframes badgeAppear {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  60% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* カウントが更新されたときのハイライト */
.detection-badge.updated {
  animation: countBump 0.3s ease-out;
}

@keyframes countBump {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); background: rgba(80, 250, 123, 0.3); }
  100% { transform: scale(1); }
}

/* =============================
   完了メッセージ
   ============================= */
.progress-complete {
  text-align: center;
  padding: 24px;
  animation: completeSlideIn 0.5s ease-out;
}

@keyframes completeSlideIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.progress-complete-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #50fa7b, #8be9fd);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 32px;
  color: #1e1e2e;
  animation: successBounce 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 30px rgba(80, 250, 123, 0.4);
}

@keyframes successBounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.progress-complete-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #50fa7b;
  margin-bottom: 8px;
}

.progress-complete-subtitle {
  font-size: 1rem;
  color: #6272a4;
}

/* =============================
   サマリー（処理結果）
   ============================= */
.progress-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin-top: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  color: #f8f8f2;
}

.summary-item i {
  color: #bd93f9;
  font-size: 1.1rem;
}

.summary-item .count {
  font-weight: 700;
  color: #50fa7b;
  font-size: 1.1rem;
}

/* =============================
   レスポンシブ対応
   ============================= */
@media (max-width: 768px) {
  .progress-indicator {
    margin: 16px;
    padding: 24px 20px;
    border-radius: 16px;
  }

  .progress-header {
    margin-bottom: 24px;
  }

  .progress-title {
    font-size: 1.1rem;
  }

  .progress-flow {
    flex-wrap: nowrap;
    padding: 0;
    margin-bottom: 24px;
  }

  .progress-flow::before {
    left: 40px;
    right: 40px;
    top: 24px;
  }

  .flow-step {
    max-width: 80px;
  }

  .flow-icon {
    width: 48px;
    height: 48px;
    font-size: 18px;
    margin-bottom: 8px;
  }

  .flow-label {
    font-size: 0.7rem;
  }

  .flow-step.active .flow-icon::after {
    inset: -4px;
    border-width: 2px;
  }

  .flow-connector {
    top: 24px;
  }

  .flow-connector[data-connector="1"] {
    left: 40px;
  }

  .flow-connector.completed {
    width: calc(25% - 30px) !important;
  }

  .progress-detail-area {
    padding: 16px;
    min-height: 70px;
  }

  .detail-main {
    font-size: 1rem;
  }

  .detection-badge {
    padding: 6px 14px;
    font-size: 0.9rem;
  }

  .progress-summary {
    flex-direction: column;
    gap: 12px;
  }

  .summary-item {
    font-size: 0.9rem;
  }
}

/* =============================
   ダークモード調整
   ============================= */
@media (prefers-color-scheme: light) {
  .progress-indicator {
    background: linear-gradient(135deg, #ffffff 0%, #f5f5fa 100%);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  }

  .progress-title {
    color: #2d2d44;
  }

  .flow-icon {
    background: #f5f5fa;
    border-color: rgba(0, 0, 0, 0.12);
    color: #6272a4;
  }

  .flow-label {
    color: #6272a4;
  }

  .flow-step.active .flow-label,
  .detail-main {
    color: #2d2d44;
  }

  .progress-flow::before {
    background: rgba(0, 0, 0, 0.1);
  }

  .progress-detail-area {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.06);
  }

  .progress-summary {
    background: rgba(0, 0, 0, 0.03);
  }

  .summary-item {
    color: #2d2d44;
  }
}

/* =============================
   キャンセルボタン
   ============================= */
.progress-cancel-container {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.progress-cancel-button {
  display: none;  /* デフォルトは非表示、JSで表示制御 */
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 500;
  color: #f8f8f2;
  background: rgba(255, 85, 85, 0.15);
  border: 2px solid rgba(255, 85, 85, 0.4);
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.progress-cancel-button:hover:not(:disabled) {
  background: rgba(255, 85, 85, 0.3);
  border-color: rgba(255, 85, 85, 0.7);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(255, 85, 85, 0.3);
}

.progress-cancel-button:active:not(:disabled) {
  transform: translateY(0);
}

.progress-cancel-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.progress-cancel-button i {
  font-size: 1rem;
}

/* ライトモード対応 */
@media (prefers-color-scheme: light) {
  .progress-cancel-container {
    border-top-color: rgba(0, 0, 0, 0.08);
  }

  .progress-cancel-button {
    color: #444;
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.3);
  }

  .progress-cancel-button:hover:not(:disabled) {
    background: rgba(220, 53, 69, 0.2);
    border-color: rgba(220, 53, 69, 0.5);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.2);
  }
}

/* モバイル対応 */
@media (max-width: 768px) {
  .progress-cancel-container {
    margin-top: 16px;
    padding-top: 12px;
  }

  .progress-cancel-button {
    padding: 10px 24px;
    font-size: 0.9rem;
  }
}

/* =============================
   旧スタイルとの互換性（非表示）
   ============================= */
.progress-steps,
.progress-bar-container {
  display: none !important;
}
