/* ============================================================
   PMC Hub — Semeq  ·  tema escuro (padrao) + claro via toggle
   ============================================================ */

:root {
  /* marca */
  --brand: #1c273c;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --accent-grad: linear-gradient(135deg, #4f8cff 0%, #7c5cff 100%);

  /* tema escuro (padrao) */
  --bg: #0b101d;
  --bg-glow: radial-gradient(900px 400px at 80% -10%, rgba(79, 140, 255, .10), transparent 60%),
             radial-gradient(700px 350px at 10% 110%, rgba(124, 92, 255, .07), transparent 60%);
  --panel: #121a2c;
  --panel-2: #182238;
  --border: #223050;
  --border-soft: #1b2740;
  --text: #e8edf6;
  --muted: #8b98b3;
  --input-bg: #0e1526;

  --sidebar-bg: linear-gradient(180deg, #16203a 0%, #0d1424 100%);
  --sidebar-text: #aab6cf;
  --sidebar-border: rgba(255, 255, 255, .06);

  --ok: #3ddc84;   --ok-bg: rgba(61, 220, 132, .12);
  --err: #ff5d5d;  --err-bg: rgba(255, 93, 93, .12);
  --run: #4f8cff;  --run-bg: rgba(79, 140, 255, .14);
  --wait: #ffb454; --wait-bg: rgba(255, 180, 84, .12);

  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .25);
  --card-hover-glow: 0 0 0 1px rgba(79, 140, 255, .45), 0 12px 34px rgba(79, 140, 255, .12);
}

[data-theme="light"] {
  --bg: #f3f5f9;
  --bg-glow: none;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --border: #e1e6ee;
  --border-soft: #e9edf3;
  --text: #1f2733;
  --muted: #66718a;
  --input-bg: #ffffff;

  --sidebar-bg: linear-gradient(180deg, #1c273c 0%, #141d30 100%);
  --sidebar-text: #aab6cf;
  --sidebar-border: rgba(255, 255, 255, .07);

  --ok: #14914f;   --ok-bg: #e3f6ec;
  --err: #d64545;  --err-bg: #fdeaea;
  --run: #2f6fed;  --run-bg: #e8f0fe;
  --wait: #9a6810; --wait-bg: #fcf2dd;

  --shadow: 0 8px 24px rgba(28, 39, 60, .10);
  --shadow-sm: 0 1px 3px rgba(28, 39, 60, .08);
  --card-hover-glow: 0 0 0 1px rgba(79, 140, 255, .55), 0 10px 28px rgba(47, 111, 237, .14);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  transition: background .25s, color .25s;
}

a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

.icon { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor;
  fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ============ Layout ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 234px; flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.brand { padding: 24px 22px 20px; border-bottom: 1px solid var(--sidebar-border); }
.logo { height: 30px; width: auto; display: block; }
.brand-sub {
  margin-top: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: 2.5px;
  text-transform: uppercase; color: #5f6f92;
}

.nav { padding: 16px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: 9px;
  color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s, transform .1s;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active {
  background: linear-gradient(90deg, rgba(79, 140, 255, .18), rgba(124, 92, 255, .10));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 10px;
}
.user-chip {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; text-transform: uppercase; flex-shrink: 0;
}
.user { font-size: 13px; color: #e8edf6; font-weight: 600; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  background: none; border: none; color: var(--sidebar-text); cursor: pointer;
  padding: 6px; border-radius: 8px; display: flex; align-items: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
[data-theme="light"] .theme-only-dark { display: none; }
:root:not([data-theme="light"]) .theme-only-light { display: none; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 34px 0;
}
.topbar h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.2px; }
.container { padding: 22px 34px 40px; max-width: 1160px; }

.back { color: var(--muted); display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 16px; font-size: 13px; }
.back:hover { color: var(--text); }

/* toasts (django messages) */
.toasts { padding: 14px 34px 0; }
.toast {
  border-radius: 10px; padding: 11px 16px; font-size: 13px; font-weight: 500;
  margin-bottom: 8px; border: 1px solid;
  animation: slide-in .25s ease;
}
.toast-success { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.toast-error, .toast-warning { background: var(--err-bg); color: var(--err); border-color: var(--err); }
.toast-info { background: var(--run-bg); color: var(--run); border-color: var(--run); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } }

/* ============ Busca ============ */
.search { display: flex; gap: 10px; margin-bottom: 22px; max-width: 460px; }
.search input {
  flex: 1; padding: 11px 15px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit;
  background: var(--input-bg); color: var(--text);
}
.search input::placeholder { color: var(--muted); }
.search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, .18);
}

/* ============ Cards (catalogo) ============ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}
.card {
  position: relative; overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex; flex-direction: column; gap: 13px;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent-grad); opacity: 0; transition: opacity .16s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--card-hover-glow); }
.card:hover::before { opacity: 1; }

.card-top { display: flex; align-items: center; justify-content: space-between; }
.card-code {
  font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  color: #fff; background: var(--accent-grad);
  padding: 4px 11px; border-radius: 7px;
}
.card-body h3 { margin: 0 0 7px; font-size: 15.5px; letter-spacing: -.1px; }
.card-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; padding-top: 4px;
}
.ver { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.card-go { color: var(--accent); font-size: 12.5px; font-weight: 600;
  opacity: 0; transform: translateX(-4px); transition: all .16s; }
.card:hover .card-go { opacity: 1; transform: translateX(0); }

/* ============ Panels ============ */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.panel.no-pad { padding: 0; overflow: hidden; }
.panel-title {
  margin: 0 0 16px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--muted); font-weight: 700;
}
.desc { margin: 0 0 14px; line-height: 1.65; color: var(--text); }
.meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted);
  font-size: 13px; align-items: center; }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; }
.badge-muted { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border-soft); }
.badge-muted::before { display: none; }
.status-queued  { background: var(--wait-bg); color: var(--wait); }
.status-running { background: var(--run-bg);  color: var(--run); }
.status-running::before { animation: blink 1s ease-in-out infinite; }
.status-success { background: var(--ok-bg);   color: var(--ok); }
.status-error   { background: var(--err-bg);  color: var(--err); }
.status-canceled{ background: var(--panel-2); color: var(--muted); }
@keyframes blink { 50% { opacity: .25; } }

/* ============ Forms ============ */
.run-form { display: flex; flex-direction: column; gap: 17px; max-width: 520px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-weight: 600; font-size: 13px; }
.field .req { color: var(--err); }
.run-form input, .run-form select, .run-form textarea,
.field input, .field select, .field textarea {
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px; font-family: inherit;
  background: var(--input-bg); color: var(--text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.run-form input:focus, .run-form select:focus, .run-form textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, .18);
}
.field-check { flex-direction: row; align-items: center; gap: 10px; }
.field-check input { width: 17px; height: 17px; accent-color: var(--accent); }
.field-check label { order: 2; font-weight: 500; }
.hint { color: var(--muted); font-size: 12px; }
.err { color: var(--err); font-size: 12px; }
.saved-hint { margin: -6px 0 14px; display: flex; align-items: center; gap: 6px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: 9px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: transform .1s, box-shadow .15s, filter .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--accent-grad); color: #fff;
  box-shadow: 0 4px 14px rgba(79, 140, 255, .3);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 6px 18px rgba(79, 140, 255, .4); }
.btn-ghost {
  background: var(--panel); border-color: var(--border); color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
  background: rgba(220, 53, 69, .15); border-color: rgba(220, 53, 69, .5); color: #f87171;
}
.btn-danger:hover { background: rgba(220, 53, 69, .25); border-color: #f87171; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.inline { display: inline; }

/* ============ Run detail ============ */
.run-head { display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  justify-content: space-between; }
.run-meta { display: flex; gap: 26px; margin: 0; flex-wrap: wrap; }
.run-meta div { display: flex; flex-direction: column; }
.run-meta dt { color: var(--muted); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .8px; font-weight: 700; }
.run-meta dd { margin: 3px 0 0; font-weight: 600; font-size: 13.5px; }
.pulse { color: var(--run); font-size: 12px; margin-left: 10px;
  animation: blink 1.2s ease-in-out infinite; }

.artifacts { list-style: none; margin: 0; padding: 0; }
.artifacts li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 8px; background: var(--panel-2);
  transition: border-color .15s;
}
.artifacts li:hover { border-color: var(--accent); }
.artifacts a { color: var(--accent); font-weight: 600; flex: 1;
  font-family: ui-monospace, Menlo, monospace; font-size: 13px;
  overflow-wrap: anywhere; }
.artifacts a:hover { text-decoration: underline; }
.artifacts .size { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* terminal de log */
.terminal {
  border-radius: 10px; overflow: hidden;
  border: 1px solid #1b2740;
  background: #0a0f1c;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
[data-theme="light"] .terminal { border-color: #2a3550; }
.term-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 14px; background: #111830;
  border-bottom: 1px solid #1b2740;
}
.term-dot { width: 11px; height: 11px; border-radius: 50%; }
.term-dot.r { background: #ff5f57; } .term-dot.y { background: #febc2e; }
.term-dot.g { background: #28c840; }
.term-title { margin-left: 8px; color: #5f6f92; font-size: 11.5px;
  font-family: ui-monospace, Menlo, monospace; }
.log {
  color: #c9d4e8; padding: 16px 18px; margin: 0;
  font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
  font-size: 12.5px; line-height: 1.6;
  overflow: auto; max-height: 480px;
  white-space: pre-wrap; word-break: break-word;
}

/* ============ Ultimas execucoes ============ */
.recent-runs { list-style: none; margin: 0; padding: 0; }
.recent-runs li {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 4px; border-bottom: 1px solid var(--border-soft); font-size: 13px;
}
.recent-runs li:last-child { border-bottom: none; }
.recent-runs a { color: var(--accent); font-weight: 700;
  font-family: ui-monospace, Menlo, monospace; }
.recent-runs a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* ============ Tabela (historico) ============ */
.filters { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.filters select {
  padding: 9px 13px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--input-bg); color: var(--text);
  font-size: 13.5px; font-family: inherit;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 13px 18px; font-size: 13px; }
.table thead th {
  background: var(--panel-2); color: var(--muted); text-transform: uppercase;
  font-size: 10.5px; letter-spacing: 1px; font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.table tbody tr {
  border-bottom: 1px solid var(--border-soft); cursor: pointer;
  transition: background .12s;
}
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--panel-2); }
.empty-row { text-align: center; color: var(--muted); padding: 36px; cursor: default; }

.empty {
  background: var(--panel); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 40px; color: var(--muted); text-align: center; grid-column: 1 / -1;
  line-height: 1.8;
}
code {
  background: var(--panel-2); border: 1px solid var(--border-soft);
  padding: 2px 7px; border-radius: 5px; font-size: 12.5px;
  font-family: ui-monospace, Menlo, monospace;
}

.alert-err {
  background: var(--err-bg); color: var(--err); border: 1px solid var(--err);
  border-radius: 10px; padding: 13px 16px; margin-bottom: 16px; font-size: 13px;
}

/* ============ Ajuda (adicionar script) ============ */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  position: relative; padding: 0 0 22px 46px; counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.steps li::after {
  content: ""; position: absolute; left: 14.5px; top: 32px; bottom: 4px;
  width: 1px; background: var(--border);
}
.steps li:last-child::after { display: none; }
.steps h3 { margin: 2px 0 6px; font-size: 14.5px; }
.steps p { margin: 0 0 8px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.codeblock { position: relative; margin-top: 10px; }
.codeblock pre {
  background: #0a0f1c; color: #c9d4e8; border: 1px solid #1b2740;
  border-radius: 10px; padding: 16px 18px; margin: 0;
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
  font-size: 12.5px; line-height: 1.6; overflow-x: auto;
}
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255, 255, 255, .07); border: 1px solid #2a3550;
  color: #8b98b3; font-size: 11.5px; font-weight: 600;
  padding: 5px 12px; border-radius: 7px; cursor: pointer;
}
.copy-btn:hover { color: #fff; border-color: var(--accent); }

/* ============ Login ============ */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: #0b101d;
  background-image:
    radial-gradient(800px 400px at 70% 20%, rgba(79, 140, 255, .16), transparent 60%),
    radial-gradient(600px 300px at 20% 80%, rgba(124, 92, 255, .12), transparent 60%);
}
.login-card {
  background: rgba(18, 26, 44, .9);
  border: 1px solid #223050;
  backdrop-filter: blur(12px);
  border-radius: 16px; padding: 42px 38px; width: 360px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5); text-align: center;
}
.login-logo { height: 32px; margin-bottom: 20px; }
.login-card h1 { margin: 0; font-size: 21px; color: #e8edf6; letter-spacing: -.2px; }
.login-sub { margin: 5px 0 26px; color: #8b98b3; font-size: 13px; }
.login-card .field { text-align: left; margin-bottom: 15px; }
.login-card label { color: #c3cde0; }
.login-card input {
  width: 100%; padding: 11px 13px; border: 1px solid #223050;
  border-radius: 9px; font-size: 14px; font-family: inherit;
  background: #0e1526; color: #e8edf6;
}
.login-card input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, .18);
}
.login-card .alert-err { text-align: left; }
