/*
 * Visual language approximates the real Notable webapp's own look (colors/button shape pulled
 * directly from a real read of ctp.notable.webapp's src/assets/scss/_variables.scss +
 * components/button.scss, 2026-07-22) -- NOT their actual stack (React + hand-rolled SCSS, no
 * component library). This stays plain CSS, no build step, per that same decision.
 */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e2e6ea;
  --text: #1f1f1f;
  --text-muted: #6b7684;

  /* Real Notable tokens: $color-primary-dark/$color-primary/$color-primary-light, $hover-color */
  --primary: #4a90e2;
  --primary-dark: #3b73b5;
  --primary-light: #5ea1ee;
  --hover-color: #1580fc;

  --success: #1e8e5a;
  --success-bg: #e6f6ee;
  /* Real Notable token: $color-text-danger */
  --danger: #e24a4a;
  --danger-bg: #fbe9e7;
  /* Real Notable token: $color-text-warning */
  --warning: #b7791f;
  --warning-bg: #fff8e1;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

header.topbar {
  background: var(--primary-dark);
  color: #fff;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header.topbar .brand {
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

header.topbar .session {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: #d7e3ee;
}

header.topbar form { margin: 0; }

header.topbar button.linklike {
  background: none;
  border: none;
  color: #d7e3ee;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/*
 * Persistent left vertical nav (2026-08-01) -- approximates real Notable's own module-list sidebar
 * (ctp.notable.webapp's src/shared/layout/menubar.js), plain flexbox, no new dependency. `.app-layout`
 * wraps the sidebar + `main` side by side; `main` above still centers its own content within
 * whatever width that leaves it.
 */
.app-layout {
  display: flex;
  align-items: flex-start;
  max-width: 1280px;
  margin: 0 auto;
}

.app-layout main {
  flex: 1;
  min-width: 0; /* let content shrink below its own intrinsic width inside the flex row */
}

.sidebar {
  flex: 0 0 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: calc(100vh - 3.6rem); /* fills below the topbar */
  padding: 1.5rem 0;
}

.sidebar-nav, .sidebar-section { padding: 0 1rem; }

.sidebar-section { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0 0.75rem;
  margin-bottom: 0.4rem;
}

.sidebar-link {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  color: var(--text);
  font-weight: 500;
}

.sidebar-link:hover { background: var(--bg); text-decoration: none; }

@media (max-width: 720px) {
  .app-layout { flex-direction: column; }
  .sidebar { flex: none; width: 100%; min-height: 0; border-right: none; border-bottom: 1px solid var(--border); padding: 0.75rem 0; }
  .sidebar-nav, .sidebar-section { display: flex; gap: 0.5rem; padding: 0 1rem; }
  .sidebar-section { border-top: none; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
  .sidebar-section-title { display: none; }
}

/*
 * Main Publisher screen (2026-08-01, revised for a closer real-Notable match) -- center job-list
 * panel + a right-hand action panel styled like the left nav sidebar (full-height, distinct
 * surface/border), rather than just another `.card`.
 */
.dashboard-layout {
  display: flex;
  align-items: stretch; /* both columns share the row's own full height */
  gap: 1.5rem;
}

.dashboard-layout .main-panel {
  flex: 1;
  min-width: 0;
}

.dashboard-layout .detail-panel {
  flex: 0 0 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  box-shadow: 0 1px 3px rgba(20, 30, 40, 0.04);
}

.dashboard-layout .detail-panel .sidebar-section-title {
  padding: 0;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: var(--text);
}

.dashboard-layout .detail-panel .btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-bottom: 0.6rem;
}

@media (max-width: 720px) {
  .dashboard-layout { flex-direction: column; }
  .dashboard-layout .detail-panel { flex: none; width: 100%; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(20, 30, 40, 0.04);
}

.card h1, .card h2 { margin-top: 0; }

h1 { font-size: 1.5rem; font-weight: 600; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 0.95rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }

.login-wrap {
  max-width: 380px;
  margin: 4rem auto;
}

.field { margin-bottom: 1.1rem; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary-light);
  outline-offset: 1px;
}

/* Real Notable button shape: pill (border-radius ~21.5px), soft shadow + inset highlight,
   primary-dark background, $hover-color on hover -- see components/button.scss in ctp.notable.webapp. */
button, .btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(74, 144, 226, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.25);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

button:hover, .btn:hover { background: var(--hover-color); border-color: var(--hover-color); text-decoration: none; }
button:active, .btn:active { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn.secondary {
  background: var(--surface);
  color: var(--primary-dark);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.secondary:hover { background: var(--bg); border-color: var(--border); color: var(--primary-dark); }

.linklike-danger {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 0;
  text-decoration: underline;
}

.error-banner {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(226, 74, 74, 0.25);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
}

.success-banner {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(30, 142, 90, 0.25);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
}

.warning-banner {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(183, 121, 31, 0.3);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 1.1rem;
  font-size: 0.88rem;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.repeating-rows th, .repeating-rows td { padding: 0.4rem 0.35rem; }
.repeating-rows input[type="text"] { min-width: 6rem; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.status-0, .badge.status-4 { background: var(--warning-bg); color: var(--warning); }
.badge.status-1 { background: #e3edf7; color: var(--primary-dark); }
.badge.status-2 { background: var(--success-bg); color: var(--success); }
.badge.status-3 { background: var(--danger-bg); color: var(--danger); }

/* Brand Workspace status pills (2026-07-30) -- same real, computed states throughout: good/crit/
   warn/dim, never decoration (see brandStatus.js's own doc comment). */
.badge.state-good { background: var(--success-bg); color: var(--success); }
.badge.state-crit { background: var(--danger-bg); color: var(--danger); }
.badge.state-warn { background: var(--warning-bg); color: var(--warning); }
.badge.state-dim { background: var(--bg); color: var(--text-muted); }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.tile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.tile-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.tile-head strong { font-size: 0.95rem; }
.tile-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.setup-list { display: flex; flex-direction: column; }
.setup-step {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.setup-step:last-child { border-bottom: none; }
.setup-step .setup-num {
  font-weight: 700;
  color: var(--text-muted);
  width: 1.5rem;
  flex: none;
}
.setup-step .setup-body { flex: 1; min-width: 0; }
.setup-step .setup-body strong { display: block; font-size: 0.95rem; }
.setup-step .setup-actions { display: flex; gap: 0.5rem; flex: none; flex-wrap: wrap; }

.actions-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
}

.field-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem;
  margin-bottom: 1.25rem;
  background: #fafbfc;
}
.field-group legend { font-weight: 600; padding: 0 0.4rem; font-size: 0.92rem; }

.script-hook-row {
  background: #fff;
  margin-bottom: 0.85rem;
}

#statusPoll { transition: opacity 0.2s ease; }
