/* ============================================
   건축물 세대수 집계기 - 스타일 (전체)
============================================ */

:root {
  --bg: #0f1115;
  --bg-2: #161922;
  --bg-3: #1d2230;
  --border: #2a3142;
  --border-light: #3a4256;
  --text: #e8ecf3;
  --text-dim: #8893a8;
  --text-mute: #5a6378;
  --accent: #ff6b1a;
  --accent-glow: rgba(255, 107, 26, 0.15);
  --accent-2: #3ddc97;
  --warn: #ffb547;
  --danger: #ff5c5c;
  --map-bg: #f5f6f8;
  --panel-width: 380px;
  --font-mono: 'JetBrains Mono', 'Menlo', monospace;
  --font-sans: 'IBM Plex Sans KR', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%; overflow: hidden;
  font-family: var(--font-sans);
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 1fr var(--panel-width);
  height: 100vh; width: 100vw;
}

/* ── 지도 ── */
.map-wrap { position: relative; background: var(--map-bg); overflow: hidden; }
#map { width: 100%; height: 100%; }

.ol-zoom { top: auto; bottom: 80px; left: 16px; right: auto; }
.ol-zoom button {
  background: var(--bg-2) !important; color: var(--text) !important;
  font-family: var(--font-mono); font-size: 18px;
  border: 1px solid var(--border) !important;
  width: 36px; height: 36px;
}
.ol-zoom button:hover { background: var(--bg-3) !important; }
.ol-attribution { background: rgba(15,17,21,0.7) !important; color: var(--text-dim) !important; font-size: 11px; padding: 4px 8px; }
.ol-attribution a { color: var(--text-dim); }

/* ── 상단 바 ── */
.topbar {
  position: absolute; top: 16px; left: 16px; right: 16px;
  display: flex; align-items: center; gap: 16px;
  z-index: 10; pointer-events: none;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--border);
  padding: 10px 16px; pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.brand-mark { font-family: var(--font-mono); font-weight: 700; font-size: 18px; background: var(--accent); color: #fff; padding: 4px 8px; }
.brand-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.brand-sub { font-family: var(--font-mono); font-size: 10px; color: var(--text-mute); letter-spacing: 0.5px; margin-top: 2px; }

.search-box {
  flex: 1; max-width: 480px; display: flex;
  background: var(--bg); border: 1px solid var(--border);
  pointer-events: auto; box-shadow: 0 4px 16px rgba(0,0,0,0.12); overflow: hidden;
}
.search-box input {
  flex: 1; background: transparent; border: none; outline: none;
  padding: 12px 16px; color: var(--text); font-family: var(--font-sans); font-size: 13px;
}
.search-box input::placeholder { color: var(--text-mute); }
.search-box button {
  background: var(--bg-3); border: none; border-left: 1px solid var(--border);
  padding: 0 20px; color: var(--text); cursor: pointer;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.5px; transition: background 0.15s;
}
.search-box button:hover { background: var(--accent); }

/* ── 범례 ── */
.legend {
  position: absolute; bottom: 16px; left: 16px;
  background: var(--bg); border: 1px solid var(--border);
  padding: 14px 16px; font-size: 11px; z-index: 5; min-width: 200px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.legend-title { font-family: var(--font-mono); text-transform: uppercase; font-size: 10px; letter-spacing: 1.2px; color: var(--text-mute); margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.legend-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; color: var(--text-dim); }
.legend-row span { margin-left: auto; color: var(--text); font-size: 11px; }
kbd { font-family: var(--font-mono); background: var(--bg-3); border: 1px solid var(--border-light); border-bottom-width: 2px; padding: 2px 6px; font-size: 10px; border-radius: 2px; color: var(--text); min-width: 38px; text-align: center; display: inline-block; }
.mini-btn { width: 100%; margin-top: 8px; background: var(--accent); color: #fff; border: none; padding: 8px; font-family: var(--font-mono); font-size: 11px; font-weight: 500; cursor: pointer; transition: filter 0.15s; }
.mini-btn:hover { filter: brightness(1.1); }

/* ── 상태바 ── */
.status-bar {
  position: absolute; bottom: 16px; right: 16px;
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--border);
  padding: 8px 14px; font-family: var(--font-mono); font-size: 11px; color: var(--text-dim);
  z-index: 5; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.load-indicator { display: flex; align-items: center; gap: 6px; color: var(--accent); }
.load-indicator .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── 우측 패널 ── */
.panel { background: var(--bg-2); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.summary { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.summary-title { font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px; color: var(--text-mute); text-transform: uppercase; margin-bottom: 12px; }

/* 계량기 총합 */
.meter-total {
  display: flex; align-items: baseline; justify-content: space-between;
  background: linear-gradient(135deg, var(--accent-glow), transparent);
  border: 1px solid var(--accent); padding: 14px 16px; margin-bottom: 8px; position: relative;
}
.meter-total::before { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--accent); }
.meter-total-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.8px; color: var(--text-dim); text-transform: uppercase; }
.meter-total-value { font-family: var(--font-mono); font-size: 32px; font-weight: 700; color: var(--text); line-height: 1; }
.meter-unit { font-size: 14px; color: var(--text-dim); margin-left: 4px; }

/* 용도별 소계 */
.meter-breakdown { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.breakdown-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 13px; transition: opacity 0.2s; }
.breakdown-row span:nth-child(2) { margin-left: auto; font-weight: 700; font-size: 15px; color: var(--text); }
.bd-unit { font-size: 11px; color: var(--text-mute); }

/* 용도 뱃지 */
.type-badge { font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.3px; padding: 2px 7px; border-radius: 2px; white-space: nowrap; flex-shrink: 0; }

.summary-sub { font-size: 11px; color: var(--text-mute); font-family: var(--font-mono); text-align: right; margin-bottom: 10px; }
.summary-sub strong { color: var(--text); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-primary, .btn-secondary { border: none; padding: 10px; font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.5px; cursor: pointer; transition: all 0.15s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--bg-3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

/* ── 목록 ── */
.list-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-mute); border-bottom: 1px solid var(--border); }
.badge { background: var(--bg-3); color: var(--text); padding: 2px 8px; border-radius: 999px; font-size: 11px; letter-spacing: 0; }

.list-wrap { flex: 1; overflow-y: auto; position: relative; }
.list-wrap::-webkit-scrollbar { width: 6px; }
.list-wrap::-webkit-scrollbar-track { background: transparent; }
.list-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

#selectionList { list-style: none; }
#selectionList li { padding: 12px 20px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
#selectionList li:hover { background: var(--bg-3); }
#selectionList li.error { background: rgba(255,92,92,0.05); }

.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.item-name { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.3; }
.item-remove { background: none; border: none; color: var(--text-mute); cursor: pointer; font-size: 14px; padding: 0 4px; flex-shrink: 0; }
.item-remove:hover { color: var(--danger); }
.item-addr { font-size: 11px; color: var(--text-dim); line-height: 1.4; margin-bottom: 6px; }
.item-loading { font-family: var(--font-mono); font-size: 11px; color: var(--text-mute); }
.item-error { font-family: var(--font-mono); font-size: 11px; color: var(--warn); }

.item-breakdown { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }
.item-breakdown strong { color: var(--text); }
.item-total { margin-top: 4px; font-family: var(--font-mono); font-size: 11px; color: var(--text-mute); text-align: right; }
.item-total strong { color: var(--accent); font-size: 13px; }

.empty { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); text-align: center; color: var(--text-mute); font-size: 13px; width: 100%; padding: 20px; }
.empty-icon { font-size: 32px; margin-bottom: 12px; color: var(--border-light); }
.empty-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.5px; color: var(--text-mute); margin-top: 6px; }

/* ── 토스트 ── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%,20px); background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 10px 16px; font-size: 12px; border-radius: 2px; opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,0.3); border-left: 3px solid var(--accent); }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.toast.error { border-left-color: var(--danger); }
.toast.warn  { border-left-color: var(--warn); }

/* ── 반응형 ── */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .panel { max-height: 50vh; border-left: none; border-top: 1px solid var(--border); }
  .topbar { flex-direction: column; align-items: stretch; }
  .legend { display: none; }
}
