/* ============================================================
 * 주간 인사이트 리포트 — creative-analysis 디자인 시스템 사용
 * styles.css + creative-analysis.css 위에 weekly-only 스타일만
 * ============================================================ */

/* 주간 리포트 KPI: 8지표 (4×2 그리드 — 카드 폭 줄이고 값 폰트 살짝 다운) */
.kpi-row {
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi-card {
  padding: 14px 16px;
  gap: 4px;
}
.kpi-card .kpi-label { font-size: 11.5px; }
.kpi-card .kpi-value { font-size: 19px; letter-spacing: -0.3px; }
.kpi-card .kpi-delta { font-size: 11.5px; }
.kpi-card .kpi-delta-prev { font-size: 10.5px; }

@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .kpi-row { grid-template-columns: 1fr; }
}

/* dropdown 리스트 (브랜드 / 주차 선택) */
.dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: white;
  border: 1px solid var(--border, #E8E8EC);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(20,20,30,0.10);
  z-index: 30;
  min-width: 240px;
  max-height: 420px;
  overflow-y: auto;
  padding: 6px;
}

.dropdown-panel[hidden] { display: none; }

.dropdown-list {
  display: flex;
  flex-direction: column;
}

.dropdown-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 9px 12px;
  text-align: left;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  border-radius: 6px;
  transition: background 0.12s;
}

.dropdown-item:hover {
  background: var(--bg-hover, #F4F4F7);
}

.dropdown-item.is-selected {
  background: var(--primary-soft, #ECECFB);
  color: var(--primary, #5C5CE0);
  font-weight: 600;
}

/* 헤더 액션 버튼 (마크다운 복사 / PDF) — subnav row meta 영역 */
.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wr-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: white;
  border: 1px solid var(--border, #E8E8EC);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text, #1A1A1A);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.wr-action:hover {
  background: var(--bg-hover, #F4F4F7);
  border-color: var(--text-mute, #999);
}

.wr-action-copy {
  background: var(--primary, #5C5CE0);
  color: white;
  border-color: var(--primary, #5C5CE0);
}
.wr-action-copy:hover {
  background: var(--primary-strong, #4A4ACF);
  border-color: var(--primary-strong, #4A4ACF);
}

/* ============ 강화 인사이트 카드 (그리드) ============ */
.wr-insights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 900px) {
  .wr-insights-grid { grid-template-columns: 1fr; }
}

.wr-insight-card {
  background: #FAFAFC;
  border: 1px solid var(--border, #E8E8EC);
  border-radius: 10px;
  padding: 14px 16px;
}

.wr-insight-card.is-warn { border-color: #F4C95C; background: #FFFAF0; }
.wr-insight-card.is-bad  { border-color: #DC5D6F; background: #FDF1F3; }
.wr-insight-card.is-good { border-color: #1F9D55; background: #F2FCF6; }

.wr-insight-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text, #1A1A1A);
}

.wr-insight-card-icon { font-size: 16px; }

.wr-insight-card-body {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-soft, #666);
}

.wr-insight-card-body strong { color: var(--text, #1A1A1A); font-weight: 600; }

.wr-insight-list {
  margin: 6px 0 0;
  padding-left: 16px;
}
.wr-insight-list li { margin: 3px 0; font-size: 12px; }

.wr-mix-bar {
  display: flex;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin: 6px 0 4px;
  background: #F0F0F3;
}
.wr-mix-bar > div { height: 100%; }
.wr-mix-bar-meta { background: #1877F2; }
.wr-mix-bar-google { background: #E89A2A; }
.wr-mix-bar-naver_sa, .wr-mix-bar-naver_gfa { background: #03C75A; }
.wr-mix-bar-tiktok { background: #DC5D6F; }

.wr-mix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--text-soft, #666);
  margin-top: 4px;
}
.wr-mix-legend i {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 3px;
  vertical-align: middle;
}

.wr-anomaly {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 0;
}
.wr-anomaly-date { color: var(--text-soft, #666); font-variant-numeric: tabular-nums; min-width: 56px; }
.wr-anomaly-metric { font-weight: 600; min-width: 40px; }
.wr-anomaly-arrow.up { color: #1F9D55; }
.wr-anomaly-arrow.down { color: #DC5D6F; }
.wr-anomaly.high { font-weight: 600; }

.wr-ad-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px dashed #F0F0F3;
}
.wr-ad-row:last-child { border-bottom: none; }
.wr-ad-row-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text, #1A1A1A);
}
.wr-ad-row-metric {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 70px;
  text-align: right;
}

/* ============ 매체별 카드 (접이식) ============ */
.wr-platform {
  background: #FAFAFC;
  border: 1px solid var(--border, #E8E8EC);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.wr-platform-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.wr-platform.is-open .wr-platform-head {
  border-bottom-color: #F0F0F3;
}

.wr-platform-head:hover { background: #F4F4F7; }

.wr-platform-name {
  font-size: 14px;
  font-weight: 700;
  flex: 1;
  color: var(--text, #1A1A1A);
}

.wr-platform-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: #F0F0F3;
}
.wr-platform-pill.meta { background:#E1ECFB; color:#1877F2; }
.wr-platform-pill.google { background:#FFF1E0; color:#E89A2A; }
.wr-platform-pill.naver_sa, .wr-platform-pill.naver_gfa { background:#DCF3E5; color:#03C75A; }
.wr-platform-pill.tiktok { background:#FCE9F0; color:#DC5D6F; }

.wr-platform-summary {
  font-size: 12.5px;
  color: var(--text-soft, #666);
  font-variant-numeric: tabular-nums;
}

.wr-platform-caret {
  color: var(--text-mute, #999);
  transition: transform 0.2s;
}

.wr-platform.is-open .wr-platform-caret {
  transform: rotate(180deg);
}

.wr-platform-body {
  padding: 14px 16px 16px;
  background: white;
}

.wr-platform:not(.is-open) .wr-platform-body { display: none; }

/* ============ WoW 비교 표 (매체 카드 내부) ============ */
.wr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-bottom: 10px;
}
.wr-table th, .wr-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #F0F0F3;
}
.wr-table th {
  background: #FAFAFC;
  font-weight: 600;
  color: var(--text-soft, #666);
  font-size: 11.5px;
}
.wr-table td { font-variant-numeric: tabular-nums; }
.wr-table td.num, .wr-table th.num { text-align: right; font-feature-settings: "tnum"; }
.wr-table tr:last-child td { border-bottom: none; }

.wr-delta-pos { color: #1F9D55; font-weight: 600; }
.wr-delta-neg { color: #DC5D6F; font-weight: 600; }
.wr-delta-neu { color: var(--text-mute, #999); }

/* 8컬럼 표 — 가로 스크롤 + 컴팩트 폰트 */
.wr-table-8col {
  font-size: 11.5px;
  table-layout: auto;
  white-space: nowrap;
}
.wr-table-8col th, .wr-table-8col td {
  padding: 7px 8px;
}
.wr-table-8col th {
  font-size: 11px;
}
.wr-table-8col .wr-delta-pos,
.wr-table-8col .wr-delta-neg,
.wr-table-8col .wr-delta-neu {
  font-size: 10.5px;
  margin-left: 2px;
}
/* 부모를 가로 스크롤 가능하게 */
.wr-platform-body, .wr-campaign {
  overflow-x: auto;
}
.wr-platform-body .wr-table-8col,
.wr-campaign .wr-table-8col {
  min-width: 760px;
}

/* ============ 매체 인사이트 박스 ============ */
.wr-insight {
  margin-top: 10px;
  padding: 10px 12px;
  background: #E8F1FA;
  border-left: 3px solid #3795C8;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #1c5078;
}
.wr-insight.is-warn { background: #FFF7E6; border-left-color: #E89A2A; color: #8c6014; }
.wr-insight.is-bad { background: #FDE3E7; border-left-color: #DC5D6F; color: #8a2030; }
.wr-insight.is-good { background: #DCF3E5; border-left-color: #1F9D55; color: #145631; }
.wr-insight ul { margin: 4px 0 0; padding-left: 18px; }
.wr-insight ul li { margin: 2px 0; }
.wr-insight strong { font-weight: 700; }

/* ============ 캠페인 카드 ============ */
.wr-campaigns-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.wr-campaign {
  background: #FAFAFC;
  border: 1px solid var(--border, #E8E8EC);
  border-radius: 8px;
  padding: 11px 13px;
}

.wr-campaign-name {
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text, #1A1A1A);
}

.wr-campaign-mini-table {
  display: grid;
  grid-template-columns: 90px 1fr 1fr 1fr;
  gap: 4px 12px;
  font-size: 11.5px;
  align-items: center;
}

.wr-campaign-mini-table .label { color: var(--text-soft, #666); font-weight: 500; }
.wr-campaign-mini-table .val { font-feature-settings: "tnum"; text-align: right; }

/* ============ 보고서 스타일 캠페인 카드 ============ */
.wr-campaign {
  background: white;
  border: 1px solid var(--border, #E8E8EC);
  border-radius: 10px;
  padding: 14px 16px;
}

.wr-campaign-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.wr-campaign-name {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: var(--text, #1A1A1A);
}

.wr-campaign-link {
  font-size: 11.5px;
  color: var(--primary, #5C5CE0);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--border, #E8E8EC);
}
.wr-campaign-link:hover { background: var(--primary-soft, #ECECFB); }

/* WoW 4컬럼 표 (보고서와 동일) */
.wr-campaign-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-bottom: 10px;
  border: 1px solid #F0F0F3;
  border-radius: 6px;
  overflow: hidden;
}
.wr-campaign-table th, .wr-campaign-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #F0F0F3;
}
.wr-campaign-table th {
  background: #FAFAFC;
  font-weight: 600;
  color: var(--text-soft, #666);
  font-size: 11.5px;
}
.wr-campaign-table td.num, .wr-campaign-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.wr-campaign-table tr.curr-row { background: #FAFCFF; }
.wr-campaign-table tr:last-child td { border-bottom: none; }

/* 14일 sparkline 차트 박스 */
.wr-campaign-chart {
  padding: 8px 10px;
  background: #FAFAFC;
  border-radius: 6px;
  margin-bottom: 10px;
}
.wr-campaign-chart-legend {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-mute, #999);
  margin-bottom: 4px;
}

/* 인사이트 callout (보고서 톤) */
.wr-campaign-insight {
  background: #EFF7FE;
  border-left: 3px solid #3795C8;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  color: #1c5078;
  margin-top: 6px;
}
.wr-campaign-insight.is-warn { background: #FFF7E6; border-left-color: #E89A2A; color: #8c6014; }
.wr-campaign-insight.is-bad { background: #FDE3E7; border-left-color: #DC5D6F; color: #8a2030; }
.wr-campaign-insight.is-good { background: #DCF3E5; border-left-color: #1F9D55; color: #145631; }

.wr-campaign-insight-head { margin-bottom: 4px; }
.wr-campaign-insight-head strong { font-weight: 700; }

.wr-campaign-insight-list {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.55;
}
.wr-campaign-insight-list li { margin: 2px 0; }
.wr-campaign-insight-list li b { font-weight: 700; color: inherit; }

.wr-campaign-actions {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  padding-top: 6px;
  border-top: 1px dashed currentColor;
  opacity: 0.85;
}
.wr-campaign-actions strong { font-weight: 700; }

/* 광고그룹 접기 */
.wr-campaign-adsets {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #E8E8EC;
}
.wr-campaign-adsets summary {
  font-size: 11.5px;
  color: var(--text-soft, #666);
  cursor: pointer;
  user-select: none;
  margin-bottom: 6px;
}
.wr-campaign-adsets summary:hover { color: var(--text, #1A1A1A); }

.wr-adset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 4px 0;
  color: var(--text-soft, #666);
}
.wr-adset-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wr-adset-metric {
  font-variant-numeric: tabular-nums;
}

/* ============ 위닝 소재 갤러리 ============ */
.wr-winners-group { margin-bottom: 18px; }
.wr-winners-group:last-child { margin-bottom: 0; }

.wr-winners-group-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft, #666);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wr-winners-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 1200px) { .wr-winners-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .wr-winners-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .wr-winners-grid { grid-template-columns: 1fr; } }

.wr-winner-card {
  background: white;
  border: 1px solid var(--border, #E8E8EC);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.wr-winner-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(20,20,30,0.10);
}

.wr-winner-thumb {
  width: 100%;
  aspect-ratio: 1/1;
  background: #1a1a1a;
  position: relative;
  overflow: hidden;
}

.wr-winner-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wr-winner-overlay-tl {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 4px;
}

.wr-winner-roas-badge {
  display: inline-block;
  background: rgba(31, 157, 85, 0.95);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 5px;
  font-feature-settings: "tnum";
}

.wr-winner-platform-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 5px;
  letter-spacing: 0.5px;
}

.wr-winner-info { padding: 10px 12px; }

.wr-winner-name {
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  height: 32px;
}

.wr-winner-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  font-size: 11px;
}

.wr-winner-metric { text-align: center; }
.wr-winner-metric .lbl { color: var(--text-mute, #999); display: block; margin-bottom: 1px; }
.wr-winner-metric .val { font-weight: 700; font-feature-settings: "tnum"; }
.wr-winner-metric.roas .val { color: #1F9D55; }

/* ============ 데이터 신선도 ============ */
.wr-freshness {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  font-size: 12.5px;
}

.wr-fresh-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #FAFAFC;
  border: 1px solid var(--border, #E8E8EC);
  border-radius: 6px;
}

.wr-fresh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1F9D55;
}

.wr-fresh-dot.stale { background: #E89A2A; }
.wr-fresh-dot.gone { background: #DC5D6F; }

.wr-fresh-lbl { font-weight: 600; margin-right: auto; }
.wr-fresh-time { color: var(--text-soft, #666); font-variant-numeric: tabular-nums; }

/* ============ 토스트 ============ */
.wr-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text, #1A1A1A);
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 100;
  transition: opacity 0.2s;
}

.wr-toast[hidden] { display: none; }

.wr-empty {
  padding: 32px;
  text-align: center;
  color: var(--text-mute, #999);
  font-size: 13px;
}

/* ============ 인쇄 ============ */
@media print {
  .sidebar, .header-controls, .header-meta { display: none !important; }
  .main { padding-left: 0 !important; }
  .wr-platform { break-inside: avoid; }
  .wr-platform-body { display: block !important; }
  .wr-winner-card:hover { transform: none; box-shadow: none; }
}
