/* =========================================
   ポケモン相性補完サーチャー : ps-style.css
========================================= */

/* --- カラー定義（ポケモン風テーマ） --- */
:root {
  --ps-primary: #e63946;       /* モンスターボール・レッド */
  --ps-primary-hover: #c92a37;
  --ps-accent: #ffcb05;        /* ポケモン・イエロー */
  --ps-dark: #1d3557;          /* メインダークネイビー */
  --ps-dark-sub: #2b4c7e;      /* サブネイビー */
  --ps-bg-light: #f8f9fa;
  --ps-border: #dcdfe6;
  --ps-text: #2d3748;
}

/* =========================================
   1. 検索フォーム & オプションエリア
========================================= */
#ps-search-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--ps-bg-light);
  padding: 20px;
  border-radius: 12px;
  border: 2px solid #eaeef3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
}

.ps-form-main-controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

.ps-form-field {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ps-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

/* ドロップダウン＆ボタン */
#ps-search-form select {
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ps-text);
  border: 1px solid var(--ps-border);
  border-radius: 6px;
  min-width: 180px;
  outline: none;
  background-color: #ffffff;
  transition: border-color 0.2s;
}

#ps-search-form select:focus {
  border-color: var(--ps-dark-sub);
}

.ps-submit-btn {
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--ps-primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(230, 57, 70, 0.3);
  transition: all 0.2s ease;
}

.ps-submit-btn:hover {
  background: var(--ps-primary-hover);
  transform: translateY(-1px);
}

.ps-submit-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* トグルスイッチ（オプション設定） */
.ps-form-options {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 14px;
  border-top: 2px dashed #e2e8f0;
  width: 100%;
}

.ps-options-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #718096;
}

.ps-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.ps-toggle-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ps-toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  background-color: #cbd5e0;
  border-radius: 20px;
  transition: background-color 0.2s ease;
}

.ps-toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.ps-toggle-label input[type="checkbox"]:checked + .ps-toggle-switch {
  background-color: var(--ps-dark);
}

.ps-toggle-label input[type="checkbox"]:checked + .ps-toggle-switch::after {
  transform: translateX(18px);
}

.ps-toggle-text {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ps-text);
}

/* ローダー */
#ps-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #4a5568;
  font-size: 0.88rem;
  font-weight: bold;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--ps-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Select2 カスタマイズ */
.select2-container--default .select2-selection--single {
  height: 40px !important;
  border: 1px solid var(--ps-border) !important;
  border-radius: 6px !important;
  display: flex;
  align-items: center;
}

.ps-select-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.ps-select-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

/* =========================================
   2. 結果テーブル & スクロール設定
========================================= */
.ps-type-table-wrapper {
  overflow-y: auto;
  overflow-x: auto;
  max-height: 650px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  background: #ffffff;
  margin-top: 20px;
  border: 1px solid #e2e8f0;
}

/* スクロールバー */
.ps-type-table-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.ps-type-table-wrapper::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.ps-type-table-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.ps-type-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.ps-type-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  color: var(--ps-text);
  min-width: 1280px;
}

.ps-type-table th,
.ps-type-table td {
  padding: 8px 6px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid #edf2f7;
  font-size: 0.85rem;
}

.ps-type-table td {
  border-right: 1px solid #f7fafc;
}

/* 行のホバー時ハイライト */
.ps-type-table tbody tr:hover td {
  background-color: #f0f4f8 !important;
}

/* =========================================
   3. ヘッダー & 追従（Sticky）制御
========================================= */
.ps-type-table thead th {
  position: sticky;
  top: 0;
  background-color: var(--ps-dark);
  color: #ffffff;
  z-index: 10;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 10px 6px;
  border-bottom: 2px solid #0f172a;
}

.ps-stat-col {
  background-color: var(--ps-dark-sub) !important;
  min-width: 88px;
}

/* 固定1列目: No. */
.ps-type-table th:first-child,
.ps-type-table td.ps-no-col {
  position: sticky;
  left: 0;
  z-index: 6;
  min-width: 42px;
  width: 42px;
  background-color: #ffffff;
  color: #a0aec0;
  font-family: "Roboto Mono", Consolas, monospace;
  font-weight: bold;
}

/* 固定2列目: ポケモン名 */
.ps-type-table th:nth-child(2) {
  position: sticky;
  left: 42px;
  z-index: 20;
  background-color: var(--ps-dark);
  border-right: 2px solid #cbd5e1;
}

.ps-type-table td.ps-sticky-col {
  position: sticky;
  left: 42px;
  z-index: 5;
  min-width: 180px;
  background-color: #ffffff;
  border-right: 2px solid #cbd5e1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ps-pokemon-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.ps-pokemon-name {
  font-weight: 700;
  white-space: nowrap;
  color: var(--ps-dark);
}

/* 重なる左上ヘッダーの z-index 固定 */
.ps-type-table thead th:first-child {
  z-index: 30;
  background-color: var(--ps-dark);
}

.ps-type-table thead th:nth-child(2) {
  z-index: 25;
  background-color: var(--ps-dark);
  border-right: 2px solid #cbd5e1;
}

/* =========================================
   4. 相性記号・数値セル表現
========================================= */
.ps-badge-cell {
  width: 32px;
}

.ps-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.78rem;
  line-height: 1;
}

/* 4倍〜0倍の記号配色 */
.m-4 { background-color: #f59e0b; color: #fff; box-shadow: 0 1px 3px rgba(245,158,11,0.3); } 
.m-2 { background-color: #ef4444; color: #fff; box-shadow: 0 1px 3px rgba(239,68,68,0.3); } 
.m-1 { background-color: transparent; color: #94a3b8; font-weight: normal; } 
.m-0-5 { background-color: #10b981; color: #fff; } 
.m-0-25 { background-color: #059669; color: #fff; } 
.m-0 { background-color: #3b82f6; color: #fff; } 

.ps-stat-cell {
  white-space: nowrap;
  font-family: "Roboto Mono", Consolas, monospace;
}

.ps-stat-num {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ps-dark);
}

.ps-stat-rate {
  font-size: 0.72rem;
  color: #718096;
  margin-left: 2px;
}

/* =========================================
   5. タイプバッジ
========================================= */
.ps-type-col {
  min-width: 120px;
  text-align: center;
  white-space: nowrap;
}

.ps-type-badge {
  display: inline-block;
  padding: 3px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #ffffff;
  border-radius: 4px;
  margin: 1px;
  min-width: 52px;
  text-align: center;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

/* 公式風タイプカラー */
.type-ノーマル   { background-color: #9fa19f; }
.type-ほのお     { background-color: #e62829; }
.type-みず       { background-color: #2980ef; }
.type-でんき     { background-color: #fac000; color: #2d3748; box-shadow: none; }
.type-くさ       { background-color: #3fa129; }
.type-こおり     { background-color: #3dcef3; color: #2d3748; box-shadow: none; }
.type-かくとう   { background-color: #ff8000; }
.type-どく       { background-color: #9141cb; }
.type-じめん     { background-color: #915121; }
.type-ひこう     { background-color: #81b9ef; color: #2d3748; box-shadow: none; }
.type-エスパー   { background-color: #ef4179; }
.type-むし       { background-color: #91a119; }
.type-いわ       { background-color: #afa981; }
.type-ゴースト   { background-color: #704170; }
.type-ドラゴン   { background-color: #5060e1; }
.type-あく       { background-color: #50413f; }
.type-はがね     { background-color: #60a1b8; }
.type-フェアリー { background-color: #ef70ef; }

/* =========================================
   6. ツールチップ（補完タイプ表示）
========================================= */
.ps-has-tooltip {
  position: relative;
  cursor: help;
}

/* ポップアップ本体（視認性を高めた白カード風） */
.ps-has-tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  
  /* 配色・枠線・影の調整 */
  background-color: #ffffff !important; /* 白背景で確実に背景から孤立させる */
  color: #1a202c !important;           /* 濃いダークグレー文字でくっきり */
  border: 1px solid #cbd5e1;           /* 境界線 */
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  
  /* 影を強くして背景（ヘッダーなど）から完全に浮き立たせる */
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 9999; /* 重なり順を最前面に設定 */
  pointer-events: none;
}

/* 下向きの吹き出し矢印（白色） */
.ps-has-tooltip:hover::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 7px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent; /* 白い三角形 */
  
  /* 矢印の影風のフチ取り用 */
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1));
  z-index: 10000;
  pointer-events: none;
}

/* =========================================
   7. レスポンシブ微調整（スマホ向け）
========================================= */
@media screen and (max-width: 600px) {
  #ps-search-form {
    padding: 14px;
  }
  
  .ps-form-main-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .ps-form-field {
    flex-direction: column;
    align-items: flex-start;
  }

  #ps-search-form select {
    width: 100%;
  }

  .ps-submit-btn {
    width: 100%;
    padding: 12px;
  }
}