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

:root {
    --primary: #4a6cf7;
    --primary-dark: #3b5de7;
    --success: #52c41a;
    --warning: #faad14;
    --danger: #ff4d4f;
    --bg: #f0f2f5;
    --card-bg: #fff;
    --text: #333;
    --text-secondary: #888;
    --border: #e8e8e8;
    --radius: 10px;
    --nav-height: 56px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.hidden { display: none !important; }

/* ====== 登录页 ====== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: var(--card-bg);
    padding: 36px 28px;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    width: 380px;
    max-width: 100%;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 6px;
    color: #1a1a2e;
    font-size: 22px;
}

.login-sub {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 13px;
}

/* ====== 表单 ====== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

input[type="text"],
input[type="password"],
.auth-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
.auth-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,108,247,0.15);
}

/* ====== 按钮 ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { background: #2f4fd6; }

.btn-outline {
    background: transparent;
    border: 1px solid #ddd;
    color: #555;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-block {
    display: flex;
    width: 100%;
    padding: 13px;
    font-size: 16px;
}

.btn-warn {
    background: #ff9800 !important;
    color: #fff !important;
    border-color: #ff9800 !important;
}

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
}

.alert-error {
    background: #fff2f0;
    border: 1px solid #ffccc7;
    color: var(--danger);
}

/* ====== 导航栏 ====== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--nav-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.navbar h1 {
    font-size: 16px;
    color: #1a1a2e;
    white-space: nowrap;
}

.nav-center { flex: 1; display: flex; justify-content: center; }

.nav-right { display: flex; gap: 6px; flex-shrink: 0; }

/* ====== 平台状态条 ====== */
.platform-status-bar {
    display: flex;
    gap: 16px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #666;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: #d9d9d9; }
.status-dot.connecting { background: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ====== 布局（桌面端） ====== */
.container {
    display: flex;
    height: calc(100vh - var(--nav-height));
}

.sidebar {
    width: 210px;
    min-width: 210px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ====== 筛选 ====== */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-btn {
    padding: 9px 12px;
    border: none;
    background: transparent;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.filter-btn:hover { background: #f5f5f5; }
.filter-btn.active { background: #e6f0ff; color: var(--primary); font-weight: 600; }

.search-box input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    -webkit-appearance: none;
    appearance: none;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

@media (max-width: 768px) {
    .actions { flex-direction: row; }
    .actions .btn { flex: 1; }
}

/* ====== 消息头 ====== */
.msg-header {
    padding: 10px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 13px;
    color: #888;
    flex-wrap: wrap;
}

.badge {
    background: var(--primary);
    color: #fff;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

/* ====== 消息列表 ====== */
.msg-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px;
    -webkit-overflow-scrolling: touch;
}

.msg-item {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.msg-item:hover { background: #f9f9fb; }
.msg-item.unread { background: #f0f5ff; border-color: #d6e4ff; }

.msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
    margin-bottom: 3px;
}

.platform-tag {
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.platform-telegram { background: #e6f0ff; color: #4a6cf7; }
.platform-signal { background: #e6f6ff; color: #2f8cff; }
.platform-whatsapp { background: #e6ffe6; color: #25d366; }

.msg-sender { font-weight: 600; color: var(--text); }
.msg-chat { color: #888; font-size: 12px; }
.msg-type {
    padding: 0 5px;
    border-radius: 3px;
    font-size: 10px;
    background: #f5f5f5;
    color: #999;
    flex-shrink: 0;
}
.type-image { background: #fff7e6; color: #fa8c16; }
.type-file { background: #f6ffed; color: var(--success); }
.type-sticker { background: #fff0f6; color: #eb2f96; }
.type-voice { background: #f0f5ff; color: #2f54eb; }

.msg-time { color: #bbb; font-size: 11px; margin-left: auto; white-space: nowrap; }

.unread-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

.msg-content {
    color: #555;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: break-word;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #bbb;
    font-size: 15px;
}

.pagination {
    padding: 10px 16px;
    text-align: center;
}

/* ====== 认证中心 ====== */
.auth-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.auth-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.auth-card h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #1a1a2e;
}

.auth-status {
    font-size: 13px;
    padding: 4px 0;
    margin-bottom: 10px;
}

.status-online { color: var(--success); }
.status-offline { color: #bbb; }
.status-connecting { color: var(--warning); }

.auth-body { margin-top: 10px; }

.auth-hint {
    font-size: 13px;
    color: #888;
    margin-bottom: 8px;
    line-height: 1.6;
}

.auth-input {
    margin-bottom: 10px;
}

.qr-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 10px;
}

.qr-container canvas,
.qr-container img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ====== PC 端（> 1024px） ====== */
@media (min-width: 1025px) {
    .sidebar { width: 230px; }
    .msg-list { padding: 8px 16px; }
}

/* ====== 平板端（769-1024px） ====== */
@media (max-width: 1024px) {
    .auth-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        padding: 16px;
        gap: 14px;
    }
    .sidebar { width: 180px; min-width: 180px; }
    .platform-status-bar { gap: 10px; }
    .status-item span:last-child { display: none; }
}

/* ====== 手机端 H5（≤ 768px） ====== */
@media (max-width: 768px) {
    /* ---- 导航 ---- */
    .navbar {
        padding: 0 10px;
        height: 50px;
    }
    .navbar h1 { font-size: 15px; }
    .nav-center { justify-content: flex-start; margin-left: 8px; }
    .platform-status-bar { gap: 8px; }
    .status-item { font-size: 11px; }
    .status-item span:last-child { display: none; }
    .status-dot { width: 6px; height: 6px; }
    .nav-right .btn { padding: 5px 10px; font-size: 12px; }

    /* ---- 主页布局：竖排 ---- */
    .container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 50px);
    }

    .sidebar {
        width: 100%;
        min-width: 0;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 50px;
        z-index: 99;
    }

    .filter-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .filter-btn {
        padding: 6px 10px;
        font-size: 12px;
        border-radius: 6px;
    }

    .search-box { flex: 1; min-width: 120px; }
    .search-box input { padding: 7px 10px; font-size: 13px; }

    .actions { flex-direction: row; gap: 6px; }
    .actions .btn { flex: 1; font-size: 12px; padding: 6px 8px; }

    /* ---- 消息列表 ---- */
    .main-content { height: calc(100vh - 50px - 110px); }

    .msg-header { padding: 8px 12px; font-size: 12px; gap: 8px; }

    .msg-list { padding: 4px 6px; }

    .msg-item {
        padding: 10px 12px;
        border-radius: 8px;
        margin-bottom: 3px;
    }

    .msg-meta { gap: 5px; font-size: 11px; }
    .msg-sender { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .msg-content { font-size: 14px; }
    .msg-time { font-size: 10px; }

    /* ---- 认证页 ---- */
    .auth-grid {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 10px;
    }

    .auth-card {
        padding: 16px;
        border-radius: 10px;
    }

    .auth-card h3 { font-size: 15px; }

    .qr-container {
        padding: 8px;
    }

    .qr-container img {
        width: 180px !important;
        height: 180px !important;
    }

    .auth-hint { font-size: 12px; }

    /* ---- 登录页 ---- */
    .login-body { padding: 16px; }
    .login-box { padding: 28px 20px; }
    .login-box h2 { font-size: 20px; }
}

/* ====== 小屏手机（≤ 480px） ====== */
@media (max-width: 480px) {
    .navbar h1 { font-size: 14px; }
    .sidebar { padding: 8px 10px; }
    .filter-btn { padding: 5px 8px; font-size: 11px; }
    .filter-group { gap: 2px; }
    .msg-sender { max-width: 70px; }
    .platform-tag { font-size: 10px; padding: 1px 5px; }
    .msg-type { font-size: 9px; }
    .qr-container img {
        width: 150px !important;
        height: 150px !important;
    }
    .auth-card { padding: 14px; }
}

/* ====== 触摸优化 ====== */
@media (hover: none) and (pointer: coarse) {
    .msg-item { padding: 12px 14px; } /* 增大触控区域 */
    .filter-btn { padding: 8px 12px; }
    .btn { padding: 10px 16px; }
    .btn-sm { padding: 7px 12px; }
}
