/* NetSim – Stylesheet */

:root {
  --header: #1d3557;
  --header-2: #24426a;
  --bg: #eef1f5;
  --panel: #ffffff;
  --border: #d5dbe3;
  --text: #1f2933;
  --muted: #66727f;
  --accent: #1f6feb;
  --ok: #16a34a;
  --warn: #b45309;
  --err: #dc2626;
  --radius: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  font: 13px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

button { font: inherit; color: inherit; }
code, kbd { font-family: Consolas, "Cascadia Mono", "Courier New", monospace; font-size: 12px; }
code { background: #eef2f6; padding: 1px 4px; border-radius: 4px; }
kbd { border: 1px solid #c3ccd6; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: #f8fafc; }

/* ---------- Toolbar ---------- */

#toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: linear-gradient(var(--header-2), var(--header));
  color: #fff;
  flex-wrap: wrap;
  box-shadow: 0 1px 0 rgba(0,0,0,.2);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; margin-right: 6px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.brand-file {
  color: #b9c8db; font-size: 12px; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 1px solid rgba(255,255,255,.2); padding-left: 8px;
}
.tb { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: #e3ebf5; padding: 5px 9px; cursor: pointer; white-space: nowrap;
}
.tb-btn:hover { background: rgba(255,255,255,.12); }
.tb-btn:active { background: rgba(255,255,255,.2); }
.tb-btn:disabled { opacity: .4; cursor: default; background: transparent; }
.tb-btn.icon-only { padding: 5px 7px; }
.tb-btn svg { flex: none; }
.tb-sep { width: 1px; height: 22px; background: rgba(255,255,255,.18); margin: 0 6px; }
.tb-check { display: inline-flex; align-items: center; gap: 5px; color: #dbe5f0; cursor: pointer; user-select: none; }

/* ---------- Layout ---------- */

#main { display: grid; grid-template-columns: 132px 1fr; min-height: 0; }

#palette {
  background: #f7f9fb;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 10px 8px;
  user-select: none;
}
.pal-group { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 6px 4px 6px; text-align: center; }
.pal-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px; margin-bottom: 6px;
  border: 1px solid transparent; border-radius: var(--radius);
  cursor: grab; text-align: center; font-size: 12px;
}
.pal-item:hover { background: #fff; border-color: var(--border); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.pal-item:active { cursor: grabbing; }
.pal-item svg { max-width: 96px; max-height: 50px; width: auto; height: auto; }
.pal-item small { color: var(--muted); font-size: 11px; }
.pal-hint { font-size: 11px; color: var(--muted); padding: 8px 4px; border-top: 1px solid var(--border); margin-top: 8px; text-align: center; }
.pal-version { margin-top: 6px; font-weight: 700; letter-spacing: .4px; }

#stage { position: relative; overflow: hidden; background: #fff; }
#ws { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
#ws text { font-family: "Segoe UI", Arial, Helvetica, sans-serif; pointer-events: none; }
#ws.panning, #ws.space { cursor: grab; }
#ws.panning { cursor: grabbing; }
#ws .device { cursor: move; }
#ws .port { cursor: crosshair; }
#ws .port rect { transition: stroke-width .1s; }
#ws .port:hover rect { stroke: var(--accent); stroke-width: 2.5; }
#ws .port.used { cursor: pointer; }
#ws.linking .port:not(.used) rect { stroke: var(--accent); stroke-width: 2; }
#ws .port.drop-ok rect { stroke: var(--ok) !important; stroke-width: 3.5 !important; }
#ws .port.drop-bad rect { stroke: var(--err) !important; stroke-width: 3.5 !important; }
#ws .link { cursor: pointer; }
#ws .link:hover .link-line { stroke: #1f6feb; }
#layer-overlay { pointer-events: none; }
#ws.exporting .no-export { display: none; }

#empty-hint {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%);
  text-align: center; color: var(--muted); pointer-events: none;
  background: rgba(255,255,255,.85); padding: 22px 28px; border-radius: 12px;
  border: 1px dashed #c6d0db;
}
#empty-hint .eh-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
#empty-hint .btn { pointer-events: auto; margin-top: 14px; }
#empty-hint[hidden] { display: none; }

#zoombar {
  position: absolute; right: 14px; bottom: 14px;
  display: flex; background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08); overflow: hidden;
}
#zoombar button {
  border: 0; background: none; padding: 6px 9px; cursor: pointer; display: inline-flex; align-items: center;
  color: #334; min-width: 32px; justify-content: center;
}
#zoombar button:hover { background: #eef3f9; }
#zoom-label { font-variant-numeric: tabular-nums; min-width: 56px !important; border-left: 1px solid var(--border) !important; border-right: 1px solid var(--border) !important; }

#statusbar {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 4px 12px; background: #f7f9fb; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px;
}
#status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status-info { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Buttons & Formulare ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #b9c4d0; background: linear-gradient(#fff, #f1f4f8);
  border-radius: 6px; padding: 5px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:active { background: #e8eef6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-icon { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 4px; }
.btn-icon:hover { background: #fde8e8; color: var(--err); }

input[type=text], input[type=number], select {
  font: inherit; color: inherit;
  border: 1px solid #c3ccd6; border-radius: 5px; padding: 5px 7px; background: #fff;
  min-width: 0;
}
input[type=text]:focus, input[type=number]:focus, select:focus { outline: 2px solid rgba(31,111,235,.25); border-color: var(--accent); }
input:disabled, select:disabled { background: #f1f4f7; color: #6b7785; }
input.invalid { border-color: var(--err); background: #fff5f5; }

/* ---------- Fenster ---------- */

.win {
  position: fixed;
  width: 560px; height: 520px;
  min-width: 380px; min-height: 240px;
  max-width: calc(100vw - 20px); max-height: calc(100vh - 20px);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid #9aa8b8;
  border-radius: 10px;
  box-shadow: 0 12px 34px rgba(16,32,56,.28);
  resize: both; overflow: hidden;
}
.win.focused { border-color: #5d7ea6; box-shadow: 0 14px 40px rgba(16,32,56,.36); }
.win-title {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 10px;
  background: linear-gradient(#3a5a83, #284772);
  color: #fff; cursor: move; user-select: none; flex: none;
}
.win:not(.focused) .win-title { background: linear-gradient(#73869e, #63768e); }
.win-ico { display: inline-flex; background: #fff; border-radius: 4px; padding: 1px 3px; }
.win-name { font-weight: 600; }
.win-kind { color: #c9d6e6; font-size: 12px; }
.win-close { margin-left: auto; border: 0; background: none; color: #fff; cursor: pointer; font-size: 14px; width: 26px; height: 24px; border-radius: 4px; }
.win-close:hover { background: #e5484d; }
.win-tabs { display: flex; gap: 2px; padding: 6px 8px 0; background: #eef1f5; border-bottom: 1px solid var(--border); flex: none; }
.win-tabs button {
  border: 1px solid transparent; border-bottom: 0; background: none;
  padding: 6px 14px; border-radius: 6px 6px 0 0; cursor: pointer; color: #45505c;
}
.win-tabs button:hover { background: #e2e8ef; }
.win-tabs button.active { background: #fff; border-color: var(--border); margin-bottom: -1px; color: var(--text); font-weight: 600; }
.win-body { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; }
.win-body .pane[hidden] { display: none; }

.pane { display: flex; flex-direction: column; gap: 10px; }
.pane.pane-term { height: 100%; }
.row { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 8px; }
.row > label:first-child { color: #45505c; }
.inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.radios { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.radios label, .chk { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.radios .btn { margin-left: auto; }
fieldset.box { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
fieldset.box legend { font-weight: 600; padding: 0 5px; color: #2c3a4a; }
.note { color: #1d5fbf; font-size: 12px; }
.note:empty, .warn:empty { display: none; }
.warn { color: var(--warn); font-size: 12px; }
.err { color: var(--err); font-size: 12px; }
.err:empty { display: none; }
.meta { color: var(--muted); font-size: 12px; margin: 0; }
.ok-text { color: var(--ok); }
.add-row { display: flex; gap: 6px; align-items: center; }
.add-row input { flex: 1; }
.add-row input[type=number] { flex: 0 0 110px; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 4px 6px; border-bottom: 1px solid #e6eaef; text-align: left; vertical-align: middle; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f7f9fb; }
.tbl td select, .tbl td input { width: 100%; }
.tbl.mono td { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; }
.tbl .empty { color: var(--muted); font-style: italic; }
.badge { display: inline-block; min-width: 18px; text-align: center; font-weight: 700; font-size: 11px; border-radius: 4px; padding: 0 4px; color: #fff; background: #64748b; }
.badge.C { background: #16a34a; }
.badge.S { background: #2563eb; }
.badge.R { background: #7c3aed; }

.kv { border-collapse: collapse; }
.kv th { text-align: left; font-weight: 600; color: #45505c; padding: 2px 14px 2px 0; white-space: nowrap; vertical-align: top; }
.kv td { padding: 2px 0; }
.stp-state { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 6px; color: #fff; }
.stp-state.fwd { background: var(--ok); }
.stp-state.blk { background: #f59e0b; }
.stp-state.lis { background: var(--err); }
.stp-root { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; color: #b45309; background: #fef3c7; border-radius: 4px; padding: 1px 6px; }

/* ---------- Terminal ---------- */

.term {
  flex: 1; min-height: 220px;
  background: #0d1117; color: #d6dde6;
  font: 13px/1.35 Consolas, "Cascadia Mono", "Courier New", monospace;
  padding: 8px 10px; border-radius: 6px; overflow: auto; cursor: text;
}
.term-out { white-space: pre-wrap; word-break: break-word; }
.term-line { display: flex; white-space: pre; }
.term-line input[type=text], .term-line input[type=text]:focus {
  flex: 1; border: 0; outline: 0; border-radius: 0; background: transparent; color: inherit; font: inherit; padding: 0; margin: 0;
  caret-color: #7ee787;
}

/* ---------- Text-Werkzeug ---------- */

#ws .note { cursor: move; }
.pal-item.pal-tool svg { max-height: 40px; }

.note-editor {
  position: fixed; z-index: 9500;
  width: 600px; max-width: calc(100vw - 16px);
  background: #fff; border: 1px solid #9aa8b8; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(16,32,56,.25);
  padding: 8px; display: flex; flex-direction: column; gap: 8px;
}
.ne-bar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ne-colors { display: flex; align-items: center; gap: 3px; }
.ne-swatch {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px #c3ccd6; cursor: pointer; padding: 0;
}
.ne-swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.ne-custom {
  position: relative; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; overflow: hidden;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); box-shadow: 0 0 0 1px #c3ccd6;
}
.ne-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.ne-sep { width: 1px; height: 22px; background: var(--border); }
.ne-size { padding: 3px 5px; }
.ne-seg { display: inline-flex; border: 1px solid #c3ccd6; border-radius: 6px; overflow: hidden; }
.ne-seg button { border: 0; background: #fff; padding: 3px 9px; cursor: pointer; min-width: 30px; }
.ne-seg button + button { border-left: 1px solid #c3ccd6; }
.ne-seg button:hover { background: #eef3f9; }
.ne-seg button.active { background: #dbe7fb; color: #1747a6; }
.ne-grow { flex: 1; }
.note-editor textarea {
  font: 15px/1.35 "Segoe UI", system-ui, sans-serif; resize: vertical; min-height: 44px;
  border: 1px solid #c3ccd6; border-radius: 6px; padding: 6px 8px;
}
.note-editor textarea:focus { outline: 2px solid rgba(31,111,235,.25); border-color: var(--accent); }

/* ---------- Kontextmenü, Toasts, Modal ---------- */

#ctxmenu {
  position: fixed; z-index: 10000; min-width: 190px;
  background: #fff; border: 1px solid #c3ccd6; border-radius: 8px; padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
#ctxmenu button {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  padding: 6px 10px; border-radius: 5px; cursor: pointer;
}
#ctxmenu button:hover { background: #eaf1fc; }
#ctxmenu button.danger { color: var(--err); }
#ctxmenu button.danger:hover { background: #fdecec; }
#ctxmenu hr { border: 0; border-top: 1px solid #e3e8ee; margin: 4px 2px; }

#toasts { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 10001; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #1f2933; color: #fff; padding: 8px 16px; border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); max-width: 560px; text-align: center;
  animation: toast-in .18s ease-out; transition: opacity .3s, transform .3s;
}
.toast.error { background: #b42318; }
.toast.warn { background: #9a5b06; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 9000; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal-box { position: relative; background: #fff; border-radius: 12px; padding: 20px 26px; width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box h2 { margin: 0 0 10px; font-size: 19px; }
.modal-box h3 { margin: 16px 0 6px; font-size: 14px; }
.modal-box ul { padding-left: 18px; margin: 0; }
.modal-box li { margin: 5px 0; }
.modal-close { position: absolute; right: 12px; top: 10px; border: 0; background: none; font-size: 16px; cursor: pointer; width: 30px; height: 30px; border-radius: 6px; }
.modal-close:hover { background: #eef1f5; }
.keys td { padding: 3px 12px 3px 0; }

@media (max-width: 900px) {
  .tb-btn:not(.icon-only) { font-size: 0; gap: 0; }
  .tb-btn:not(.icon-only) svg { margin: 0; }
  .brand-file { display: none; }
}
