/* 360 DB-Admin – eigenes Aussehen, Anordnung wie phpMyAdmin (Navigation links, Pfad + Reiter oben). */

:root {
  --bg: #ffffff;
  --text: #2b3138;
  --muted: #6b7682;
  --line: #d4dae0;
  --line-soft: #e6eaee;
  --nav-bg: #f1f3f5;
  --nav-hover: #e2e7ec;
  --nav-active: #d6e4f2;
  --crumb-bg: #3d4852;
  --crumb-text: #ffffff;
  --tab-bg: #f6f7f9;
  --tab-active: #ffffff;
  --link: #1f5f99;
  --accent: #1f5f99;
  --accent-text: #ffffff;
  --head-bg: #e3e8ed;
  --row-alt: #f6f8fa;
  --row-hover: #e3eef9;
  --row-marked: #ffe7c2;
  --card-bg: #f8f9fb;
  --code-bg: #f3f5f7;
  --ok-bg: #e8f5e4;
  --ok-line: #9ccc8e;
  --ok-text: #2c5e22;
  --err-bg: #fdeceb;
  --err-line: #e6a29d;
  --err-text: #8a1f17;
  --warn-bg: #fff6dc;
  --warn-line: #e8cf83;
  --warn-text: #6b5210;
  --info-bg: #eaf2fb;
  --info-line: #a9c7e8;
  --danger: #b3261e;
  --null: #9aa4ae;
  --nav-w: 250px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1f23;
    --text: #dde3e8;
    --muted: #9aa6b1;
    --line: #39414a;
    --line-soft: #2c333a;
    --nav-bg: #22272c;
    --nav-hover: #2c333a;
    --nav-active: #23384d;
    --crumb-bg: #11151a;
    --tab-bg: #22272c;
    --tab-active: #1b1f23;
    --link: #79b4ec;
    --accent: #3b82c4;
    --head-bg: #2a3138;
    --row-alt: #20252a;
    --row-hover: #243445;
    --row-marked: #4a3b1f;
    --card-bg: #20252a;
    --code-bg: #232a31;
    --ok-bg: #1f3320;
    --ok-line: #3f6b3a;
    --ok-text: #b6e0aa;
    --err-bg: #3a1f1d;
    --err-line: #7d3a34;
    --err-text: #f2b8b2;
    --warn-bg: #3a321b;
    --warn-line: #7a6630;
    --warn-text: #ecd798;
    --info-bg: #1c2b3b;
    --info-line: #35577a;
    --danger: #f08a82;
    --null: #7b8691;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 16px; margin: 16px 0 8px; font-weight: 600; }
h3 { font-size: 14px; margin: 14px 0 6px; }
code, pre, .mono, textarea#sqltext { font-family: ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace; }
.mono { font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
[hidden] { display: none !important; }

svg.i { width: 15px; height: 15px; vertical-align: -3px; flex: none; }

/* ---------- Grundgerüst ---------- */

#nav {
  position: fixed; inset: 0 auto 0 0; width: var(--nav-w);
  background: var(--nav-bg); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden; z-index: 10;
}
#main { margin-left: var(--nav-w); min-height: 100vh; }

.logo { display: flex; align-items: center; gap: 8px; padding: 12px 14px 6px; font-size: 18px; color: var(--text); }
.logo svg.i { width: 26px; height: 26px; color: var(--accent); }
.logo b { color: var(--accent); }
.logo:hover { text-decoration: none; }

.quick { display: flex; gap: 2px; padding: 2px 10px 8px; align-items: center; }
.quick a, .quick .linkbtn { padding: 4px 6px; border-radius: 4px; color: var(--muted); }
.quick a:hover, .quick .linkbtn:hover { background: var(--nav-hover); color: var(--text); text-decoration: none; }
.quick form { margin: 0; }

#navfilter {
  margin: 0 10px 6px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg); color: var(--text); font: inherit;
}

.tree { list-style: none; margin: 0; padding: 0 0 12px; overflow-y: auto; flex: 1; }
.tree ul { list-style: none; margin: 0 0 0 18px; padding: 0 0 4px 6px; border-left: 1px dotted var(--line); }
.tree li { white-space: nowrap; }
.tree a { display: flex; align-items: center; gap: 6px; padding: 2px 8px; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.tree a span { overflow: hidden; text-overflow: ellipsis; }
.tree a:hover { background: var(--nav-hover); text-decoration: none; }
.tree .dbname { padding: 4px 12px; font-weight: 500; }
.tree .dbname svg.i { color: var(--muted); }
.tree li.open > .dbname svg.i { color: var(--accent); }
.tree .active, .tree li.tbl.active > a { background: var(--nav-active); }
.tree li.tbl { display: flex; align-items: center; }
.tree li.tbl > a.ico { padding: 2px 2px 2px 4px; color: var(--muted); flex: none; }
.tree li.tbl > a:last-child { flex: 1; padding-left: 2px; }
.tree li.new a { color: var(--muted); }

.who { border-top: 1px solid var(--line); padding: 8px 14px; font-size: 12px; }
.who .muted { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#top { position: sticky; top: 0; z-index: 5; background: var(--bg); }
.crumbs {
  background: var(--crumb-bg); color: var(--crumb-text);
  padding: 6px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
}
.crumbs a { color: var(--crumb-text); font-weight: 600; }
.crumbs .sep { opacity: .6; }
.crumbs svg.i { opacity: .85; }
.crumbs em.comment { opacity: .85; font-weight: normal; }

.tabs {
  list-style: none; margin: 0; padding: 6px 12px 0; display: flex; flex-wrap: wrap; gap: 2px;
  background: var(--tab-bg); border-bottom: 1px solid var(--line);
}
.tabs li a {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px; color: var(--text);
  border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; margin-bottom: -1px;
}
.tabs li a:hover { background: var(--nav-hover); text-decoration: none; }
.tabs li.active a { background: var(--tab-active); border-color: var(--line); font-weight: 600; }
.tabs svg.i { color: var(--muted); }
.tabs li.active svg.i { color: var(--accent); }

#content { padding: 12px 16px 48px; }

/* ---------- Meldungen, SQL ---------- */

.msg { border: 1px solid; border-radius: 5px; padding: 8px 12px; margin: 8px 0; white-space: pre-wrap; }
.msg-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-text); }
.msg-error { background: var(--err-bg); border-color: var(--err-line); color: var(--err-text); }
.msg-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.msg-info { background: var(--info-bg); border-color: var(--info-line); }
.err { color: var(--err-text); }

.sqlbox { border: 1px solid var(--line); border-radius: 5px; background: var(--code-bg); margin: 8px 0; }
.sqlbox pre.sql { margin: 0; padding: 8px 12px; white-space: pre-wrap; word-break: break-word; font-size: 12px; max-height: 260px; overflow: auto; }
.sqllinks { border-top: 1px solid var(--line); padding: 4px 12px; display: flex; gap: 16px; justify-content: flex-end; font-size: 12px; }

/* ---------- Karten, Formulare, Buttons ---------- */

fieldset.card { border: 1px solid var(--line); border-radius: 6px; background: var(--card-bg); padding: 10px 14px 12px; margin: 12px 0; min-width: 0; }
fieldset.card legend { font-weight: 600; padding: 2px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; }
fieldset.card label { display: inline-flex; align-items: center; gap: 6px; margin: 4px 14px 4px 0; }
label.row, div.row { display: flex !important; align-items: center; gap: 10px; margin: 6px 0; flex-wrap: wrap; }
label.row > span:first-child, div.row > span:first-child { min-width: 180px; }
.radios { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 4px 0; }
.formend { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.formend .muted { margin-right: auto; }
.rowform { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 10px 0; }
.rowform label { display: inline-flex; align-items: center; gap: 6px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; max-width: 100%;
}
input[type=checkbox], input[type=radio] { padding: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; cursor: pointer;
}
.btn:hover { background: var(--nav-hover); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.small { padding: 2px 7px; }
.linkbtn {
  background: none; border: none; padding: 0; margin: 0; font: inherit; color: var(--link); cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.linkbtn:hover:not(:disabled) { text-decoration: underline; }
.linkbtn:disabled { color: var(--muted); cursor: default; opacity: .6; }
.danger { color: var(--danger); }

/* ---------- Tabellen ---------- */

table.list, table.grid { border-collapse: collapse; margin: 6px 0; }
table.list th, table.list td, table.grid th, table.grid td { border: 1px solid var(--line-soft); padding: 4px 8px; text-align: left; vertical-align: top; }
table.list thead th, table.grid thead th, table.list tfoot th { background: var(--head-bg); font-weight: 600; white-space: nowrap; }
table.list tbody tr:nth-child(even), table.grid tbody tr:nth-child(even) { background: var(--row-alt); }
table.list tbody tr:hover, table.grid tbody tr:hover { background: var(--row-hover); }
table.list tbody th { font-weight: 600; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.center { text-align: center !important; }

td.actions { white-space: nowrap; }
td.actions > a, td.actions > .linkbtn, td.actions > details { margin-right: 10px; }
td.actions form { display: inline; }

.gridwrap { overflow-x: auto; max-width: 100%; }
table.grid td { max-width: 480px; white-space: pre-wrap; word-break: break-word; }
table.grid td.act { white-space: nowrap; width: 1px; padding: 4px 6px; }
table.grid thead th a { color: var(--text); }
table.grid tr.marked, table.grid tr.marked:hover { background: var(--row-marked); }
table.grid td[data-c] { cursor: cell; }
table.grid td.editing { padding: 2px; background: var(--bg); }
i.null { color: var(--null); }
.blob, .hex { color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.cell-editor { display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.cell-editor textarea { min-height: 2.4em; font-size: 13px; }
.cell-editor .row { display: flex !important; gap: 8px; align-items: center; font-size: 12px; margin: 0; }
.cell-editor .row .muted { margin-left: auto; }

.withsel { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin: 6px 0 12px 6px; }
.withsel form { display: inline; margin: 0; }
.withsel .hint { margin-left: auto; font-size: 12px; }

.navbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 8px 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--card-bg); }
.navbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.navbar label { display: inline-flex; align-items: center; gap: 6px; }
form.inline { display: inline-flex; margin: 0; }

fieldset.ops { display: flex; gap: 18px; flex-wrap: wrap; }

/* Struktur */
.keyicon svg.i { color: #c9a227; }
.idxicon svg.i { color: var(--muted); }
details.more { display: inline-block; position: relative; }
details.more summary { cursor: pointer; color: var(--link); list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: " ▾"; font-size: 10px; }
details.more .menu {
  position: absolute; right: 0; top: 100%; z-index: 20; background: var(--bg); border: 1px solid var(--line);
  border-radius: 5px; box-shadow: 0 4px 14px rgba(0,0,0,.12); padding: 4px 0; min-width: 170px;
}
details.more .menu > * { display: flex; padding: 4px 12px; width: 100%; }
details.more .menu > *:hover { background: var(--row-hover); text-decoration: none; }
details.create { margin: 14px 0; }
details.create summary { cursor: pointer; color: var(--link); }

.cols { display: flex; flex-wrap: wrap; gap: 0 18px; align-items: flex-start; }
.cols > fieldset.card { flex: 1 1 260px; }
.colmain { flex: 3 1 520px; min-width: 0; }
.colside { flex: 1 1 260px; }
ul.facts { list-style: none; margin: 0; padding: 0; }
ul.facts li { padding: 3px 0; border-bottom: 1px solid var(--line-soft); }
ul.facts li:last-child { border-bottom: 0; }
table.facts { border-collapse: collapse; width: 100%; }
table.facts th { text-align: left; font-weight: normal; color: var(--muted); padding: 3px 12px 3px 0; }
table.facts td { padding: 3px 0; }

/* SQL-Seite */
.sqlarea { display: flex; gap: 10px; align-items: stretch; }
.sqlarea textarea { flex: 1; font-size: 13px; min-height: 180px; }
.colpick { display: flex; flex-direction: column; gap: 4px; width: 180px; }
.colpick select { flex: 1; }

/* Spalten-Editor */
table.coledit td { padding: 3px 4px; }
table.coledit td.def { white-space: nowrap; }
table.coledit td.def input { margin-left: 4px; }

/* Bearbeiten */
table.editrow td.value { min-width: 380px; }
table.editrow td.value > input:not([type=file]):not([type=checkbox]) { width: 100%; }

/* Operationen */
.opsgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 0 16px; }
.opform { margin: 0; }
.oplinks { display: flex; flex-direction: column; gap: 6px; }

/* Bestätigung */
.confirm form { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

/* Login / einfache Seiten */
body.plain { background: var(--nav-bg); }
.loginbox, .errorpage { max-width: 440px; margin: 9vh auto 40px; padding: 0 16px; }
.loginlogo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 26px; }
.loginlogo svg.i { width: 40px; height: 40px; color: var(--accent); }
.loginlogo b { color: var(--accent); }
.loginbox h1 { text-align: center; font-size: 18px; font-weight: 500; margin: 8px 0 16px; }
.loginbox fieldset.card { background: var(--bg); }
.loginbox label.row > span:first-child { min-width: 120px; }
.loginbox label.row input { flex: 1; }
.loginbox p { text-align: center; }
.errorpage h1 { font-size: 20px; }

/* Schmale Bildschirme: Navigation oben statt links. */
@media (max-width: 760px) {
  #nav { position: static; width: auto; max-height: 45vh; border-right: 0; border-bottom: 1px solid var(--line); }
  #main { margin-left: 0; }
  .sqlarea { flex-direction: column; }
  .colpick { width: auto; }
  label.row > span:first-child, div.row > span:first-child { min-width: 0; }
}

@media print {
  #nav, .tabs, .navbar, .withsel, td.act, th.act { display: none !important; }
  #main { margin: 0; }
}
