/*
 * 랜딩페이지 통계 (.lps-* / .lpsb-*)  2026-08-21 컴포넌트 이관·재설계
 * 소비처 2곳: 편집모달 통계탭(개별) + 랜딩페이지관리 통합 통계 — shared/_visit_stats_content 공용.
 * (구 파셜 내 <style> 블록을 이관 — 규칙 1. 다크모드 셀렉터 보존)
 */

/* 래퍼 — 로딩 컨테이너(text-align:center·회색)의 상속 오염 차단 */
.lps-wrap {
  max-width: 1040px;
  margin: 0 auto;          /* 광폭 모달에서 가운데 정렬 */
  text-align: left;
  color: #374151;
}

/* ── 헤더: 타이틀 + 기간 툴바 ── */
.lps-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.lps-title { font-size: 15px; font-weight: 700; color: #1e293b; margin: 0; }
.lps-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.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: #2563eb; }
.lps-preset-btn.is-active {
  background: #ffffff;
  color: #1e293b;
  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: #2563eb;
  color: #ffffff;
  font-weight: 700;
  white-space: nowrap;
}
.lps-go-btn:hover { background: #1d4ed8; }

/* ── KPI 카드 ── */
.lps-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.lps-card {
  padding: 12px 14px 11px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 11px;
  border-top: 3px solid #cbd5e1;
}
.lps-card.is-green { border-top-color: #10b981; }
.lps-card.is-blue { border-top-color: #3b82f6; }
.lps-card.is-amber { border-top-color: #f59e0b; }
.lps-card.is-red { border-top-color: #f87171; }
.lps-card-label { font-size: 11.5px; color: #64748b; margin-bottom: 5px; font-weight: 600; }
.lps-card-value { font-size: 22px; font-weight: 700; color: #111827; line-height: 1.1; }
.lps-card-value.is-green { color: #059669; }
.lps-card-value.is-blue { color: #2563eb; }
.lps-card-value.is-red { color: #dc2626; }
.lps-card-value.is-muted { color: #9ca3af; }
.lps-card-sub { font-size: 10.5px; color: #94a3b8; margin-top: 4px; line-height: 1.45; }
.lps-card-sub.is-amber { color: #d97706; }

/* ── 섹션 카드 ── */
.lps-section {
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 11px;
}
.lps-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 12px 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.lps-section-meta { font-weight: 400; color: #94a3b8; font-size: 11px; }
.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; }
@media (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; }

/* ── 반응형 ── */
@media (max-width: 768px) {
  .lps-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .lps-card-value { font-size: 18px; }
  .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; }
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; }
