/**
 * コレクション要素UI専用スタイル
 * 
 * ブランド原則準拠:
 * - 温かみ × 知的 × 遊び心 × 有機的
 * - カラーパレット: オレンジ(#FFB347)・グリーン(#6FCF97)・パープル(#A259FF)
 * - 角丸 + 有機曲線のカード・ボタン
 * - 粒子・インク・波紋など有機的なアニメーション
 */

/* ===== コレクション要素選択グループ ===== */
#collectionSelectionGroup {
  position: relative;
  margin-bottom: 2rem;
}

/* ===== トグルカード ===== */
.collection-toggle-card {
  background: linear-gradient(135deg, rgba(255, 179, 71, 0.05) 0%, rgba(255, 255, 255, 0.8) 100%);
  border: 2px solid rgba(255, 179, 71, 0.15);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  margin: 1rem 0;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.collection-toggle-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 80%, rgba(255, 179, 71, 0.1) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(111, 207, 151, 0.1) 0%, transparent 50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.collection-toggle-card:hover::before {
  opacity: 1;
}

.collection-toggle-card:hover {
  border-color: rgba(255, 179, 71, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(255, 179, 71, 0.15);
}

/* ===== チェックボックス ===== */
.collection-checkbox-wrapper {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.collection-checkbox-wrapper input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.collection-checkmark {
  width: 24px;
  height: 24px;
  background: white;
  border: 2px solid rgba(255, 179, 71, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.collection-checkmark::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--color-accent) 0%, #FF8C42 100%);
  border-radius: 6px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.collection-checkbox-wrapper input[type="checkbox"]:checked + .collection-checkmark::before {
  transform: translate(-50%, -50%) scale(1);
}

.collection-checkmark svg {
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: white;
  position: relative;
  z-index: 1;
}

.collection-checkbox-wrapper input[type="checkbox"]:checked + .collection-checkmark svg {
  opacity: 1;
  transform: scale(1);
}

.collection-checkbox-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.collection-checkbox-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.collection-checkbox-desc {
  font-size: 0.875rem;
  color: #6b7280;
  line-height: 1.4;
}

.collection-checkbox-wrapper input[type="checkbox"]:checked ~ .collection-checkbox-content .collection-checkbox-title {
  color: var(--color-accent);
}

.collection-checkbox-wrapper input[type="checkbox"]:checked ~ .collection-checkbox-content .collection-checkbox-desc {
  color: #f59e0b;
}

/* ===== オプションカード ===== */
.collection-options-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(249, 246, 242, 0.9) 100%);
  border: 2px solid rgba(255, 179, 71, 0.1);
  border-radius: var(--radius-card);
  padding: 0;
  margin-top: 1.5rem;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(15px);
  overflow: hidden;
  animation: slideInUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* ===== セクションヘッダー ===== */
.section-header {
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  border-bottom: 1px solid rgba(255, 179, 71, 0.1);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-accent3);
}

.section-title svg {
  color: var(--color-accent);
}

/* ===== コレクション選択セクション ===== */
.collection-selector-section {
  border-bottom: 1px solid rgba(255, 179, 71, 0.1);
}

.collection-levels-modern {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.collection-level {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.collection-level label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.collection-level select {
  background: white;
  border: 2px solid rgba(255, 179, 71, 0.2);
  border-radius: var(--radius-btn);
  padding: 0.875rem 1rem;
  font-size: 0.95rem;
  color: var(--color-text);
  transition: all 0.3s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23FFB347' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 3rem;
}

.collection-level select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.1);
}

.collection-level select:hover {
  border-color: rgba(255, 179, 71, 0.4);
  background-color: rgba(255, 179, 71, 0.02);
}

/* ===== 選択パス表示 ===== */
.selected-path-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, rgba(255, 179, 71, 0.08) 0%, rgba(255, 255, 255, 0.5) 100%);
  border-radius: var(--radius-btn);
  margin: 0 1.5rem 1.5rem 1.5rem;
}

.path-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-accent) 0%, #FF8C42 100%);
  border-radius: 8px;
  color: white;
}

.path-content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.path-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.path-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}

/* ===== スニペットセクション ===== */
.snippets-section {
  padding: 0;
}

.snippets-list-modern {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 179, 71, 0.3) rgba(255, 179, 71, 0.1);
}

.snippets-list-modern::-webkit-scrollbar {
  width: 8px;
}

.snippets-list-modern::-webkit-scrollbar-track {
  background: rgba(255, 179, 71, 0.1);
  border-radius: 4px;
}

.snippets-list-modern::-webkit-scrollbar-thumb {
  background: rgba(255, 179, 71, 0.3);
  border-radius: 4px;
  transition: background 0.2s ease;
}

.snippets-list-modern::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 179, 71, 0.5);
}

/* ===== スニペットアイテム ===== */
/* 既存の.snippet-itemは下部のゼロベース実装に統合済み */

/* 削除: 複雑な競合回避ルール */

.snippet-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 179, 71, 0.05) 0%, rgba(111, 207, 151, 0.05) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.snippet-item:hover::before {
  opacity: 1;
}

.snippet-item:hover {
  border-color: rgba(255, 179, 71, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(255, 179, 71, 0.1);
}

.snippet-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--color-accent);
  cursor: pointer;
  position: relative;
  z-index: 1;
  margin-top: 0; /* コンテナ中央揃えに任せる */
  flex-shrink: 0; /* チェックボックスのサイズを固定 */
}

.snippet-content {
  flex: 1;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0; /* テキストの切り詰めを有効にする */
}

.snippet-text {
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--color-text);
  white-space: nowrap; /* 1行表示を強制（!important禁止） */
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help; /* ホバー時にカーソルを変更 */
  transition: color 0.2s ease;
  max-width: 100%; /* 最大幅を制限 */
  display: block; /* ブロック要素として表示 */
}

.snippet-text:hover {
  color: var(--color-accent);
}

.snippet-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap; /* ラップを無効にして1行に収める */
  overflow: hidden;
}

/* タイプバッジは下部のゼロベース実装に統合済み */

.snippet-type-badge:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* コレクションラベルは下部のゼロベース実装に統合済み */

.snippet-collection-label:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.snippet-tags {
  font-size: 0.75rem;
  color: #6b7280;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px; /* 最大幅を制限 */
  cursor: help;
  transition: all 0.2s ease;
}

.snippet-tags:hover {
  color: var(--color-accent);
  transform: scale(1.02);
}

/* ===== 階層化コレクション構造対応 ===== */
.snippet-item.hierarchical {
  border-left: 4px solid var(--color-accent);
  background: linear-gradient(135deg, rgba(255, 179, 71, 0.02) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.snippet-item.hierarchical .snippet-collection-label {
  background: linear-gradient(135deg, var(--color-accent) 0%, #FF8C42 100%);
  position: relative;
}

.snippet-item.hierarchical .snippet-collection-label::before {
  content: '📁';
  margin-right: 0.25rem;
}

/* ===== ゼロベースのシンプルなスニペット高さ制御 ===== */

/* 基本スタイル: 全てのスニペット項目に適用 */
.snippet-item {
  min-height: 87px; /* UX最適化: 87pxで統一 */
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: white;
  border: 2px solid rgba(255, 179, 71, 0.1);
  border-radius: var(--radius-btn);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
}

/* スニペットコンテンツ領域 */
.snippet-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 38px; /* コンテンツ最小高さ確保 */
}

/* メタ情報領域の高さ確保 */
.snippet-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 24px; /* ラベル表示用の最小高さ */
  flex-wrap: nowrap;
}

/* タイプバッジの高さ確保 */
.snippet-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px; /* 十分な高さ確保 */
  padding: 0.375rem 0.75rem;
  background: linear-gradient(135deg, var(--color-accent2) 0%, #4ADE80 100%);
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
  cursor: help;
  transition: all 0.2s ease;
}

/* コレクションラベルの高さ確保 */
.snippet-collection-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px; /* 十分な高さ確保 */
  padding: 0.375rem 0.75rem;
  background: linear-gradient(135deg, var(--color-accent) 0%, #FF8C42 100%);
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  gap: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
  cursor: help;
  transition: all 0.2s ease;
}

/* 統一高さ制御（ユニファイドクラス適用時） */
.unified-height .snippet-item {
  min-height: 87px; /* UX最適化: 87pxで統一高さを強制 */
}

/* ===== アクションボタン ===== */
.snippets-actions-modern {
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(249, 246, 242, 0.8) 0%, rgba(255, 255, 255, 0.9) 100%);
  border-top: 1px solid rgba(255, 179, 71, 0.1);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius-btn);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
}

.action-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.action-btn:hover::before {
  opacity: 1;
}

.action-btn-primary {
  background: linear-gradient(135deg, var(--color-accent) 0%, #FF8C42 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 179, 71, 0.3);
}

.action-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 179, 71, 0.4);
}

.action-btn-secondary {
  background: linear-gradient(135deg, rgba(107, 114, 128, 0.1) 0%, rgba(255, 255, 255, 0.8) 100%);
  color: #6b7280;
  border: 2px solid rgba(107, 114, 128, 0.2);
}

.action-btn-secondary:hover {
  background: linear-gradient(135deg, rgba(107, 114, 128, 0.15) 0%, rgba(255, 255, 255, 0.9) 100%);
  border-color: rgba(107, 114, 128, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(107, 114, 128, 0.1);
}

/* ===== ヘルプテキスト ===== */
.help-text-modern {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #6b7280;
  font-style: italic;
  margin-left: auto;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 179, 71, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 179, 71, 0.1);
}

.help-text-modern svg {
  color: var(--color-accent);
  flex-shrink: 0;
}

/* ===== 空状態メッセージ ===== */
.snippets-empty,
.collections-empty,
.snippets-error,
.collections-error {
  text-align: center;
  padding: 2rem;
  color: #6b7280;
  font-style: italic;
  background: linear-gradient(135deg, rgba(255, 179, 71, 0.02) 0%, rgba(255, 255, 255, 0.5) 100%);
  border-radius: var(--radius-btn);
  border: 2px dashed rgba(255, 179, 71, 0.2);
  margin: 1rem;
}

.snippets-error,
.collections-error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.05) 0%, rgba(255, 255, 255, 0.8) 100%);
  border-color: rgba(239, 68, 68, 0.2);
  color: #dc2626;
}

/* ===== レスポンシブ対応 ===== */
@media (max-width: 768px) {
  .collection-toggle-card {
    padding: 1.25rem;
    margin: 0.75rem 0;
  }
  
  .collection-checkbox-wrapper {
    gap: 0.75rem;
  }
  
  .collection-checkbox-title {
    font-size: 0.95rem;
  }
  
  .collection-checkbox-desc {
    font-size: 0.8rem;
  }
  
  .collection-options-card {
    margin-top: 1rem;
  }
  
  .section-header {
    padding: 1.25rem 1.25rem 0.75rem 1.25rem;
  }
  
  .section-title {
    font-size: 1rem;
    gap: 0.5rem;
  }
  
  .collection-levels-modern {
    padding: 1.25rem;
    gap: 0.75rem;
  }
  
  .selected-path-display {
    margin: 0 1.25rem 1.25rem 1.25rem;
    padding: 0.875rem;
  }
  
  .snippets-list-modern {
    padding: 1.25rem;
    gap: 0.5rem;
  }
  
  .snippet-item {
    padding: 1rem;
    gap: 0.75rem;
  }
  
  .snippets-actions-modern {
    padding: 1.25rem;
    gap: 0.75rem;
    flex-direction: column;
    align-items: stretch;
  }
  
  .action-btn {
    padding: 0.875rem 1rem;
    justify-content: center;
  }
  
  .help-text-modern {
    margin-left: 0;
    text-align: center;
    justify-content: center;
  }
}

/* ===== アニメーション効果 ===== */
.collection-options-card[style*="block"] {
  animation: slideInUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.snippets-section[style*="block"] {
  animation: fadeInScale 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== フォーカス状態 ===== */
.collection-checkbox-wrapper:focus-within .collection-checkmark {
  box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.2);
}

.action-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.2);
}

/* ===== 選択状態のアニメーション ===== */
.snippet-item:has(.snippet-checkbox:checked) {
  background: linear-gradient(135deg, rgba(255, 179, 71, 0.1) 0%, rgba(255, 255, 255, 0.9) 100%);
  border-color: var(--color-accent);
  box-shadow: 0 4px 16px rgba(255, 179, 71, 0.2);
}

.snippet-item:has(.snippet-checkbox:checked) .snippet-text {
  color: var(--color-text);
  font-weight: 500;
}

/* ===== 有機的なホバー効果 ===== */
.collection-toggle-card:hover,
.collection-options-card:hover,
.snippet-item:hover {
  animation: organicPulse 2s ease-in-out infinite;
}

@keyframes organicPulse {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(255, 179, 71, 0.1);
  }
  50% {
    box-shadow: 0 6px 30px rgba(255, 179, 71, 0.15);
  }
}
