/* カード検索コンポーネント共通スタイル */

/* グリッド内もっと見るカード */
.card-item.load-more-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border: 2px dashed rgba(255, 255, 255, 0.3) !important;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative;
  overflow: hidden;
  color: white !important;
  text-align: center !important;
}

.card-item.load-more-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6) !important;
  background: linear-gradient(135deg, #5a6fd8 0%, #6b4190 100%) !important;
}

.card-item.load-more-card.loading {
  pointer-events: none;
  opacity: 0.8;
}

.load-more-content {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  color: white !important;
  text-align: center !important;
  padding: 0.5rem !important;
  margin: 0 !important;
  width: 100% !important;
  height: 100% !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
}

.load-more-content * {
  color: white !important;
}

.load-more-icon-large {
  width: 32px;
  height: 32px;
  margin-bottom: 0.25rem !important;
  transition: transform 0.3s ease;
}

.card-item.load-more-card:hover .load-more-icon-large {
  transform: translateY(4px);
}

.load-more-icon-large svg {
  width: 100%;
  height: 100%;
}

.loading-spinner-large {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
  margin-bottom: 0.25rem !important;
}

.load-more-text-large {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 !important;
  margin-bottom: 0.125rem !important;
  text-align: center;
}

.load-more-count {
  font-size: 0.75rem;
  opacity: 0.9;
  text-align: center;
  width: 100%;
  margin: 0 !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* viewモード用のもっと見るボタン */
.load-more-container-list {
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  margin-top: 1rem;
}

.load-more-btn-list {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  position: relative;
  overflow: hidden;
  min-width: 200px;
}

.load-more-btn-list:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
  background: linear-gradient(135deg, #5a6fd8 0%, #6b4190 100%);
}

.load-more-btn-list:active:not(:disabled) {
  transform: translateY(0);
}

.load-more-btn-list:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.load-more-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.load-more-icon {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.load-more-btn-list:hover:not(:disabled) .load-more-icon {
  transform: translateY(2px);
}

.loading-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

/* カード画質改善（もっと見るカードは除外） */
.card-item:not(.load-more-card) img,
.card-image,
.list-item-image {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  filter: contrast(1.1) saturate(1.05);
  transition: filter 0.2s ease;
}

.card-item:not(.load-more-card):hover img,
.card:hover .card-image {
  filter: contrast(1.15) saturate(1.1) brightness(1.05);
}

/* 一括追加関連スタイル */
.bulk-add-btn {
  background: #10b981;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.bulk-add-btn:hover {
  background: #059669;
}

.bulk-add-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  box-sizing: border-box;
}

.bulk-add-modal .modal-content {
  width: 90%;
  max-width: 600px;
  background: white;
  border-radius: 8px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.bulk-add-modal .modal-header {
  padding: 1.5rem 1.5rem 0 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.bulk-add-modal .modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.bulk-add-modal .close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.bulk-add-modal .close-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.bulk-add-modal .modal-body {
  padding: 0 1.5rem 1.5rem 1.5rem;
}

.bulk-add-instructions {
  margin-bottom: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 6px;
  border-left: 4px solid #3b82f6;
}

.bulk-add-instructions p {
  margin: 0 0 0.5rem 0;
  color: #374151;
}

.bulk-add-instructions .note {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.5rem;
}

.example {
  margin: 0.75rem 0;
}

.example-title {
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.25rem;
}

.example-text {
  font-family: "Courier New", monospace;
  background: #e5e7eb;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
  color: #1f2937;
  white-space: pre-line;
}

.bulk-add-textarea {
  width: 100%;
  min-height: 200px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.75rem;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  resize: vertical;
  box-sizing: border-box;
}

.bulk-add-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.bulk-add-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.bulk-add-actions .cancel-btn {
  background: #6b7280;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.bulk-add-actions .cancel-btn:hover {
  background: #4b5563;
}

.bulk-add-actions .submit-btn {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.bulk-add-actions .submit-btn:hover:not(:disabled) {
  background: #2563eb;
}

.bulk-add-actions .submit-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* モード別コンテナ */
.card-search-component {
  position: relative;
}

.card-search-component.mode-select {
  min-height: 100vh;
  background: #f5f5f5;
}

/* カードグリッド共通 */
.card-search-component .card-grid {
  display: grid;
  gap: 1.5rem;
}

.card-search-component.mode-select .card-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.25rem;
  padding: 0.5rem;
  flex: 1;
  overflow-y: auto;
  justify-content: start;
}

/* selectモード専用スタイル */
.card-search-component.mode-select .search-results {
  background: white;
  margin: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
}

/* フィルター表示時の高さ調整 */
.card-search-component.mode-select.filter-open .search-results {
  height: calc(100vh - 280px);
}

.card-search-component.mode-select .card-item {
  aspect-ratio: 0.72;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  border: 2px solid transparent;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-search-component.mode-select .card-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-search-component.mode-select .card-item:active {
  transform: scale(0.95);
}

.card-search-component.mode-select .card-item.not-owned {
  opacity: 0.6;
}

.card-search-component.mode-select .card-item.disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.card-search-component.mode-select .card-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-search-component.mode-select .card-overlay {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  padding: 0.25rem 0.5rem;
  border-radius: 0 0 0 4px;
}

.card-search-component.mode-select .card-count {
  font-size: 0.75rem;
  color: white;
  font-weight: bold;
}

.card-search-component.mode-select .card-count.exceeded {
  color: #f44336;
}

/* viewモード用スタイル（既存のカード一覧のスタイルを維持） */
.card-search-component.mode-view .card {
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  border: 3px solid transparent;
  padding: 0;
}

.card-search-component.mode-view .card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* レスポンシブ対応 */
@media (min-width: 768px) {
  .card-search-component.mode-select .card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .card-search-component.mode-select .card-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 1rem;
  }

  .card-search-component.mode-select .search-results {
    margin: 0 2rem 2rem;
    padding: 1.5rem;
  }
}

@media (min-width: 1400px) {
  .card-search-component.mode-select .card-grid {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
}

.card-search-component.mode-view .card-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.card-search-component.mode-view .card-grid.grid-cols-1 {
  grid-template-columns: minmax(200px, 400px);
}

.card-search-component.mode-view .card-grid.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(200px, 1fr));
}

.card-search-component.mode-view .card-grid.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.card-search-component.mode-view .card-grid.grid-cols-4 {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

#back-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  background-color: #3b82f6;
  color: white;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

#back-to-top.show {
  opacity: 1;
  pointer-events: auto;
}

/* 複数選択モード用スタイル */
.multi-select-controls {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 1rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 10;
}

.selected-count {
  font-weight: bold;
  color: #1f2937;
}

.btn-add-selected {
  background: #10b981;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.btn-add-selected:hover {
  background: #059669;
}

.btn-remove-card {
  background: #f59e0b;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.btn-remove-card:hover {
  background: #d97706;
}

.btn-cancel {
  background: #6b7280;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.btn-cancel:hover {
  background: #4b5563;
}

.card-item.selected {
  border: 3px solid #10b981 !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2) !important;
  transform: scale(0.98);
}

.card-item.selected::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 8px;
  background: #10b981;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  z-index: 2;
}

/* 複数選択モード用のオーバーレイ */
.multi-select-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  padding: 8px;
  z-index: 3;
}

.count-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.count-btn {
  background: #10b981;
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
}

.count-btn:hover:not(:disabled) {
  background: #059669;
}

.count-btn:disabled {
  background: #6b7280;
  cursor: not-allowed;
  opacity: 0.5;
}

.count-btn.minus {
  background: #ef4444;
}

.count-btn.minus:hover:not(:disabled) {
  background: #dc2626;
}

.count-display {
  background: rgba(255, 255, 255, 0.9);
  color: #1f2937;
  padding: 4px 12px;
  border-radius: 16px;
  font-weight: bold;
  min-width: 32px;
  text-align: center;
}

/* カードオーバーレイの表示を強制 */
.search-results .card-item {
  position: relative !important;
}

.search-results .card-item .card-overlay {
  position: absolute !important;
  top: 2px !important;
  right: 2px !important;
  bottom: auto !important;
  left: auto !important;
  background: rgba(0, 0, 0, 0.9) !important;
  padding: 0.15rem 0.35rem !important;
  border-radius: 0 0 0 4px !important;
  z-index: 30 !important;
  display: block !important;
  visibility: visible !important;
}

.card-count {
  font-size: 0.75rem !important;
  color: white !important;
  font-weight: bold !important;
  display: inline-block !important;
}

/* グリッドビュー用もっと見るボタン */
.load-more-container-grid {
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  margin-top: 1rem;
  grid-column: 1 / -1; /* グリッド全体の幅を使用 */
}

.load-more-btn-grid {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  position: relative;
  overflow: hidden;
  min-width: 200px;
}

.load-more-btn-grid:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
  background: linear-gradient(135deg, #5a6fd8 0%, #6b4190 100%);
}

.load-more-btn-grid:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.load-more-btn-grid:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.load-more-btn-grid:hover:not(:disabled) .load-more-icon {
  transform: translateY(2px);
}

.load-more-btn-grid .load-more-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.load-more-btn-grid .load-more-icon {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.load-more-btn-grid .loading-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.load-more-btn-grid .loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
