/* ---------------------------------------------------------------------------
   Imkerschule LDAP-Portal – Gestaltung
   Ein einziges Stylesheet, keine externen Abhängigkeiten.
   --------------------------------------------------------------------------- */

:root {
    --bg: #faf8f4;
    --bg-soft: #f2eee6;
    --surface: #ffffff;
    --surface-2: #fbf9f5;
    --border: #e3ddd1;
    --border-strong: #cfc6b4;
    --text: #23201a;
    --text-soft: #6b6459;
    --text-faint: #938b7c;
    --accent: #b8860b;
    --accent-strong: #966d09;
    --accent-soft: #fdf3d8;
    --ok: #2f7d4f;
    --ok-soft: #e6f4ec;
    --warn: #a86a12;
    --warn-soft: #fdf1dc;
    --err: #b3261e;
    --err-soft: #fcebe9;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(35, 32, 26, .06), 0 4px 14px rgba(35, 32, 26, .05);
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16150f;
        --bg-soft: #1d1c15;
        --surface: #1f1e17;
        --surface-2: #26241c;
        --border: #35322a;
        --border-strong: #4a463b;
        --text: #ece7dc;
        --text-soft: #a8a294;
        --text-faint: #7d7768;
        --accent: #e0b13c;
        --accent-strong: #f2c75c;
        --accent-soft: #332910;
        --ok: #6cc48c;
        --ok-soft: #1c2f23;
        --warn: #e0aa55;
        --warn-soft: #322613;
        --err: #f28b82;
        --err-soft: #34201e;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: var(--text);
    background: var(--bg);
}

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 620; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1rem; }
small { font-size: .82rem; }

/* --- Gerüst -------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 236px;
    flex: 0 0 236px;
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    padding: 1.1rem .8rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.brand { display: flex; align-items: center; gap: .6rem; padding: .2rem .5rem .4rem; }
.brand svg { flex: 0 0 auto; }
.brand-text { font-weight: 650; font-size: .96rem; line-height: 1.2; }
.brand-text span { display: block; font-weight: 400; font-size: .74rem; color: var(--text-faint); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group { margin-top: .9rem; padding: 0 .55rem .3rem; font-size: .7rem; letter-spacing: .07em;
             text-transform: uppercase; color: var(--text-faint); font-weight: 600; }
.nav a {
    display: flex; align-items: center; gap: .55rem;
    padding: .44rem .55rem; border-radius: var(--radius-sm);
    color: var(--text-soft); font-size: .9rem; text-decoration: none;
}
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 560; }
.nav a svg { opacity: .75; flex: 0 0 auto; }

.sidebar-foot { margin-top: auto; padding: .6rem .55rem 0; border-top: 1px solid var(--border);
                font-size: .8rem; color: var(--text-faint); }
.sidebar-foot strong { display: block; color: var(--text-soft); font-weight: 560; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .85rem 1.6rem; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar h1 { margin: 0; font-size: 1.12rem; }
.content { padding: 1.4rem 1.6rem 3rem; max-width: 1180px; width: 100%; }

/* --- Karten -------------------------------------------------------------- */

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.card-head h2 { margin: 0; }
.card p.hint { color: var(--text-soft); font-size: .87rem; }
.hint { color: var(--text-soft); font-size: .87rem; }

.grid { display: grid; gap: 1.1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat .label { font-size: .78rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 1.7rem; font-weight: 640; line-height: 1.2; margin-top: .15rem; }
.stat .sub { font-size: .82rem; color: var(--text-soft); }

/* --- Formulare ----------------------------------------------------------- */

label { display: block; font-size: .84rem; font-weight: 560; color: var(--text-soft); margin-bottom: .25rem; }
.field { margin-bottom: .85rem; }
.field .hint { margin: .25rem 0 0; font-size: .8rem; }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=search], select, textarea {
    width: 100%; padding: .5rem .65rem; font: inherit; font-size: .9rem;
    color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); background: var(--surface);
}
textarea { min-height: 5rem; resize: vertical; font-family: var(--mono); font-size: .85rem; }
input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--accent); vertical-align: -2px; }
.check { display: flex; align-items: flex-start; gap: .5rem; margin-bottom: .7rem; }
.check label { margin: 0; font-weight: 400; color: var(--text); }

.row { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.btn {
    display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
    padding: .48rem .9rem; font: inherit; font-size: .88rem; font-weight: 560;
    border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--surface-2); color: var(--text); text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #201a06; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--border-strong)); }
.btn-danger:hover { background: var(--err-soft); }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .9rem; }

/* --- Meldungen ----------------------------------------------------------- */

.flash { border-radius: var(--radius-sm); padding: .65rem .85rem; margin-bottom: .9rem;
         font-size: .9rem; border: 1px solid transparent; }
.flash.success { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.flash.error   { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 35%, transparent); color: var(--err); }
.flash.warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.flash.info    { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--accent-strong); }

.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .74rem;
         font-weight: 600; letter-spacing: .01em; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.neutral { background: var(--bg-soft); color: var(--text-soft); }

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

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
    text-align: left; font-weight: 600; font-size: .77rem; letter-spacing: .04em; text-transform: uppercase;
    color: var(--text-faint); padding: .55rem .8rem; border-bottom: 1px solid var(--border);
    background: var(--surface-2); white-space: nowrap;
}
tbody td { padding: .55rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .85em; }
.nowrap { white-space: nowrap; }

.empty { padding: 2rem 1rem; text-align: center; color: var(--text-faint); font-size: .9rem; }

/* --- Definitionslisten --------------------------------------------------- */

dl.detail { display: grid; grid-template-columns: minmax(140px, 210px) 1fr; gap: .05rem 1rem; margin: 0; }
dl.detail dt { color: var(--text-faint); font-size: .84rem; padding: .35rem 0; }
dl.detail dd { margin: 0; padding: .35rem 0; border-bottom: 1px solid var(--border); }
dl.detail dt { border-bottom: 1px solid var(--border); }
dl.detail dt:last-of-type, dl.detail dd:last-of-type { border-bottom: none; }

/* --- Anmeldeseite -------------------------------------------------------- */

.plain { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.plain-box { width: 100%; max-width: 26rem; }
.plain-box.wide { max-width: 34rem; }
.plain-box .card { padding: 1.5rem; }
.plain-brand { display: flex; align-items: center; gap: .6rem; justify-content: center; margin-bottom: 1.1rem; }
.plain-brand .brand-text { text-align: left; }

.code-input {
    font-family: var(--mono); font-size: 1.5rem; letter-spacing: .35em;
    text-align: center; padding: .6rem .5rem;
}

.qr { display: flex; justify-content: center; padding: .9rem; background: #fff;
      border: 1px solid var(--border); border-radius: var(--radius); }
.qr img { width: 100%; max-width: 240px; height: auto; display: block; }

.secret {
    font-family: var(--mono); font-size: .95rem; letter-spacing: .06em; word-break: break-all;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: .55rem .7rem; text-align: center;
}

.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .4rem; margin: .6rem 0 0; padding: 0; list-style: none; }
.codes li { font-family: var(--mono); font-size: .9rem; background: var(--surface-2);
            border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .35rem .5rem; text-align: center; }

/* --- Baum ---------------------------------------------------------------- */

.crumbs { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; font-size: .85rem;
          margin-bottom: .8rem; color: var(--text-faint); }
.crumbs a { color: var(--text-soft); }
.crumbs span.sep { opacity: .5; }

.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-list li { border-bottom: 1px solid var(--border); }
.tree-list li:last-child { border-bottom: none; }
.tree-list a, .tree-list div.leaf { display: flex; align-items: center; gap: .55rem; padding: .5rem .8rem;
                                    color: var(--text); text-decoration: none; }
.tree-list a:hover { background: var(--surface-2); text-decoration: none; }
.tree-list .rdn { font-family: var(--mono); font-size: .86rem; }
.tree-list .meta { margin-left: auto; color: var(--text-faint); font-size: .8rem; }

/* --- Tabs ---------------------------------------------------------------- */

.tabs { display: flex; flex-wrap: wrap; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; }
.tabs a { padding: .45rem .8rem; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
          font-size: .88rem; color: var(--text-soft); margin-bottom: -1px; border: 1px solid transparent; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { background: var(--surface); border-color: var(--border); border-bottom-color: var(--surface);
                 color: var(--text); font-weight: 560; }

/* --- Zuordnungstabelle --------------------------------------------------- */

.map-table input[type=text], .map-table select { font-size: .85rem; padding: .35rem .45rem; }
.map-table td { padding: .35rem .4rem; }
.map-table td:first-child { padding-left: .8rem; }

pre.raw { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
          padding: .7rem .8rem; overflow: auto; max-height: 22rem; font-size: .8rem; margin: 0; }

/* --- Kleinigkeiten ------------------------------------------------------- */

.inline-form { display: inline; }
.right { text-align: right; }
.muted { color: var(--text-faint); }
hr { border: none; border-top: 1px solid var(--border); margin: 1.2rem 0; }

.pager { display: flex; gap: .4rem; align-items: center; justify-content: center; margin-top: 1rem; font-size: .85rem; }

@media (max-width: 800px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: 0 0 auto; border-right: none; border-bottom: 1px solid var(--border); }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav-group { display: none; }
    .content, .topbar { padding-left: 1rem; padding-right: 1rem; }
    dl.detail { grid-template-columns: 1fr; }
    dl.detail dt { border-bottom: none; padding-bottom: 0; }
}

/* --- Kopierbare Werte ---------------------------------------------------- */

.copy-row { display: flex; gap: .4rem; align-items: center; }
.copy-row input[readonly] {
    font-family: var(--mono);
    font-size: .82rem;
    background: var(--surface-2);
}
.btn.is-copied { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

pre.acl {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: .8rem .9rem; overflow-x: auto; font-size: .82rem; line-height: 1.5; margin: 0;
    white-space: pre;
}
