/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: #fff;
  color: #333;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ===== Control Bar ===== */
#control-bar {
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

#control-bar h1 {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.header-subtitle {
  font-size: 11px;
  font-weight: 400;
  color: #888;
  margin-left: 4px;
}

.header-link {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: #e91e63;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.header-link:hover {
  background: #c2185b;
}

.controls {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.control-group label {
  font-size: 13px;
  color: #666;
  white-space: nowrap;
}

#threshold-select {
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.control-toggles {
  gap: 10px;
}

.toggle-label {
  font-size: 13px;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.toggle-label input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.toggle-icon {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.lh-dot {
  background: #e91e63;
}

.rr-dot {
  background: #7c4dff;
}

#walk-filter {
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

#search-input {
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 200px;
}

/* ===== Search Results Dropdown ===== */
#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 4px 4px;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  display: none;
  z-index: 2000;
  min-width: 260px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#search-results.active {
  display: block;
}

#search-results li {
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}

#search-results li:last-child {
  border-bottom: none;
}

#search-results li:hover {
  background: #f0f4ff;
}

#search-results li .line-name {
  color: #888;
  font-size: 11px;
  margin-left: 6px;
}

/* ===== Map ===== */
#map {
  flex: 1;
  min-height: 0;
}

/* ===== Popup ===== */
.station-popup table {
  font-size: 13px;
  border-collapse: collapse;
}

.station-popup th {
  text-align: left;
  padding: 2px 8px 2px 0;
  color: #666;
  font-weight: normal;
  white-space: nowrap;
}

.station-popup td {
  padding: 2px 0;
}

.station-popup .ridership-value {
  font-weight: 600;
  color: #1a73e8;
}

/* ===== Love Hotel Markers ===== */
.lh-icon {
  background: none;
  border: none;
}

.lh-marker {
  width: 20px;
  height: 20px;
  background: #e91e63;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.rr-icon {
  background: none;
  border: none;
}

.rr-marker {
  width: 20px;
  height: 20px;
  background: #7c4dff;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.lovehotel-popup .lh-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.lovehotel-popup .lh-info {
  font-size: 12px;
  color: #555;
  line-height: 1.6;
}

.lovehotel-popup .lh-distance {
  color: #e65100;
  font-weight: 600;
}

.lovehotel-popup .lh-rating {
  color: #f9a825;
}

/* ===== Spot City Tabs ===== */
.spot-city-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border-bottom: 2px solid #e8eaed;
}

.spot-city-btn {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #888;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
}

.spot-city-btn:hover {
  color: #555;
}

.spot-city-btn.active {
  color: #e91e63;
  border-bottom-color: #e91e63;
}

.spot-city-pane {
  display: none;
}

.spot-city-pane.active {
  display: block;
}


/* ===== Data Source Footer ===== */
#data-source {
  background: #f8f8f8;
  border-top: 1px solid #eee;
  padding: 4px 16px;
  font-size: 11px;
  color: #999;
  text-align: center;
}

#data-source a {
  color: #888;
  text-decoration: underline;
}

/* ===== Legend ===== */
.legend {
  background: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  font-size: 12px;
  line-height: 1;
}

.legend-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 8px;
  color: #333;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-circle {
  display: inline-block;
  border-radius: 50%;
  opacity: 0.7;
  flex-shrink: 0;
}

.legend-label {
  color: #555;
  white-space: nowrap;
}

/* ===== Table Panel ===== */
#table-panel {
  border-top: 1px solid #ddd;
  background: #fff;
  z-index: 1000;
}

#table-toggle {
  display: block;
  width: 100%;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  background: #f8f8f8;
  border: none;
  cursor: pointer;
  text-align: center;
}

#table-toggle:hover {
  background: #eee;
}

#table-tabs {
  display: none;
  gap: 0;
  border-bottom: 2px solid #e8eaed;
  padding: 0 16px;
  background: #fafafa;
}

#table-tabs.active {
  display: flex;
}

.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #888;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #555;
}

.tab-btn.active {
  color: #1a73e8;
  border-bottom-color: #1a73e8;
}

.tab-btn-expand {
  margin-left: auto;
  padding: 6px 12px;
  font-size: 12px;
  color: #1a73e8;
  background: none;
  border: 1px solid #1a73e8;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn-expand:hover {
  background: #e8f0fe;
}

#table-content {
  display: none;
  max-height: 40vh;
  overflow-y: auto;
  padding: 0 16px 16px;
}

@media (max-width: 600px) {
  #table-content {
    max-height: 60vh;
  }
}

#table-content.active {
  display: block;
}

/* Full screen mode */
body.table-fullscreen #map,
body.table-fullscreen #data-source,
body.table-fullscreen .legend {
  display: none;
}

body.table-fullscreen #table-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.table-fullscreen #table-content {
  max-height: none;
  flex: 1;
  min-height: 0;
}

body.table-fullscreen #table-content.active {
  display: block;
  overflow-y: auto;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Capital ranking specific */
.capital-rank {
  font-size: 12px;
  color: #999;
  width: 30px;
  text-align: right;
}

.capital-bar-cell {
  width: 40%;
}

.capital-bar {
  height: 14px;
  border-radius: 2px;
  min-width: 2px;
}

.capital-comment {
  font-size: 11px;
  color: #999;
  font-style: italic;
}

.region-section {
  margin-bottom: 16px;
}

.region-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: #1a73e8;
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 2px solid #e8eaed;
}

.region-section .region-summary {
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
}

.region-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.region-table th {
  text-align: left;
  padding: 4px 8px;
  background: #f5f5f5;
  color: #666;
  font-weight: 600;
  border-bottom: 1px solid #ddd;
  white-space: nowrap;
}

.region-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #eee;
}

.region-table tr:hover td {
  background: #f0f4ff;
}

.region-table .ridership-cell {
  text-align: right;
  font-weight: 600;
  color: #1a73e8;
}

.region-table .clickable-row {
  cursor: pointer;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  #control-bar {
    padding: 10px 10px;
    gap: 8px;
  }

  .header-left {
    width: 100%;
    gap: 6px;
  }

  #control-bar h1 {
    font-size: 13px;
  }

  .header-link {
    padding: 3px 8px;
    font-size: 11px;
  }

  .controls {
    width: 100%;
    gap: 6px;
    flex-wrap: wrap;
  }

  .control-group {
    min-width: 0;
  }

  /* 閾値セレクト */
  #threshold-select {
    padding: 6px 8px;
    font-size: 13px;
  }

  /* トグル: ラベルテキスト非表示、アイコン+チェックのみ */
  .control-toggles {
    gap: 8px;
  }

  .toggle-text {
    display: none;
  }

  .toggle-label {
    font-size: 12px;
    gap: 2px;
  }

  .toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }

  .toggle-icon {
    width: 12px;
    height: 12px;
  }

  /* 徒歩フィルタ */
  #walk-filter {
    padding: 6px 8px;
    font-size: 13px;
  }

  /* 検索 */
  .control-search {
    flex: 1;
  }

  #search-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 14px;
  }

  /* テーブル */
  .region-table th:nth-child(3),
  .region-table td:nth-child(3) {
    display: none;
  }

  .hide-sp {
    display: none;
  }

  .region-table {
    font-size: 12px;
  }

  .region-table th,
  .region-table td {
    padding: 3px 4px;
  }

  .region-table .ridership-cell {
    white-space: nowrap;
  }

  #table-tabs {
    padding: 0 4px;
    flex-wrap: wrap;
    gap: 0;
  }

  .tab-btn {
    padding: 6px 6px;
    font-size: 10px;
  }

  .tab-btn-expand {
    padding: 4px 6px;
    font-size: 10px;
  }

  /* 出典フッター */
  #data-source {
    padding: 3px 8px;
    font-size: 10px;
  }

  /* ポップアップ */
  .station-popup table {
    font-size: 12px;
  }

  .lovehotel-popup .lh-name {
    font-size: 13px;
  }

  .lovehotel-popup .lh-info {
    font-size: 11px;
  }

  /* おすすめ駅タブ */
  .spot-city-tabs {
    margin-bottom: 8px;
  }

  .spot-city-btn {
    padding: 5px 10px;
    font-size: 12px;
  }
}
