/* ============================================================
   不動産マップ検索 — スタイルシート
   ============================================================ */

/* --- リセット & ベース --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    "Yu Gothic", "Meiryo", sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
}

/* --- ヘッダー --- */
.app-header {
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
  color: #fff;
  padding: 16px 24px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.app-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
}
.app-header .subtitle {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-top: 4px;
}

/* --- レイアウト --- */
.app-container {
  display: flex;
  height: calc(100vh - 80px);
  overflow: hidden;
}

/* --- サイドバー --- */
.sidebar {
  width: 320px;
  min-width: 280px;
  background: #fff;
  border-right: 1px solid #dfe3e8;
  overflow-y: auto;
  padding: 16px;
  flex-shrink: 0;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #1a73e8;
}
.filter-header h2 {
  font-size: 1.1rem;
  color: #1a73e8;
}

.btn-reset {
  background: #e8eaed;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-reset:hover {
  background: #dadce0;
}

/* --- フィルターグループ --- */
.filter-group {
  margin-bottom: 16px;
}

.filter-label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: #444;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 3px 0;
  white-space: nowrap;
}
.checkbox-group input[type="checkbox"] {
  accent-color: #1a73e8;
}
.checkbox-group-compact label {
  font-size: 0.78rem;
  padding: 1px 0;
  min-width: 60px;
}
#zoneTypeCheckboxes {
  max-height: 150px;
  overflow-y: auto;
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.range-inputs input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.82rem;
}
.range-inputs span {
  font-size: 0.85rem;
  color: #888;
}

.filter-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.82rem;
  background: #fff;
}

.filter-count {
  text-align: center;
  padding: 10px;
  background: #e8f0fe;
  border-radius: 8px;
  font-weight: 600;
  color: #1a73e8;
  font-size: 0.9rem;
  margin-top: 12px;
}

/* --- メインコンテンツ --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- マップ --- */
.map-container {
  height: 50%;
  min-height: 300px;
  border-bottom: 2px solid #dfe3e8;
}

/* --- 物件一覧ヘッダー --- */
.property-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
}
.property-list-header h2 {
  font-size: 1rem;
  color: #333;
}
.sort-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
}
.sort-controls select {
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.82rem;
  background: #fff;
}

/* --- 物件一覧 --- */
.property-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  align-content: start;
}

/* --- 建物カード --- */
.building-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s, transform 0.15s;
  border-top: 4px solid #1a73e8;
  display: flex;
  flex-direction: column;
}
.building-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  transform: translateY(-2px);
}
.building-card.highlight {
  border-top-color: #ff6b35;
  box-shadow: 0 0 0 2px #ff6b35, 0 4px 16px rgba(255, 107, 53, 0.25);
}
.building-card[data-type="マンション"] {
  border-top-color: #1a73e8;
}
.building-card[data-type="一戸建て"] {
  border-top-color: #34a853;
}
.building-card[data-type="土地"] {
  border-top-color: #f9ab00;
}
.building-card.building-delisted {
  border-top-color: #bdbdbd;
  opacity: 0.7;
  background: #f5f5f5;
}
.building-card.building-delisted:hover {
  opacity: 0.85;
}

/* --- 建物ヘッダー --- */
.building-header {
  padding: 10px;
  cursor: pointer;
  flex: 1;
}
.building-title-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.building-name {
  font-weight: 700;
  font-size: 0.82rem;
  color: #1a237e;
  flex: 1;
  min-width: 0;
  word-break: break-all;
}
.listing-count-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
}
.listing-count-badge.active { background: #2e7d32; }
.listing-count-badge.delisted { background: #9e9e9e; }
.building-price-range {
  font-size: 0.85rem;
  font-weight: 700;
  color: #d32f2f;
  margin-bottom: 3px;
}
.building-address {
  font-size: 0.78rem;
  color: #555;
  margin-bottom: 2px;
}
.building-spec {
  font-size: 0.78rem;
  color: #555;
  margin-bottom: 2px;
}
.building-station {
  font-size: 0.78rem;
  color: #555;
  margin-bottom: 2px;
}
.building-mgmt {
  font-size: 0.72rem;
  color: #888;
  margin-top: 2px;
}
.library-link {
  display: inline-block;
  font-size: 0.72rem;
  margin-top: 4px;
  padding: 2px 8px;
  background: #1565c0;
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
}
.library-link:hover {
  background: #0d47a1;
}

/* --- 売出物件一覧 --- */
.building-listings {
  border-top: 1px solid #eee;
}
.listings-toggle {
  padding: 8px 14px;
  font-size: 0.78rem;
  color: #555;
  cursor: pointer;
  background: #f9fafb;
  user-select: none;
}
.listings-toggle:hover {
  background: #f0f1f3;
}
.listings-body {
  display: none;
}
.listings-body.open {
  display: block;
}

/* --- 個別リスティング --- */
.listing-item {
  padding: 10px 14px;
  border-top: 1px solid #f0f0f0;
}
.listing-item.delisted {
  opacity: 0.65;
  background: #fafafa;
}
.listing-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.listing-spec {
  font-size: 0.82rem;
  font-weight: 600;
  color: #333;
  flex: 1;
  min-width: 0;
}
.listing-price {
  font-size: 1rem;
  font-weight: 700;
  color: #d32f2f;
  white-space: nowrap;
}
.listing-price .unit {
  font-size: 0.7rem;
  font-weight: 400;
  color: #888;
}
.listing-status {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  color: #fff;
  white-space: nowrap;
}
.listing-status.active { background: #2e7d32; }
.listing-status.delisted { background: #9e9e9e; }
.listing-meta {
  font-size: 0.72rem;
  color: #757575;
}
.listing-period-inline {
  font-size: 0.72rem;
  color: #757575;
}
.listing-costs {
  font-size: 0.75rem;
  color: #795548;
  margin: 2px 0;
}
.listing-equipment {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
}
.equipment-tag-sm {
  display: inline-block;
  font-size: 0.65rem;
  padding: 1px 5px;
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 8px;
  white-space: nowrap;
}
.suumo-link-sm {
  font-size: 0.68rem;
  padding: 1px 5px;
  background: #43a047;
  color: #fff;
  border-radius: 3px;
  text-decoration: none;
  white-space: nowrap;
}
.suumo-link-sm:hover {
  background: #2e7d32;
}

/* --- ポップアップ リスティング一覧 --- */
.popup-listings {
  margin-top: 6px;
  border-top: 1px solid #eee;
  padding-top: 4px;
}
.popup-listing-row {
  font-size: 0.75rem;
  color: #333;
  padding: 1px 0;
}
.popup-listing-more {
  font-size: 0.72rem;
  color: #999;
  font-style: italic;
}

/* --- タイプバッジ --- */
.card-type {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.card-type.mansion {
  background: #e3f2fd;
  color: #1565c0;
}
.card-type.house {
  background: #e8f5e9;
  color: #2e7d32;
}
.card-type.land {
  background: #fff8e1;
  color: #f57f17;
}
.card-type.rental {
  background: #fce4ec;
  color: #c2185b;
}

/* --- Leaflet ポップアップカスタム --- */
.leaflet-popup-content {
  font-family: inherit;
  line-height: 1.5;
}
.popup-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: #1a237e;
  margin-bottom: 4px;
}
.popup-price {
  font-size: 1rem;
  font-weight: 700;
  color: #d32f2f;
}
.popup-info {
  font-size: 0.78rem;
  color: #555;
  margin-top: 4px;
}

/* --- カード画像 --- */
.building-image {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  border-radius: 6px 6px 0 0;
}
.building-image-placeholder {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #bbb;
  border-radius: 6px 6px 0 0;
}
.building-image-placeholder.mansion {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
}
.building-image-placeholder.house {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}
.building-image-placeholder.land {
  background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
}
.building-image-placeholder.rental {
  background: linear-gradient(135deg, #fce4ec 0%, #f8bbd0 100%);
}

/* --- 現在地ボタン --- */
.locate-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  width: 36px;
  height: 36px;
  background: #fff;
  border: 2px solid rgba(0,0,0,0.2);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 1px 5px rgba(0,0,0,0.15);
  transition: background 0.2s;
}
.locate-btn:hover {
  background: #f4f4f4;
}
.locate-btn.locating {
  animation: pulse-locate 1s ease-in-out infinite;
}
@keyframes pulse-locate {
  0%, 100% { background: #fff; }
  50% { background: #e3f2fd; }
}

/* --- 結果なし --- */
.no-results {
  text-align: center;
  padding: 40px 20px;
  color: #888;
  font-size: 1rem;
}
.no-results .no-results-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* --- レスポンシブ --- */
@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
    height: auto;
  }
  .sidebar {
    width: 100%;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid #dfe3e8;
  }
  .map-container {
    height: 300px;
    min-height: 200px;
  }
  .property-list {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* --- スクロールバー --- */
.sidebar::-webkit-scrollbar,
.property-list::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-thumb,
.property-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover,
.property-list::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* --- バージョン選択ドロップダウン --- */
.filter-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  margin-bottom: 4px;
}
.compare-controls-hidden {
  display: none;
}

/* --- バージョン管理 --- */
.compare-toggle-wrapper {
  margin-top: 8px;
}
.filter-sublabel {
  font-size: 0.8rem;
  color: #666;
  margin: 6px 0 4px;
}

/* --- ポップアップ 掲載状態 --- */
.popup-status {
  font-size: 0.7rem;
  margin-bottom: 4px;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
}
.popup-status.delisted {
  color: #d32f2f;
  background: #ffebee;
}
.popup-history {
  font-size: 0.75rem;
  color: #e65100;
  margin-bottom: 4px;
}

/* --- 価格推移 --- */
.price-history {
  font-size: 0.8rem;
  margin: 4px 0;
  padding: 4px 8px;
  background: #fff8e1;
  border-radius: 4px;
  border: 1px solid #ffe082;
}
.price-down {
  color: #2e7d32;
  font-weight: 600;
}
.price-up {
  color: #c62828;
  font-weight: 600;
}
.price-diff {
  font-size: 0.75rem;
  font-weight: 700;
}

/* --- 設備フィルター --- */
#equipmentFilterGroup {
  max-height: 180px;
  overflow-y: auto;
}
#equipmentCheckboxes label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  margin-bottom: 2px;
}
#equipmentCheckboxes .eq-count {
  font-size: 0.72rem;
  color: #999;
}
