/* ═══════════════════════════════════════════════════════════
   WEB API MAP — style.css
   ═══════════════════════════════════════════════════════════ */

/* ── リセット & ベース ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #0d1117;
  --bg-sidebar:   #111827;
  --bg-card:      #1a2332;
  --bg-hover:     #1f2d45;
  --bg-detail:    #0f1c2e;
  --border:       #1f3050;
  --border-light: #2a4060;
  --text-primary: #e2e8f0;
  --text-muted:   #6b8097;
  --text-dim:     #94a3b8;
  --accent:       #e94560;
  --accent-dim:   #7c3244;
  --blue:         #3b82f6;
  --green:        #22c55e;
  --yellow:       #f59e0b;
  --sidebar-w:    300px;
  --detail-w:     400px;
  --font:         "Hiragino Sans", "Meiryo", "Yu Gothic UI", sans-serif;
}

html, body { height: 100%; font-family: var(--font); font-size: 13px; background: var(--bg-base); color: var(--text-primary); }

button { font-family: var(--font); cursor: pointer; border: none; }
select { font-family: var(--font); }
input  { font-family: var(--font); }

/* ── メインレイアウト ───────────────────────────────────── */
body { display: flex; height: 100vh; overflow: hidden; }

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow: hidden;
  z-index: 100;
}

#map-area {
  flex: 1;
  height: 100vh;
  min-width: 0;
  position: relative;
}

#map { width: 100%; height: 100%; background: #0a0e1a; }

/* ── ブランディング ─────────────────────────────────────── */
#branding {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#branding h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
}
#branding p { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ── 検索 ──────────────────────────────────────────────── */
#search-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-wrap {
  display: flex;
  align-items: center;
  background: #0d1827;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0 8px;
  gap: 6px;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { font-size: 12px; opacity: 0.5; }
#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 12px;
  padding: 7px 0;
}
#search-input::placeholder { color: var(--text-muted); }
.search-clear {
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
}
.search-clear:hover { color: var(--accent); }

/* ── クイックフィルタ ───────────────────────────────────── */
#quick-section {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.qchip {
  padding: 4px 9px;
  border-radius: 12px;
  font-size: 11px;
  background: #1a2840;
  color: var(--text-dim);
  border: 1px solid var(--border-light);
  transition: all 0.15s;
  white-space: nowrap;
}
.qchip:hover { background: var(--bg-hover); color: var(--text-primary); }
.qchip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

/* ── 詳細フィルタ ───────────────────────────────────────── */
#adv-filter {
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#adv-filter summary {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
#adv-filter summary:hover { color: var(--text-dim); }
#adv-filter summary::after {
  content: '▶';
  font-size: 9px;
  opacity: 0.5;
  transition: transform 0.2s;
}
#adv-filter[open] summary::after { transform: rotate(90deg); }

.filter-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
}

#adv-filter-body { padding: 8px 12px 12px; }
.filter-row { margin-bottom: 7px; }
.filter-row label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.filter-row select {
  width: 100%;
  padding: 5px 8px;
  background: #0d1827;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.filter-row select:focus { border-color: var(--blue); }
.reset-btn {
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  background: #1a2840;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-size: 11px;
  transition: all 0.15s;
}
.reset-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── 統計 ──────────────────────────────────────────────── */
#stats-section {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.stat-cell {
  background: #0d1827;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 4px;
  text-align: center;
}
.stat-val {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.stat-val.accent { color: var(--accent); }
.stat-lbl {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── 一覧パネル ─────────────────────────────────────────── */
#list-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#list-header {
  padding: 7px 14px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
#list-header span:first-child { color: var(--text-dim); font-weight: 600; }
.list-hint { font-size: 10px; opacity: 0.6; }
#list-body { flex: 1; overflow-y: auto; }
#list-body::-webkit-scrollbar { width: 4px; }
#list-body::-webkit-scrollbar-track { background: transparent; }
#list-body::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

/* ── 一覧アイテム ───────────────────────────────────────── */
.list-item {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.list-item:hover { background: var(--bg-hover); }
.list-item.selected { background: #162338; border-left: 3px solid var(--accent); }

.li-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.li-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.li-nogeo {
  font-size: 10px;
  opacity: 0.4;
  margin-left: auto;
}

.li-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 4px;
}

.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.b-cat    { background: #1a3060; color: #6ea8fe; }
.b-cntry  { background: #0d2a1a; color: #4ade80; }
.b-free   { background: #0d2a1a; color: #4ade80; }
.b-nokey  { background: #0d2a1a; color: #4ade80; }
.b-key    { background: #2a1a0d; color: #fbbf24; }

.li-overview {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.li-ratings {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--text-muted);
}
.li-ratings .r-star { color: var(--yellow); }

.list-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ── 詳細パネル ─────────────────────────────────────────── */
#detail-panel {
  position: fixed;
  right: 0;
  top: 0;
  width: var(--detail-w);
  height: 100vh;
  background: var(--bg-detail);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 500;
  overflow: hidden;
  box-shadow: -4px 0 20px rgba(0,0,0,0.4);
}
#detail-panel.open { transform: translateX(0); }

#detail-topbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}
#detail-close {
  background: #1a2840;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-size: 11px;
  padding: 4px 10px;
  transition: all 0.15s;
}
#detail-close:hover { background: var(--accent-dim); color: #fff; border-color: var(--accent); }

#detail-body { flex: 1; overflow-y: auto; padding: 16px; }
#detail-body::-webkit-scrollbar { width: 4px; }
#detail-body::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

/* ── 詳細パネル内コンテンツ ─────────────────────────────── */
.dp-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  line-height: 1.3;
}
.dp-formal {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.dp-top-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.dp-stars {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.dp-stars span { display: flex; align-items: center; gap: 3px; }

.dp-section { margin-bottom: 16px; }
.dp-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.dp-field { margin-bottom: 6px; }
.dp-field-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.dp-field-value {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.5;
}
.dp-field-value.mono { font-family: monospace; font-size: 11px; color: #7dd3fc; }
.dp-field-value.comment {
  color: var(--text-dim);
  font-style: italic;
  border-left: 2px solid var(--border-light);
  padding-left: 8px;
}
.dp-link {
  color: var(--blue);
  text-decoration: none;
  font-size: 11px;
  word-break: break-all;
  display: block;
  margin-bottom: 4px;
}
.dp-link:hover { color: var(--accent); text-decoration: underline; }

/* ── Leaflet カスタム ───────────────────────────────────── */
.leaflet-container { background: #0a0e1a; }
.leaflet-popup-content-wrapper {
  background: #1a2744;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.leaflet-popup-tip { background: #1a2744; }
.leaflet-popup-content { margin: 10px 12px; font-size: 12px; max-width: 220px; }
.lp-name { font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.lp-cat  { font-size: 10px; color: #6ea8fe; }

.api-tooltip {
  background: rgba(15, 28, 46, 0.95) !important;
  border: 1px solid var(--border-light) !important;
  color: var(--text-primary) !important;
  font-size: 11px !important;
  padding: 3px 8px !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
}
.api-tooltip::before { display: none !important; }

/* ── ユーティリティ ─────────────────────────────────────── */
.hidden { display: none !important; }

/* ── モバイル ───────────────────────────────────────────── */
@media (max-width: 768px) {
  body { flex-direction: column; }

  #sidebar {
    width: 100%;
    min-width: unset;
    height: auto;
    max-height: 50vh;
    flex-direction: column;
    overflow-y: auto;
  }

  #map-area {
    flex: 1;
    min-height: 200px;
  }

  #detail-panel {
    width: 100%;
    top: auto;
    bottom: 0;
    height: 60vh;
    border-left: none;
    border-top: 1px solid var(--border);
    transform: translateY(100%);
  }
  #detail-panel.open { transform: translateY(0); }

  #list-section { max-height: 30vh; }
}
