/*
 * ss-pages — 대시보드 배치 (ss = shadcn-studio). 설계 §5.5, 4단계 계획 06-dashboard.
 *
 * 원본 블록(shadcn-studio, MCP로 소스를 읽었다):
 *   dashboard-shell-01        본문 격자: 통계 줄(col-span-full) · 위젯 카드들 · 표 카드(col-span-full, py-0)
 *   statistics-component-01   통계 카드: 머리(아이콘 칸 size-8 bg-primary/10 + 수치) · 이름 · 설명. 격자 sm 2열 · lg 4열, gap-4
 *   widget-component-03       목록 위젯: CardHeader(제목 · 메뉴) · CardContent(flex-col gap-4, 한 줄 = 아이콘 · 두 줄 글 · 오른쪽 값)
 * 컴포넌트는 Card·Item·Table·Badge·Alert·Button이다. 여기는 배치 유틸리티만 옮겼다(색·모서리·글자는 components.css의 [data-slot]).
 *
 * 블록과 다른 점:
 *   - 통계 카드는 누르는 Item(button)이다(발송 관제로 간다). 수치 옆 증감 %는 없다: 목록에 분모가 없어 개수만 센다.
 *     아이콘 칸은 bg-primary/10 대신 item-media icon 변형(회색 칸)이다. 좁은 컨테이너(30rem 이하)에서는 아이콘 칸을 숨긴다.
 *   - 위젯 머리의 ⋮ 메뉴 대신 ghost '전체 보기' 단추(card-action)다. 머리 아래에 출처별 확인 상태(Alert)가 붙는다.
 *   - 목록 한 줄은 아바타 대신 글만 쌓는다(다음 할 일: 방·사유 Badge / 위치 / 조치 / 공지·시각, 최근 활동: 이벤트 / 대상·작업자 | 결과·시각).
 *   - 표 카드에 쪽 이동이 없다(어제·오늘 공지 전체를 보인다). 셀은 줄을 바꾸지 않고 제목·주제 칸만 줄바꿈 칸(8~20rem)이다.
 *   - 열 전환은 lg(1024px) 대신 본문 크기 컨테이너 50rem이다(사이드바가 열린 901–1152px는 내용 폭이 610–860px뿐이다). 900px 이하는 한 열이다.
 */
@layer ss-pages {
  /* 본문: 요약 줄, 그 아래 다음 할 일 | 최근 활동, 그 아래 최근 공지(전체 폭). DOM 순서가 읽는 순서다. */
  .ss-dashboard-body { container: ss-dashboard / inline-size; }
  .ss-dashboard-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 0 0 1.5rem; }
  .ss-dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 1.25rem; }

  /* 요약 카드: 누르는 Item. 카드 바탕은 Card와 같은 흰색이고, 손을 올리면 옅은 강조색이다. */
  .ss-dashboard-stat { align-content: start; gap: .5rem; min-width: 0; padding: 1.25rem; background: var(--ss-card); border-radius: var(--ss-radius-xl); box-shadow: var(--ss-shadow-sm); }
  .ss-dashboard-stat:hover { background: color-mix(in srgb, var(--ss-accent) 50%, var(--ss-card)); }
  .ss-dashboard-stat-head { display: flex; align-items: center; gap: .75rem; min-width: 0; }
  .ss-dashboard-stat-head > .ss-stat-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
  .ss-dashboard-stat-head > svg { flex: none; width: 1rem; height: 1rem; color: var(--ss-muted-foreground); }
  .ss-dashboard-stat:hover .ss-dashboard-stat-head > svg { color: var(--ss-foreground); }
  .ss-dashboard-stat > .ss-stat-value { display: flex; align-items: baseline; gap: .125rem; min-height: 2.25rem; }
  .ss-dashboard-stat-unit { color: var(--ss-muted-foreground); font-size: .875rem; font-weight: 500; letter-spacing: 0; }
  .ss-dashboard-stat-meta { color: var(--ss-muted-foreground); font-size: .75rem; line-height: 1.5; word-break: keep-all; overflow-wrap: anywhere; }
  /* 주의: 실패 개수가 0이 아니면 왼쪽 띠와 수치가 위험 색이다. 0은 중립이다. */
  .ss-dashboard-stat[data-attention="true"] { border-left: 3px solid var(--ss-status-danger-fg); }
  .ss-dashboard-stat[data-attention="true"] .ss-dashboard-stat-number { color: var(--ss-status-danger-fg); }
  .ss-dashboard-stat:is([data-summary-state="failed"], [data-summary-state="stale"]) .ss-dashboard-stat-meta { color: var(--ss-destructive); font-weight: 500; }
  .ss-dashboard-stat:is([data-summary-state="unchecked"], [data-summary-state="failed"]) > .ss-stat-value { color: var(--ss-muted-foreground); }

  /* 카드 머리 아래의 출처별 확인 상태. 정상(status)이면 '마지막 정상 확인' 한 줄의 보조 글이고, 실패(destructive)면 Alert 상자다. */
  .ss-dashboard-feedback { grid-column: 1 / -1; }
  .ss-dashboard-feedback[data-variant="status"] { padding: 0; color: var(--ss-muted-foreground); background: none; border: 0; font-size: .75rem; line-height: 1.5; }

  /* 빈 목록·확인 전: 카드 안의 점선 상자. */
  .ss-dashboard-empty { margin: 0; padding: 1.5rem 1rem; color: var(--ss-muted-foreground); text-align: center; border: 1px dashed var(--ss-border); border-radius: var(--ss-radius-md); font-size: .875rem; line-height: 1.5; }

  /* 다음 할 일: 실패 한 건 = 누르는 Item(outline) 한 줄. 방 이름(최대 255자)과 경로는 줄을 바꾼다. */
  .ss-dashboard-list { gap: .5rem; }
  .ss-dashboard-failure { align-items: flex-start; padding: .875rem 1rem; }
  .ss-dashboard-failure [data-slot="item-title"] { flex-wrap: wrap; width: auto; }
  .ss-dashboard-failure-room { min-width: 0; font-size: .9375rem; font-weight: 600; overflow-wrap: anywhere; }
  .ss-dashboard-failure-guidance { display: flex; align-items: baseline; gap: .5rem; color: var(--ss-foreground); font-size: .875rem; line-height: 1.6; overflow-wrap: anywhere; }
  /* 행의 접근 이름은 단추의 aria-label이다. 이 표지는 보이기만 하고 읽히지 않는다(대체 글 ""). */
  .ss-dashboard-failure-guidance::before { flex: none; padding: 0 .375rem; content: "조치" / ""; color: var(--ss-foreground); background: var(--ss-muted); border: 1px solid var(--ss-border); border-radius: var(--ss-radius-sm); font-size: .6875rem; font-weight: 600; line-height: 1.5; }
  .ss-dashboard-failure-time { color: var(--ss-muted-foreground); font-size: .75rem; line-height: 1.5; overflow-wrap: anywhere; }

  /* 최근 활동: 좁은 열이라 한 건이 이벤트·대상 줄과 결과·시각 줄로 쌓인다. 건 사이는 위 경계선이다. */
  .ss-dashboard-activity { padding: .75rem 0; border-radius: 0; }
  .ss-dashboard-activity:first-child { padding-top: 0; }
  .ss-dashboard-activity + .ss-dashboard-activity { border-top-color: var(--ss-border); }
  /* 공용 item-content는 flex: 1 1 0%라 결과·시각이 한 줄에 들어가면 같은 줄에 남아 글 칸을 누르고, 긴 결과 라벨은 카드 밖으로 넘친다.
     글 칸이 줄 전체를 차지해 결과·시각을 다음 줄로 내리고, 그 줄도 좁으면 Badge와 시각이 다시 줄을 바꾼다(테스트). */
  .ss-dashboard-activity > [data-slot="item-content"] { flex-basis: 100%; }
  .ss-dashboard-activity > [data-slot="item-actions"] { flex-wrap: wrap; max-width: 100%; }
  .ss-dashboard-activity-time { color: var(--ss-muted-foreground); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

  /* 최근 공지: 표 카드(블록의 py-0 Card). 표는 카드 끝까지 닿고 #dashboard-recent-notice-rows(table-container) 안에서만 가로로 밀린다. */
  .ss-dashboard-notices { gap: 1rem; padding-bottom: 0; overflow: clip; }
  .ss-dashboard-notice-table { border-top: 1px solid var(--ss-border); }
  .ss-dashboard-notice-rows [data-slot="table-head"] { color: var(--ss-muted-foreground); }
  .ss-dashboard-notice-rows :is([data-slot="table-head"], [data-slot="table-cell"]):first-child { padding-left: 1.5rem; }
  .ss-dashboard-notice-rows :is([data-slot="table-head"], [data-slot="table-cell"]):last-child { padding-right: 1.5rem; }
  .ss-dashboard-notice-rows > .ss-dashboard-empty { margin: 0 1.5rem 1.5rem; }
  /* 행을 고르는 공지 제목(link Button). 80자까지 오는 제목이 줄바꿈 칸 안에서 줄을 바꾸고, 조작 영역 44px은 그대로다. */
  .ss-dashboard-notice-open[data-slot="button"] { justify-content: flex-start; min-height: var(--ss-control-height); padding-inline: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  /* 고른 행은 tr의 data-state="selected" 바탕이 보여 준다. 단추의 aria-pressed(사본과 같은 계약)가 Button의 눌림 상자를 그리지 않게 한다. */
  .ss-dashboard-notice-open[data-slot="button"][aria-pressed="true"] { background: transparent; border-color: transparent; }

  /* 고른 공지의 상세: 화면의 직계 자식일 때(시트로 옮겨지기 전)는 숨는다. 시트가 이 노드를 자기 본문으로 옮긴다(테스트). */
  .ss-view > .ss-dashboard-detail { display: none; }
  .ss-dashboard-detail { display: grid; gap: 1.25rem; min-width: 0; }
  .ss-dashboard-detail-heading { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
  .ss-dashboard-detail-body { margin: 0; padding: 1rem; font-size: 1rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--ss-card); border: 1px solid var(--ss-border); border-radius: var(--ss-radius-md); }
  .ss-dashboard-detail-helper { margin: 0; color: var(--ss-muted-foreground); font-size: .875rem; line-height: 1.5; }
  .ss-dashboard-detail-subheading { margin: 0 0 -.5rem; font-size: .875rem; font-weight: 600; line-height: 1.5; }
  .ss-dashboard-detail-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

  /* 넓은 본문(내용 폭 50rem 이상): 요약 4열. 900px보다 넓은 화면이면 다음 할 일 | 최근 활동 두 열이고 최근 공지가 아래 전체 폭이다. */
  @container ss-dashboard (min-width: 50rem) {
    .ss-dashboard-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
  @media (min-width: 901px) {
    @container ss-dashboard (min-width: 50rem) {
      .ss-dashboard-grid { grid-template-columns: minmax(0, 1.75fr) minmax(17rem, 1fr); gap: 1.5rem; }
      .ss-dashboard-notices { grid-column: 1 / -1; }
    }
  }
  /* 좁은 본문: 요약 카드 두 열에 이름이 들어가도록 아이콘 칸을 숨긴다(꺾쇠는 남는다). */
  @container ss-dashboard (max-width: 30rem) {
    .ss-dashboard-stat-head > [data-slot="item-media"] { display: none; }
  }
  @media (max-width: 640px) {
    .ss-dashboard-summary { gap: .75rem; margin-bottom: 1.25rem; }
    .ss-dashboard-stat { padding: 1rem; }
    .ss-dashboard-stat > .ss-stat-value { min-height: 2rem; font-size: 1.25rem; }
    .ss-dashboard-card { gap: 1rem; padding-block: 1rem; }
    .ss-dashboard-card > :is([data-slot="card-header"], [data-slot="card-content"]) { padding-inline: 1rem; }
    .ss-dashboard-notices { padding-bottom: 0; }
    .ss-dashboard-notice-rows :is([data-slot="table-head"], [data-slot="table-cell"]):first-child { padding-left: 1rem; }
    .ss-dashboard-notice-rows :is([data-slot="table-head"], [data-slot="table-cell"]):last-child { padding-right: 1rem; }
    .ss-dashboard-notice-rows > .ss-dashboard-empty { margin-inline: 1rem; margin-bottom: 1rem; }
    .ss-dashboard-failure { padding-inline: .75rem; }
  }

  #recovery-dialog {
    margin: auto;
    width: min(44rem, 94vw);
    max-height: 85dvh;
    overflow: auto;
    padding: 1.25rem;
    color: var(--ss-foreground);
    background: var(--ss-card);
    border: 1px solid var(--ss-border);
    border-radius: var(--ss-radius-lg);
  }
  #recovery-dialog::backdrop { background: var(--ss-overlay); }
  #recovery-dialog form, #recovery-dialog label { display: grid; gap: .375rem; }
  #recovery-dialog form { padding-block: .5rem; }
  #recovery-dialog details { padding-block: .75rem; border-bottom: 1px solid var(--ss-border); }
  #recovery-dialog summary { overflow-wrap: anywhere; cursor: pointer; }
  #recovery-dialog input { min-width: 0; }
}
