/* =========================================
   通用样式
   ========================================= */

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

:root {
    /* 品牌色（用于文字/边框/图标 —— 绿字压白底，对比度充足） */
    --primary-color: #07c160;

    /* 填充专用主色：用于"绿底 + 白字"的按钮与徽标。
       为什么必须与 --primary-color 分开：
       白字压 #07c160 只有 2.38:1，连 UI 组件最低要求的 3:1 都不到，
       正文标准 4.5:1 更是差得远。实测把绿色压到 #04803f 可得 5.04:1 通过。
       注意这是真实的取舍：微信原版绿配白字本身就不达标，
       若日后要以"绝对还原微信"为最高优先，可把本值改回 --primary-color，
       但请同时接受对比度不达标——二者无法同时满足。 */
    --primary-fill: #04803f;

    --primary-gradient: linear-gradient(135deg, #04803f 0%, #036c34 100%);

    /* 布局尺寸 */
    --sidebar-width: 80px;
    --sidebar-expanded-width: 200px;
    --list-width: 320px;
    --tab-bar-height: 65px;

    /* 注意：颜色类变量（--glass-*、--red-badge、--bg-*、--text-*、--border-* 等）
       统一由 css/theme.css 维护，本文件不再重复定义。
       此处原有一份浅色硬编码副本，会与 theme.css 冲突且无法随主题切换。 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", 
                 "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary-color);
    background: var(--background-color);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================
   登录页面
   ========================================= */

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    /* 微信风深绿渐变，日夜模式共用（登录页本身即是深色场景） */
    background: linear-gradient(135deg, #1f3b2c 0%, #0f1f17 100%);
}

.login-container {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    /* 未选中态压在 --bg-tertiary 灰底上，用纯 --text-secondary 只有 4.24:1，
       故提亮到 --text-primary；选中态则用深绿渐变 + 白字（5.04:1 起）。 */
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: var(--text-inverse);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group input {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary-gradient);
    color: var(--text-inverse);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(7, 193, 96, 0.25);
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(7, 193, 96, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
}

.error-message {
    color: var(--red-badge);
    font-size: 13px;
    margin-top: 5px;
    text-align: center;
}

/* =========================================
   主应用容器
   ========================================= */

.app-container {
    display: flex;
    height: 100vh;
    background: var(--bg-primary);
    overflow: hidden;
    width: 100%;
}

/* 移动端app-container确保占满全宽 */
@media (max-width: 768px) {
    .app-container {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

/* =========================================
   侧边菜单栏（PC端）
   ========================================= */

.sidebar-menu {
    width: var(--sidebar-width);
    flex-shrink: 0;
    flex-grow: 0;
    /* 左侧功能栏在日间/夜间都是深色（同微信），文字须用 --text-on-sidebar，
       不能用 --text-secondary-color —— 否则日间模式下会出现深灰字压深底的不可读情况 */
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 20px 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar-menu.expanded {
    width: var(--sidebar-expanded-width);
    box-shadow: var(--shadow-md);
}

.menu-avatar {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    margin: 0 15px 25px;
    position: relative;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.sidebar-menu.expanded .menu-avatar {
    width: 60px;
    height: 60px;
    margin: 0 20px 25px;
}

.menu-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.menu-avatar-name {
    position: absolute;
    left: 70px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-on-sidebar);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.sidebar-menu.expanded .menu-avatar-name {
    opacity: 1;
}

.menu-items {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    padding: 0 10px;
}

.menu-item {
    width: 100%;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    margin: 5px 0;
    position: relative;
    color: var(--text-on-sidebar);
    background: transparent;
    border-radius: 8px;
    padding: 10px;
    transition: background-color 0.2s ease, color 0.2s ease;
    gap: 12px;
}

/* 侧边栏是深色底，悬停用半透明白叠加，
   这样日间/夜间都不需要各自的硬编码色值 */
.menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.menu-item.active {
    color: var(--primary-color);
    background: rgba(7, 193, 96, 0.16);
}

.menu-item .icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 30px;
    text-align: center;
}

.menu-item.active .icon {
    color: var(--primary-color);
}

.menu-item-label {
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    flex: 1;
}

.sidebar-menu.expanded .menu-item-label {
    opacity: 1;
}

.menu-item .badge {
    position: absolute;
    top: 8px;
    right: 10px;
    background: var(--red-badge);
    color: var(--text-inverse);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(250, 81, 81, 0.3);
}

/* =========================================
   主内容区域
   ========================================= */

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

/* 移动端主内容区域不使用flex布局 */
@media (max-width: 768px) {
    .main-content {
        display: block !important;
        flex: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* 可调整宽度的分割线 */
.resizer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.2s ease;
}

.resizer:hover {
    background: var(--primary-color);
}

.resizer.resizing {
    background: var(--primary-color);
}

/* =========================================
   详情面板
   ========================================= */

.detail-panel {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
    display: flex;
    overflow: hidden;
    position: relative;
}

/* PC端详情面板始终显示 */
@media (min-width: 769px) {
    .detail-panel {
        border-left: 1px solid var(--border-color);
    }
    
    /* 确保PC端只显示pc-only的detail-panel */
    .detail-panel.mobile-only {
        display: none !important;
    }
    
    /* 确保移动端只显示mobile-only的detail-panel */
    .detail-panel.pc-only {
        display: flex !important;
    }
}

/* PC端详情面板优化 */
@media (min-width: 769px) {
    .detail-panel.pc-only {
        background: var(--bg-primary);
        /* 确保占据剩余空间 */
        flex: 1;
        min-width: 0;
        /* 移除居中，让内容自然填充 */
        justify-content: flex-start;
        align-items: stretch;
        display: flex !important;
    }
    
    /* 确保移动端detail-panel在PC端隐藏 */
    .detail-panel.mobile-only {
        display: none !important;
    }
    
    /* 空状态时显示logo */
    .detail-panel.empty-state {
        justify-content: center;
        align-items: center;
    }
    
    .empty-logo-container {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 0;
        pointer-events: none;
    }
    
    .empty-logo-container img {
        pointer-events: auto;
    }
    
    /* 空状态插画
       ---------------------------------
       原先用的是 img/logo.png / logo1.png —— 那两张实际上是"蓝色书本"插画，
       与微信画风完全不符，且带白色底、在深色模式下很扎眼。
       现改用主题色的内联 SVG：通过 mask 上色，颜色跟随 --text-tertiary，
       两个模式自动适配，也不会出现白底方块。 */
    .empty-illustration {
        width: 128px;
        height: 128px;
        background-color: var(--text-tertiary);
        opacity: 0.6;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-size: contain;
        mask-size: contain;
        animation: fadeIn 0.35s ease-in;
    }

    .empty-illustration-chat {
        -webkit-mask-image: url('../img/empty-chat.svg');
        mask-image: url('../img/empty-chat.svg');
    }

    .empty-illustration-contacts {
        -webkit-mask-image: url('../img/empty-contacts.svg');
        mask-image: url('../img/empty-contacts.svg');
    }

    /* 兼容：若还有别处引用 .empty-logo，保持可用但不再放大到 400px */
    .empty-logo {
        max-width: 160px;
        max-height: 160px;
        object-fit: contain;
        opacity: 0.55;
    }
    
    /* 确保聊天窗口和好友详情填充整个面板 */
    .chat-window,
    .friend-detail,
    .moments-container,
    .profile-container {
        width: 100%;
        height: 100%;
    }
    
    /* 当没有列表时，detail-panel占据全屏 */
    .main-content.no-list + .detail-panel.pc-only {
        border-left: none;
    }
}

/* =========================================
   移动端底部Tab栏
   ========================================= */

.mobile-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-bar-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex !important;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0);
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

.tab-item {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    padding: 8px 5px;
    -webkit-tap-highlight-color: transparent;
    min-width: 0;
    box-sizing: border-box;
    width: auto !important;
    max-width: none !important;
}

.tab-item:active {
    opacity: 0.7;
}

.tab-icon {
    font-size: 20px;
    margin-bottom: 2px;
    color: var(--text-secondary);
}

.tab-item.active .tab-icon {
    color: var(--primary-color);
}

.tab-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.tab-item.active .tab-label {
    color: var(--primary-color);
    font-weight: 500;
}

.tab-badge {
    position: absolute;
    top: 6px;
    right: calc(25% - 8px);
    background: var(--red-badge);
    color: var(--text-inverse);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(250, 81, 81, 0.3);
}

/* =========================================
   通用列表样式
   ========================================= */

.list-container {
    width: var(--list-width);
    flex-shrink: 0;
    flex-grow: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* PC端列表容器 - 确保没有空隙 */
@media (min-width: 769px) {
    .main-content {
        gap: 0;
        display: flex;
    }
    
    .list-container {
        margin-right: 0;
    }
    
    .detail-panel {
        margin-left: 0;
    }
}

/* 确保移动端朋友圈和个人页面组件占满全宽 */
@media (max-width: 768px) {
    moments-page,
    profile-page {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        flex: none !important;
    }
}

.list-header {
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 18px;
    font-weight: 600;
    background: var(--bg-secondary);
    color: var(--text-primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-header-actions {
    display: flex;
    gap: 8px;
}

.header-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary-color);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.header-action-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary-color);
}

@media (max-width: 768px) {
    .header-action-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

.list-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.list-search input {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary-color);
}

.list-search input::placeholder {
    color: var(--text-tertiary-color);
}

.list-search input:focus {
    outline: none;
    background: var(--bg-primary);
}

.list-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 13px 14px;
    cursor: pointer;
    /* 微信列表用"极浅分隔线"而非明显边框，避免密集列表显得碎 */
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-secondary);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.15s ease;
}

.list-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
    opacity: 0;
}

.list-item.active::before {
    opacity: 1;
}

.list-item:hover {
    background: var(--list-item-hover);
}

.list-item.active {
    background: var(--list-item-active);
}

.list-item:active {
    background: var(--list-item-active);
}

.list-item-avatar {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    margin-right: 12px;
    object-fit: cover;
    flex-shrink: 0;
    /* 给头像容器一个主题底色：默认头像 zanwu.png 是白底方块，
       在深色模式下会非常刺眼；有背景色后即使图片加载中也不突兀 */
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 1px rgba(128, 128, 128, 0.12);
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-size: 16px;
    font-weight: 500;
    /* 收紧标题与摘要的间距（原 6px 偏松，列表显松散） */
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.list-item-desc {
    font-size: 13px;
    /* 用 --text-secondary 时，列表项一旦进入悬停/选中态，
       底色变成灰(#f2f2f2)，对比度会掉到 4.06:1 不达标。
       这里改用 --text-secondary 的深一档 --text-primary 不现实（会与标题同级），
       故保持次级色，但悬停时提升到主色 —— 见下方 .list-item:hover 规则。 */
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.35;
}

/* 悬停/选中时提高文字强度：既符合"交互态文字更清晰"的直觉，
   也把灰底上的对比度拉回达标范围。 */
.list-item:hover .list-item-desc,
.list-item.active .list-item-desc,
.list-item:hover .list-item-time,
.list-item.active .list-item-time {
    color: var(--text-primary);
}

.list-item-desc .list-emoji {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    display: inline-block;
    margin: 0 1px;
    object-fit: contain;
}

.list-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.list-item-time {
    font-size: 12px;
    color: var(--text-secondary-color);
}

.list-item-badge {
    background: var(--red-badge);
    color: var(--text-inverse);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(250, 81, 81, 0.3);
    margin-top: 4px;
}

/* =========================================
   加载和空状态
   ========================================= */

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 14px;
    animation: fadeIn 0.3s ease-out;
}

.empty {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 80px 20px;
    color: var(--text-secondary);
    animation: fadeIn 0.5s ease-out;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-icon-img {
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
    opacity: 0.5;
    animation: scaleIn 0.5s ease-out;
}

.empty div {
    font-size: 15px;
    color: var(--text-secondary);
}

/* =========================================
   滚动条样式
   ========================================= */

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* 移动端隐藏滚动条但保持滚动功能 */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 0;
        height: 0;
    }
}

/* =========================================
   工具类
   ========================================= */

.pc-only {
    display: block;
}

.mobile-only {
    display: none;
}

/* =========================================
   图标和按钮样式
   ========================================= */

/* 按钮样式 */
.fab-button,
.publish-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.fab-button:active,
.publish-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* 加载动画 */
.loading::after {
    content: '...';
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

