/* ==========================================================
   ベアウェザー：秋田県 天気＆リアルタイム安全対策
   -- 元のUIの配色・配置・雰囲気を維持しつつ、PC/スマホの
      両方で読みやすく、フィルタ機能・投稿機能を追加したUI --
   ========================================================== */

:root {
  --header-bg: #1e293b;
  --alert-blue-1: #1e3a8a;
  --alert-blue-2: #3b82f6;
  --alert-orange-1: #c2410c;
  --alert-orange-2: #ea580c;
  --alert-red-1: #7f1d1d;
  --alert-red-2: #dc2626;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --bg: #f0f3f6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%; width: 100%; margin: 0; padding: 0;
  font-family: 'Helvetica Neue', 'Hiragino Sans', 'Yu Gothic', Arial, sans-serif;
  background: var(--bg); color: #333; overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; width: 100vw; position: relative; }

/* ---------- ヘッダー ---------- */
.header {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 6px 16px; background: var(--header-bg); color: #fff; flex-shrink: 0; z-index: 1000;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.header-date { font-size: 12px; color: #94a3b8; white-space: nowrap; }

.dashboard { display: flex; flex-direction: column; flex: 1; height: 100%; width: 100%; overflow: hidden; }

/* ---------- アラートバナー（現在の天気＋3時間ごとの予報） ---------- */
.weather-bear-alert {
  background: linear-gradient(135deg, var(--alert-blue-1) 0%, var(--alert-blue-2) 100%);
  color: #fff; padding: 12px 20px; display: flex; flex-direction: row; align-items: center; gap: 20px;
  flex-shrink: 0; box-shadow: inset 0 -3px 6px rgba(0,0,0,0.15);
}
.alert-top-row { display: flex; gap: 15px; align-items: center; flex-shrink: 0; }
.w-card {
  display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.2);
  padding: 10px 16px; border-radius: 12px; flex-shrink: 0; backdrop-filter: blur(4px);
}
.w-icon { font-size: 30px; line-height: 1; }
.w-info .w-temp { font-size: 22px; font-weight: bold; }
.w-info .w-text { font-size: 12px; opacity: 0.92; white-space: nowrap; font-weight: 500; }
.alert-message { min-width: 0; }
.alert-message .alert-title { font-size: 15px; font-weight: bold; margin: 0; white-space: nowrap; }
.alert-message .alert-desc { font-size: 12px; opacity: 0.95; margin-top: 4px; line-height: 1.45; white-space: nowrap; }

/* PC版：予報を天気カードの横に並べる（横並び） */
.forecast-row { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.weather-forecast-title { font-size: 11px; font-weight: bold; color: rgba(255,255,255,0.85); letter-spacing: .02em; white-space: nowrap; flex-shrink: 0; }
.weather-timeline { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; flex: 1; min-width: 0; }
.weather-timeline::-webkit-scrollbar { height: 5px; }
.weather-timeline::-webkit-scrollbar-track { background: rgba(255,255,255,0.15); border-radius: 10px; }
.weather-timeline::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.4); border-radius: 10px; }
.forecast-item {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.25); border-radius: 8px;
  padding: 7px 9px; min-width: 62px; text-align: center; backdrop-filter: blur(3px);
}
.forecast-time { font-size: 10.5px; color: rgba(255,255,255,0.85); font-weight: bold; }
.forecast-icon { font-size: 17px; margin: 3px 0; }
.forecast-temp { font-size: 12.5px; font-weight: bold; color: #fff; }
.weather-details-mini { margin-top: 4px; width: 100%; font-size: 9.5px; border-top: 1px dashed rgba(255,255,255,0.3); padding-top: 3px; }
.w-info-mini.pop { color: #bfe0ff; font-weight: 600; }

.content-body { display: flex; flex-direction: row; flex: 1; width: 100%; height: 100%; position: relative; overflow: hidden; }

/* ---------- サイドバー ---------- */
.sidebar {
  width: 380px; min-width: 380px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; height: 100%; flex-shrink: 0; z-index: 10; position: relative;
  transition: width 0.25s ease, min-width 0.25s ease;
  overflow: hidden;
}
.sidebar-scroll-wrapper { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-width: 380px; min-height: 0; }
.sidebar-collapse-btn { display: none; }

/* 🡄 PC向け：サイドバーの端につくタブ型の最小化ボタン
   （.sidebar ではなく .content-body 基準で配置。.sidebar は overflow:hidden の
    ため、内部に置くと幅0の最小化時にボタンごと見えなくなり再展開できなくなる） */
.sidebar-edge-toggle {
  position: absolute; top: 50%; left: 380px; transform: translate(-50%, -50%);
  width: 32px; height: 64px; display: flex; align-items: center; justify-content: center;
  background: var(--header-bg); color: #fff; border: none; border-radius: 0 10px 10px 0;
  cursor: pointer; z-index: 2800; box-shadow: 2px 0 8px rgba(0,0,0,0.2); font-size: 16px; font-weight: bold;
  transition: left .25s ease, background .15s ease;
}
.sidebar-edge-toggle:hover { background: #0f172a; }
.sidebar.mini + .sidebar-edge-toggle { left: 0; }

.sidebar.mini { width: 0; min-width: 0; border-right: none; }
.sidebar.mini .sidebar-scroll-wrapper,
.sidebar.mini .action-panel { visibility: hidden; }

/* ---------- フィルター ---------- */
.filter-box { padding: 12px 15px; border-bottom: 1px solid var(--line); background: #fff; }
.filter-box-period { background: var(--surface-soft); border-bottom: 1px dashed var(--line); }
.filter-box-title { font-size: 11px; font-weight: bold; color: var(--muted); margin-bottom: 7px; letter-spacing: .02em; }
.fbtn-row { display: flex; gap: 6px; }
.fbtn {
  flex: 1; padding: 8px 4px; border: 1px solid #cbd5e1; background: #fff; border-radius: var(--radius-sm);
  font-size: 12px; cursor: pointer; text-align: center; font-weight: bold; color: var(--ink-soft);
  user-select: none; transition: background .15s ease, color .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.fbtn:hover { border-color: #94a3b8; }
.fbtn.on { background: var(--header-bg); color: #fff; border-color: var(--header-bg); }
.fbtn.on-orange { background: var(--alert-orange-2); color: #fff; border-color: var(--alert-orange-2); }
.fbtn.on-red { background: var(--alert-red-2); color: #fff; border-color: var(--alert-red-2); }

.list-hdr { padding: 9px 15px; background: #f1f5f9; font-size: 12px; font-weight: bold; color: var(--muted); flex-shrink: 0; }
.list-scroll { flex: 1; min-height: 0; overflow-y: auto; background: #fff; -webkit-overflow-scrolling: touch; }

/* ---------- リストアイテム ---------- */
.sitem { padding: 12px 15px; border-bottom: 1px solid #f1f5f9; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.sitem:hover, .sitem:active { background: var(--surface-soft); }
.sitem-content { flex: 1; min-width: 0; }
.sitem-title { font-weight: bold; font-size: 13px; color: var(--ink); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sitem-meta { font-size: 11.5px; color: var(--muted); }
.sitem-meta strong { color: var(--ink); }
.type-tag { display: inline-block; font-size: 10px; padding: 3px 7px; border-radius: 3px; font-weight: bold; color: #fff; margin-top: 5px; }
.tag-目撃 { background: #eab308; color: #000; }
.tag-痕跡 { background: #64748b; }
.tag-人身被害 { background: #dc2626; }
.tag-熊の人身被害 { background: #dc2626; }
.empty-state { padding: 30px 15px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* ---------- 投稿ボタン（アクションパネル） ---------- */
.action-panel { padding: 12px 15px; background: #fff; border-top: 1px solid var(--line); flex-shrink: 0; }
.btn-primary {
  width: 100%; padding: 12px; background: #27ae60; color: #fff; border: none; border-radius: var(--radius-sm);
  font-weight: bold; cursor: pointer; text-align: center; font-size: 14px; transition: background .15s ease;
}
.btn-primary:hover { background: #219653; }
.btn-primary:active { transform: scale(0.99); }

/* ---------- マップエリア ---------- */
#map { flex: 1; height: 100%; width: 100%; background: #e5e9f0; position: relative; }

/* 🗺️ 地図右上のアイコンツールバー（ズームコントロールの下に縦並び） */
.map-toolbar {
  position: absolute; top: 96px; right: 10px; z-index: 2000;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.map-icon-btn {
  width: 44px; height: 44px; border: none; border-radius: 10px; cursor: pointer;
  font-size: 20px; color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25); flex-shrink: 0;
}
.map-icon-btn:active { transform: scale(0.94); }
#btn-radar-toggle { background: #2563eb; }
#btn-bear-toggle { background: #1e293b; }
#btn-gps { background: #16a34a; }
.map-icon-btn.alarm { background: linear-gradient(135deg, #ef4444, #b91c1c); }

.slider-container {
  background: rgba(255,255,255,0.97); padding: 8px; border-radius: 8px; border: 1px solid var(--line);
  width: 175px; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.res-toggle-row { display: flex; gap: 4px; margin-bottom: 6px; }
.res-btn {
  flex: 1; padding: 5px 2px; border: 1px solid #cbd5e1; background: #fff; border-radius: 5px;
  font-size: 10.5px; font-weight: bold; cursor: pointer; color: var(--ink-soft); white-space: nowrap;
}
.res-btn.on { background: var(--header-bg); color: #fff; border-color: var(--header-bg); }
.slider-label-row { display: flex; align-items: center; gap: 6px; }
.play-btn {
  flex-shrink: 0; width: 24px; height: 24px; border: none; border-radius: 50%; cursor: pointer;
  background: var(--header-bg); color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.play-btn.playing { background: var(--alert-red-2); }
.play-btn:disabled { background: #cbd5e1; cursor: not-allowed; }
.slider-label { font-size: 11px; font-weight: bold; text-align: center; color: var(--ink); flex: 1; }
.time-display { color: var(--alert-red-2); font-weight: bold; }
.range-slider { width: 100%; cursor: pointer; margin-top: 4px; }

.leaflet-control-zoom { margin-top: 15px !important; }
.leaflet-top.leaflet-right { z-index: 1900; }

#loading { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #fff; z-index: 9999; display: flex; align-items: center; justify-content: center; font-weight: bold; color: #555; }

/* ==========================================================
   投稿モーダル
   ========================================================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55); display: none;
  align-items: center; justify-content: center; z-index: 6000; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-window {
  background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 880px;
  height: 90vh; max-height: 720px; display: flex; flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3); overflow: hidden;
}
.modal-hdr {
  padding: 16px 18px; background: var(--header-bg); color: #fff; font-weight: bold; font-size: 15px;
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-close { background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; padding: 4px 8px; }
.modal-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; gap: 20px; }
.modal-left { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.modal-right { width: 380px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.form-grp { display: flex; flex-direction: column; gap: 5px; }
.form-grp label { font-size: 12px; font-weight: bold; color: var(--ink-soft); }
.form-grp input, .form-grp select, .form-grp textarea {
  padding: 10px; border: 1px solid #cbd5e1; border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
}
.form-grp textarea { resize: none; height: 80px; }
.mini-map-label { font-size: 12px; font-weight: bold; color: var(--ink-soft); }
#mini-map { width: 100%; flex: 1; min-height: 260px; border: 1px solid #cbd5e1; border-radius: var(--radius-sm); }
#coord-info { font-size: 11.5px; background: var(--surface-soft); padding: 8px; border-radius: 6px; color: var(--ink-soft); }
.modal-ftr { padding: 14px 18px; background: var(--surface-soft); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }
.btn-sec { padding: 10px 18px; background: #e2e8f0; border: none; border-radius: var(--radius-sm); cursor: pointer; font-weight: bold; color: var(--ink-soft); }
.btn-submit { padding: 10px 22px; background: #27ae60; color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; font-weight: bold; }
.btn-submit:disabled { background: #94a3b8; cursor: not-allowed; }

/* ==========================================================
   レスポンシブ（タブレット／スマホ）
   ========================================================== */
@media (max-width: 1024px) {
  .sidebar { width: 320px; min-width: 320px; }
  .sidebar-scroll-wrapper { min-width: 320px; }
  .sidebar-edge-toggle { left: 320px; }
  .modal-right { width: 320px; }
}

@media (max-width: 768px) {
  .header { padding: 5px 14px; }
  .header-date { font-size: 11px; }

  /* バナーは縦積みにして、天気予報の行が画面幅いっぱいを使って
     横スクロールできるようにする（1行のままだと幅を奪い合って
     予報が見えなくなる／スクロールできなくなるため） */
  .weather-bear-alert { flex-direction: column; align-items: stretch; padding: 10px 14px; gap: 8px; overflow: hidden; }
  .alert-top-row { width: 100%; padding: 0; gap: 10px; }
  .w-card { padding: 7px 11px; gap: 8px; }
  .w-icon { font-size: 24px; }
  .w-info .w-temp { font-size: 18px; }
  .w-info .w-text { font-size: 10.5px; }
  .alert-message { flex: 1; min-width: 0; overflow: hidden; }
  .alert-message .alert-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .alert-message .alert-desc { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .forecast-row { width: 100%; }

  .content-body { flex-direction: column; }

  /* サイドバーは折りたたみ可能な下部シートに */
  .sidebar {
    width: 100%; min-width: 100%; height: 58%; border-right: none; border-top: 3px solid var(--header-bg);
    order: 2; transition: height .25s ease;
  }
  .sidebar-scroll-wrapper { min-width: 100%; overflow-y: auto; }
  .list-scroll { flex: 1 1 110px; min-height: 110px; }
  .sidebar.collapsed { height: 56px; }
  .sidebar.collapsed .sidebar-scroll-wrapper { display: none; }
  .sidebar.collapsed .action-panel { display: none; }
  .sidebar-collapse-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 10px; background: var(--header-bg); color: #fff; border: none;
    font-size: 12px; font-weight: bold; cursor: pointer; flex-shrink: 0;
  }
  .sidebar-edge-toggle { display: none; }

  #map { width: 100%; flex: 1; order: 1; min-height: 0; }

  /* フィルターボタンは折り返さず1行に収める
     （折り返すと縦に場所を取りすぎて、下のリストが表示できなくなるため） */
  .filter-box { padding: 6px 12px; }
  .filter-box-title { margin-bottom: 4px; }
  .fbtn-row { flex-wrap: nowrap; gap: 4px; }
  .fbtn { padding: 6px 2px; font-size: 10.5px; white-space: nowrap; }

  /* 地図アイコンツールバー（少し下げて、少し小さく） */
  .map-toolbar { top: 88px; right: 8px; gap: 6px; }
  .map-icon-btn { width: 40px; height: 40px; font-size: 18px; }
  .slider-container { width: 150px; }

  .leaflet-top.leaflet-right { top: 8px; }
  .leaflet-control-zoom { margin-top: 0 !important; }

  .modal-window { height: 94vh; max-height: none; border-radius: 10px; }
  .modal-body { flex-direction: column; padding: 14px; gap: 14px; }
  .modal-right { width: 100%; }
  #mini-map { min-height: 200px; }
  .modal-ftr { flex-direction: column-reverse; }
  .btn-sec, .btn-submit { width: 100%; }
}

@media (max-width: 380px) {
  .fbtn { font-size: 11px; padding: 9px 4px; }
}
