/*
 * 랜딩페이지 통계 (.lps-* / .lpsb-*)  2026-08-21 컴포넌트 이관·재설계
 * 소비처 2곳: 편집모달 통계탭(개별) + 랜딩페이지관리 통합 통계 — shared/_visit_stats_content 공용.
 * (구 파셜 내 <style> 블록을 이관 — 규칙 1. 다크모드 셀렉터 보존)
 *
 * 2026-08-22 A-4 개편: 전폭 사용 + 2컬럼(좌 집계 | 우 방문자 랭킹·방문 로그) + 섹션 헤더 밴드.
 * 반응형은 컨테이너 쿼리(.lps-wrap 이 컨테이너) — rmm 모달이 드래그 리사이즈라 뷰포트 기준 불가.
 */

/* 래퍼 — 로딩 컨테이너(text-align:center·회색)의 상속 오염 차단. 전폭 사용(구 max-width 1040 폐기) */
.lps-wrap {
  container-type: inline-size;
  text-align: left;
  color: #374151;
}

/* ── 2컬럼: 좌 집계 | 우 방문자(랭킹·로그 — 11컬럼 표라 약간 넓게) ── */
.lps-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 12px;
  align-items: start;
}
.lps-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ── 필터 바 (2026-09-08 — 광고캠페인 통계 필터 바와 같은 문법: 기간 세그먼트·날짜·조회·랜딩 선택·상태 + 메타 한 줄) ── */
.lps-fbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; background: #fff; border: 1px solid #dbe6f0; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.lps-fgrp { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lps-flab { font-size: 11.5px; font-weight: 700; color: #6b7280; white-space: nowrap; }
.lps-seg { display: inline-flex; background: #f1f5f9; border-radius: 8px; padding: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.lps-seg button { font-family: inherit; border: 0; background: transparent; padding: 4px 11px; border-radius: 6px; font-size: 12px; font-weight: 600; color: #64748b; cursor: pointer; white-space: nowrap; line-height: 1.5; }
.lps-seg button.on { background: #fff; color: #3e6187; font-weight: 800; box-shadow: 0 1px 2px rgba(15,23,42,.1); }
.lps-pick { font-family: inherit; font-size: 12px; font-weight: 700; border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; padding: 5px 10px; color: #374151; cursor: pointer; min-width: 180px; max-width: 320px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.lps-pick:hover { border-color: #9db7cf; color: #3e6187; }
.lps-pick-caret { margin-left: auto; color: #9ca3af; font-size: 11px; }
.lps-fmeta { font-size: 11.5px; color: #9ca3af; margin-left: auto; }
.lps-loading { text-align: center; padding: 28px 0; color: #9ca3af; font-size: 13px; }
.lps-spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid #e5e7eb; border-top-color: #3e6187; border-radius: 50%; animation: lps-spin .6s linear infinite; }
@keyframes lps-spin { to { transform: rotate(360deg); } }
.lps-wrap.is-loading > [data-visit-stats-target="content"] { opacity: .5; pointer-events: none; }

/* 방문자 랭킹 [방문순|전환순] 이 쓰는 프리셋 칩(구 기간 툴바 잔재 — 랭킹 섹션 전용) */
.lps-presets {
  display: inline-flex;
  gap: 2px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  padding: 3px;
}
.lps-preset-btn {
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  padding: 5px 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-weight: 600;
  user-select: none;
  white-space: nowrap;
}
.lps-preset-btn:hover { color: #3e6187; }
.lps-preset-btn.is-active {
  background: #ffffff;
  color: #3e6187;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.lps-range { display: inline-flex; align-items: center; gap: 6px; }
.lps-date-input {
  padding: 6px 9px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 12px;
  background: #ffffff;
  color: #111827;
  width: 132px;
  box-sizing: border-box;
}
.lps-range-sep { font-size: 11px; color: #9ca3af; }
.lps-go-btn {
  padding: 6px 15px;
  border: 0;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  background: #3e6187;
  color: #ffffff;
  font-weight: 700;
  white-space: nowrap;
}
.lps-go-btn:hover { background: #355475; }

/* ── KPI 카드 — K3 문법 (2026-09-08: 라벨+전기 배지 / 큰 값 / 보조 지표 한 줄, 광고캠페인 통계 카드와 동일) ── */
.lps-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.lps-card { padding: 11px 14px 10px; background: #ffffff; border: 1px solid #dbe6f0; border-radius: 10px; min-width: 0; }
.lps-card.hero { background: linear-gradient(180deg, #f3f7fb, #fff); border-color: #c9d8e6; }
.lps-card-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.lps-card-label { font-size: 11.5px; color: #6b7280; font-weight: 700; white-space: nowrap; }
.lps-card-value { font-size: 26px; font-weight: 800; color: #111827; line-height: 1.15; margin-top: 4px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.lps-card-value small { font-size: 12px; font-weight: 600; color: #9ca3af; margin-left: 3px; letter-spacing: 0; }
.lps-card-value.is-green { color: #059669; }
.lps-card-value.is-blue { color: #3e6187; }
.lps-card-value.is-red { color: #dc2626; }
.lps-card-value.is-muted { color: #9ca3af; }
.lps-card-sub { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #dbe6f0; font-size: 11px; color: #6b7280; display: flex; gap: 10px; flex-wrap: wrap; line-height: 1.45; }
.lps-card-sub b { color: #374151; }
.lps-card-sub .is-amber { color: #d97706; }
.lps-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.lps-delta.up { background: #ecfdf5; color: #047857; } .lps-delta.down { background: #fef2f2; color: #b91c1c; } .lps-delta.flat { background: #f1f5f9; color: #64748b; }
.lps-delta.inv.up { background: #fef2f2; color: #b91c1c; } .lps-delta.inv.down { background: #ecfdf5; color: #047857; }
/* 카드 라벨 옆 도움말 (?) — title 툴팁 (2026-09-06 집계 제외 카드) */
.lps-help { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; margin-left: 4px; border-radius: 50%; border: 1px solid #c4d3e2; color: #64748b; font-size: 9px; font-weight: 700; cursor: help; vertical-align: middle; }

/* ── 섹션 카드 — A-4 언어: 헤더 밴드(.lps-section-title) + 본문(.lps-section-bd) ── */
.lps-section {
  padding: 0;
  background: #ffffff;
  border: 1px solid #dbe6f0;
  border-radius: 10px;
  overflow: hidden;
}
.lps-section-title {
  font-size: 12px;
  font-weight: 700;
  color: #3e6187;
  margin: 0;
  padding: 8px 14px;
  background: #f3f7fb;
  border-bottom: 1px solid #e4edf5;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.lps-section-bd { padding: 12px 14px; }
.lps-section-meta { font-weight: 400; color: #94a3b8; font-size: 10.5px; }
.lps-sub-title { font-size: 11.5px; font-weight: 700; color: #64748b; margin-bottom: 6px; text-align: center; }
.lps-charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* ⚠Chart.js 랫칫 차단 (7/21 대시보드 교훈) — 캔버스가 인라인 px 폭을 갖는데 그리드 아이템의
   기본 min-width:auto 는 내용 이하로 줄지 못해 그리드가 래퍼 폭을 뚫고 나간다 */
.lps-charts-grid > * { min-width: 0; }
.lps-chart-box { position: relative; height: 200px; }
.lps-chart-box canvas { max-width: 100% !important; }
.lps-chart-box.sm { height: 160px; }
.lps-empty { color: #9ca3af; font-size: 12.5px; text-align: center; padding: 22px 0; margin: 0; }
.lps-peak-note { text-align: center; margin-top: 6px; font-size: 11px; color: #6b7280; }
.lps-peak-note b { color: #2563eb; }

/* ── 행동 분석 (2026-08-06) ── */
.lpsb-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.lpsb-label { flex: 0 0 82px; font-size: 11.5px; color: #475569; text-align: right; }
.lpsb-label.sm { flex-basis: 68px; font-size: 11px; }
.lpsb-track { flex: 1; height: 15px; background: #eef2f7; border-radius: 4px; overflow: hidden; }
.lpsb-track.sm { height: 12px; }
.lpsb-fill { height: 100%; background: #64748b; border-radius: 4px; transition: width 0.3s; }
.lpsb-fill.is-form { background: #3b82f6; }
.lpsb-val { flex: 0 0 84px; font-size: 11.5px; color: #111827; font-weight: 600; text-align: right; }
.lpsb-val.sm { flex-basis: 46px; font-weight: 500; color: #475569; }
.lpsb-pct { color: #94a3b8; font-weight: 400; margin-left: 5px; }
.lpsb-drop { flex: 0 0 52px; font-size: 10.5px; color: #dc2626; text-align: right; }
.lpsb-note { font-size: 11px; color: #94a3b8; margin: 8px 0 0; line-height: 1.6; }
.lpsb-dist {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
}
.lpsb-dist-title { font-size: 11.5px; font-weight: 600; color: #64748b; margin-bottom: 7px; }
@container (max-width: 640px) { .lpsb-dist { grid-template-columns: 1fr; } }

/* ── 페이지별 비교(통합 통계) ── */
.lps-bar-row { display: flex; align-items: center; gap: 8px; }
.lps-bar-name {
  font-size: 11px;
  color: #374151;
  min-width: 80px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lps-bar-track { flex: 1; height: 18px; background: #f3f4f6; border-radius: 4px; overflow: hidden; }
.lps-bar-fill { height: 100%; background: #60a5fa; border-radius: 4px; min-width: 2px; }
.lps-bar-val { font-size: 10.5px; color: #6b7280; min-width: 92px; text-align: right; white-space: nowrap; }

/* ── 최근 방문 로그 ── */
.lps-table-view { overflow-x: auto; border: 1px solid #e5e7eb; border-radius: 10px; }
.lps-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.lps-table th {
  padding: 8px 10px;
  text-align: center;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
  background: #f8fafc;
  border-bottom: 2px solid #e5e7eb;
}
.lps-table td {
  padding: 7px 10px;
  text-align: center;
  color: #374151;
  white-space: nowrap;
  border-bottom: 1px solid #f3f4f6;
}
.lps-table tbody tr:last-child td { border-bottom: 0; }
/* 고정 서버 렌더 표(숨김·재정렬 없음)라 nth-child 안전 */
.lps-table tbody tr:nth-child(even) { background: #fafbfc; }
.lps-table tbody tr:hover { background: #f1f5f9; }
.lps-td-muted { color: #6b7280; }
.lps-td-mono { font-family: monospace; font-size: 11px; color: #6b7280; }
.lps-td-mono.is-faint { color: #9ca3af; }
.lps-source-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}
.lps-conv { color: #059669; font-weight: 600; font-size: 11px; }
.lps-none { color: #d1d5db; }

/* 클릭 가능한 식별자(기기 UA·IP·쿠키) — 점선 밑줄 = 상세 있음 (2026-08-21) */
.lps-ident { cursor: pointer; border-bottom: 1px dashed #cbd5e1; }
.lps-ident:hover { color: #2563eb; border-bottom-color: #2563eb; }
.lps-ident-conv { color: #059669; margin-left: 3px; font-weight: 700; font-family: inherit; }

.lps-card-view { display: none; flex-direction: column; gap: 8px; }
.lps-log-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  background: #ffffff;
}
.lps-log-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.lps-log-card-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: #6b7280; }

/* ── 반응형 (컨테이너 쿼리 — .lps-wrap 폭 기준: rmm 모달 드래그 리사이즈 대응) ── */
@container (max-width: 1100px) {
  .lps-cols { grid-template-columns: minmax(0, 1fr); }
}
@container (max-width: 768px) {
  .lps-summary-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .lps-card-value { font-size: 22px; }
  .lps-fbar { padding: 10px 12px; gap: 10px 14px; }
  .lps-fbar .lps-fgrp { width: 100%; }
  .lps-fbar .lps-seg button { padding: 6px 11px; }
  .lps-pick { min-width: 0; flex: 1; }
  .lps-fmeta { display: none; }
  .lps-charts-grid { grid-template-columns: 1fr; }
  .lps-table-view { display: none !important; }
  .lps-card-view { display: flex !important; }
}

/* ── 다크모드(개발자 전용 테마) — 구 인라인 블록에서 보존 ── */
html.dark .lps-card { background: #1e293b; border-color: #334155; }
html.dark .lps-card-label { color: #94a3b8; }
html.dark .lps-card-value { color: #f1f5f9; }
html.dark .lps-section { background: #1e293b; border-color: #334155; }
html.dark .lps-section-title { color: #e2e8f0; background: #24344a; border-bottom-color: #334155; }
html.dark .lpsb-label, html.dark .lpsb-val.sm { color: #cbd5e1; }
html.dark .lpsb-val { color: #f1f5f9; }
html.dark .lpsb-track { background: #334155; }
html.dark .lpsb-dist { border-top-color: #334155; }
