/* =====================================================================
   孙哥的服务器聊天室 - 样式（深色 Discord 风格）
   ===================================================================== */

:root {
    --bg: #36393f;
    --bg-d: #2f3136;
    --bg-dd: #202225;
    --bg-ddd: #1a1b2e;
    --tx: #dcddde;
    --tx-m: #8e9297;
    --tx-b: #fff;
    --brand: #5865f2;
    --brand-h: #4752c4;
    --green: #3ba55c;
    --red: #ed4245;
    --admin: #faa61a;
    --b: #40444b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    background: var(--bg-ddd);
    color: var(--tx);
}
button { cursor: pointer; border: none; font-family: inherit; }
input, textarea { font-family: inherit; }

.btn {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--brand);
    transition: .15s;
}
.btn:hover { background: var(--brand-h); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-block { width: 100%; }
.icon-btn {
    background: transparent;
    color: var(--tx-m);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover { background: #3c3f45; color: var(--tx); }

/* ===== 登录页 ===== */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 20%, #2a2d5a 0%, var(--bg-ddd) 60%);
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    border: 1px solid var(--b);
}
.auth-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--brand);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}
.auth-title { text-align: center; color: var(--tx-b); font-size: 22px; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--tx-m); font-size: 13px; margin-bottom: 24px; }
.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--tx-m);
    margin-bottom: 6px;
}
.field input {
    width: 100%;
    background: var(--bg-d);
    border: 1px solid var(--b);
    color: var(--tx-b);
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
}
.field input:focus { border-color: var(--brand); }
.err {
    background: rgba(237, 66, 69, .15);
    border: 1px solid var(--red);
    color: #ffb3b5;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
    display: none;
}
.auth-tip { text-align: center; color: var(--tx-m); font-size: 12px; margin-top: 18px; }

/* ===== 聊天页 ===== */
.chat-body { overflow: hidden; }
.chat-app {
    display: grid;
    grid-template-columns: 240px 1fr;
    height: 100vh;
}

/* 顶栏（手机端） */
.topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: 48px;
    background: var(--bg-dd);
    border-bottom: 1px solid var(--b);
    flex-shrink: 0;
}
.topbar-title { font-weight: 600; color: var(--tx-b); }

/* 左侧侧边栏 */
.sidebar {
    background: var(--bg-dd);
    border-right: 1px solid var(--b);
    display: flex;
    flex-direction: column;
}
.sidebar-h {
    padding: 14px 16px;
    border-bottom: 1px solid var(--b);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-h h2 { font-size: 14px; font-weight: 700; color: var(--tx-b); }
.online-c {
    background: var(--green);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}
.user-list { flex: 1; overflow-y: auto; padding: 6px; list-style: none; }
.user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 8px;
    transition: .1s;
}
.user-item:hover { background: #3c3f45; }
.user-item.kickable { cursor: pointer; }
.user-item.kickable:hover { background: rgba(237, 66, 69, .2); }
.user-item .av {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    position: relative;
}
.user-item .av::after {
    content: '';
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 9px;
    height: 9px;
    background: var(--green);
    border: 2px solid var(--bg-dd);
    border-radius: 50%;
}
.user-item.admin .av { background: var(--admin); color: #000; }
.user-item .un { font-size: 13px; color: var(--tx); font-weight: 500; }
.user-item.admin .un { color: var(--admin); font-weight: 600; }

/* 当前用户 */
.me-box {
    padding: 10px 12px;
    border-top: 1px solid var(--b);
    display: flex;
    align-items: center;
    gap: 10px;
}
.me-box .av {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.me-box.admin .av { background: var(--admin); color: #000; }
.me-info { display: flex; flex-direction: column; gap: 2px; }
.me-name { font-size: 13px; color: var(--tx-b); font-weight: 600; }
.adm-badge {
    align-self: flex-start;
    background: var(--admin);
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    display: none;
}
.me-box.admin .adm-badge { display: inline; }

/* 主聊天区 */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chat-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--b);
    flex-shrink: 0;
}
.chat-header h1 { font-size: 14px; font-weight: 700; color: var(--tx-b); }
.conn-status { font-size: 11px; color: var(--green); display: flex; align-items: center; gap: 4px; }
.conn-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--green);
    border-radius: 50%;
    display: inline-block;
}
.conn-status.off { color: var(--red); }
.conn-status.off::before { background: var(--red); }

/* 消息区 */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 1px; }
.msg-empty { text-align: center; color: var(--tx-m); padding: 40px 0; font-size: 14px; }
.msg {
    display: flex;
    gap: 12px;
    padding: 6px 8px;
    border-radius: 8px;
    position: relative;
    transition: .1s;
}
.msg:hover { background: rgba(0, 0, 0, .06); }
.msg:hover .msg-del { opacity: 1; }
.msg .av {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.msg.admin .av { background: var(--admin); color: #000; }
.msg.sys .av { background: var(--tx-m); }
.msg-body { min-width: 0; flex: 1; }
.msg-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
    flex-wrap: wrap;
}
.msg-author { font-weight: 600; color: var(--tx-b); font-size: 14px; }
.msg.admin .msg-author { color: var(--admin); }
.adm-tag {
    background: var(--admin);
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    display: none;
}
.msg.admin .adm-tag { display: inline; }
.msg-time { font-size: 11px; color: var(--tx-m); }
.msg-content {
    font-size: 15px;
    color: var(--tx);
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}
.msg.sys .msg-content { color: var(--admin); font-style: italic; font-size: 13px; }
.msg-img { max-width: 320px; max-height: 320px; border-radius: 8px; cursor: pointer; display: block; margin-top: 4px; }
.msg-video { max-width: 360px; max-height: 360px; border-radius: 8px; display: block; margin-top: 4px; }
.msg-del {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--bg-dd);
    color: var(--red);
    border: 1px solid var(--b);
    border-radius: 6px;
    padding: 3px 7px;
    font-size: 11px;
    opacity: 0;
    transition: .12s;
}
.msg-del:hover { background: var(--red); color: #fff; }

/* 滚动条 */
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: #42464d; border-radius: 4px; }

/* 输入框 */
.composer { padding: 10px 16px 14px; flex-shrink: 0; }
.up-prev {
    display: none;
    align-items: center;
    gap: 10px;
    background: var(--bg-d);
    border: 1px solid var(--b);
    border-radius: 8px;
    padding: 7px 10px;
    margin-bottom: 8px;
}
.up-prev img, .up-prev video { max-height: 50px; max-width: 70px; border-radius: 4px; }
.up-prev .up-n {
    font-size: 12px;
    color: var(--tx);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.up-prev .up-x { background: transparent; color: var(--tx-m); font-size: 18px; padding: 2px 6px; }
.up-prev .up-x:hover { color: var(--red); }
.comp-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-d);
    border: 1px solid var(--b);
    border-radius: 8px;
    padding: 8px;
}
.up-btn {
    background: #3c3f45;
    color: var(--tx-m);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: .12s;
    cursor: pointer;
}
.up-btn:hover { background: var(--brand); color: #fff; }
.msg-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--tx-b);
    font-size: 15px;
    resize: none;
    outline: none;
    max-height: 140px;
    line-height: 1.4;
    padding: 7px 4px;
}
.msg-input::placeholder { color: var(--tx-m); }
.send-btn { padding: 9px 18px; flex-shrink: 0; }

/* 弹窗 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
}
.modal-card {
    background: var(--bg);
    border-radius: 12px;
    padding: 28px 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.modal-card h3 { color: var(--red); margin-bottom: 12px; font-size: 18px; }
.modal-card p { color: var(--tx); margin-bottom: 20px; font-size: 14px; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dd);
    color: var(--tx);
    padding: 11px 20px;
    border-radius: 8px;
    border: 1px solid var(--b);
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    z-index: 1000;
    animation: ti .2s;
}
.toast.e { border-color: var(--red); color: #ffb3b5; }
.toast.s { border-color: var(--green); color: #b3ffc0; }
@keyframes ti {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

/* 手机端 */
@media (max-width: 768px) {
    .chat-app {
        grid-template-columns: 1fr;
        grid-template-rows: 48px 1fr;
    }
    .topbar { display: flex; }
    .sidebar {
        position: fixed;
        top: 48px;
        bottom: 0;
        left: 0;
        width: 260px;
        z-index: 50;
        transform: translateX(-100%);
        transition: .25s;
        box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open + .main::before {
        content: '';
        position: fixed;
        inset: 48px 0 0 0;
        background: rgba(0, 0, 0, .5);
        z-index: 40;
    }
    .msg-img { max-width: 220px; max-height: 220px; }
    .msg-video { max-width: 260px; max-height: 260px; }
    .composer { padding: 8px 10px 12px; }
}
