/* 全体を横並びに */
body {
  margin: 0;
  display: flex;
  height: 100vh;
  /* デフォルトはPCの横並び */
}

/* 左：地図エリア */
#mapcontainer {
  flex: 1;
  position: relative;
}

/* サイドバーはデフォルトで左上に絶対配置 */
#sidebar {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 270px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  padding: 12px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
  color: #333;
  z-index: 10; /* 地図の上に表示するため */
}

/* 右：検索結果パネル */
#table-panel {
  width: 320px;
  background: #fff;
  border-left: 1px solid #aaa;
  overflow-y: auto;
  padding: 10px;
  font-size: 12px;
  /* スクロールを有効にするため、heightを100vhから調整する必要があるが、ここではシンプルに */
}

/* インフォボタンの位置調整 */
#info-button {
  position: absolute;
  top: 10px;
  left: 320px; /* #sidebar の右上外側あたり */
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: #1976d2;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  z-index: 10; /* 地図の上に表示するため */
}

#info-button:hover {
  transform: scale(1.1);
}

/*
==================================================
レスポンシブ対応（最大画面幅768px）
スマートフォン・タブレット向けレイアウト
==================================================
*/
@media (max-width: 768px) {
  /* 全体を縦並び（1カラム）に */
  body {
    flex-direction: column;
    height: auto; /* 縦スクロールを許可 */
    min-height: 100vh; /* 画面の高さは最低限確保 */
  }

  /* 地図エリア */
  #mapcontainer {
    /* 地図の高さは固定値またはビューポート比率で指定 */
    height: 60vh; /* 例として画面の高さの60% */
    flex: none; /* Flexboxの比率を解除 */
    width: 100%; /* 幅いっぱいに */
    order: 1; /* 縦並びの1番目 */
  }

  /* サイドバー */
  #sidebar {
    position: relative; /* 絶対配置から相対配置に変更 */
    top: auto;
    left: auto;
    width: auto; /* 幅を自動調整（padding込みで100%近くになる） */
    margin: 10px; /* 余白を追加 */
    box-shadow: none; /* シャドウを削除または軽減 */
    order: 2; /* 縦並びの2番目 */
  }

  /* 検索結果パネル */
  #table-panel {
    width: auto; /* 幅を自動調整 */
    border-left: none; /* 左側のボーダーを削除 */
    border-top: 1px solid #aaa; /* 上側にボーダーを追加 */
    order: 3; /* 縦並びの3番目 */
  }

  /* インフォボタン */
  #info-button {
    /* スマートフォンではサイドバーに隠れるため、位置を調整または非表示にする */
    /* 今回は地図エリアの上に移動し、画面右上に固定 */
    left: 10px;
    right: auto;
    top: 10px;
    z-index: 11;
  }
}


/* 既存のスタイル */

/* 検索フォーム */
#search-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

#search-controls {
  display: flex;
  gap: 8px;
}

#search-input {
  flex: 1; /* 残りのスペースを埋める */
  min-width: 50%; /* 少なくとも50%の幅を確保 */
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

#search-form button {
  padding: 6px;
  background: #1976d2;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
#search-form button:hover {
  background: #125a9c;
}

/* プルダウンメニューのスタイル */
#search-mode {
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: white;
  font-size: 14px;
  color: #333;
  width: auto;
}

/* セクション区切り */
.section-divider {
  margin: 10px 0;
  border: none;
  border-top: 1px solid #ccc;
}

/* トグル */
.toggle-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 16px 0;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.toggle input[type="checkbox"] {
  appearance: none;
  width: 40px;
  height: 20px;
  background-color: #ccc;
  border-radius: 20px;
  position: relative;
  outline: none;
  transition: background-color 0.2s;
}

.toggle input[type="checkbox"]::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: white;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}

.toggle input[type="checkbox"]:checked {
  background-color: #1976d2;
}

.toggle input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

.label-text {
  font-size: 0.9rem;
}

.toggle-hidden {
  display: none
}

/* 凡例 */
#legend {
  border-top: 1px solid #ddd;
  padding-top: 10px;
}

.legend-section {
  margin-bottom: 8px;
}

.legend-title {
  font-weight: bold;
  margin-bottom: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.legend-color {
  width: 18px;
  height: 18px;
  border: 1px solid #ccc;
  margin-right: 6px;
}

/*検索結果なし */
.no-results {
  padding: 10px;
  background-color: #f8d7da;
  color: red;
  text-align: center;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  font-size: 14px;
}

/* 検索切り替え */
/* 横並びレイアウト（3つ以下） */
.legend-switch-horizontal {
  display: flex;
  justify-content: left;
  margin: 12px 0 6px 0;
  font-size: 13px;
  width: 100%;
  gap: 4px; /* ← ボタン間の間隔を追加 */
}

.legend-switch-horizontal input[type="radio"] {
  display: none;
}

.legend-switch-horizontal label {
  flex: 1 1 auto;
}

.legend-switch-horizontal span {
  display: block;
  padding: 4px 12px;
  border: 1px solid #4287f5;
  cursor: pointer;
  background: #fff;
  font-size: 13px;
  transition: all 0.2s ease;
  text-align: center;
  border-radius: 6px; /* ← すべて角丸に */
}

/* 選択時 */
.legend-switch-horizontal input[type="radio"]:checked + span {
  background: #4287f5;
  color: white;
  border-color: #4287f5;
}

/* ホバー時 */
.legend-switch-horizontal span:hover {
  background: #ccc;
}

/* 2列レイアウト（4つ以上） */
.legend-switch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 12px 0 6px 0;
  font-size: 13px;
  width: 100%;
  gap: 4px; /* ← 各ボタンの間にスペース */
}

.legend-switch-grid input[type="radio"] {
  display: none;
}

.legend-switch-grid label {
  display: block;
}

.legend-switch-grid span {
  display: block;
  padding: 4px 12px;
  border: 1px solid #1976d2;
  cursor: pointer;
  background: #fff;
  font-size: 13px;
  transition: all 0.2s ease;
  text-align: center;
  border-radius: 6px; /* ← すべて角丸 */
}

/* 選択時 */
.legend-switch-grid input[type="radio"]:checked + span {
  background: #4287f5;
  color: white;
  border-color: #4287f5;
}

/* ホバー時 */
.legend-switch-grid span:hover {
  background: #ccc;
}


/* タブ */
.tab-header {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0 0 1em 0;
}

.tab {
  cursor: pointer;
  padding: 0.5em 1em;
  border-radius: 6px;
  font-size: 13px;
  background:#fff;
  border: 1px solid #888;
  margin-right: 0.5em;
}

.tab:hover {
  background: #ccc; 
}
.tab.active {
  background-color: #4287f5; 
  color: white;
  font-size: 13px;
  border-radius: 6px;
}

.tab-contents {
  border: none; /*1px solid #888;*/
  padding: 0;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* 見出し */
#table-panel h3 {
  margin-top: 0;
  font-size: 15px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 2px;
}

#table-panel h4 {
  margin-top: 0;
  margin-bottom: 4px;
  font-size: 14px;
}

/* テーブル共通スタイル */
.result-table {
  border-collapse: collapse;
  width: 100%;
}

.result-table td {
  border: 1px solid #ccc;
  padding: 4px 6px;
  text-align: left;
}

.result-table th {
  border: 1px solid #ccc;
  background-color: #1976d2;
  color: #fff;
}

/* ローディングアイコン */
.spinner {
  display: none;
  width: 10px;
  height: 10px;
  border: 5px solid #1976d2;       /* 輪っかのベース */
  border-top: 5px solid #ddd;   /* 回転して見える部分の色 */
  border-radius: 50%;           /* 丸くする */
  animation: spin 1s linear infinite; /* 回転アニメーション */
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}