/* Setup screen (server workstream). Self-contained: does not depend on client/styles/core.css. */
:root {
  --bg: #0e1013; --panel: #16181d; --panel-2: #1d2027; --border: #343843; --text: #e6e1d6; --dim: #9a968c;
  --accent: #ff6400; --accent-soft: rgba(255, 100, 0, 0.18); --ok: #3fa34d; --warn: #d39e00; --err: #d9534f; --info: #3c8ce7;
  --radius: 6px; --font: "Signika", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body.setup { font-family: var(--font); font-size: 14px; color: var(--text); background: radial-gradient(circle at 30% 0%, #23262e, var(--bg) 70%); display: flex; flex-direction: column; overflow: hidden; }
.hidden { display: none !important; }
.spacer { flex: 1; }
a { color: var(--accent); }
button, select, input, textarea { font: inherit; color: var(--text); }
button { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover:not(:disabled) { border-color: var(--accent); box-shadow: 0 0 6px var(--accent-soft); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { border-color: var(--err); color: #ffb3b0; }
input, select, textarea { background: #0b0c0f; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; }
input:focus, select:focus, textarea:focus, [contenteditable]:focus { outline: 1px solid var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
h1, h2, h3 { margin: 0.3em 0; font-weight: 600; }
.hint { color: var(--dim); font-size: 12px; margin: 4px 0; }
.error { color: #ff8a80; min-height: 1.2em; margin: 6px 0; }
.empty { color: var(--dim); text-align: center; padding: 40px; }

/* Header */
#setup-header { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: rgba(0, 0, 0, 0.5); border-bottom: 1px solid var(--border); }
#setup-header .brand { font-size: 18px; font-weight: 600; }
#setup-header .brand i { color: var(--accent); }
#busy-indicator { color: var(--warn); }

#setup-body { flex: 1; display: flex; min-height: 0; }

/* Navigation */
#setup-nav { width: 250px; flex: 0 0 250px; padding: 12px; border-right: 1px solid var(--border); background: rgba(0, 0, 0, 0.3); display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
#setup-nav hr { border: 0; border-top: 1px solid var(--border); width: 100%; margin: 8px 0; }
.nav-item { width: 100%; justify-content: flex-start; background: transparent; border-color: transparent; padding: 8px 10px; }
.nav-item.active { background: var(--accent-soft); border-color: var(--accent); }
.nav-item .count { margin-left: auto; color: var(--dim); font-size: 12px; }
#software-panel { margin-top: 16px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
#software-panel h3 { font-size: 14px; }
#software-panel dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 6px 0; font-size: 12px; }
#software-panel dt { color: var(--dim); } #software-panel dd { margin: 0; text-align: right; }
#notifications { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.notice { padding: 8px; border-radius: var(--radius); border-left: 3px solid var(--info); background: var(--panel); font-size: 12px; }
.notice.warn { border-left-color: var(--warn); } .notice.error { border-left-color: var(--err); } .notice.ok { border-left-color: var(--ok); }
.notice button { margin-top: 6px; padding: 3px 8px; font-size: 12px; }

/* Main */
#setup-main { flex: 1; overflow-y: auto; padding: 16px; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { display: flex; align-items: center; gap: 6px; background: #0b0c0f; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 8px; }
.toolbar .search input { border: 0; background: transparent; width: 220px; outline: none; }
.toolbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.view-toggle { display: flex; }
.view-toggle button { border-radius: 0; } .view-toggle button:first-child { border-radius: var(--radius) 0 0 var(--radius); } .view-toggle button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.view-toggle button.active { background: var(--accent-soft); border-color: var(--accent); }

/* Package tiles / list */
.package-list.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.package-list.list { display: flex; flex-direction: column; gap: 6px; }
.package { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.package.unavailable { border-color: rgba(217, 83, 79, 0.6); }
.package.active-pkg { border-color: var(--ok); }
.package .cover { height: 120px; background: linear-gradient(135deg, #2b2f3a, #14161b) center / cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 42px; color: rgba(255, 255, 255, 0.15); }
.package .body { padding: 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.package .title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.package .title .id { color: var(--dim); font-weight: 400; font-size: 12px; }
.package .meta { color: var(--dim); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.package .desc { color: var(--dim); font-size: 12px; max-height: 3.2em; overflow: hidden; }
.package .badges { display: flex; flex-wrap: wrap; gap: 4px; }
.package .actions { display: flex; gap: 6px; padding: 0 10px 10px; }
.package .actions .primary { flex: 1; justify-content: center; }
.package .menu-btn { position: absolute; top: 6px; right: 6px; background: rgba(0, 0, 0, 0.55); padding: 4px 8px; }
.package-list.list .package { flex-direction: row; align-items: center; }
.package-list.list .package .cover { width: 90px; height: 64px; flex: 0 0 90px; font-size: 24px; }
.package-list.list .package .desc { display: none; }
.package-list.list .package .body { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px; }
.package-list.list .package .actions { padding: 0 8px; }
.package-list.list .package .menu-btn { position: static; margin-right: 8px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 6px; border-radius: 10px; border: 1px solid var(--border); background: #0b0c0f; white-space: nowrap; }
.badge.ok { border-color: var(--ok); color: #9be3a5; } .badge.warn { border-color: var(--warn); color: #ffd56a; } .badge.err { border-color: var(--err); color: #ffb3b0; } .badge.info { border-color: var(--info); color: #a9cdf7; }

/* Context menu */
#context-menu { position: fixed; z-index: 50; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 24px #000; padding: 4px; min-width: 200px; }
#context-menu button { width: 100%; justify-content: flex-start; background: transparent; border-color: transparent; }
#context-menu button:hover:not(:disabled) { background: var(--accent-soft); }
#context-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* Dialog */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 0; width: min(640px, 94vw); max-height: 90vh; box-shadow: 0 10px 40px #000; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog form { display: flex; flex-direction: column; max-height: 90vh; }
dialog header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
dialog header h2 { font-size: 17px; flex: 1; }
dialog .content { padding: 12px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
dialog footer { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group > label { font-weight: 600; font-size: 13px; }
.form-group .row { display: flex; gap: 6px; align-items: center; }
.form-group .row > input[type=text], .form-group .row > input:not([type]), .form-group .row > input[type=url] { flex: 1; }
.form-group.inline { flex-direction: row; align-items: center; gap: 8px; }
.form-group.inline > label { flex: 1; }
.restart-flag { color: var(--warn); font-size: 11px; font-weight: 400; margin-left: 6px; }
.override-flag { color: var(--info); font-size: 11px; font-weight: 400; margin-left: 6px; }
.editor-toolbar { display: flex; gap: 2px; flex-wrap: wrap; }
.editor-toolbar button { padding: 3px 7px; }
.rich-editor { min-height: 120px; max-height: 260px; overflow-y: auto; background: #0b0c0f; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.rich-editor:empty::before { content: attr(data-placeholder); color: var(--dim); }
textarea.html-source { min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.dep-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.dep-list li { display: flex; align-items: center; gap: 8px; padding: 6px; background: var(--panel-2); border-radius: var(--radius); }
.dep-list li .grow { flex: 1; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { color: var(--dim); font-weight: 600; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data td.actions button { padding: 3px 7px; }
.backup-group { margin-bottom: 18px; }
.backup-group h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }

/* File picker (setup) */
.fp-browser { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; max-height: 340px; overflow-y: auto; padding: 4px; background: #0b0c0f; border: 1px solid var(--border); border-radius: var(--radius); }
.fp-entry { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; font-size: 11px; text-align: center; word-break: break-all; background: transparent; }
.fp-entry:hover, .fp-entry.selected { border-color: var(--accent); background: var(--accent-soft); }
.fp-entry img { width: 80px; height: 60px; object-fit: cover; border-radius: 3px; }
.fp-entry i { font-size: 36px; color: var(--warn); height: 60px; display: flex; align-items: center; }

/* Config form */
#config-form { max-width: 900px; display: flex; flex-direction: column; gap: 14px; }
#config-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; background: var(--panel); }
#config-form legend { padding: 0 6px; font-weight: 600; color: var(--accent); }
#config-form .actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Logs */
#log-output { background: #08090b; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: calc(100vh - 170px); overflow-y: auto; }
#log-output .warn { color: #ffd56a; } #log-output .error { color: #ff8a80; }

/* Progress & toasts */
#progress { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); width: min(520px, 90vw); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 6px 24px #000; z-index: 40; }
#progress .label { font-size: 13px; margin-bottom: 6px; }
#progress .bar { height: 8px; background: #0b0c0f; border-radius: 4px; overflow: hidden; }
#progress .fill { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
#progress.indeterminate .fill { width: 30% !important; animation: indet 1.2s infinite linear; }
@keyframes indet { from { margin-left: -30%; } to { margin-left: 100%; } }
#toasts { position: fixed; top: 56px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, 90vw); }
.toast { padding: 10px 12px; border-radius: var(--radius); background: var(--panel); border-left: 4px solid var(--info); box-shadow: 0 4px 16px #000; }
.toast.error { border-left-color: var(--err); } .toast.warn { border-left-color: var(--warn); } .toast.success { border-left-color: var(--ok); }

/* Auth gate */
#auth-gate { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: radial-gradient(#2a2d35, #0e1013); }
#auth-gate .card { width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 20px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 0 30px #000; }
#auth-gate h1 { font-size: 20px; } #auth-gate h1 i { color: var(--accent); }

@media (max-width: 760px) {
  #setup-body { flex-direction: column; }
  #setup-nav { width: auto; flex: 0 0 auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); }
  #setup-nav .nav-item { width: auto; }
  #software-panel, #notifications, #setup-nav hr { display: none; }
  .toolbar .search input { width: 140px; }
}

/* Links styled as buttons, misc */
a.button, label.button { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px 7px; color: var(--text); text-decoration: none; cursor: pointer; }
a.button:hover, label.button:hover { border-color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.desc-html { background: #0b0c0f; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; max-height: 300px; overflow-y: auto; }
.desc-html img { max-width: 100%; }
dialog .row.toolbar { margin: 0; }
dialog .notice ul { margin: 4px 0 0 18px; padding: 0; }
dialog h3 { font-size: 14px; margin-top: 6px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }

/* Package browser (install dialog) */
.package-browser { list-style: none; margin: 6px 0; padding: 0; max-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.package-browser li { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.package-browser li:last-child { border-bottom: 0; }
.package-browser .entry-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.package-browser .entry-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 4px; }
.package-browser .tag { font-size: 11px; padding: 0 5px; border: 1px solid var(--border); border-radius: 8px; }
