/* ============================================================
   クマ出没マップ - スタイルシート
   参考画像の自然なカラースキームに準拠
   ============================================================ */

/* ---------- リセット & ベース ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', 'Hiragino Sans', 'Meiryo', sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f5f0;
}

/* ---------- ヘッダー ---------- */
header {
  background: linear-gradient(135deg, #2d5016 0%, #4a7c28 100%);
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  z-index: 1000;
}
header h1 {
  font-size: 1.3rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
header h1 .app-icon { font-size: 1.5rem; }
header h1 .app-version {
  font-size: .65rem;
  opacity: .7;
  font-weight: 400;
}

/* ---------- フィルターバー ---------- */
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filters label {
  font-size: .85rem;
  font-weight: 500;
}
.filters select,
.filters input {
  padding: 5px 10px;
  border: none;
  border-radius: 6px;
  font-size: .85rem;
  background: rgba(255,255,255,.9);
  cursor: pointer;
}

/* ボタン共通 */
.btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: all .2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-locate {
  background: #fff;
  color: #2d5016;
}
.btn-locate:hover { background: #e8f5e9; }
.btn-debug {
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: .75rem;
}
.btn-debug:hover { background: rgba(255,255,255,.3); }
.btn-diag {
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: .75rem;
}
.btn-diag:hover { background: rgba(255,255,255,.3); }

/* ---------- 地図 ---------- */
#map { flex: 1; z-index: 1; }

/* ---------- スキップリンク ---------- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #2d5016;
  color: #fff;
  padding: 8px 16px;
  z-index: 1100;
  font-size: .85rem;
  transition: top .2s;
}
.skip-link:focus {
  top: 0;
}

/* ---------- オフラインバナー ---------- */
.offline-banner {
  background: #ff9800;
  color: #fff;
  text-align: center;
  padding: 6px 12px;
  font-size: .85rem;
  font-weight: 600;
  z-index: 1001;
}

/* ---------- 情報パネル ---------- */
.info-panel {
  position: absolute;
  top: 70px;
  left: 10px;
  z-index: 999;
  background: rgba(255,255,255,.95);
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
  font-size: .8rem;
  max-width: 260px;
  backdrop-filter: blur(8px);
}
.info-panel h4,
.info-panel .info-panel-heading {
  margin-bottom: 6px;
  font-size: .85rem;
  color: #333;
  font-weight: 700;
}
.stat {
  font-size: 1.8rem;
  font-weight: 700;
  color: #c62828;
  line-height: 1.2;
}
.stat-sub {
  color: #666;
  font-size: .75rem;
  margin-top: 2px;
}
.data-quality-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 600;
}
.data-quality-badge.ok {
  background: #e8f5e9;
  color: #2e7d32;
}
.data-quality-badge.warn {
  background: #fff3e0;
  color: #e65100;
}

/* ---------- 凡例 ---------- */
.legend {
  position: absolute;
  bottom: 30px;
  right: 10px;
  z-index: 999;
  background: rgba(255,255,255,.95);
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
  font-size: .8rem;
  line-height: 1.8;
  backdrop-filter: blur(8px);
}
.legend h4,
.legend .legend-heading {
  margin-bottom: 4px;
  font-size: .85rem;
  color: #333;
  font-weight: 700;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 3px rgba(0,0,0,.3);
  flex-shrink: 0;
}
.legend-circle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.legend-circle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px dashed #d32f2f;
  flex-shrink: 0;
}

/* ---------- 🐻 マーカー ---------- */
.bear-marker-icon {
  background: none !important;
  border: none !important;
}

/* 日付ラベル（常時表示ツールチップ） */
.bear-date-label {
  background: rgba(255,255,255,.92) !important;
  border: 1.5px solid #e65100 !important;
  border-radius: 4px !important;
  padding: 1px 6px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  color: #e65100 !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.15) !important;
  white-space: nowrap !important;
}
.bear-date-label::before {
  border-top-color: rgba(255,255,255,.92) !important;
}

/* クラスターアイコン */
.bear-cluster {
  background: none !important;
  border: none !important;
}
.cluster-icon {
  background: rgba(198,40,40,.85);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: #fff;
}
.cluster-icon span:first-child {
  font-size: .7em;
  position: absolute;
  left: 4px;
}
.cluster-count {
  font-weight: 700;
  font-size: inherit !important;
  margin-left: 6px;
}

/* ユーザーマーカー */
.user-marker-icon {
  background: none !important;
  border: none !important;
}
@keyframes userPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(33,150,243,.4), 0 2px 8px rgba(0,0,0,.3); }
  50% { box-shadow: 0 0 0 12px rgba(33,150,243,.1), 0 2px 8px rgba(0,0,0,.3); }
}

/* ---------- ポップアップ ---------- */
.bear-popup h3 {
  font-size: .95rem;
  margin-bottom: 6px;
  color: #2d5016;
}
.popup-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.bear-tag {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 600;
  color: #fff;
}
.bear-tag.higuma { background: #6d4c41; }
.bear-tag.tsukinowa { background: #37474f; }
.bear-count {
  font-size: .8rem;
  font-weight: 700;
  color: #d32f2f;
}
.bear-body {
  font-size: .75rem;
  color: #555;
  font-weight: 500;
}
.popup-date {
  font-size: .8rem;
  color: #555;
  margin-bottom: 4px;
}
.popup-detail {
  font-size: .8rem;
  margin-top: 6px;
  line-height: 1.5;
  color: #333;
}
.popup-distance {
  font-size: .8rem;
  color: #c62828;
  font-weight: 600;
  margin-top: 6px;
}
.popup-source {
  font-size: .7rem;
  color: #888;
  margin-top: 4px;
}

/* ---------- 診断パネル ---------- */
.diagnostics-panel {
  position: absolute;
  top: 70px;
  right: 10px;
  z-index: 999;
  background: rgba(255,255,255,.95);
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
  font-size: .8rem;
  max-width: 240px;
  backdrop-filter: blur(8px);
  display: none;
}
.diagnostics-panel h4,
.diagnostics-panel .diag-heading {
  margin-bottom: 8px;
  font-size: .85rem;
  color: #333;
  font-weight: 700;
}
.diag-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid #eee;
}
.diag-error { color: #d32f2f; font-weight: 700; }
.diag-warn { color: #f57c00; font-weight: 700; }

/* ---------- 統計ウィジェット ---------- */
.stats-widget {
  position: absolute;
  bottom: 30px;
  left: 10px;
  z-index: 999;
  background: rgba(255,255,255,.95);
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
  font-size: .8rem;
  max-width: 280px;
  backdrop-filter: blur(8px);
}
.stats-header {
  margin: 0;
  font-size: .85rem;
  color: #333;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.stats-toggle-icon {
  font-size: .65rem;
  opacity: .6;
  transition: transform .2s ease;
}
.stats-content {
  margin-top: 8px;
  overflow: hidden;
  max-height: 400px;
  transition: max-height .3s ease, opacity .3s ease;
  opacity: 1;
}
.stats-content.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}
.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}
.stats-total .stats-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #c62828;
}
.stats-label {
  font-weight: 600;
  color: #555;
}
.stats-section {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #eee;
}
.stats-section-title {
  font-size: .7rem;
  color: #888;
  font-weight: 600;
  margin-bottom: 4px;
}
.stats-type-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
}
.stats-type-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 8px;
  font-size: .7rem;
  font-weight: 600;
  color: #fff;
}
.stats-type-tag.higuma { background: #6d4c41; }
.stats-type-tag.tsukinowa { background: #37474f; }
.stats-type-count {
  font-size: .75rem;
  font-weight: 600;
  color: #555;
}
.stats-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
  padding-top: 4px;
}
.stats-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.stats-bar {
  width: 100%;
  min-height: 2px;
  background: linear-gradient(180deg, #c62828 0%, #ef5350 100%);
  border-radius: 3px 3px 0 0;
  transition: height .3s ease;
}
.stats-bar-label {
  font-size: .6rem;
  color: #888;
  margin-top: 2px;
  text-align: center;
}
.stats-detail {
  font-size: .75rem;
  color: #555;
  font-weight: 500;
}
.stats-empty {
  color: #999;
  font-size: .75rem;
  text-align: center;
  padding: 8px 0;
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 640px) {
  header { padding: 8px 12px; }
  header h1 { font-size: 1rem; }
  .filters { gap: 6px; }
  .filters label { display: none; }
  .info-panel {
    max-width: 160px;
    padding: 10px 12px;
    top: 60px;
  }
  .stat { font-size: 1.3rem; }
  .legend {
    bottom: 15px;
    padding: 10px 12px;
    font-size: .75rem;
  }
  .btn { padding: 5px 10px; font-size: .8rem; }
  .diagnostics-panel {
    top: 60px;
    max-width: 180px;
  }
  .stats-widget {
    max-width: 180px;
    padding: 10px 12px;
    bottom: 15px;
  }
  .stats-bar-chart { height: 40px; }
}

@media (max-width: 380px) {
  .btn-debug, .btn-diag { display: none; }
  .info-panel { max-width: 140px; }
}

/* ============ 広告スロット ============ */
.ad-banner-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f5f5f5;
  border-top: 1px solid #ddd;
  padding: 4px 0;
  flex-shrink: 0;
}
.ad-slot {
  position: relative;
  background: #fafafa;
  overflow: hidden;
}
.ad-slot::before {
  content: 'Sponsored';
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 9px;
  color: #999;
  z-index: 0;
  pointer-events: none;
}
.ad-728x90 { width: 728px; height: 90px; }
.ad-300x250 {
  width: 300px;
  height: 250px;
  margin-top: 8px;
}
@media (max-width: 768px) {
  .ad-banner-wrapper { display: none; }
}
@media (max-width: 640px) {
  .ad-300x250 { display: none; }
}
