/* Pi Port Check — 화면 스타일
   노드 모니터 플러그인과 독립적으로 동작하도록 이름을 pipc__ 로 따로 씁니다.
   화면 폭이 아니라 위젯 자체의 폭으로 배치를 바꿉니다. */

.pipc {
  --ink: #1d1830;
  --muted: #676179;
  --line: #e6e2ee;
  --page: #f4f2f8;
  --surface: #fff;

  --live: #1c7c52;   --live-bg: #e4f3ea;
  --warn: #93600a;   --warn-bg: #fbf0d9;
  --down: #b42f23;   --down-bg: #fbe8e5;
  --idle-bg: #efedf4;

  container-type: inline-size;
  box-sizing: border-box;
  max-width: 100%;
  padding: 12px;
  border-radius: 14px;
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
.pipc *, .pipc *::before, .pipc *::after { box-sizing: inherit; }
.pipc [hidden] { display: none !important; }
.pipc p { margin: 0; }

/* 항목별 색 */
.pipc [data-section="ports"]  { --accent: #6a3fc9; }
.pipc [data-section="alerts"] { --accent: #5b6475; }
.pipc [data-section="sync"]   { --accent: #2b62c6; }

.pipc__board { display: flex; flex-direction: column; gap: 12px; }

/* ── 상태 띠 ──────────────────────────────────── */
.pipc__hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 12px;
  background: var(--idle-bg);
}
.pipc__hero[data-tone="live"] { background: var(--live-bg); }
.pipc__hero[data-tone="warn"] { background: var(--warn-bg); }
.pipc__hero[data-tone="down"] { background: var(--down-bg); }
.pipc__hero-main { display: flex; align-items: flex-start; gap: 12px; }
.pipc__hero-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
}
.pipc__hero[data-tone="live"] .pipc__hero-title { color: var(--live); }
.pipc__hero[data-tone="warn"] .pipc__hero-title { color: var(--warn); }
.pipc__hero[data-tone="down"] .pipc__hero-title { color: var(--down); }
.pipc__hero-reason { margin-top: 4px !important; font-size: 15px; font-weight: 600; }
.pipc__hero-reason:empty { display: none; }
.pipc__hero-meta { margin-top: 2px !important; color: var(--muted); font-size: 13px; }

.pipc__dot {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: 7px;
  border-radius: 50%;
  background: #a9a3b8;
}
.pipc__dot[data-state="live"] { background: var(--live); animation: pipc-pulse 2.4s ease-out infinite; }
.pipc__dot[data-state="down"] { background: var(--down); }
@keyframes pipc-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(28, 124, 82, .45); }
  70%  { box-shadow: 0 0 0 8px rgba(28, 124, 82, 0); }
  100% { box-shadow: 0 0 0 0 rgba(28, 124, 82, 0); }
}

.pipc__check-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pipc__select {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.pipc__btn {
  min-height: 42px;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: #5a34a8;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.pipc__btn:hover { background: #4a2b8c; }
.pipc__btn[disabled] { opacity: .55; cursor: default; }
.pipc__btn:focus-visible,
.pipc__select:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pipc__link { color: #6a3fc9; }

@container (min-width: 560px) {
  .pipc__hero { flex-direction: row; align-items: flex-start; justify-content: space-between; }
}

/* ── 카드 ─────────────────────────────────────── */
.pipc__card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
}
.pipc__card-head { display: flex; align-items: center; gap: 8px; }
.pipc__card-head .pipc__pill { margin-left: auto; }
.pipc__card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.pipc__card-title::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
}
.pipc__card-inner::before { content: ""; display: block; height: 12px; }
.pipc__card-text { color: var(--muted); font-size: 13px; }

.pipc__pill {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--idle-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pipc__pill[data-state="live"] { background: var(--live-bg); color: var(--live); }
.pipc__pill[data-state="warn"] { background: var(--warn-bg); color: var(--warn); }
.pipc__pill[data-state="down"] { background: var(--down-bg); color: var(--down); }

/* ── 포트 칸 ──────────────────────────────────── */
.pipc__ports { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
@container (min-width: 560px) {
  .pipc__ports { grid-template-columns: repeat(10, minmax(0, 1fr)); }
}
.pipc__port {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 56px;
  border: 1.5px dashed #d8d3e3;
  border-radius: 8px;
  color: #a7a1b6;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.pipc__port::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #d8d3e3; }
.pipc__port[data-state="on"] {
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.pipc__port[data-state="on"]::before { background: #7ef0b5; box-shadow: 0 0 6px #7ef0b5; }
.pipc__port[data-state="refused"] {
  border: 1.5px solid #d9a441;
  background: #fdf6e7;
  color: #93600a;
  font-weight: 600;
}
.pipc__port[data-state="refused"]::before { background: #e3a93b; }
.pipc__port[data-state="timeout"] {
  border: 1.5px dashed #e3a39a;
  background: #fdf2f0;
  color: #b42f23;
}
.pipc__port[data-state="timeout"]::before { background: #e3a39a; }
.pipc__port[data-state="checking"] { animation: pipc-check 1s ease-in-out infinite alternate; }
@keyframes pipc-check { from { opacity: .35; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .pipc__dot[data-state="live"] { animation: none; }
  .pipc__port[data-state="checking"] { animation: none; opacity: .6; }
}

/* 범례 */
.pipc__legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 12px; }
.pipc__legend li { display: flex; align-items: center; gap: 6px; }
.pipc__legend i { width: 14px; height: 14px; border: 1.5px dashed #d8d3e3; border-radius: 4px; }
.pipc__legend i[data-state="on"] { border: 1.5px solid #6a3fc9; background: #6a3fc9; }
.pipc__legend i[data-state="refused"] { border: 1.5px solid #d9a441; background: #fdf6e7; }
.pipc__legend i[data-state="timeout"] { border: 1.5px dashed #e3a39a; background: #fdf2f0; }

/* ── 결과 풀이 ────────────────────────────────── */
.pipc__port-uses { margin: 0; padding: 0; list-style: none; }
.pipc__port-uses li { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid #f0edf6; font-size: 13px; }
.pipc__port-uses b { flex: none; color: #6a3fc9; font-variant-numeric: tabular-nums; }
.pipc__port-uses span { color: var(--muted); }
.pipc__port-uses span[data-state="open"] { color: var(--live); }
.pipc__port-uses span[data-state="refused"] { color: var(--warn); }
.pipc__port-uses span[data-state="timeout"] { color: var(--down); }

.pipc__action {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--down);
  border-radius: 6px;
  background: var(--down-bg);
  font-size: 13px;
}
.pipc__action > b { color: var(--down); }
.pipc__action ol { margin: 8px 0 0; padding-left: 20px; }
.pipc__action li + li { margin-top: 4px; }

/* ── 안내 ─────────────────────────────────────── */
.pipc__notes { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.pipc__notes li + li { margin-top: 6px; }
.pipc__notes b { color: var(--ink); }
