/*
 * Data surfaces.
 *
 * Every selector here names a class the console already writes into the DOM but
 * that no stylesheet ever defined. Those elements fell back to browser defaults:
 * a stat card whose value, label and sub-line are a <strong>, a <span> and a
 * <small> collapsed into one run-on line ("627명누적 회원오늘 5명"), panels with
 * no panel, toolbars with no row, tables with no frame.
 *
 * The rules follow the existing language in components.css and workbench.css —
 * same tokens, same radii, same card construction — so the repaired surfaces
 * read as part of the console rather than as a second design.
 *
 * Presentation only: no layout ownership is moved here from the page modules,
 * and no rule depends on runtime state beyond the classes the modules set.
 */

/* ── Stat cards ──────────────────────────────────────────────────────────
 * Used by the member, moderation-case, and news-viral metric blocks. */
.moderation-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
  margin: 14px 0 20px;
}

.moderation-stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-surface);
}

.moderation-stat-value {
  overflow-wrap: anywhere;
  color: var(--color-text);
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.moderation-stat-label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
}

.moderation-stat-sub {
  margin-top: 2px;
  color: var(--color-primary);
  font-size: 0.76rem;
  font-weight: 700;
}

/* A card the operator cannot trust should not look like a confident number. */
.moderation-stat-card[data-status="needs_verification"] .moderation-stat-value,
.moderation-stat-card[data-status="unavailable"] .moderation-stat-value,
.moderation-stat-card[data-status="not_calculable"] .moderation-stat-value {
  color: var(--color-text-muted);
  font-size: 1.05rem;
  font-weight: 700;
}

.moderation-stat-card[data-status="unavailable"],
.moderation-stat-card[data-status="not_calculable"] {
  border-style: dashed;
  background: var(--color-surface-muted);
  box-shadow: none;
}

/* ── Member insight block ───────────────────────────────────────────────── */
.member-insights {
  display: block;
  margin: 0 0 28px;
}

.member-insights > .catalog-heading {
  margin-bottom: 4px;
}

.member-insight-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.member-insight-list:empty {
  display: none;
}

.member-insight-list > .content-row-title {
  flex: 1 1 100%;
  margin: 4px 0 2px;
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 800;
}

/* Trend and referral rows are sentences, not chips: one per line, readable. */
.member-insight-list > p {
  flex: 1 1 100%;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.member-insight-list > p.empty-state {
  padding: 18px;
  font-size: 0.82rem;
}

/* ── Moderation case workspace ──────────────────────────────────────────── */
.moderation-case-stats {
  display: block;
  margin: 0 0 24px;
}

.moderation-case-tool,
.moderation-editor {
  display: grid;
  gap: 12px;
  margin: 0 0 24px;
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-surface);
}

.moderation-editor-title {
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 800;
}

.moderation-case-top {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.moderation-case-top:empty {
  display: none;
}

.moderation-analysis-result {
  max-height: 260px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.moderation-analysis-result:empty {
  display: none;
}

.moderation-read-only-note {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: var(--color-primary-soft);
  color: var(--color-text);
  font-size: 0.82rem;
}

/* ── Content workspace ──────────────────────────────────────────────────── */
.content-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.content-toolbar label {
  display: grid;
  gap: 4px;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.content-toolbar input,
.content-toolbar select,
.content-toolbar textarea {
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
}

.content-toolbar input[type="search"],
.content-toolbar input[type="text"] {
  min-width: 220px;
}

.content-notice {
  display: grid;
  gap: 12px;
  margin: 0 0 20px;
  padding: 18px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-surface);
}

.content-notice > p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.content-notice label {
  display: grid;
  gap: 5px;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.content-notice input,
.content-notice select,
.content-notice textarea {
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
}

.content-notice textarea {
  min-height: 96px;
  resize: vertical;
}

.content-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-surface);
}

.content-table-wrap table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.content-table-wrap th,
.content-table-wrap td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: middle;
}

.content-table-wrap th {
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.content-table-wrap tbody tr:last-child td {
  border-bottom: 0;
}

/* An empty table says so in the middle of the frame, not against its left edge. */
.content-table-wrap td[colspan] {
  padding: 26px 14px;
  color: var(--color-text-muted);
  text-align: center;
}

.content-code {
  max-height: 320px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: 0.76rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A button in a grid stretches to the column unless told otherwise, which makes
 * a submit read like a banner. Keep it the width of its own label. */
.moderation-case-tool > .button,
.moderation-editor > .button,
.content-notice > .button,
.workbench-panel > .button {
  justify-self: start;
}

/* The browser's own file control is the one part of these forms that still
 * looks like a raw form. Give it the same frame as the fields beside it. */
.moderation-case-tool input[type="file"],
.moderation-editor input[type="file"],
.content-notice input[type="file"],
.content-toolbar input[type="file"],
.workbench-panel input[type="file"] {
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.moderation-case-tool input[type="file"]::file-selector-button,
.moderation-editor input[type="file"]::file-selector-button,
.content-notice input[type="file"]::file-selector-button,
.content-toolbar input[type="file"]::file-selector-button,
.workbench-panel input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

/* ── Shared page scaffolding ────────────────────────────────────────────── */
.workspace-page-body {
  display: block;
  min-width: 0;
}

.workspace-tabs-mount {
  display: block;
  min-width: 0;
}

.workspace-tabs-mount:empty {
  display: none;
}

.workbench-panel {
  display: grid;
  gap: 12px;
  margin: 0 0 20px;
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-surface);
}

.workbench-panel > h3,
.workbench-panel > h4 {
  margin: 0;
  font-size: 1rem;
}

.workbench-panel > p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.operations-overview-copy {
  min-width: 0;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.report-collected-at {
  display: inline-block;
  color: var(--color-text-muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

/* Pointer capture band over the trend chart — deliberately invisible. */
.operations-trend-hit-area {
  fill: transparent;
  stroke: none;
}

/* ── Modifiers whose base class is styled but which carried no rule ─────── */
.button-secondary {
  border-color: var(--color-border);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-weight: 700;
}

.button-secondary:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-strong);
  color: var(--color-text);
}

.status-badge-ok {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.status-pill-neutral {
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
}

.delta-badge-unavailable {
  color: var(--color-text-muted);
  font-weight: 700;
}

.secondary-dashboard-section {
  margin-top: 24px;
}

.operations-range-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.content-performance-section,
.traffic-analysis-section {
  margin-top: 24px;
}

.advertiser-report {
  display: grid;
  gap: 14px;
}

.advertiser-report-detail {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.kakao-conversation-form,
.search-insights-internal,
.search-insights-external,
.search-insights-naver {
  display: grid;
  gap: 12px;
}

.kakao-saved-list {
  display: grid;
  gap: 10px;
}

@media (max-width: 900px) {
  .moderation-stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .content-toolbar {
    align-items: stretch;
  }

  .content-toolbar input[type="search"],
  .content-toolbar input[type="text"] {
    min-width: 0;
  }

  .moderation-case-tool,
  .moderation-editor,
  .workbench-panel,
  .content-notice {
    padding: 16px;
  }
}

/* ── Surfaces the route sweep could not reach ────────────────────────────
 * A browser pass only exercises the branches its fixtures render. These
 * classes sit on code paths behind real data — a page's own tab row, posting
 * rows, bot scheduler output, the readiness matrix — and had no rule either.
 * Found by the static contract test in tests/admin-styled-class-contract.js. */

/* A page that renders its own tab row, rather than mounting the shell's. */
.workbench-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 20px;
  border-bottom: 1px solid var(--color-border);
}

.workbench-tab {
  min-height: 40px;
  padding: 9px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.workbench-tab:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.workbench-tab[aria-selected="true"] {
  border-bottom-color: var(--color-primary);
  color: var(--color-primary);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--color-surface-strong);
  color: var(--color-text-muted);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
}

.content-link {
  color: var(--color-primary);
  font-size: 0.82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.content-link:hover {
  text-decoration: underline;
}

.content-row-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  min-width: 0;
}

.content-row-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  margin-top: 6px;
}

.content-row-links:empty {
  display: none;
}

/* Bot operations: scheduler output and the lazily mounted insight panel. */
.bot-scheduler-logs,
.bot-insights-mount {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.bot-scheduler-logs:empty,
.bot-insights-mount:empty {
  display: none;
}

/* A skeleton standing in for a secondary dashboard section. */
.secondary-section-skeleton {
  margin-top: 12px;
}

/* Readiness matrix and status views. */
.readiness-matrix-view,
.readiness-status-view {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.readiness-feature-row > td {
  vertical-align: top;
}

.readiness-feature-verification {
  display: block;
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 0.74rem;
  overflow-wrap: anywhere;
}

.readiness-blocker-feature {
  color: var(--color-text);
  font-weight: 700;
  overflow-wrap: anywhere;
}
