/*
 * Styles for the "Actions" tab (Woodpecker).
 * Everything is prefixed .wp-* and scoped under .wp-ui so the panel never
 * leaks into Forgejo's own CSS when injected into a repository page.
 */

.wp-ui {
  --wp-bg: #ffffff;
  --wp-bg-soft: #f6f8fa;
  --wp-fg: #1f2328;
  --wp-muted: #59636e;
  --wp-border: #d1d9e0;
  --wp-border-soft: #e6eaef;
  --wp-primary: var(--color-primary, #ea580c);
  --wp-primary-soft: #fff1e7;
  --wp-primary-soft: color-mix(in srgb, var(--wp-primary) 12%, #ffffff);
  --wp-ok: #1a7f37;
  --wp-ok-soft: #dafbe1;
  --wp-ko: #d1242f;
  --wp-ko-soft: #ffebe9;
  --wp-warn: #9a6700;
  --wp-warn-soft: #fff8c5;
  --wp-run: #0969da;
  --wp-run-soft: #ddf4ff;
  --wp-idle: #59636e;
  --wp-idle-soft: #eff2f5;
  --wp-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  color: var(--wp-fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

html[data-theme$="-dark"] .wp-ui {
  --wp-bg: #212830;
  --wp-bg-soft: #151b23;
  --wp-fg: #e6edf3;
  --wp-muted: #9198a1;
  --wp-border: #3d444d;
  --wp-border-soft: #2f353d;
  --wp-primary: var(--color-primary, #f97316);
  --wp-primary-soft: #3a2110;
  --wp-primary-soft: color-mix(in srgb, var(--wp-primary) 22%, #212830);
  --wp-ok: #3fb950;
  --wp-ok-soft: #12261a;
  --wp-ko: #f85149;
  --wp-ko-soft: #2d1416;
  --wp-warn: #d29922;
  --wp-warn-soft: #2a2210;
  --wp-run: #58a6ff;
  --wp-run-soft: #0d1d2e;
  --wp-idle: #9198a1;
  --wp-idle-soft: #262c34;
}

@media (prefers-color-scheme: dark) {
  html[data-theme$="-auto"] .wp-ui,
  .wp-ui.wp-standalone {
    --wp-bg: #212830;
    --wp-bg-soft: #151b23;
    --wp-fg: #e6edf3;
    --wp-muted: #9198a1;
    --wp-border: #3d444d;
    --wp-border-soft: #2f353d;
    --wp-primary: var(--color-primary, #f97316);
    --wp-primary-soft: #3a2110;
    --wp-primary-soft: color-mix(in srgb, var(--wp-primary) 22%, #212830);
    --wp-ok: #3fb950;
    --wp-ok-soft: #12261a;
    --wp-ko: #f85149;
    --wp-ko-soft: #2d1416;
    --wp-warn: #d29922;
    --wp-warn-soft: #2a2210;
    --wp-run: #58a6ff;
    --wp-run-soft: #0d1d2e;
    --wp-idle: #9198a1;
    --wp-idle-soft: #262c34;
  }
}

.wp-ui,
.wp-ui * { box-sizing: border-box; }

.wp-ui.wp-standalone { min-height: 100vh; background: var(--wp-bg-soft); }
#wp-actions-panel { background: transparent; }
/* While the panel is open, hide everything that follows it (the page content).
   A CSS rule is live: it also hides content Forgejo swaps in later (htmx),
   which an inline-style loop at open time would miss. */
#wp-actions-panel ~ * { display: none !important; }

.wp-ui a { color: var(--wp-primary); text-decoration: none; }
.wp-ui a:hover { text-decoration: underline; }
/* Forgejo's theme applies `a { color: var(--color-primary) }`; raise the
   specificity so our link-buttons keep their own color. */
.wp-ui a.wp-btn { color: var(--wp-fg); }
.wp-ui a.wp-btn:hover { color: var(--wp-fg); }
.wp-ui a.wp-btn-primary,
.wp-ui a.wp-btn-primary:hover { color: #fff; }

.wp-wrap { max-width: 1120px; margin: 0 auto; padding: 20px 16px 56px; }
.wp-table-wrap { overflow-x: auto; }

/* --- top bar (standalone page) ------------------------------------------ */

.wp-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--wp-bg);
  border-bottom: 1px solid var(--wp-border);
}
.wp-logo img { height: 26px; width: 26px; display: block; }
.wp-crumb { font-size: 15px; color: var(--wp-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wp-crumb a { color: var(--wp-fg); font-weight: 600; }
.wp-crumb-section { color: var(--wp-muted); }

/* --- toolbar / cards ----------------------------------------------------- */

.wp-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--wp-border-soft);
}
.wp-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--wp-fg); }
.wp-subtitle { margin: 0; font-size: 14px; font-weight: 600; color: var(--wp-fg); }
.wp-spacer { flex: 1 1 auto; }
.wp-summary { color: var(--wp-muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }

.wp-card {
  background: var(--wp-bg);
  border: 1px solid var(--wp-border);
  border-radius: 6px;
  overflow: hidden;
}
.wp-card + .wp-card { margin-top: 16px; }
.wp-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--wp-border-soft); }
.wp-card-body { padding: 16px; }

.wp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--wp-border);
  border-radius: 6px;
  background: var(--wp-bg);
  color: var(--wp-fg);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}
.wp-btn:hover { background: var(--wp-bg-soft); text-decoration: none; }
.wp-btn-primary { border-color: var(--wp-primary); background: var(--wp-primary); color: #fff; }
.wp-btn-primary:hover { filter: brightness(1.08); background: var(--wp-primary); }

.wp-loading, .wp-empty { padding: 28px 16px; text-align: center; color: var(--wp-muted); }
.wp-message { padding: 32px 20px; text-align: center; }
.wp-message-icon { font-size: 28px; line-height: 1; margin-bottom: 10px; }
.wp-message h2 { margin: 0 0 6px; font-size: 16px; color: var(--wp-fg); }
.wp-message p { margin: 0 auto 16px; max-width: 560px; color: var(--wp-muted); }
.wp-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* --- tables -------------------------------------------------------------- */

.wp-ui table.wp-table { width: 100%; border-collapse: collapse; margin: 0; }
.wp-ui table.wp-table th,
.wp-ui table.wp-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--wp-border-soft);
  vertical-align: middle;
  background: transparent;
  color: var(--wp-fg);
  font-size: 13.5px;
}
.wp-ui table.wp-table th {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--wp-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.wp-ui table.wp-table tbody tr:last-child td { border-bottom: none; }
.wp-ui table.wp-table tr.wp-row { cursor: pointer; }
.wp-ui table.wp-table tr.wp-row:hover td { background: var(--wp-bg-soft); }
.wp-ui table.wp-table tr.wp-row:focus { outline: 2px solid var(--wp-primary); outline-offset: -2px; }
.wp-ui table.wp-table tr.wp-active td { background: var(--wp-primary-soft); }

.wp-num { font-family: var(--wp-mono); color: var(--wp-muted); white-space: nowrap; }
.wp-commit { max-width: 380px; }
.wp-commit-inner { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.wp-sha { font-family: var(--wp-mono); font-size: 12px; color: var(--wp-primary); flex: 0 0 auto; }
.wp-msg { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wp-when, .wp-duration, .wp-author, .wp-event { color: var(--wp-muted); white-space: nowrap; }
.wp-branch code, .wp-mono {
  font-family: var(--wp-mono);
  font-size: 12px;
  background: var(--wp-bg-soft);
  border: 1px solid var(--wp-border-soft);
  border-radius: 4px;
  padding: 1px 5px;
}
.wp-ui a.wp-mono { color: var(--wp-primary); }
.wp-exit { font-family: var(--wp-mono); font-size: 12px; }
.wp-exit.wp-ko { color: var(--wp-ko); font-weight: 600; }

/* --- badges -------------------------------------------------------------- */

.wp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px 1px 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.wp-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.wp-badge.wp-ok { color: var(--wp-ok); background: var(--wp-ok-soft); }
.wp-badge.wp-ko { color: var(--wp-ko); background: var(--wp-ko-soft); }
.wp-badge.wp-warn { color: var(--wp-warn); background: var(--wp-warn-soft); }
.wp-badge.wp-run { color: var(--wp-run); background: var(--wp-run-soft); }
.wp-badge.wp-run .wp-dot { animation: wp-pulse 1.2s ease-in-out infinite; }
.wp-badge.wp-idle { color: var(--wp-idle); background: var(--wp-idle-soft); }
@keyframes wp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* --- detail -------------------------------------------------------------- */

.wp-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 20px; }
.wp-label { font-size: 11.5px; color: var(--wp-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.wp-value { word-break: break-word; }
.wp-value .wp-mono { word-break: break-all; }
.wp-message-body {
  margin: 16px 0 0;
  padding: 10px 12px;
  background: var(--wp-bg-soft);
  border: 1px solid var(--wp-border-soft);
  border-radius: 6px;
  font-family: var(--wp-mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
  color: var(--wp-fg);
}
.wp-steps td { padding: 7px 12px; }

/* --- logs ---------------------------------------------------------------- */

.wp-logcard { margin-top: 16px; }
.wp-ui pre.wp-logs {
  margin: 0;
  padding: 12px 14px;
  max-height: 62vh;
  overflow: auto;
  background: #0d1117;
  color: #c9d1d9;
  border-radius: 0 0 6px 6px;
  font-family: var(--wp-mono);
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre;
  tab-size: 4;
}
.wp-ui pre.wp-logs:empty::before { content: "(aucune sortie)"; color: #6e7681; }

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 860px) {
  .wp-col-event, .wp-col-author, .wp-col-when { display: none; }
  .wp-wrap { padding: 12px 10px 40px; }
  .wp-topbar { padding: 8px 12px; }
}
@media (max-width: 560px) {
  .wp-col-branch, .wp-col-dur { display: none; }
  .wp-commit { max-width: 220px; }
}
