/* === リセット・基本 === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background-color: #1a1a2e;
  color: #e0e0e0;
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* === ヘッダー === */
.app-header {
  background: linear-gradient(135deg, #16213e, #0f3460);
  padding: 1rem 2rem;
  text-align: center;
  border-bottom: 3px solid #e94560;
}

.app-header h1 {
  font-size: 1.5rem;
  color: #fff;
  letter-spacing: 0.05em;
}

.header-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 0.25rem;
}

.app-header .subtitle {
  font-size: 0.85rem;
  color: #a0a0b8;
}

.btn-settings-link {
  font-size: 0.8rem;
  padding: 0.3rem 1rem;
  text-decoration: none;
  border-radius: 6px;
  font-weight: bold;
}

/* === メインレイアウト === */
.app-container {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 1.5rem;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}

/* 設定ページ用レイアウト */
.settings-container {
  grid-template-columns: minmax(0, 340px) 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
  overflow-x: hidden;
}

.pokemon-list-section {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
  min-height: 0;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* === セクション共通 === */
.section {
  background: #16213e;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #1a3a5c;
}

.section-title {
  font-size: 1.1rem;
  color: #e94560;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #1a3a5c;
}

/* === タイプバッジ === */
.type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* === タイプアイコン（小さな丸） === */
.type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: bold;
  flex-shrink: 0;
  line-height: 1;
}

/* === フォーム === */
.form-group {
  margin-bottom: 0.75rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: #a0a0b8;
  margin-bottom: 0.25rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #1a3a5c;
  border-radius: 6px;
  background: #0f3460;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #e94560;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.abilities-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

.abilities-inputs input {
  width: 100%;
  padding: 0.4rem;
  font-size: 0.85rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

.stats-grid label {
  font-size: 0.75rem;
}

.stats-grid input {
  width: 100%;
  padding: 0.4rem;
  text-align: center;
}

/* === ボタン === */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: bold;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.85;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #e94560;
  color: #fff;
}

.btn-secondary {
  background: #1a3a5c;
  color: #e0e0e0;
}

.btn-danger {
  background: #c0392b;
  color: #fff;
}

.btn-small {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

.btn-edit {
  background: #2980b9;
  color: #fff;
}

.btn-preset {
  background: #27ae60;
  color: #fff;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.form-actions .btn {
  flex: 1;
}

.hidden {
  display: none !important;
}

/* === データ管理ボタン群 === */
.data-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* === ポケモンリスト === */
.pokemon-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.pokemon-count {
  font-size: 0.8rem;
  color: #a0a0b8;
}

.search-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #1a3a5c;
  border-radius: 6px;
  background: #0f3460;
  color: #e0e0e0;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.search-input:focus {
  outline: none;
  border-color: #e94560;
}

/* === 詳細検索 === */
.advanced-search {
  margin-bottom: 0.75rem;
}

.btn-toggle-advanced {
  background: none;
  border: none;
  color: #a0a0b8;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem 0;
}

.btn-toggle-advanced:hover {
  color: #e94560;
}

.advanced-search-panel {
  background: #0f3460;
  border: 1px solid #1a3a5c;
  border-radius: 6px;
  padding: 0.75rem;
  margin-top: 0.4rem;
}

.filter-group {
  margin-bottom: 0.6rem;
}

.filter-label {
  display: block;
  font-size: 0.75rem;
  color: #a0a0b8;
  margin-bottom: 0.3rem;
}

.filter-group label.filter-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: #c0c0d8;
  font-size: 0.8rem;
}

.filter-group label.filter-label input[type="checkbox"] {
  accent-color: #e94560;
}

.type-filter-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
}

.type-filter-btn {
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 2px 0;
  font-size: 0.65rem;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  opacity: 0.5;
  transition: opacity 0.15s, border-color 0.15s;
}

.type-filter-btn:hover {
  opacity: 0.8;
}

.type-filter-btn.active {
  opacity: 1;
  border-color: #fff;
}

.filter-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

/* カテゴリフィルター */
.category-filter-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
}

.confirmed-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
}

.btn-category {
  background: #2c3e50;
  color: #a0b0c0;
  border: 2px solid transparent;
  opacity: 0.6;
  transition: opacity 0.15s, border-color 0.15s;
  font-size: 0.65rem !important;
  padding: 3px 2px !important;
}

.btn-category:hover {
  opacity: 0.8;
}

.btn-category.active {
  opacity: 1;
  border-color: #fff;
  color: #fff;
}

.btn-category[data-category="normal"] { background: #27ae60; }
.btn-category[data-category="semi-legend"] { background: #2980b9; }
.btn-category[data-category="legend"] { background: #e67e22; }
.btn-category[data-category="mythical"] { background: #8e44ad; }
.btn-category[data-category="final-evo"] { background: #c0392b; }
.btn-category[data-category="pre-evo"] { background: #7f8c8d; }

.btn-confirmed {
  background: #2c3e50;
  color: #a0b0c0;
  border: 2px solid transparent;
  opacity: 0.6;
  transition: opacity 0.15s, border-color 0.15s;
  font-size: 0.65rem !important;
  padding: 3px 2px !important;
}

.btn-confirmed:hover {
  opacity: 0.8;
}

.btn-confirmed.active {
  opacity: 1;
  border-color: #fff;
  color: #fff;
}

.btn-confirmed[data-confirmed="true"] { background: #27ae60; }
.btn-confirmed[data-confirmed="false"] { background: #95a5a6; }

/* AND/OR切替ボタン */
.btn-search-mode {
  background: #2c3e50;
  color: #3498db;
  border: 2px solid #3498db;
  font-weight: bold;
  min-width: 3rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-search-mode:hover {
  opacity: 0.85;
}

.btn-search-mode.mode-and {
  background: #1a5276;
  color: #f39c12;
  border-color: #f39c12;
}

.btn-mega {
  background: #8e44ad;
  color: #fff;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.btn-mega:hover {
  opacity: 0.8;
}

.btn-mega.active {
  opacity: 1;
  box-shadow: 0 0 0 2px #fff;
}

#pokemon-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  align-content: start;
  min-width: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#pokemon-list::-webkit-scrollbar {
  display: none;
}

/* コンパクトカード */
.pokemon-card {
  background: #0f3460;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  border: 1px solid #1a3a5c;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
  position: relative;
  user-select: none;
  min-width: 0;
}

.pokemon-card:hover {
  border-color: #e94560;
  background: #153a6a;
}

.pokemon-card.in-party {
  border-color: #2980b9;
  background: #122a50;
  opacity: 0.6;
}

.pokemon-card-header {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pokemon-card-name {
  font-weight: bold;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.pokemon-card-types {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* ホバー時のアクションオーバーレイ */
.pokemon-card-actions {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 52, 96, 0.92);
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.pokemon-card:hover .pokemon-card-actions {
  display: flex;
}

.pokemon-card-actions .btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
}

/* ツールチップ（ステータス表示） — fixed で枠外にも表示 */
.pokemon-card-tooltip {
  display: none;
  position: fixed;
  z-index: 1000;
  background: #0a1e3d;
  border: 1px solid #2980b9;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  white-space: nowrap;
  font-size: 0.7rem;
  color: #c0c0d8;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.pokemon-card-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
}

/* 上向き表示時の矢印（下に矢印） */
.pokemon-card-tooltip.tooltip-above::after {
  top: 100%;
  border-top-color: #2980b9;
}

/* 下向き表示時の矢印（上に矢印） */
.pokemon-card-tooltip.tooltip-below::after {
  bottom: 100%;
  border-bottom-color: #2980b9;
}

.pokemon-card:hover .pokemon-card-tooltip {
  display: block;
}

.pokemon-card-tooltip .tooltip-name {
  font-weight: bold;
  font-size: 0.8rem;
  color: #fff;
  margin-bottom: 0.2rem;
}

.pokemon-card-tooltip .tooltip-types {
  display: flex;
  gap: 4px;
  margin-bottom: 0.3rem;
}

.pokemon-card-tooltip .tooltip-types .type-badge {
  font-size: 0.6rem;
  padding: 1px 6px;
}

.pokemon-card-tooltip .tooltip-abilities {
  margin-bottom: 0.3rem;
  font-size: 0.65rem;
  color: #a0b0d0;
}

.pokemon-card-tooltip .tooltip-abilities .ability-label {
  color: #8090b0;
}

.pokemon-card-tooltip .tooltip-abilities .ability-hidden {
  color: #c0a060;
}

.pokemon-card-tooltip .tooltip-stats {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.15rem 0.6rem;
}

.pokemon-card-tooltip .tooltip-stats span {
  text-align: right;
}

.pokemon-card-tooltip .tooltip-stats .stat-label {
  color: #8090b0;
  text-align: left;
}

.empty-message {
  text-align: center;
  color: #606080;
  padding: 2rem 0;
  font-size: 0.9rem;
  grid-column: 1 / -1;
  line-height: 1.8;
}

.empty-message a {
  color: #e94560;
  text-decoration: none;
}

.empty-message a:hover {
  text-decoration: underline;
}

/* === パーティスロット === */
#party-slots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
}

.party-slot {
  background: #0f3460;
  border-radius: 10px;
  padding: 0.75rem;
  text-align: center;
  border: 2px solid #1a3a5c;
  min-height: 100px;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.party-slot.filled {
  border-color: #2980b9;
}

.party-slot.empty {
  border-style: dashed;
  opacity: 0.6;
}

.party-slot.drag-over {
  border-color: #e94560;
  background: #1a2a4e;
}

.party-slot.dragging {
  opacity: 0.5;
}

.party-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.party-slot-number {
  font-size: 0.7rem;
  color: #606080;
  font-weight: bold;
}

.btn-remove-party {
  background: none;
  border: none;
  color: #e94560;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.btn-remove-party:hover {
  color: #ff6b81;
}

.party-slot-name {
  font-weight: bold;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
  word-break: break-all;
}

.party-slot-types {
  display: flex;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.party-slot-types .type-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
}

.party-slot-empty {
  color: #404060;
  font-size: 0.8rem;
  padding-top: 1rem;
}

.party-ability-select {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.25rem 0.3rem;
  border: 1px solid #1a3a5c;
  border-radius: 4px;
  background: #0a1e3d;
  color: #c0c0d8;
  font-size: 0.7rem;
  cursor: pointer;
}

.party-ability-select:focus {
  outline: none;
  border-color: #e94560;
}

/* === 耐性分析テーブル === */
.analysis-table-wrapper {
  overflow-x: auto;
}

.analysis-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.analysis-table th,
.analysis-table td {
  padding: 0.5rem 0.6rem;
  text-align: center;
  border: 1px solid #1a3a5c;
}

.analysis-table thead th {
  background: #0f3460;
  color: #e0e0e0;
  font-weight: bold;
  position: sticky;
  top: 0;
  z-index: 1;
}

.th-type {
  width: 100px;
  text-align: left !important;
}

.th-pokemon {
  min-width: 80px;
}

.th-eval {
  width: 60px;
}

.td-type {
  text-align: left !important;
}

/* 倍率セルの色分け */
.mult-immune {
  background: #4a4a5a;
  color: #999;
  font-weight: bold;
}

.mult-quarter {
  background: #1a5276;
  color: #7ec8e3;
  font-weight: bold;
}

.mult-half {
  background: #1e6e3e;
  color: #7dcea0;
  font-weight: bold;
}

.mult-low-resist {
  background: #2a5a3a;
  color: #a0d8b0;
}

.mult-normal {
  background: #2c2c3e;
  color: #b0b0c0;
}

.mult-double {
  background: #a0522d;
  color: #ffc299;
  font-weight: bold;
}

.mult-quad {
  background: #8b1a1a;
  color: #ff9999;
  font-weight: bold;
}

/* 特性による変更マーク */
.ability-modified {
  position: relative;
}

.ability-mark {
  font-size: 0.55em;
  color: #f1c40f;
  margin-left: 1px;
  vertical-align: super;
}

.analysis-legend {
  font-size: 0.75rem;
  color: #808098;
  margin-top: 0.5rem;
  text-align: right;
}

.analysis-legend .ability-mark {
  font-size: 0.85em;
  vertical-align: baseline;
}

/* 評価セル */
.eval-safe {
  color: #2ecc71;
  font-weight: bold;
  font-size: 1.1rem;
}

.eval-caution {
  color: #f39c12;
  font-weight: bold;
  font-size: 1.1rem;
}

.eval-dangerous {
  color: #e67e22;
  font-weight: bold;
  font-size: 1.1rem;
}

.eval-critical {
  color: #e74c3c;
  font-weight: bold;
  font-size: 1.1rem;
}

/* === サマリー === */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.summary-section {
  background: #0f3460;
  border-radius: 10px;
  padding: 1rem;
  border: 2px solid transparent;
}

.summary-critical {
  border-color: #e74c3c;
}

.summary-dangerous {
  border-color: #e67e22;
}

.summary-caution {
  border-color: #f39c12;
}

.summary-safe {
  border-color: #2ecc71;
}

.summary-title {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  text-align: center;
}

.summary-title.critical {
  color: #e74c3c;
}

.summary-title.danger {
  color: #e67e22;
}

.summary-title.caution {
  color: #f39c12;
}

.summary-title.safe {
  color: #2ecc71;
}

.summary-types {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.summary-none {
  color: #606080;
  font-size: 0.85rem;
}

/* === レスポンシブ === */
@media (max-width: 1100px) {
  .app-container {
    grid-template-columns: 1fr;
  }

  .settings-container {
    grid-template-columns: 1fr;
  }

  #pokemon-list {
    max-height: 400px;
  }

  #party-slots {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .app-container {
    padding: 0.75rem;
  }

  #party-slots {
    grid-template-columns: repeat(2, 1fr);
  }

  #pokemon-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .abilities-inputs {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .analysis-table {
    font-size: 0.75rem;
  }

  .analysis-table th,
  .analysis-table td {
    padding: 0.3rem;
  }

  .header-row {
    flex-direction: column;
    gap: 0.5rem;
  }
}
