/**
 * topic_filter.css
 * トピック切り替えドロップダウン用の共通スタイル
 */

/* トピックドロップダウン */
.topic-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.topic-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s;
}

.topic-dropdown-toggle:hover {
  background: #374151;
  color: #fff;
}

.topic-dropdown-toggle:hover h3,
.topic-dropdown-toggle:hover h2 {
  color: #fff;
}

.topic-dropdown-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform .2s;
}

.topic-dropdown.open .topic-dropdown-toggle svg {
  transform: rotate(180deg);
}

.topic-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, .12);
  z-index: 100;
  display: none;
  margin-top: 6px;
}

.topic-dropdown.open .topic-dropdown-menu {
  display: block;
}

.topic-dropdown-item {
  display: block;
  padding: 10px 14px;
  font-size: .9rem;
  color: #374151;
  text-decoration: none;
  transition: background .1s;
}

.topic-dropdown-item:hover {
  background: #f3f4f6;
}

.topic-dropdown-item.active {
  background: #eef2ff;
  color: #4f46e5;
  font-weight: 600;
}

.topic-dropdown-item.highlight {
  color: #4f46e5;
  font-weight: 600;
}

.topic-dropdown-item.legacy-header {
  background: #111827;
  color: #fff;
  font-weight: 800;
  cursor: default;
  pointer-events: none;
  text-transform: none;
  letter-spacing: 0.02em;
}

.topic-divider {
  display: block;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  color: #111;
  background: #e5e7eb;
  letter-spacing: 0.02em;
  cursor: default;
  pointer-events: none;
  border-top: 1px solid #d1d5db;
}

.topic-divider.legacy-header {
  /* legacy-header のスタイルを継承 */
}

.topic-dropdown-item.legacy {
  background: #6b7280;
  color: #fff;
}

.topic-dropdown-item.legacy:hover {
  background: #4b5563;
  color: #fff;
}

/* 検索欄（モーダル共通） */
.filter-search-container {
  padding: 0 0 12px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.filter-search-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: #111827;
  background: #f9fafb;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.filter-search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: #fff;
}

.filter-search-input::placeholder {
  color: #9ca3af;
}

.filter-options-list,
.topic-options-list,
.topic-dropdown-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ドロップダウン内の検索欄 */
.topic-dropdown-menu .filter-search-container {
  padding: 10px 10px 8px;
  margin: 0;
  border-bottom: 1px solid #e5e7eb;
}

.topic-dropdown-menu .filter-search-input {
  padding: 8px 10px;
  font-size: 13px;
}

.topic-dropdown-menu .topic-dropdown-list {
  padding: 4px 0;
}

/* 検索行（検索欄 + ユーザートピックボタン） */
.dropdown-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-search-row .filter-search-input {
  flex: 1;
  min-width: 0;
}

/* ユーザートピック切り替えボタン */
.user-topics-toggle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f9fafb;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.user-topics-toggle:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #374151;
}

.user-topics-toggle.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

.user-topics-toggle.active:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.user-topics-toggle svg {
  width: 18px;
  height: 18px;
}

/* もっと見るボタン */
.topic-dropdown-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  margin: 4px 0;
  font-size: 13px;
  font-weight: 600;
  color: #3b82f6;
  text-decoration: none;
  background: #eff6ff;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.topic-dropdown-more:hover {
  background: #dbeafe;
  color: #2563eb;
}

.topic-dropdown-more svg {
  width: 14px;
  height: 14px;
}

/* フィルターモーダル（compare, cbo_topic 用） */
.filter-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.filter-modal-backdrop.is-open {
  display: flex;
}

.filter-modal-panel {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  width: 92vw;
  max-width: 340px;
  max-height: 78vh;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.filter-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
}

.filter-modal-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}

.filter-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.filter-modal-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.filter-modal-body {
  padding: 10px 12px;
  max-height: calc(78vh - 70px);
  overflow-y: auto;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-option {
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.filter-option:hover {
  background: #f3f4f6;
}

.filter-option.selected {
  background: #eef2ff;
  color: #4f46e5;
}

.filter-option.filter-divider {
  background: #111827;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: default;
  pointer-events: none;
}

.filter-option.legacy {
  background: #6b7280;
  color: #fff;
}

.filter-option.legacy:hover {
  background: #4b5563;
  color: #fff;
}

.filter-modal-footer {
  padding: 0 12px 12px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
}

.filter-modal-btn-secondary {
  padding: 8px 14px;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  cursor: pointer;
  transition: background .15s;
}

.filter-modal-btn-secondary:hover {
  background: #f3f4f6;
}

/* トピックモーダル（cbo_topic 用） */
.topic-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.topic-modal-backdrop.is-open {
  display: flex;
}

.topic-modal-panel {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  width: 92vw;
  max-width: 340px;
  max-height: 78vh;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.topic-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
}

.topic-modal-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}

.topic-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.topic-modal-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.topic-modal-body {
  padding: 10px 12px;
  max-height: calc(78vh - 70px);
  overflow-y: auto;
}

.topic-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topic-option {
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.topic-option:hover {
  background: #f3f4f6;
}

.topic-option.selected {
  background: #eef2ff;
  color: #4f46e5;
}

.topic-option-divider {
  background: #111827;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: default;
  pointer-events: none;
}

.topic-option.legacy {
  background: #6b7280;
  color: #fff;
}

.topic-option.legacy:hover {
  background: #4b5563;
  color: #fff;
}
