/* ── apt-detail.css — apt 단지 상세 페이지 전용 스타일 ── */

/* ── 변수 (main.css 변수 재사용 + 추가) ── */
:root {
  --cyan:    #0891b2;
  --purple:  #7c3aed;
  --amber:   #d97706;
  --indigo:  #6366f1;
  --text-sub: #4a7fa5;
}

/* ── Breadcrumb ── */
.apt-breadcrumb { padding: 12px 0 0; }
.apt-breadcrumb ol { list-style: none; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.apt-breadcrumb li { font-size: 13px; color: var(--text-faint); }
.apt-breadcrumb a  { color: var(--text-faint); text-decoration: none; }
.apt-breadcrumb a:hover { color: var(--primary); }
.apt-breadcrumb .sep { margin: 0 2px; }

/* ── Hero ── */
.apt-hero { margin: 16px 0 20px; }
.apt-title { font-size: 26px; font-weight: 800; margin-bottom: 8px; }
.apt-meta  { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-muted); flex-wrap: wrap; }
.apt-tag   { background: #f1f5f9; border-radius: 4px; padding: 2px 8px; font-size: 13px; color: var(--text-faint); }

/* ── 요약 카드 3개 ── */
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 640px) { .summary-grid { grid-template-columns: 1fr; } }

/* ── 2열 나란히 ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.two-col > * { min-width: 0; }
.two-col > .apt-section { margin-bottom: 0; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }
.summary-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.sc-type { font-size: 11px; font-weight: 700; letter-spacing: .5px;
           display: flex; align-items: center; gap: 5px; margin-bottom: 10px; }
.sc-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sc-dot-trade  { background: var(--primary); }
.sc-dot-jeonse { background: var(--cyan); }
.sc-dot-wolse  { background: var(--purple); }
.sc-lbl-trade  { color: var(--primary); }
.sc-lbl-jeonse { color: var(--cyan); }
.sc-lbl-wolse  { color: var(--purple); }
.sc-main { font-size: 21px; font-weight: 800; margin-bottom: 3px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; }
.sc-main-sm { font-size: 17px; }
.sc-sub  { font-size: 13px; color: var(--text-faint); }
.sc-row  { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-faint);
           margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.sc-val  { color: var(--text-muted); font-weight: 600; }
.badge-up   { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 3px;
              background: #fee2e2; color: var(--danger); }
.badge-down { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 3px;
              background: var(--primary-light); color: var(--primary); }
.badge-neu  { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 3px;
              background: #f1f5f9; color: var(--text-muted); }
.ratio-safe    { color: #16a34a; font-weight: 600; }
.ratio-caution { color: var(--amber); font-weight: 600; }
.ratio-danger  { color: var(--danger); font-weight: 600; }

/* ── 섹션 공통 ── */
.apt-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 16px; overflow: hidden;
  display: flex; flex-direction: column;
}
.apt-section-noclip { overflow: visible; }
.sec-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--border);
}
.sec-title { font-size: 14px; font-weight: 700; }
.sec-sub   { font-size: 13px; color: var(--text-faint); margin-left: 8px; }
.sec-link  { font-size: 13px; color: var(--primary); text-decoration: none; white-space: nowrap; }
.sec-link:hover { text-decoration: underline; }
.scroll-header { display: flex; align-items: center; gap: 8px; }


/* ── 차트 탭 ── */
.chart-tabs { display: flex; border-bottom: 1px solid var(--border); }
.chart-tab  {
  padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text-faint);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  user-select: none;
}
.chart-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.chart-body  { padding: 16px; }
.chart-label { font-size: 13px; color: var(--text-faint); margin-bottom: 12px; }
.chart-pane  { display: none; }
.chart-pane.active { display: block; }
.chart-note      { font-size: 12px; color: var(--text-faint); margin-top: 8px; }
.chart-narrative {
  font-size: 12px; font-weight: 600; color: var(--primary);
  background: var(--primary-light); border-radius: 4px;
  padding: 4px 10px; margin-bottom: 10px; display: inline-block;
}

/* ── 연간 거래량 — 숫자 카드 ── */
.yearly-cards { display: flex; gap: 8px; padding: 12px; overflow-x: auto; scrollbar-width: none; flex: 1; align-items: stretch; }
.yearly-cards::-webkit-scrollbar { display: none; }
.yn-card {
  flex: 1 0 72px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 8px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.yn-card-cur { background: var(--primary); border-color: var(--primary); }
.yn-card-year { font-size: 12px; font-weight: 700; color: var(--text-sub); }
.yn-card-cur .yn-card-year { color: rgba(255,255,255,.8); }
.yn-card-vol { font-size: 28px; font-weight: 900; line-height: 1; color: var(--text-main); letter-spacing: -1px; padding: 4px 0; }
.yn-card-cur .yn-card-vol { color: #fff; }
.yn-card-vol .yn-card-unit { font-size: 14px; font-weight: 700; letter-spacing: 0; }
.yn-card-trend { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.yn-trend-up   { background: #fee2e2; color: var(--danger); }
.yn-trend-down { background: var(--primary-light); color: var(--primary); }
.yn-card-cur .yn-card-trend { background: rgba(255,255,255,.2); color: #fff; }

/* ── 면적별 시세 — 가로 스크롤 카드 ── */
.area-scroll { display: flex; gap: 10px; padding: 14px 0 14px 16px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.area-scroll::after { content: ''; flex: 0 0 16px; min-width: 16px; }
.area-scroll::-webkit-scrollbar { display: none; }
.area-card {
  flex: 1 0 150px; scroll-snap-align: start;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 12px; background: var(--surface);
}
.area-card-major { border-color: var(--primary); background: var(--primary-light); }
.area-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.area-card-sqm { font-size: 15px; font-weight: 800; color: var(--text-muted); }
.area-major-chip { font-size: 11px; font-weight: 800; color: var(--primary); background: #bfdbfe; border-radius: 4px; padding: 2px 6px; }
.area-cnt-chip   { font-size: 12px; font-weight: 700; color: var(--text-sub); background: #e2e8f0; border-radius: 4px; padding: 2px 6px; }
.area-card-major .area-cnt-chip { background: #bfdbfe; color: var(--primary); }
.area-card-pyeong { font-size: 13px; font-weight: 600; color: var(--text-sub); margin-bottom: 8px; }
.area-card-price  { font-size: 22px; font-weight: 900; color: var(--text-main); line-height: 1.1; letter-spacing: -.5px; margin-bottom: 8px; }
.area-card-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding-top: 8px; border-top: 1px solid var(--border); }
.area-card-major .area-card-row { border-top-color: #bfdbfe; }
.area-card-row-label { color: var(--text-sub); font-weight: 600; }
.area-card-row-val   { color: var(--text-muted); font-weight: 700; }

/* ── 거래 테이블 ── */
.tbl-wrap { overflow-x: auto; min-width: 0; }
.tbl-wrap table { width: 100%; border-collapse: collapse; }
.tbl-wrap th {
  font-size: 12px; font-weight: 700; color: var(--text-faint);
  text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.tbl-wrap th * { pointer-events: none; }
.tbl-wrap th:hover { background: var(--primary-light); color: var(--primary); }
.tbl-wrap th.sort-active { color: var(--primary); }
.tbl-wrap td {
  font-size: 14px; padding: 10px 14px; border-bottom: 1px solid #f8fafc;
  color: var(--text-muted); white-space: nowrap;
}
.tbl-wrap tbody tr:last-child td { border-bottom: none; }
.tbl-wrap tbody tr:hover td { background: #f8fafc; }
.tbl-wrap tbody tr.row-cur-ym td { background: #eff6ff; }
.tbl-wrap tbody tr.row-cur-ym:hover td { background: #dbeafe; }
.td-amt { font-weight: 700; color: var(--text-main); }
.td-area-sub { font-size: 12px; color: var(--text-faint); margin-left: 2px; }
.td-change { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 5px; border-radius: 3px; }
.change-up   { background: #fee2e2; color: var(--danger); }
.change-down { background: var(--primary-light); color: var(--primary); }
.change-neu  { background: #f1f5f9; color: var(--text-muted); }
.change-high { background: #fee2e2; color: var(--danger); }
.rent-type { font-weight: 600; }
.rt-jeonse { color: var(--cyan); }
.rt-wolse  { color: var(--purple); }
.rt-banjeonse { color: var(--amber); }
.contract-new { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 5px; border-radius: 3px; background: var(--primary-light); color: var(--primary); }
.contract-renew { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 5px; border-radius: 3px; background: #f0fdf4; color: #16a34a; }

/* ── 더보기 인라인 ── */
.more-inline { border-top: 1px solid var(--border); }
.more-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px; font-size: 14px; color: var(--primary); cursor: pointer; font-weight: 600;
}
.more-btn:hover { background: #f8fafc; }
.more-rows { display: none; }
.more-hint {
  font-size: 12px; color: var(--text-faint); padding: 6px 14px 10px;
  border-top: 1px dashed var(--border); text-align: center;
}

/* ── 스크롤 화살표 (공용) ── */
.compare-arrows { display: flex; gap: 4px; }
.compare-arrow {
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-muted); line-height: 1;
  transition: opacity .15s, background .15s;
}
.compare-arrow:hover { background: #f1f5f9; }
.compare-arrow.hidden { opacity: 0; pointer-events: none; }

/* ── 인근 단지 비교 ── */
.compare-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.compare-wrap { max-height: 380px; overflow-y: auto; border-top: 1px solid var(--border); }
.compare-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.compare-table thead th { position: sticky; top: 0; background: var(--surface); font-size: 12px; font-weight: 700; color: var(--text-sub); padding: 8px 12px; border-bottom: 2px solid var(--border); text-align: left; white-space: nowrap; z-index: 1; cursor: pointer; user-select: none; }
.compare-table thead th * { cursor: pointer; pointer-events: none; }
.compare-table thead th.r { text-align: right; }
.compare-table thead th:hover { background: var(--primary-light); }
.compare-table thead th.sort-active { color: var(--primary); }
.sort-icon { font-size: 10px; opacity: 0.5; }
.sort-active .sort-icon { opacity: 1; }
.compare-table tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.compare-table tbody tr:hover { background: var(--primary-light); }
.compare-table tbody tr.row-current { background: #eff6ff; }
.compare-table td { padding: 9px 12px; }
.compare-table td.r { text-align: right; }
.ct-name { font-size: 13px; font-weight: 700; color: var(--text-main); }
.ct-dong { font-size: 12px; font-weight: 600; color: var(--text-sub); }
.ct-price { font-size: 13px; font-weight: 800; color: var(--text-main); white-space: nowrap; }
.ct-ratio-safe { color: var(--primary); font-weight: 700; }
.ct-ratio-warn { color: var(--danger); font-weight: 700; }
.ct-vol { color: var(--text-muted); font-weight: 600; }
.cc-badge-now { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 3px; background: var(--primary-light); color: var(--primary); margin-left: 4px; }
.compare-footer { padding: 10px 16px 14px; border-top: 1px solid var(--border); text-align: right; }

/* ── 이웃 동네 카드 ── */
.sibling-nav-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 12px;
}
.month-nav-label { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 12px; }
.neighbor-links { display: flex; flex-wrap: wrap; gap: 8px; }
.neighbor-link {
  font-size: 13px; font-weight: 600; text-decoration: none;
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text);
}
.neighbor-link:hover { border-color: var(--primary); color: var(--primary); }

/* ── 하단 네비게이션 ── */
.apt-bottom-nav { margin-top: 8px; margin-bottom: 32px; }
.apt-bottom-nav .month-nav { display: flex; justify-content: space-between; align-items: center; }
.apt-bottom-nav .month-link {
  font-size: 13px; font-weight: 600; color: var(--text-muted); text-decoration: none;
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer;
}
.apt-bottom-nav .month-link:hover { border-color: var(--primary); color: var(--primary); }
.apt-bottom-nav .month-select {
  font-size: 14px; font-weight: 700; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); cursor: pointer;
}

/* ── 모바일 ── */
@media (max-width: 640px) {
  .tbl-wrap { overflow-x: unset; }

  #trades-tbl,
  #rents-tbl { display: block; }

  /* 컬럼명 헤더 바 — flex wrap으로 나열, 클릭 정렬 유지 */
  #trades-tbl thead,
  #rents-tbl thead { display: block; }

  #trades-tbl thead tr,
  #rents-tbl thead tr {
    display: flex;
    flex-wrap: wrap;
    gap: 0 10px;
    padding: 6px 16px 8px;
    border-bottom: 2px solid var(--border);
  }

  #trades-tbl thead th,
  #rents-tbl thead th { padding: 6px 0; font-size: 13px; white-space: nowrap; cursor: pointer; border-bottom: none; }
  #trades-tbl thead th:hover,
  #rents-tbl thead th:hover { background: transparent; }

  #trades-tbl tbody,
  #rents-tbl tbody { display: block; }

  #trades-tbl tr,
  #rents-tbl tr {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    -webkit-tap-highlight-color: transparent;
  }
  #trades-tbl tr:last-child,
  #rents-tbl tr:last-child { border-bottom: none; }
  #trades-tbl tr:hover td,
  #rents-tbl tr:hover td { background: transparent; }

  #trades-tbl td,
  #rents-tbl td { white-space: normal; border-bottom: none; padding: 0; }

  /* 현재월 연속 행 구분: 배경 + 파란 구분선 */
  #trades-tbl tr.row-cur-ym,
  #rents-tbl  tr.row-cur-ym { background: #eff6ff; border-bottom: 1px solid #bfdbfe; }
  #trades-tbl tr.row-cur-ym td,
  #rents-tbl  tr.row-cur-ym td { background: transparent; }
  #trades-tbl tr.row-cur-ym:hover,
  #rents-tbl  tr.row-cur-ym:hover { background: #dbeafe; }

  /* 매매: (1)거래월 | (2)전용면적 | (3)층 | (4)거래금액 | (5)직전 거래 대비
     줄1: 거래월(flex:1)  직전거래대비(right)
     줄2: 거래금액(full-width, large)
     줄3: 전용면적 · 층 (border-top, 한 줄) */
  #trades-tbl td:nth-child(1) { order: 1; flex: 1; font-size: 12px; color: var(--text-faint); font-weight: 700; }
  #trades-tbl td:nth-child(5) { order: 2; flex-shrink: 0; font-size: 12px; }
  #trades-tbl td:nth-child(4) { order: 3; width: 100%; margin-top: 6px; font-size: 18px; font-weight: 800; color: var(--text-main); }
  #trades-tbl td:nth-child(2) { order: 4; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
  #trades-tbl td:nth-child(3) { order: 5; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
  #trades-tbl td:nth-child(3)::before { content: " · "; color: var(--text-faint); }

  /* 전월세: (1)거래월 | (2)유형 | (3)전용면적 | (4)층 | (5)보증금/월세 | (6)계약
     줄1: 거래월(flex:1)  유형  계약
     줄2: 보증금/월세(full-width, large)
     줄3: 전용면적 · 층 (border-top, 한 줄) */
  #rents-tbl td:nth-child(1) { order: 1; flex: 1; font-size: 12px; color: var(--text-faint); font-weight: 700; }
  #rents-tbl td:nth-child(2) { order: 2; flex-shrink: 0; font-size: 12px; }
  #rents-tbl td:nth-child(6) { order: 3; flex-shrink: 0; font-size: 12px; margin-left: 6px; }
  #rents-tbl td:nth-child(5) { order: 4; width: 100%; margin-top: 6px; font-size: 18px; font-weight: 800; color: var(--text-main); }
  #rents-tbl td:nth-child(3) { order: 5; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
  #rents-tbl td:nth-child(4) { order: 6; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
  #rents-tbl td:nth-child(4)::before { content: " · "; color: var(--text-faint); }
}
