/* MZBuschFunk — Design-System (v0.6.0)
   Dark-Theme, Discord-inspiriert. Primär wird ui-text deutsch, code englisch. */

:root {
    --bg: #1e1f22;
    --bg2: #2b2d31;
    --bg3: #313338;
    --fg: #dbdee1;
    --muted: #9a9da3;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --border: #26282c;
    --green: #23a55a;
    --red: #f23f43;
    --yellow: #f0b232;
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--fg);
    font-family: "Segoe UI", system-ui, sans-serif;
    min-height: 100vh;
}

/* ---------- Layout ---------- */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.content {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
}

.footer {
    position: fixed;
    bottom: 8px;
    right: 12px;
    font-size: 12px;
    color: var(--muted);
}
.footer .ver { color: var(--accent); }

/* ---------- Kopf ---------- */
.logo { font-size: 20px; font-weight: 700; cursor: default; }
.logo span { color: var(--accent); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.health { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--green); }
.dot.err { background: var(--red); }
.ws-state { font-size: 12px; color: var(--muted); }
.ws-state.on { color: var(--green); }
.ws-state.off { color: var(--yellow); }

/* ---------- Karten ---------- */
.card {
    background: var(--bg2);
    border-radius: 12px;
    padding: 28px;
    width: 380px;
    border: 1px solid var(--border);
}
.card.main { width: 460px; max-width: 100%; }

.sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

.sec {
    margin: 14px 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, .12);
}

/* ---------- Formulare ---------- */
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
input[type="text"], input[type="password"], input[type="email"] {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
}
input:focus { border-color: var(--accent); }

.cb-row { display: flex; align-items: center; gap: 8px; margin: 12px 0; font-size: 13px; color: var(--muted); }
.cb-row input { accent-color: var(--accent); }

/* ---------- Buttons ---------- */
.row { display: flex; gap: 8px; margin-top: 16px; }
button {
    flex: 1;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 10px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
    transition: background .15s;
}
button:hover { background: var(--accent-hover); }
button.ghost { background: var(--bg3); color: var(--fg); }
button.ghost:hover { background: #3a3d44; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.danger { color: var(--red); }

/* ---------- Meldungen ---------- */
.msg {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    display: none;
    line-height: 1.4;
}
.msg.ok { background: rgba(35, 165, 90, .12); color: var(--green); display: block; }
.msg.err { background: rgba(242, 63, 67, .12); color: var(--red); display: block; }
.msg.info { background: rgba(240, 178, 50, .12); color: var(--yellow); display: block; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }

.who { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.who .avatar {
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px; color: #fff;
    flex: 0 0 auto;
}

.placeholder {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 22px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.link { display: block; text-align: center; margin-top: 14px; font-size: 13px; color: var(--muted); text-decoration: none; }
.link:hover { color: var(--accent); }

/* ---------- v1.1: App-Layout (Sidebar + Content) ---------- */
.app-main {
    display: flex;
    gap: 0;
    width: 860px;
    max-width: 100%;
    min-height: 70vh;
    background: var(--bg2);
    border-radius: var(--radius);
    overflow: hidden;
}

.server-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    min-width: 64px;
}

.server-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    width: 100%;
}

.server-pill {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: var(--bg3);
    color: var(--fg);
    font-weight: 700;
    font-size: 17px;
    cursor: pointer;
    transition: border-radius .15s, background .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.server-pill:hover { border-radius: 14px; background: var(--accent); color: #fff; }
.server-pill.active { border-radius: 14px; background: var(--accent); color: #fff; }

.server-add {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--green);
    font-size: 22px;
    cursor: pointer;
    transition: border-radius .15s, background .15s;
    flex: 0 0 auto;
}

.server-add:hover { border-radius: 14px; background: var(--green); color: #fff; }

.main-content {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    max-height: 70vh;
}

.server-area { margin-bottom: 18px; }
.server-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.invite-code {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg3);
    border-radius: var(--radius);
    padding: 8px 12px;
}

.invite-code code {
    font-size: 15px;
    letter-spacing: 1px;
    color: var(--accent);
    user-select: all;
    word-break: break-all;
}

/* ---------- v1.2: Kanalbaum ---------- */
.channel-panel {
    display: flex;
    flex-direction: column;
    width: 200px;
    flex: 0 0 200px;
    background: var(--bg3);
    border-right: 1px solid var(--border);
    padding: 10px;
    gap: 8px;
    overflow-y: auto;
    max-height: 70vh;
}

.channel-panel.hidden { display: none; }

#input-filter-channels {
    width: 100%;
    font-size: 12px;
    padding: 5px 8px;
}

.channel-tree { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }

.channel-cat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-top: 8px;
    padding: 2px 4px;
}

.channel-cat:first-child { margin-top: 0; }

.channel-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
}

.channel-row:hover { background: rgba(255, 255, 255, .05); color: var(--fg); }
.channel-row.active { background: var(--accent); color: #fff; }
.channel-row .icon { flex: 0 0 auto; width: 16px; text-align: center; }
.channel-row .cname { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.channel-row .badges { flex: 0 0 auto; font-size: 10px; display: flex; gap: 3px; }
.channel-row .admin { display: none; gap: 3px; flex: 0 0 auto; }
.channel-cat:hover .admin, .channel-row:hover .admin { display: flex; }
.channel-row .admin button, .channel-cat .admin button {
    background: none; border: none; color: inherit; cursor: pointer; font-size: 11px; padding: 0 2px;
}

.channel-child { margin-left: 14px; }

.channel-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }

.channel-empty { font-size: 12px; color: var(--muted); padding: 6px; }

/* ---------- v1.3: Chat ---------- */
.chat-view {
    display: flex;
    flex-direction: column;
    min-height: 320px;
    max-height: 46vh;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg2);
    margin-bottom: 16px;
}

.chat-view.hidden { display: none; }

#chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

#chat-header b { font-size: 14px; }

.msg-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
}

.chat-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0; }

.msg-row {
    border-radius: var(--radius);
    padding: 6px 8px;
    background: rgba(255, 255, 255, .03);
    position: relative;
}

.msg-row.mine { background: rgba(88, 101, 242, .08); }
.msg-row:hover .msg-actions { opacity: 1; }

.msg-head { display: flex; align-items: center; gap: 8px; }
.msg-author { color: var(--accent); font-size: 13px; }
.msg-time { font-size: 11px; color: var(--muted); }
.msg-body { font-size: 13.5px; margin-top: 2px; word-wrap: break-word; line-height: 1.45; }
.msg-body code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.msg-body pre.codeblock { background: var(--bg); padding: 8px 10px; border-radius: 6px; overflow-x: auto; font-size: 12px; margin: 4px 0; }
.msg-body .mention { background: rgba(88, 101, 242, .25); color: var(--accent); border-radius: 4px; padding: 1px 5px; font-weight: 600; }
.msg-body a { color: var(--accent); text-decoration: underline; }
.msg-body .embed-img { max-width: 240px; max-height: 160px; border-radius: 6px; margin-top: 4px; display: block; }
.msg-body .pin { color: var(--yellow); }
.msg-body .edited { color: var(--muted); font-size: 11px; }
.attach { margin-top: 4px; font-size: 12.5px; }
.attach a { color: var(--accent); }

.msg-actions {
    position: absolute;
    top: 4px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity .15s;
}

.msg-actions button {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    padding: 1px 5px;
}

.msg-actions button:hover { color: var(--fg); background: var(--bg2); }

.chat-input-row { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); }

#btn-attach {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 10px;
}

#btn-attach:hover { color: var(--fg); }

#input-message { flex: 1; }

/* ---------- v1.1: Modals ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal.hidden { display: none; }

.modal-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    width: 360px;
    max-width: calc(100vw - 32px);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (max-width: 480px) {
    .card, .card.main { width: calc(100vw - 32px); }
    .app-main { width: calc(100vw - 16px); }
}