/* ========== 抖音私信聚合系统 - 样式表 ========== */
/* 参考 zidonghuifu.com 风格 */

:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-bg: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --bg: #f5f6f8;
    --sidebar-bg: #fff;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-light: #6b7280;
    --text-lighter: #9ca3af;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* ========== 登录页 ========== */
.login-page {
    display: flex; align-items:center; justify-content:center;
    min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
    background: #fff; border-radius: 16px; padding: 40px;
    width: 400px; max-width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-box h2 { text-align:center; font-size:24px; margin-bottom:8px; color:var(--text); }
.login-box .subtitle { text-align:center; color:var(--text-light); margin-bottom:28px; font-size:14px; }

.form-group { margin-bottom:18px; }
.form-group label { display:block; margin-bottom:6px; font-weight:500; color:var(--text); font-size:13px; }
.form-group input { 
    width:100%; padding:10px 14px; border:1px solid var(--border); border-radius:var(--radius);
    font-size:14px; transition: border-color 0.2s; outline:none;
}
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

.btn {
    display:inline-flex; align-items:center; gap:6px;
    padding:10px 20px; border-radius:var(--radius); font-size:14px; font-weight:500;
    cursor:pointer; border:none; transition: all 0.2s; white-space:nowrap;
}
.btn-primary { background:var(--primary); color:#fff; }
.btn-primary:hover { background:var(--primary-light); }
.btn-success { background:var(--success); color:#fff; }
.btn-danger { background:var(--danger); color:#fff; }
.btn-ghost { background:transparent; color:var(--text); border:1px solid var(--border); }
.btn-ghost:hover { background:var(--bg); }
.btn-sm { padding:4px 12px; font-size:12px; }
.btn-block { display:flex; width:100%; justify-content:center; padding:12px; }
.btn:disabled { opacity:0.6; cursor:not-allowed; }

.toast {
    position:fixed; top:20px; left:50%; transform:translateX(-50%);
    padding:12px 24px; border-radius:var(--radius); font-size:14px; z-index:9999;
    animation: toastIn 0.3s ease; box-shadow: var(--shadow-lg);
}
.toast-success { background:#10b981; color:#fff; }
.toast-error { background:#ef4444; color:#fff; }
.toast-warning { background:#f59e0b; color:#fff; }

@keyframes toastIn { from { opacity:0; transform:translateX(-50%) translateY(-20px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* ========== 主布局 ========== */
.app { display:flex; height:100vh; flex-direction:column; }
.app-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:0 20px; height:52px; background:#fff; border-bottom:1px solid var(--border);
    flex-shrink:0; z-index:10;
}
.app-header .logo { font-size:18px; font-weight:700; color:var(--primary); }
.app-header .header-right { display:flex; align-items:center; gap:14px; }
.app-header .nav-link { color:var(--text); text-decoration:none; font-size:13px; padding:6px 12px; border-radius:6px; cursor:pointer; }
.app-header .nav-link:hover, .app-header .nav-link.active { background:var(--primary-bg); color:var(--primary); }
.app-header .btn-logout { font-size:13px; cursor:pointer; color:var(--text-light); }
.app-header .btn-logout:hover { color:var(--danger); }

.app-body { display:flex; flex:1; overflow:hidden; }

/* ========== 左侧账号面板 ========== */
.account-panel {
    width:200px; min-width:200px; background:#fafbfc; border-right:1px solid var(--border);
    display:flex; flex-direction:column; flex-shrink:0;
}
.account-panel-header {
    padding:12px 14px; font-size:13px; font-weight:600; color:var(--text-light);
    border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center;
}
.account-panel-header .count { font-size:11px; color:var(--text-lighter); }

.account-list { flex:1; overflow-y:auto; }
.account-item {
    display:flex; align-items:center; gap:10px; padding:10px 14px;
    cursor:pointer; transition:background 0.15s; position:relative;
}
.account-item:hover, .account-item.active { background:#fff; }
.account-item .avatar {
    width:32px; height:32px; border-radius:50%; background:var(--primary-bg);
    display:flex; align-items:center; justify-content:center;
    color:var(--primary); font-size:14px; font-weight:600;
    flex-shrink:0; overflow:hidden;
}
.account-item .avatar img { width:100%; height:100%; object-fit:cover; }
.account-item .info { flex:1; min-width:0; }
.account-item .name { font-size:13px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.account-item .status-dot { 
    width:8px; height:8px; border-radius:50%; flex-shrink:0;
}
.status-online { background:var(--success); }
.status-offline { background:var(--text-lighter); }
.status-error { background:var(--danger); }

/* ========== 中间会话面板 ========== */
.conv-panel {
    width:280px; min-width:280px; background:#fff; border-right:1px solid var(--border);
    display:flex; flex-direction:column; flex-shrink:0;
}
.conv-panel-header {
    padding:12px 14px; border-bottom:1px solid var(--border);
    display:flex; justify-content:space-between; align-items:center;
}
.conv-panel-header .title { font-size:14px; font-weight:600; }
.conv-panel-header .btn-refresh { 
    width:28px; height:28px; display:flex; align-items:center; justify-content:center;
    border:none; background:transparent; cursor:pointer; border-radius:6px;
    color:var(--text-light); font-size:16px;
}
.conv-panel-header .btn-refresh:hover { background:var(--bg); }

.conv-list { flex:1; overflow-y:auto; }
.conv-item {
    display:flex; align-items:flex-start; gap:10px; padding:12px 14px;
    cursor:pointer; border-bottom:1px solid #f3f4f6; transition:background 0.15s;
}
.conv-item:hover, .conv-item.active { background:var(--primary-bg); }
.conv-item .avatar {
    width:40px; height:40px; border-radius:50%; background:var(--primary-bg);
    display:flex; align-items:center; justify-content:center;
    color:var(--primary); font-size:16px; font-weight:600;
    flex-shrink:0; overflow:hidden;
}
.conv-item .avatar img { width:100%; height:100%; object-fit:cover; }
.conv-item .conv-info { flex:1; min-width:0; }
.conv-item .conv-top { display:flex; justify-content:space-between; align-items:center; margin-bottom:3px; }
.conv-item .conv-name { font-size:13px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.conv-item .conv-time { font-size:11px; color:var(--text-lighter); flex-shrink:0; margin-left:8px; }
.conv-item .conv-preview { 
    display:flex; justify-content:space-between; align-items:center;
    font-size:12px; color:var(--text-light);
}
.conv-item .conv-msg { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; }
.conv-item .unread-badge {
    background:var(--danger); color:#fff; font-size:10px; font-weight:600;
    min-width:18px; height:18px; border-radius:9px; display:flex;
    align-items:center; justify-content:center; padding:0 5px; margin-left:6px;
}
.conv-item .unread-badge:empty { display:none; }

/* ========== 右侧聊天窗口 ========== */
.chat-panel {
    flex:1; display:flex; flex-direction:column; background:#fff; min-width:0;
}
.chat-header {
    height:54px; padding:0 20px; border-bottom:1px solid var(--border);
    display:flex; align-items:center; gap:10px; flex-shrink:0;
}
.chat-header .peer-name { font-size:15px; font-weight:500; }
.chat-header .chat-back-btn {
    display:none; align-items:center; gap:4px; font-size:13px; color:var(--primary);
    background:none; border:none; cursor:pointer; padding:4px 8px; border-radius:6px;
}
.chat-header .chat-back-btn:hover { background:var(--primary-bg); }

.chat-messages {
    flex:1; overflow-y:auto; padding:16px 20px;
    display:flex; flex-direction:column; gap:14px;
    background:#fafbfc;
}
.chat-empty {
    flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
    color:var(--text-lighter); gap:12px;
}
.chat-empty .empty-icon { font-size:48px; opacity:0.4; }
.chat-empty p { font-size:14px; }

/* 消息气泡 */
.msg-row { display:flex; gap:10px; max-width:70%; }
.msg-row.self { align-self:flex-end; flex-direction:row-reverse; }
.msg-row .msg-avatar {
    width:32px; height:32px; border-radius:50%; background:var(--primary-bg);
    display:flex; align-items:center; justify-content:center;
    font-size:13px; color:var(--primary); flex-shrink:0;
}
.msg-row.self .msg-avatar { display:none; }
.msg-bubble {
    padding:10px 14px; border-radius:12px; font-size:14px; line-height:1.5;
    word-break:break-word; position:relative;
}
.msg-row.peer .msg-bubble { background:#fff; border:1px solid var(--border); border-top-left-radius:2px; }
.msg-row.self .msg-bubble { background:var(--primary); color:#fff; border-top-right-radius:2px; }
.msg-time { font-size:11px; color:var(--text-lighter); margin-top:4px; }
.msg-row.self .msg-time { text-align:right; }

.msg-system {
    text-align:center; font-size:12px; color:var(--text-lighter); padding:4px 0;
}

/* 输入框 */
.chat-input-area {
    padding:12px 16px; border-top:1px solid var(--border); flex-shrink:0;
}
.chat-input-area .toolbar {
    display:flex; gap:8px; margin-bottom:8px;
}
.chat-input-area .tool-btn {
    width:30px; height:30px; border:none; background:transparent; cursor:pointer;
    border-radius:6px; font-size:16px; display:flex; align-items:center; justify-content:center;
    color:var(--text-light);
}
.chat-input-area .tool-btn:hover { background:var(--bg); }
.chat-input-row { display:flex; gap:10px; align-items:flex-end; }
.chat-input-row textarea {
    flex:1; min-height:40px; max-height:120px; padding:10px 14px;
    border:1px solid var(--border); border-radius:var(--radius);
    font-size:14px; resize:none; outline:none; font-family:inherit;
}
.chat-input-row textarea:focus { border-color:var(--primary); }
.chat-input-row .btn-send {
    height:40px; padding:0 24px; background:var(--primary); color:#fff;
    border:none; border-radius:var(--radius); font-size:14px; cursor:pointer; font-weight:500;
}
.chat-input-row .btn-send:hover { background:var(--primary-light); }
.chat-input-row .btn-send:disabled { opacity:0.5; cursor:not-allowed; }

/* ========== 账号管理页 ========== */
.account-mgmt { flex:1; overflow-y:auto; padding:24px; }
.page-title { font-size:20px; font-weight:600; margin-bottom:20px; }

.toolbar-row {
    display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; gap:12px;
}
.search-box { 
    display:flex; gap:8px; 
}
.search-box input {
    padding:8px 12px; border:1px solid var(--border); border-radius:var(--radius);
    font-size:13px; outline:none; width:180px;
}
.search-box input:focus { border-color:var(--primary); }

.table-container {
    background:#fff; border-radius:var(--radius); box-shadow:var(--shadow);
    overflow:hidden;
}
table { width:100%; border-collapse:collapse; }
table th {
    text-align:left; padding:12px 16px; font-size:12px; font-weight:600;
    color:var(--text-light); background:#fafbfc; border-bottom:1px solid var(--border);
}
table td {
    padding:14px 16px; font-size:13px; border-bottom:1px solid #f3f4f6;
}
table tr:hover td { background:#fafbfc; }
table .status-badge {
    display:inline-flex; align-items:center; gap:5px; font-size:12px;
    padding:3px 10px; border-radius:12px; font-weight:500;
}
.status-badge.online { background:#ecfdf5; color:#059669; }
.status-badge.offline { background:#f3f4f6; color:#6b7280; }
.status-badge.error { background:var(--danger-bg); color:var(--danger); }

table .actions { display:flex; gap:6px; }

/* ========== 模态框 ========== */
.modal-overlay {
    position:fixed; inset:0; background:rgba(0,0,0,0.4); z-index:100;
    display:flex; align-items:center; justify-content:center;
    animation: fadeIn 0.2s;
}
.modal {
    background:#fff; border-radius:14px; padding:28px; width:520px; max-width:90vw;
    max-height:85vh; overflow-y:auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h3 { font-size:18px; margin-bottom:20px; }
.modal .form-group textarea {
    width:100%; padding:10px 14px; border:1px solid var(--border); border-radius:var(--radius);
    font-size:13px; outline:none; font-family:monospace; resize:vertical; min-height:100px;
}
.modal .form-group textarea:focus { border-color:var(--primary); }
.modal-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:20px; }

/* Cookie 帮助提示 */
.cookie-help {
    background:#fffbeb; border:1px solid #fde68a; border-radius:var(--radius);
    padding:12px 16px; margin-top:10px; font-size:12px; color:#92400e; line-height:1.6;
}
.cookie-help strong { color:#d97706; }

/* ========== 加载 & 通用 ========== */
.loading {
    display:flex; align-items:center; justify-content:center; padding:40px;
    color:var(--text-lighter); gap:8px;
}
.spinner {
    width:20px; height:20px; border:2px solid var(--border); border-top-color:var(--primary);
    border-radius:50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.text-center { text-align:center; }
.mt-4 { margin-top:16px; }
.mb-4 { margin-bottom:16px; }
.hidden { display:none !important; }

/* 响应式 */
@media (max-width: 1024px) {
    .account-panel { width:160px; min-width:160px; }
    .conv-panel { width:240px; min-width:240px; }
    .msg-row { max-width:90%; }
}
@media (max-width: 768px) {
    .account-panel { display:none; }
    .conv-panel { width:100%; }
    .chat-panel { display:none; position:fixed; inset:0; z-index:50; }
    .chat-panel.show { display:flex; }
    .chat-header .chat-back-btn { display:flex; }
}
