/* /opt/m-messenger/public/css/app.css */
:root {
  --brand: #1565c0;
  --brand-ink: #ffffff;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #18202b;
  --muted: #5f6b7a;
  --line: #dfe4ea;
  --danger: #c62828;
  --ok: #2e7d32;
  --warn: #b26a00;
  --radius: 14px;
  --tabbar-h: 62px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #5c9ded;
    --brand-ink: #0b1420;
    --bg: #0f141a;
    --surface: #18202a;
    --ink: #e7ecf2;
    --muted: #94a1b2;
    --line: #2a3542;
    --danger: #ef6a6a;
    --ok: #6ccf73;
    --warn: #f0b04a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.45 var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .5rem; }
a { color: var(--brand); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }

.splash { display: grid; place-items: center; height: 100vh; }
.splash img { border-radius: 22px; opacity: .9; }

/* Layout */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

.shell { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.2rem; }
.brand img { border-radius: 7px; }
.tenant { flex: 1; text-align: right; color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.conn[data-status="online"] { background: var(--ok); }
.conn[data-status="connecting"] { background: var(--warn); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .35; } }

.content {
  flex: 1; width: 100%; max-width: 760px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 20px);
}
.loading { padding: 40px; text-align: center; color: var(--muted); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .72rem;
}
.tabbar a .ico { font-size: 1.3rem; line-height: 1; filter: grayscale(1); opacity: .75; }
.tabbar a.active { color: var(--brand); font-weight: 600; }
.tabbar a.active .ico { filter: none; opacity: 1; }

/* Karten & Listen */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.hint { border-color: var(--brand); }
.card.error { border-color: var(--danger); color: var(--danger); }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item.link { cursor: pointer; }
.list-item.inactive { opacity: .55; }
.list-item .title { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chev { color: var(--muted); font-size: 1.4rem; }
.back { text-decoration: none; font-weight: 600; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: .95rem;
  background: color-mix(in srgb, var(--brand) 16%, var(--surface)); color: var(--brand);
}
.badge { font-size: .7rem; font-weight: 600; padding: 2px 7px; border-radius: 99px; background: var(--line); color: var(--ink); }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: var(--warn); }

.empty { text-align: center; padding: 48px 16px; }
.empty-ico { font-size: 3rem; margin-bottom: 8px; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; font-weight: 600; }
.field small { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink);
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
input[readonly] { opacity: .8; }
select.small { width: auto; padding: 6px 8px; font-size: .85rem; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: .9rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

/* Anmeldung */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px;
}
.auth-card h1 { text-align: center; }
.auth-logo { align-self: center; border-radius: 16px; }

/* Toast & Dialog */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  max-width: calc(100% - 32px); z-index: 100; font-size: .92rem;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }
#toast.ok { background: var(--ok); color: #fff; }

.modal {
  border: 0; border-radius: 18px; padding: 20px; width: min(440px, calc(100% - 32px));
  background: var(--surface); color: var(--ink);
}
.modal::backdrop { background: rgb(0 0 0 / .45); }
.modal .row.end { margin-top: 16px; }
