/* ========================================
   飞到西边去聊天室 - DNF 深色主题样式
   ======================================== */

/* ---- 全局重置 ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ---- 图片查看弹窗 ---- */
.image-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}
.image-viewer-img {
    max-width: 95%;
    max-height: 85%;
    object-fit: contain;
    border-radius: 4px;
}
.image-viewer-close {
    position: fixed;
    top: 15px;
    right: 25px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    line-height: 1;
}
.image-viewer-close:hover {
    color: #f6ad55;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    background: #0f0f1a;
    color: #e2e8f0;
    font-size: 14px;
}

/* ---- 滚动条 ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #4a5568; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #f6ad55; }

/* ---- 链接 ---- */
a { color: #f6ad55; text-decoration: none; }
a:hover { color: #fbd38d; text-decoration: underline; }

/* ========================================
   昵称弹窗
   ======================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 15, 26, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid #2d3748;
    border-radius: 16px;
    padding: 40px;
    width: 360px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    color: #f6ad55;
    margin-bottom: 8px;
}

.modal-desc {
    color: #a0aec0;
    font-size: 14px;
    margin-bottom: 24px;
}

.modal-input {
    width: 100%;
    padding: 12px 16px;
    background: #1e2a3a;
    border: 1px solid #2d3748;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: #f6ad55;
}

.modal-input::placeholder {
    color: #4a5568;
}

.error-msg {
    color: #fc8181;
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}

.modal-btn {
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: linear-gradient(135deg, #f6ad55 0%, #dd6b20 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}

.modal-btn:hover {
    opacity: 0.9;
}

.modal-btn:active {
    transform: scale(0.98);
}

/* ========================================
   主界面布局
   ======================================== */
#chat-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* ---- 顶栏 ---- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: linear-gradient(90deg, #1a1a2e 0%, #16213e 100%);
    border-bottom: 1px solid #2d3748;
    flex-shrink: 0;
    z-index: 10;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    color: #f6ad55;
}

/* ---- 移动端适配 ---- */

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.online-count {
    color: #68d391;
    font-size: 14px;
    font-weight: 500;
}

.icon-btn {
    background: none;
    border: 1px solid #2d3748;
    color: #a0aec0;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: none;
}

.icon-btn:hover {
    background: #1e2a3a;
}

/* ---- 主内容区 ---- */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---- 消息区 ---- */
.message-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 60px;
    background: #0f0f1a;
}

#messages-container {
    max-width: 800px;
    margin: 0 auto;
}

/* ---- 消息样式 ---- */
.message {
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #1a1a2e;
    border-radius: 8px;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
    border: 1px solid transparent;
    transition: border-color 0.3s;
    max-width: 80%;
    clear: both;
    float: left;
    margin-right: auto;
}

.message.system {
    background: transparent;
    text-align: center;
    padding: 4px 8px;
    float: none;
    margin: 0 auto 10px;
    max-width: 100%;
}

.system-text {
    color: #718096;
    font-size: 12px;
    font-style: italic;
}

.message.mentioned {
    border-color: #f6ad55;
    background: #1e2a3a;
}

.mention-flash {
    animation: flashHighlight 0.5s ease 3;
}

@keyframes flashHighlight {
    0%, 100% { background-color: #1e2a3a; }
    50% { background-color: #2d3748; border-color: #fbd38d; }
}

.msg-nickname {
    color: #f6ad55;
    font-weight: 600;
    margin-right: 6px;
}

.msg-content {
    color: #e2e8f0;
}

.msg-content .mention {
    color: #fbd38d;
    font-weight: 600;
    background: rgba(246, 173, 85, 0.15);
    padding: 1px 4px;
    border-radius: 3px;
}

.msg-time {
    color: #4a5568;
    font-size: 11px;
    float: right;
    margin-top: 2px;
    margin-left: 8px;
}

.msg-link {
    color: #63b3ed;
    text-decoration: underline;
    word-break: break-all;
}
.msg-link:hover {
    color: #90cdf4;
}

/* ---- 自己发的消息靠右 ---- */
.message.self {
    text-align: right;
    float: right;
    margin-left: auto;
    margin-right: 0;
    background: #1e3a5f;
    border-color: #2b6cb0;
}

.message.self .msg-nickname {
    color: #90cdf4;
}

.message.self .msg-time {
    float: none;
    margin-left: 0;
    margin-right: 8px;
}

.deleted-msg {
    color: #718096;
    font-style: italic;
    font-size: 13px;
}

/* ---- 图片消息 ---- */
.chat-image {
    max-width: 240px;
    max-height: 180px;
    border-radius: 6px;
    margin-top: 4px;
    border: 1px solid #2d3748;
    cursor: pointer;
    transition: opacity 0.2s;
    filter: grayscale(100%);
}

.chat-image:hover {
    opacity: 0.85;
}

/* ---- 在线用户侧栏 ---- */
.users-sidebar {
    width: 200px;
    background: #14142a;
    border-left: 1px solid #2d3748;
    padding: 12px;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-title {
    color: #a0aec0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2d3748;
}

.user-item {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 14px;
    color: #e2e8f0;
    margin-bottom: 4px;
    transition: background 0.2s;
}

.user-item:hover {
    background: #1e2a3a;
}

.user-self {
    color: #68d391;
    font-weight: 500;
}

/* ---- 底部输入区 ---- */
.input-area {
    flex-shrink: 0;
    background: #1a1a2e;
    border-top: 1px solid #2d3748;
    padding: 10px 20px 14px;
    position: relative;
}

.input-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.toolbar-btn {
    background: none;
    border: 1px solid #2d3748;
    color: #a0aec0;
    font-size: 18px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: #1e2a3a;
    color: #f6ad55;
    border-color: #f6ad55;
}

.toolbar-hint {
    color: #4a5568;
    font-size: 12px;
    margin-left: 8px;
}

.input-row {
    display: flex;
    gap: 10px;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.msg-input {
    width: 100%;
    padding: 10px 14px;
    background: #0f0f1a;
    border: 1px solid #2d3748;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.msg-input:focus {
    border-color: #f6ad55;
}

.send-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, #f6ad55 0%, #dd6b20 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.send-btn:hover {
    opacity: 0.9;
}

.send-btn:active {
    transform: scale(0.97);
}

/* ---- Emoji 面板 ---- */
.emoji-panel {
    position: absolute;
    bottom: 100%;
    left: 20px;
    background: #1e2a3a;
    border: 1px solid #2d3748;
    border-radius: 10px;
    padding: 12px;
    width: 320px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
    z-index: 20;
}

/* 手机端 Emoji 面板固定到可视区域底部 */
@media (max-width: 768px) {
    .emoji-panel {
        position: fixed;
        bottom: 56px;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 180px;
        border-radius: 12px 12px 0 0;
        z-index: 1000;
    }
}

.emoji-category {
    color: #a0aec0;
    font-size: 12px;
    margin: 8px 0 4px;
    font-weight: 600;
}

.emoji-category:first-child {
    margin-top: 0;
}

.emoji-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    font-size: 22px;
}

.emoji-grid span {
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    width: 36px;
    text-align: center;
}

.emoji-grid span:hover {
    background: #2d3748;
}

/* ---- @某人弹窗 ---- */
.mention-popup {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #1e2a3a;
    border: 1px solid #2d3748;
    border-radius: 8px;
    padding: 4px;
    max-height: 150px;
    overflow-y: auto;
    min-width: 150px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
    z-index: 20;
}

.mention-item {
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    color: #e2e8f0;
    font-size: 14px;
}

.mention-item:hover {
    background: #f6ad55;
    color: #1a1a2e;
}

/* ---- 禁言遮罩 ---- */
.muted-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 15, 26, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.muted-box {
    text-align: center;
    padding: 40px;
    background: #1a1a2e;
    border: 1px solid #e53e3e;
    border-radius: 16px;
}

.muted-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.muted-box div:last-child {
    color: #fc8181;
    font-size: 16px;
}

/* ---- Toast 提示 ---- */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e2a3a;
    color: #e2e8f0;
    padding: 12px 24px;
    border-radius: 8px;
    border: 1px solid #2d3748;
    font-size: 14px;
    z-index: 2000;
    transition: opacity 0.3s;
    display: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* ========================================
   管理后台样式
   ======================================== */
.admin-container {
    height: 100vh;
    overflow-y: auto;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #2d3748;
}

.admin-header h1 {
    font-size: 20px;
    color: #f6ad55;
}

.admin-logout-btn {
    padding: 8px 16px;
    background: #2d3748;
    color: #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
}

.admin-logout-btn:hover {
    background: #4a5568;
}

.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.admin-tab {
    padding: 8px 20px;
    background: #1a1a2e;
    border: 1px solid #2d3748;
    border-radius: 6px;
    color: #a0aec0;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.admin-tab.active {
    background: #2d3748;
    color: #f6ad55;
    border-color: #f6ad55;
}

.admin-tab:hover {
    background: #2d3748;
}

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

.admin-action-bar {
    margin-bottom: 16px;
}

.admin-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s;
}

.admin-btn:hover {
    opacity: 0.85;
}

.admin-btn.danger {
    background: #e53e3e;
    color: white;
}

.admin-btn.warn {
    background: #dd6b20;
    color: white;
}

.admin-btn.small {
    padding: 4px 10px;
    font-size: 12px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.admin-table th {
    background: #1a1a2e;
    color: #a0aec0;
    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #2d3748;
}

.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #1e2a3a;
    font-size: 13px;
}

.admin-table tr:hover td {
    background: #1a1a2e;
}

.ip-addr {
    font-family: "Consolas", "Courier New", monospace;
    color: #68d391;
    font-size: 12px;
}

.msg-preview {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.time-cell {
    color: #718096;
    font-size: 12px;
    white-space: nowrap;
}

.deleted-badge {
    background: #e53e3e;
    color: white;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    margin-left: 6px;
}

.empty-row {
    text-align: center;
    color: #4a5568;
    padding: 30px !important;
}

.action-cell {
    white-space: nowrap;
    display: flex;
    gap: 4px;
}

/* ---- 登录页 ---- */
.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f0f1a;
}

.login-box {
    background: #1a1a2e;
    border: 1px solid #2d3748;
    border-radius: 16px;
    padding: 40px;
    width: 360px;
    max-width: 90vw;
    text-align: center;
}

.login-box h1 {
    font-size: 22px;
    color: #f6ad55;
    margin-bottom: 4px;
}

.login-box h2 {
    font-size: 16px;
    color: #a0aec0;
    font-weight: 400;
    margin-bottom: 24px;
}

.back-link {
    display: block;
    margin-top: 16px;
    color: #4a5568;
    font-size: 13px;
}

.back-link:hover {
    color: #f6ad55;
}

/* ========================================
   响应式 - 手机适配
   ======================================== */
@media (max-width: 768px) {
    .header {
        padding: 8px 12px;
    }

    .header-title {
        font-size: 15px;
    }

    .users-sidebar {
        position: fixed;
        right: -220px;
        top: 50px;
        bottom: 0;
        width: 200px;
        z-index: 100;
        transition: right 0.3s;
        display: block;
    }

    .users-sidebar.show {
        right: 0;
        box-shadow: -4px 0 20px rgba(0,0,0,0.5);
    }

    .icon-btn {
        display: inline-block;
    }

    .message-area {
        padding: 12px;
    }

    .input-area {
        padding: 8px 12px 12px;
    }

    .chat-image {
        max-width: 180px;
        max-height: 140px;
    }

    .emoji-panel {
        width: 280px;
        left: 12px;
    }

    .modal-box {
        padding: 28px 20px;
    }

    .admin-container {
        padding: 12px;
    }

    .admin-table {
        font-size: 12px;
    }

    .admin-table td, .admin-table th {
        padding: 6px 8px;
    }

    .msg-preview {
        max-width: 120px;
    }
}

@media (max-width: 480px) {
    .emoji-panel {
        width: 260px;
    }

    .emoji-grid {
        font-size: 20px;
    }

    .chat-image {
        max-width: 140px;
        max-height: 110px;
    }

    .toolbar-hint {
        display: none;
    }
}
