/* style.css - NekoChat 粉色主题 */

/* ============ 主题变量 ============ */
:root {
    --primary: #ff69b4;
    --bg: #f8f9fa;
    --card: #ffffff;
    --text: #333333;
    --text-muted: #888888;
    --border: #e0e0e0;

    /* 聊天扩展 */
    --own-bubble: #ffe3ef;
    --own-text: #b32d6e;
    --other-bubble: #ffffff;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

html[data-theme="dark"] {
    --primary: #ff9ebb;
    --bg: #121212;
    --card: #1e1e1e;
    --text: #e0e0e0;
    --text-muted: #999999;
    --border: #333333;

    --own-bubble: #4a1e33;
    --own-text: #ffb3d1;
    --other-bubble: #2a2a2a;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}
a { text-decoration: none; color: inherit; }

/* ============ 顶部导航 ============ */
.cute-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 15px;
    flex-shrink: 0;
}
.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}
.search-bar {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 350px;
}
.search-bar input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px 0 0 6px;
    background: var(--bg);
    color: var(--text);
    outline: none;
}
.search-bar button {
    width: 70px;
    min-width: 70px;
    white-space: nowrap;
    padding: 8px 0;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    transition: opacity 0.2s;
}
.search-bar button:hover { opacity: 0.9; }
.nav {
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav a {
    color: var(--text);
    font-size: 14px;
}
.nav a:hover { color: var(--primary); }
.user-area {
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-area .avatar-sm {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}
.user-area .uname { font-size: 14px; color: var(--text); }

/* ============ 按钮 ============ */
.btn {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    display: inline-block;
    text-align: center;
    transition: opacity 0.2s;
}
.btn:hover { opacity: 0.9; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 38px; height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.icon-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ============ 卡片（备用）============ */
.feed-container {
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    padding: 0 10px;
    flex: 1;
}
.post-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 15px;
}
.profile-header {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
    text-align: center;
}
.profile-avatar {
    width: 80px; height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    margin-bottom: 15px;
}
.profile-info h2 { font-size: 20px; margin-bottom: 8px; }
.profile-info .bio { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; }
.profile-info .join-date { font-size: 12px; color: var(--text-muted); }

/* ============ 登录注册页 ============ */
.center-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-card {
    background: var(--card);
    padding: 30px;
    border-radius: 8px;
    width: 100%;
    max-width: 380px;
    border: 1px solid var(--border);
}
.auth-card h2 {
    margin-bottom: 20px;
    font-size: 20px;
    text-align: center;
    color: var(--text);
}
.auth-card input, .auth-card textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    font-family: inherit;
}
.auth-card input:focus, .auth-card textarea:focus { border-color: var(--primary); }
.auth-card button[type="submit"] { width: 100%; padding: 10px; }
.switch-link {
    margin-top: 15px;
    font-size: 13px;
    text-align: center;
    color: var(--text-muted);
}
.switch-link a { color: var(--primary); }

/* ============ 页脚 ============ */
.cute-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ============ 顶部加载条 ============ */
#progress-bar {
    position: fixed;
    top: 0; left: 0;
    height: 4px;
    background: var(--primary);
    width: 0%;
    z-index: 999999;
    opacity: 0;
    transition: width 0.4s ease, opacity 0.3s ease;
    box-shadow: 0 0 10px var(--primary), 0 0 5px var(--primary);
    pointer-events: none;
    border-radius: 0 4px 4px 0;
}

/* ===================================================
   聊天主界面
   =================================================== */
.chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    height: calc(100vh - 57px);
    overflow: hidden;
}

/* --- 左侧栏 --- */
.chat-sidebar {
    width: 280px;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}
.sidebar-user {
    padding: 20px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.sidebar-user .avatar-lg {
    width: 64px; height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    margin-bottom: 10px;
}
.sidebar-user .name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}
.sidebar-user .title-tag {
    font-size: 12px;
    color: var(--primary);
    margin-top: 2px;
}
.sidebar-user .online-count {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}
.sidebar-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}
.section-title .mini-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    cursor: pointer;
}
.section-title .mini-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* 好友/在线列表行 */
.friend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    color: inherit;
}
.friend-row:hover { background: var(--bg); }
.friend-row img {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.friend-row .fr-name {
    flex: 1;
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.friend-row .fr-title {
    font-size: 11px;
    color: var(--primary);
    margin-left: 4px;
}
.online-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    flex-shrink: 0;
}
.offline-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.4;
    flex-shrink: 0;
}
.unread-badge {
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* --- 右侧聊天区 --- */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}
.chat-topbar {
    padding: 10px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chat-topbar h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.chat-topbar .status {
    font-size: 12px;
    color: var(--text-muted);
}
.chat-topbar .status.connected { color: #2ecc71; }
.chat-topbar .status.disconnected { color: #e74c3c; }

/* 消息列表 */
.messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.load-more-wrap {
    text-align: center;
    padding: 8px;
}
.load-more-wrap .btn-outline {
    padding: 4px 16px;
    font-size: 13px;
}

/* 单条消息 */
.msg {
    display: flex;
    gap: 10px;
    max-width: 75%;
    align-self: flex-start;
}
.msg.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.msg-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.msg-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.msg-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 3px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.msg.own .msg-meta {
    flex-direction: row-reverse;
}
.msg-author {
    color: var(--text-muted);
    font-weight: 600;
}
.msg.own .msg-author { color: var(--primary); }
.msg-time { font-size: 11px; opacity: 0.75; }
.msg-bubble {
    background: var(--other-bubble);
    border: 1px solid var(--border);
    border-radius: 10px 10px 10px 2px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: var(--shadow);
}
.msg.own .msg-bubble {
    background: var(--own-bubble);
    color: var(--own-text);
    border-color: var(--primary);
    border-radius: 10px 10px 2px 10px;
}
.msg-bubble img {
    max-width: 260px;
    max-height: 260px;
    border-radius: 6px;
    cursor: pointer;
    display: block;
}
.msg-bubble.recalled {
    font-style: italic;
    color: var(--text-muted);
    opacity: 0.7;
}
.msg-bubble .quote {
    background: rgba(255,105,180,0.08);
    border-left: 3px solid var(--primary);
    padding: 6px 10px;
    margin-bottom: 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-muted);
}
html[data-theme="dark"] .msg-bubble .quote {
    background: rgba(255,158,187,0.1);
}

/* 发送中状态 */
.msg.sending .msg-bubble { opacity: 0.6; }
.msg.failed .msg-bubble { border-color: #e74c3c; }
.msg.failed .msg-meta::after {
    content: "⚠ 发送失败";
    color: #e74c3c;
    font-size: 11px;
    margin-left: 6px;
}

/* 撤回按钮 */
.msg-recall {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.msg:hover .msg-recall { opacity: 1; }
.msg-recall:hover { color: #e74c3c; }

/* 输入栏 */
.chat-input-bar {
    padding: 12px 20px;
    background: var(--card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.reply-preview {
    background: var(--bg);
    border-left: 3px solid var(--primary);
    padding: 6px 12px;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.reply-preview .cancel-reply {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
}
.input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    font-size: 14px;
    font-family: inherit;
}
.chat-input:focus { border-color: var(--primary); }
.send-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}
.send-btn:hover { opacity: 0.9; }

/* 公告条 */
.announcement-bar {
    background: linear-gradient(90deg, rgba(255,105,180,0.12), rgba(255,105,180,0.05));
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.announcement-bar .close-ann {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
}

/* 用户信息弹窗 */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay .modal-content {
    background: var(--card);
    border-radius: 10px;
    border: 1px solid var(--border);
    max-width: 320px;
    width: 90%;
    padding: 24px;
    text-align: center;
}
.modal-content .modal-avatar {
    width: 80px; height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    margin-bottom: 12px;
}
.modal-content .modal-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.modal-content .modal-uid {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* 滚动条 */
.chat-sidebar::-webkit-scrollbar,
.messages-list::-webkit-scrollbar {
    width: 6px;
}
.chat-sidebar::-webkit-scrollbar-thumb,
.messages-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .cute-header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 14px;
    }
    .search-bar { display: none; }
    .nav, .user-area { width: 100%; justify-content: space-between; }

    .chat-layout {
        flex-direction: column;
        height: calc(100vh - 100px);
    }
    .chat-sidebar {
        width: 100%;
        max-height: 180px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-user { padding: 12px; }
    .sidebar-user .avatar-lg { width: 40px; height: 40px; }
    .sidebar-user .name { font-size: 13px; }
    .msg { max-width: 88%; }
    .chat-input-bar { padding: 10px 12px; }
    .chat-input { font-size: 16px; } /* 防止 iOS 缩放 */
}
