/* uproj webviz — debug UI. Same dark-sidebar / light-main grid as forestry/webviz. */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  background: #f4f4f4;
  color: #1a1a1a;
}

code, pre {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
}

button {
  font: inherit;
  cursor: pointer;
}

#app {
  display: grid;
  grid-template-columns: 240px 1fr 360px;
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
}
/* Tabs that don't need the detail rail (tables) collapse the 360px column
   so the main area grows to full width — set by nav.js#setActive. */
#app.no-detail {
  grid-template-columns: 240px 1fr;
}

/* ── Sidebar ──────────────────────────────────────────── */
#sidebar {
  background: #1e2430;
  color: #d0d8e8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar h1 {
  font-size: 15px;
  font-weight: 600;
  padding: 16px;
  border-bottom: 1px solid #2e3a4e;
  color: #e8eef8;
  letter-spacing: 0.05em;
}

#section-nav {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  border-bottom: 1px solid #2e3a4e;
}

.nav-btn {
  background: transparent;
  border: 0;
  color: #d0d8e8;
  padding: 10px 16px;
  text-align: left;
  font-size: 13px;
}

.nav-btn:hover {
  background: #29354a;
}

.nav-btn.is-active {
  background: #29354a;
  color: #e8eef8;
  border-left: 2px solid #6ea8fe;
  padding-left: 14px;
}

#sidebar-filters {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid #2e3a4e;
}

.hint {
  color: #8a96aa;
  font-size: 12px;
}

/* ── Main ─────────────────────────────────────────────── */
#main {
  position: relative;
  background: #ffffff;
  overflow: hidden;
}

.section-host {
  position: absolute;
  inset: 0;
}

#table-host {
  padding: 16px;
  overflow: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th, table.data td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #ececec;
}

table.data th {
  font-weight: 600;
  background: #fafafa;
  position: sticky;
  top: 0;
}

/* ── Detail rail ───────────────────────────────────────── */
#detail {
  background: #fafafa;
  border-left: 1px solid #e0e0e0;
  padding: 16px;
  overflow-y: auto;
}

/* ── User badge ────────────────────────────────────────── */
#user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #d0d8e8;
}
#user-badge .user-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#btn-logout {
  background: transparent;
  border: 1px solid #2e3a4e;
  color: #8a96aa;
  border-radius: 3px;
  width: 22px;
  height: 22px;
  line-height: 1;
  font-size: 14px;
}
#btn-logout:hover {
  color: #e8eef8;
  border-color: #6ea8fe;
}

/* ── Login overlay ─────────────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 44, 0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#login-form {
  background: #ffffff;
  padding: 28px 32px;
  border-radius: 6px;
  width: 320px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#login-form h2 {
  font-size: 17px;
  margin-bottom: 4px;
}
#login-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #555;
}
#login-form input {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
}
#login-form input:focus {
  outline: 0;
  border-color: #6ea8fe;
  box-shadow: 0 0 0 2px rgba(110, 168, 254, 0.25);
}
#login-form button {
  background: #1e2430;
  color: #fff;
  border: 0;
  padding: 10px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
#login-form button:hover {
  background: #29354a;
}
#login-form .error {
  color: #c0392b;
  font-size: 12px;
  margin: 0;
}

/* ── Admin tools (sidebar) ─────────────────────────────── */
#admin-tools {
  padding: 14px 16px;
  border-top: 1px solid #2e3a4e;
}
#admin-tools h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8a96aa;
  margin-bottom: 8px;
}
#admin-tools ul {
  list-style: none;
}
#admin-tools li {
  margin: 4px 0;
}
#admin-tools a {
  color: #d0d8e8;
  text-decoration: none;
  font-size: 13px;
}
#admin-tools a:hover {
  color: #6ea8fe;
}

/* ── Toolbar (over the table-host) ─────────────────────── */
#toolbar {
  padding: 10px 16px;
  border-bottom: 1px solid #ececec;
  display: flex;
  gap: 8px;
  align-items: center;
}
#toolbar:empty {
  display: none;
}
button.primary {
  background: #1e2430;
  color: #fff;
  border: 0;
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
button.primary:hover {
  background: #29354a;
}

/* ── Per-row action buttons in tables ─────────────────── */
table.data td.actions {
  text-align: right;
  white-space: nowrap;
}
table.data td.actions button {
  margin-left: 4px;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid #d0d0d0;
  background: #fff;
  border-radius: 3px;
}
table.data td.actions button.primary {
  background: #1e2430;
  color: #fff;
  border-color: #1e2430;
}
table.data td.actions button:hover {
  border-color: #6ea8fe;
}

#table-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
}
#table-host {
  display: flex;
  flex-direction: column;
  position: absolute;
  inset: 0;
}

/* ── HTML5 hidden attribute beats element-id display rules ───────────────
   Without this, `hidden=true` on #login-overlay (display:flex) and
   #user-badge (display:flex) is silently ignored — element ID specificity
   (1,0,0) wins over [hidden] (0,1,0). */
[hidden] { display: none !important; }

/* ── Catalog detail rail ─────────────────────────────── */
#detail h3 {
  font-size: 14px;
  margin-bottom: 4px;
}
#detail h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #777;
  margin: 14px 0 6px;
}
#detail .desc {
  color: #555;
  font-size: 12px;
  line-height: 1.4;
  margin: 4px 0 12px;
}
#detail dl.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  font-size: 12px;
  margin: 8px 0 16px;
}
#detail dl.meta dt {
  color: #777;
  font-weight: 500;
}
#detail dl.meta dd {
  color: #1a1a1a;
}

ul.collection-list, ul.item-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.collection-list li, ul.item-list li {
  padding: 0;
  margin: 0 0 4px;
}

button.collection-btn {
  width: 100%;
  text-align: left;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 8px 10px;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}
button.collection-btn:hover {
  border-color: #6ea8fe;
  background: #fff;
}
button.collection-btn .cid {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: #1a1a1a;
}
button.collection-btn .ctitle {
  color: #777;
  font-size: 11px;
}

ul.item-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 3px;
}
ul.item-list li:hover {
  background: #fafafa;
}
ul.item-list code {
  font-size: 11px;
  background: transparent;
  padding: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
ul.item-list .datetime {
  color: #888;
  font-size: 11px;
  white-space: nowrap;
}

button.back-btn {
  background: transparent;
  border: 0;
  color: #6ea8fe;
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-size: 12px;
  margin-bottom: 8px;
}
button.back-btn:hover {
  text-decoration: underline;
}

/* ── Sidebar layout: nav at top, spacer fills, footer pinned bottom ─── */
#sidebar {
  display: flex;
  flex-direction: column;
}
.sidebar-spacer { flex: 1; }
#sidebar-footer {
  position: relative;
  border-top: 1px solid #2e3a4e;
  padding: 10px;
}

/* ── User trigger (pill) ──────────────────────────────── */
#user-trigger {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: #d0d8e8;
  padding: 6px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font: inherit;
}
#user-trigger:hover {
  background: #29354a;
}
#user-trigger.is-open {
  background: #29354a;
  border-color: #3a4a64;
}
#user-trigger .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6ea8fe 0%, #3a6fc7 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
#user-trigger .meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
#user-trigger .user-name {
  font-size: 13px;
  color: #e8eef8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
#user-trigger .user-role {
  font-size: 11px;
  color: #8a96aa;
}
#user-trigger .caret {
  color: #8a96aa;
  font-size: 10px;
}

/* ── User menu popover ────────────────────────────────── */
#user-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 10px;
  right: 10px;
  background: #232b3a;
  border: 1px solid #3a4a64;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 6px;
  z-index: 100;
}
.menu-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8a96aa;
  padding: 6px 10px 4px;
}
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #d0d8e8;
  padding: 7px 10px;
  border-radius: 4px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.menu-item:hover {
  background: #2e3a4e;
  color: #e8eef8;
}
.menu-item.destructive {
  color: #f08988;
}
.menu-item.destructive:hover {
  background: #4a2828;
  color: #ffd6d5;
}
.menu-divider {
  height: 1px;
  background: #2e3a4e;
  margin: 6px 0;
}

/* Browser default styles on <button> can leak through .menu-item (outline,
   intrinsic width). Reset everything explicitly so the Sign-out button
   renders identically to the <a> menu items above it. */
button.menu-item {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  outline: none;
  white-space: nowrap;
  box-sizing: border-box;
  width: 100%;
  display: block;
  text-align: left;
  line-height: 1.4;
}

/* Spacing between the count line and the collection/item list. */
#detail-content p.hint  { margin: 4px 0 12px; }
#detail-content h3      { margin-bottom: 4px; }
ul.collection-list,
ul.item-list            { margin-top: 4px; }

/* ── Per-row pill action buttons ───────────────────────── */
td.actions {
  white-space: nowrap;
  text-align: right;
  padding-right: 8px;
}
.pill-btn {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid #cdd5e3;
  background: #fff;
  color: #2c3645;
  font: inherit;
  font-size: 12px;
  line-height: 1.1;
  padding: 4px 9px;
  margin: 0 3px;
  border-radius: 12px;
  vertical-align: middle;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.pill-btn:hover {
  background: #e7ecf3;
  color: #1a1a1a;
  border-color: #b6c0d3;
}
.pill-btn.primary {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}
.pill-btn.primary:hover {
  background: #1d4ed8;
  border-color: #1e40af;
}
.pill-btn.danger {
  color: #b42318;
  border-color: #f4c2c2;
}
.pill-btn.danger:hover {
  background: #fde2e2;
  color: #8b1d12;
}

/* Item-preview image fits the detail rail. */
img.item-preview {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 6px 0 12px;
  background: #eef1f6;
  border: 1px solid #d8dde8;
  border-radius: 3px;
}

/* Asset list (in item detail). */
ul.asset-list {
  list-style: none;
  margin: 4px 0 12px;
  padding: 0;
}
ul.asset-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid #ececec;
}
.asset-key  { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; flex: 0 0 90px; }
.asset-type { color: #6b7280; font-size: 11px; flex: 1; }
.asset-dl   { color: #2563eb; text-decoration: none; font-size: 12px; }
.asset-dl:hover { text-decoration: underline; }

button.back-btn {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: transparent;
  color: #4a5670;
  font-size: 12px;
  padding: 2px 0;
  margin-bottom: 6px;
}
button.back-btn:hover { color: #1a1a1a; text-decoration: underline; }

/* ── Modal overlay (forms + logs) ──────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 24, 36, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  padding: 22px;
  width: min(520px, 92vw);
  max-height: 88vh;
  overflow: auto;
}
.modal h2 {
  font-size: 16px;
  margin-bottom: 14px;
}
.modal label {
  display: block;
  margin: 10px 0;
}
.modal label > span {
  display: block;
  font-size: 12px;
  color: #4a5670;
  margin-bottom: 3px;
}
.modal input,
.modal select,
.modal textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #cdd5e3;
  border-radius: 4px;
  font: inherit;
}
.modal textarea {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  resize: vertical;
}
.modal input[readonly] {
  background: #f4f4f4;
  color: #6b7280;
}
.field-hint {
  display: block;
  font-size: 11px;
  color: #6b7280;
  margin-top: 3px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.modal-actions button {
  padding: 7px 14px;
  border: 1px solid #cdd5e3;
  background: #f4f4f4;
  border-radius: 4px;
}
.modal-actions button.primary {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}
.modal-actions button:hover { background: #e7ecf3; }
.modal-actions button.primary:hover { background: #1d4ed8; }

/* ── Logs modal ─────────────────────────────────────────── */
.logs-modal {
  width: min(900px, 96vw);
  display: flex;
  flex-direction: column;
  padding: 0;
  height: 70vh;
}
.logs-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #ececec;
}
.logs-header h2 { font-size: 14px; margin: 0; flex: 1; }
.logs-header code { font-size: 11px; color: #6b7280; }
.logs-state {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #eef1f6;
  color: #4a5670;
}
.logs-state.state-running    { background: #dbeafe; color: #1d4ed8; }
.logs-state.state-succeeded  { background: #dcfce7; color: #166534; }
.logs-state.state-failed,
.logs-state.state-cancelled  { background: #fde2e2; color: #b42318; }
.logs-close {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid #cdd5e3;
  background: #f4f4f4;
  padding: 4px 10px;
  border-radius: 4px;
}
.logs-pane {
  flex: 1;
  margin: 0;
  padding: 12px 16px;
  background: #0d1117;
  color: #c9d1d9;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Archived / disabled row dimming ────────────────────── */
tr.row-archived td,
tr.row-disabled td {
  opacity: 0.55;
}

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e2430;
  color: #e8eef8;
  padding: 9px 16px;
  border-radius: 4px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 200;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
