@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@100..900&family=Outfit:wght@100..900&display=swap');

/* 全体のスタイル */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* ライトテーマ（デフォルト） */
  --bg-color: #f5f5f5;
  --card-bg-color: #fff;
  --text-color: #333;
  --header-color: #2c3e50;
  --border-color: #e0e0e0;
  --button-color: #3498db;
  --button-hover-color: #2980b9;
  --button-text-color: #fff;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --highlight-color: #3498db;
  --secondary-text-color: #7f8c8d;
  --detail-item-bg: #e9f7fe;
  --detail-item-color: #2980b9;
  --header-bg-color: #fff;
  --fontweght-bold : 600;
}

/* ダークテーマ */
.theme-dark {
  --bg-color: #1a1a2e;
  --card-bg-color: #16213e;
  --text-color: #e0e0e0;
  --header-color: #e0e0e0;
  --border-color: #2c3e50;
  --button-color: #2c3e50;
  --button-hover-color: #1a1a2e;
  --button-text-color: #e0e0e0;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --highlight-color: #3498db;
  --secondary-text-color: #95a5a6;
  --detail-item-bg: #2c3e50;
  --detail-item-color: #3498db;
  --header-bg-color: #16213e;
}

/* グリーンテーマ */
.theme-outdoors {
  --bg-color: #f0f7ee;
  --card-bg-color: #fff;
  --text-color: #2c3e50;
  --header-color: #2c3e50;
  --border-color: #d1e7dd;
  --button-color: #27ae60;
  --button-hover-color: #219653;
  --button-text-color: #fff;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --highlight-color: #27ae60;
  --secondary-text-color: #7f8c8d;
  --detail-item-bg: #d1e7dd;
  --detail-item-color: #219653;
  --header-bg-color: #fff;
}

/* 衛星テーマ */
.theme-satellite {
  --bg-color: #1a1a2e;
  --card-bg-color: #2c3e50;
  --text-color: #e0e0e0;
  --header-color: #e0e0e0;
  --border-color: #34495e;
  --button-color: #8e44ad;
  --button-hover-color: #6c3483;
  --button-text-color: #fff;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --highlight-color: #8e44ad;
  --secondary-text-color: #bdc3c7;
  --detail-item-bg: #34495e;
  --detail-item-color: #9b59b6;
  --header-bg-color: #2c3e50;
}

body {
    font-family: 'Outfit', 'Noto Sans Japanese', sans-serif;
    font-weight: 300;
    font-style: normal;
    font-optical-sizing: auto;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ヘッダー */
header {
  text-align: center;
  padding: 20px 0;
  background-color: var(--header-bg-color);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 2px 5px var(--shadow-color);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* ロゴコンテナ */
.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  /* margin-bottom: 10px; */
}

.header-logo {
  height: 40px;
  width: auto;
}

header h1 {
  font-weight: 600;
  color: var(--header-color);
  transition: color 0.3s ease;
}

.header-controls {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* テーマコントロール */
.theme-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 10px;
}

.theme-button {
  background-color: #95a5a6;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.3s ease;
  flex: 1;
  min-width: 80px;
  max-width: 120px;
}

.theme-button:hover {
  opacity: 0.9;
}

.theme-button.active {
  background-color: #2c3e50;
  font-weight: var(--fontweght-bold);
}

/* カテゴリフィルターボタン */
.category-filter {
  margin: 10px 0;
}

.category-filter label {
  display: block;
  margin-bottom: 8px;
  font-weight: var(--fontweght-bold);
}

.category-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.category-button {
  background-color: #95a5a6;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  opacity: 0.6;
  transition: all 0.3s ease;
  flex: 1;
  min-width: 80px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.category-button:hover {
  opacity: 0.8;
}

.category-button.active {
  opacity: 1;
  font-weight: var(--fontweght-bold);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* カテゴリー別の色 */
#category-power {
  background-color: #ea3323;
}

#category-battery {
  background-color: #334bff;
}

#category-other {
  background-color: #27ae60;
}

/* アクティブ状態を示すインジケーター */
.category-button::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  background-color: #fff;
  border-radius: 50%;
  width: 10px;
  height: 10px;
  margin: 5px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.category-button.active::after {
  opacity: 1;
}

#theme-light {
  background-color: #3498db;
}

#theme-dark {
  background-color: #2c3e50;
}

#theme-outdoors {
  background-color: #27ae60;
}

#theme-satellite {
  background-color: #8e44ad;
}

/* メインコンテンツ */
.content {
  display: flex;
  flex: 1;
  gap: 20px;
  margin-bottom: 20px;
}

/* 検索結果リスト */
.search-results {
  background-color: var(--card-bg-color);
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow-color);
  margin: 10px 0 20px;
  padding: 15px;
  position: relative;
  max-height: 300px;
  overflow-y: auto;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.search-results h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: var(--header-color);
  padding-right: 30px;
  transition: color 0.3s ease;
}

.results-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--secondary-text-color);
  transition: color 0.3s ease;
}

.results-close:hover {
  color: #e74c3c;
}

.search-results ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.result-item {
  padding: 10px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s;
}

.result-item:last-child {
  border-bottom: none;
}

.result-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.result-name {
  font-weight: var(--fontweght-bold);
  color: var(--header-color);
  margin-bottom: 3px;
  transition: color 0.3s ease;
}

.result-address {
  font-size: 0.9em;
  color: var(--secondary-text-color);
  transition: color 0.3s ease;
}

/* サイドバー */
.sidebar {
  flex: 0 0 350px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 入力セクションと保存された場所 */
.input-section,
.saved-locations,
.spreadsheet-section,
.json-section,
.hazard-map-section {
  background-color: var(--card-bg-color);
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow-color);
  /* margin-bottomを削除 - sidebarのgapで間隔を取るため */
  padding: 15px;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* 保存された場所セクションがサイドバー内で拡張するように */
.saved-locations {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* 保存された場所のリストが利用可能なスペースを最大限使用 */
.saved-locations #locations-list {
  flex: 1;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  color: var(--header-color);
  font-weight: var(--fontweght-bold);
  transition: color 0.3s ease;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: border-color 0.3s ease, background-color 0.3s ease,
    color 0.3s ease;
}

button {
  background-color: var(--button-color);
  color: var(--button-text-color);
  border: none;
  padding: 10px 15px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  transition: background-color 0.3s ease, color 0.3s ease;
}

button:hover {
  background-color: var(--button-hover-color);
}

.control-button {
  background-color: var(--button-color);
  color: var(--button-text-color);
  font-size: 0.9em;
  padding: 8px 12px;
}

.control-button:hover {
  background-color: var(--button-hover-color);
}

.locations-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.locations-controls button {
  padding: 5px 10px;
  font-size: 0.8em;
}

/* 都道府県フィルター */
.prefecture-filter {
  margin: 10px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.prefecture-filter label {
  font-size: 0.9em;
  color: var(--text-color);
}

.prefecture-filter select {
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--card-bg-color);
  color: var(--text-color);
  font-size: 0.9em;
  flex-grow: 1;
}

/* 保存された場所のリスト */
#locations-list {
  list-style: none;
  padding: 0;
  margin: 10px 0;
  max-height: calc(100vh - 687px);
  min-height: 300px;
  overflow-y: auto;
}

#locations-list li {
  padding: 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s;
}

#locations-list li:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.location-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-color);
  transition: color 0.3s ease;
}

/* JSONデータの場所リスト用スタイル */
.json-location {
  flex-direction: column;
  align-items: flex-start;
}

.location-info {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-bottom: 8px;
}

.location-name {
  font-weight: var(--fontweght-bold);
  margin-bottom: 4px;
}

.location-address {
  font-size: 0.9em;
  color: var(--secondary-text-color);
}

.location-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
}

.location-detail-button,
.location-show-button {
  padding: 4px 8px;
  font-size: 0.8em;
  background-color: var(--button-color);
  color: var(--button-text-color);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.location-detail-button:hover,
.location-show-button:hover {
  background-color: var(--button-hover-color);
}

.delete-btn {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 1.2em;
  padding: 0 5px;
  transition: color 0.2s;
}

.delete-btn:hover {
  color: #c0392b;
}

/* 地図コンテナ */
.map-container {
  flex: 1;
  height: calc(100vh - 128px) !important;
  /* min-height: 300px; */
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px var(--shadow-color);
  transition: box-shadow 0.3s ease;
  height: calc(100vh - 250px); /* 画面の高さから余白を引いた値 */
}

#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

/* フッター */
footer {
  text-align: center;
  padding: 15px 0;
  color: var(--secondary-text-color);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  transition: color 0.3s ease, border-color 0.3s ease;
}

/* スプレッドシート関連 */
.spreadsheet-section {
  margin-top: 0;
}

.spreadsheet-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.spreadsheet-info {
  font-size: 0.9em;
  color: var(--secondary-text-color);
  margin-top: 10px;
  transition: color 0.3s ease;
}

#loading-indicator {
  color: var(--highlight-color);
  font-weight: var(--fontweght-bold);
  margin-top: 5px;
  transition: color 0.3s ease;
}

/* スプレッドシートマーカー */
.spreadsheet-marker {
  width: 20px;
  height: 20px;
  background-color: #e74c3c;
  border-radius: 50%;
  border: 2px solid white;
  cursor: pointer;
}

/* 設定ダイアログ */
.settings-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--card-bg-color);
  border-radius: 8px;
  box-shadow: 0 5px 15px var(--shadow-color);
  width: 90%;
  max-width: 500px;
  z-index: 1000;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.dialog-header h3 {
  margin: 0;
  color: var(--header-color);
  transition: color 0.3s ease;
}

.dialog-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--secondary-text-color);
  transition: color 0.3s ease;
}

.dialog-close:hover {
  color: #e74c3c;
}

.dialog-content {
  padding: 20px;
}

.dialog-info {
  background-color: var(--bg-color);
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 15px;
  font-size: 0.9em;
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.primary-button {
  background-color: var(--highlight-color);
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.primary-button:hover {
  background-color: var(--button-hover-color);
}

/* ポップアップスタイル */
.popup-content {
  padding: 5px;
}

.popup-content h3 {
  margin: 0 0 5px 0;
  font-size: 16px;
  color: var(--header-color);
  transition: color 0.3s ease;
}

.popup-content p {
  margin: 5px 0;
  font-size: 14px;
  color: var(--secondary-text-color);
  transition: color 0.3s ease;
}

/* JSONファイル関連 */
.json-section {
  margin-top: 0;
  display: none; /* JSONファイル読み込みセクションを非表示に */
}

.json-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.json-controls .form-group {
  margin-bottom: 10px;
}

.json-controls select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: border-color 0.3s ease, background-color 0.3s ease,
    color 0.3s ease;
}

.json-info {
  font-size: 0.9em;
  color: var(--secondary-text-color);
  margin-top: 10px;
  transition: color 0.3s ease;
}

.json-note {
  font-size: 0.8em;
  color: var(--secondary-text-color);
  font-style: italic;
  margin-top: 5px;
  transition: color 0.3s ease;
}

/* 物件詳細モーダル */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.property-modal {
  background-color: var(--card-bg-color);
  border-radius: 8px;
  padding: 20px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  position: relative;
  transform: translateY(-20px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal-overlay.active .property-modal {
  transform: translateY(0);
  opacity: 1;
}

.property-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.property-modal h3 {
  margin: 0;
  color: var(--header-color);
  font-size: 1.2em;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: var(--secondary-text-color);
}

.modal-close:hover {
  color: #e74c3c;
}

.property-modal .modal-content {
  margin-bottom: 15px;
}

.property-modal .detail-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.property-modal .detail-item {
  background-color: var(--detail-item-bg);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--detail-item-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* 従来の物件詳細表示（サイドバー用）は残しておく */
.property-detail {
  background-color: var(--bg-color);
  padding: 15px;
  border-radius: 8px;
  margin-top: 15px;
  font-size: 0.9em;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  border-left: 4px solid var(--highlight-color);
  transition: background-color 0.3s ease, border-left-color 0.3s ease;
  display: none; /* デフォルトで非表示に */
}

.property-detail h3 {
  margin-top: 0;
  color: var(--header-color);
  margin-bottom: 10px;
  transition: color 0.3s ease;
}

.property-detail p {
  margin: 5px 0;
}

.property-detail .detail-items {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.property-detail .detail-item {
  background-color: var(--detail-item-bg);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--detail-item-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* JSONマーカー */
.json-marker {
  width: 24px;
  height: 24px;
  background-color: #27ae60;
  border-radius: 50%;
  border: 2px solid white;
  cursor: pointer;
  transition: opacity 200ms ease-in-out;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* パワーマーカー（発電所） */
.power-marker {
  background-color: transparent;
  border: none;
}

/* バッテリーマーカー（蓄電所） */
.battery-marker {
  background-color: transparent;
  border: none;
}

/* SVGアイコンのスタイル */
.json-marker img {
  width: 24px;
  height: 24px;
}

/* マーカーのフェードイン・アウト用クラス */
.marker-fade-in {
  opacity: 1;
}

.marker-fade-out {
  opacity: 0;
}

/* クラスターマーカーのスタイル */
.mapboxgl-cluster-marker {
  background-color: #51bbd6;
  border-radius: 50%;
  border: 2px solid white;
  color: white;
  text-align: center;
  font-weight: var(--fontweght-bold);
  font-family: "Arial", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* クラスターマーカーのホバー効果 */
.mapboxgl-cluster-marker:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transform: scale(1.05);
  transition: all 0.2s ease;
}

/* クラスターカウントスタイル */
.cluster-count {
  font-size: 14px;
  line-height: 1;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
  .content {
    flex-direction: column;
  }

  .sidebar {
    flex: none;
    width: 100%;
  }

  .map-container {
    height: calc(100vh - 300px); /* 小さい画面ではさらに調整 */
    min-height: 300px;
  }

  #map {
    min-height: 300px;
  }

  .locations-controls {
    flex-direction: column;
  }

  .locations-controls button {
    width: 100%;
  }

  .theme-controls {
    flex-wrap: wrap;
  }

  .theme-button {
    flex: 1 0 40%;
    margin-bottom: 5px;
  }
}

/* さらに小さい画面用 */
@media (max-width: 480px) {
  .map-container {
    height: calc(100vh - 350px);
    min-height: 250px;
  }

  #map {
    min-height: 250px;
  }

  /* ヘッダーを簡素化 */
  header h1 {
    font-size: 1.5em;
  }

  header p {
    font-size: 0.9em;
  }
}

/* ハザードマップセクション */
.hazard-map-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hazard-map-section h2 {
  color: var(--header-color);
  margin-bottom: 10px;
  font-size: 1.2em;
  transition: color 0.3s ease;
}

.hazard-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 液状化ハザードマップボタンを非表示 */
.hazard-toggle:has(#liquefaction-toggle) {
  display: none;
}

/* 古いブラウザ向けの互換性対策 */
label[for="liquefaction-toggle"],
.hazard-toggle:nth-of-type(4) {
  display: none;
}

.hazard-toggle {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 4px;
  background-color: var(--card-bg-color);
  border: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

.hazard-toggle:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.hazard-toggle label {
  display: flex;
  align-items: center;
  cursor: pointer;
  width: 100%;
  font-size: 0.95em;
  color: var(--text-color);
}

.hazard-toggle input[type="checkbox"] {
  margin-right: 10px;
  cursor: pointer;
}

.hazard-info {
  margin-top: 8px;
}

.hazard-note {
  font-size: 0.8em;
  color: var(--secondary-text-color);
  font-style: italic;
}

.header-controls {
  display: none;
}
