/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Noto Sans SC", "Noto Sans JP", "Microsoft YaHei UI", "Yu Gothic UI", "Microsoft YaHei", "Yu Gothic", sans-serif;
    font-weight: 300;
    background: #fafafa;
    padding-top: 70px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 主内容区域最小高度，确保页脚在底部 */
.msg {
    min-height: calc(100vh - 400px);
}

/* 页脚固定在底部，不被侧边栏遮挡 */
footer {
    margin-top: auto;
    position: relative;
    z-index: 1;
}

/* 导航栏 */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 999;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.navbar-logo {
    font-size: 20px;
    font-weight: 300;
    color: #742581;
    text-decoration: none;
    letter-spacing: 0.5px;
}

.navbar-links {
    display: flex;
    gap: 24px;
}

.navbar-link {
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: color 0.2s;
}

.navbar-link:hover {
    color: #742581;
}

.navbar-link.active {
    color: #742581;
}

/* 移动端导航栏右侧 */
.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 移动端菜单按钮 - 默认隐藏 */
.mobile-menu-btn {
    display: none;
}

/* 移动端侧边栏 - 默认隐藏 */
.mobile-sidebar {
    display: none;
}

/* 移动端遮罩层 - 默认隐藏 */
.mobile-menu-overlay {
    display: none;
}

/* 成员选择器切换按钮 - 默认隐藏 */
.preset-toggle-btn {
    display: none;
}

/* FAB容器 */
.fab-container {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    flex-direction: column;
    gap: 15px;
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 16px;
    }
    
    .navbar-links {
        display: none;
    }

    /* 汉堡菜单按钮 */
    .mobile-menu-btn {
        display: flex;
        width: 40px;
        height: 40px;
        background: white;
        border: 1px solid #e8e8e8;
        border-radius: 0;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
    }

    .mobile-menu-btn:hover {
        background: #f5f5f5;
        border-color: #d0d0d0;
    }

    .mobile-menu-btn svg {
        width: 24px;
        height: 24px;
        color: #374151;
    }

    /* 侧边栏菜单 */
    .mobile-sidebar {
        display: block;
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: white;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
        z-index: 9999;
        transition: right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        border-left: 1px solid #e8e8e8;
        will-change: right;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-sidebar.active {
        right: 0;
    }

    .mobile-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid #e8e8e8;
    }

    .mobile-menu-title {
        font-size: 18px;
        font-weight: 500;
        color: #374151;
    }

    .mobile-menu-close {
        width: 32px;
        height: 32px;
        background: none;
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
        transition: background 0.2s;
    }

    .mobile-menu-close:hover {
        background: #f5f5f5;
    }

    .mobile-menu-close svg {
        width: 20px;
        height: 20px;
        color: #374151;
    }

    .mobile-menu-content {
        padding: 20px;
    }

    .mobile-nav-links {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .mobile-nav-link {
        display: block;
        padding: 12px 16px;
        color: #374151;
        text-decoration: none;
        font-size: 14px;
        font-weight: 300;
        transition: background 0.2s, color 0.2s;
        border-radius: 6px;
    }

    .mobile-nav-link:hover {
        background: #f9fafb;
        color: #742581;
    }

    .mobile-nav-link.active {
        background: #f3f4f6;
        color: #742581;
        font-weight: 400;
    }

    /* 遮罩层 */
    .mobile-menu-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9990;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.25s, visibility 0.25s;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* 移动端成员选择器优化 */
    .preset-container {
        position: fixed !important;
        top: 60px !important;
        left: -100% !important;
        width: 80% !important;
        max-width: 300px !important;
        height: calc(100vh - 160px) !important;
        max-height: calc(100vh - 160px) !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 9995 !important;
    }

    .preset-container.active {
        left: 0 !important;
    }

    .preset-toggle-btn svg {
        width: 24px;
        height: 24px;
    }

    /* FAB容器在移动端显示 */
    .fab-container {
        display: flex;
    }
}

/* 主标题 */
h1 {
    font-size: 36px;
    font-weight: 300;
    text-align: center;
    margin: 32px 0 16px;
    color: #1f2937;
    letter-spacing: 1px;
}

.subtitle {
    text-align: center;
    color: #6b7280;
    font-size: 16px;
    margin-bottom: 32px;
    font-weight: 300;
}

/* 搜索栏 */
#search-container {
    max-width: 500px;
    margin: 0 auto 24px;
    position: relative;
}

#search-input {
    width: 100%;
    padding: 14px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s;
    outline: none;
    background: white;
}

#search-input:focus {
    border-color: #742581;
    box-shadow: 0 0 0 3px rgba(116, 37, 129, 0.1);
}

/* 成员选择区域 */
.member-selection {
    width: 500px;
    margin: 0 auto 32px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 12px 12px 0 0;
}

.tab {
    flex: 1;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    color: #6b7280;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab:hover {
    background: rgba(116, 37, 129, 0.05);
    color: #742581;
}

.tab.active {
    color: #742581;
    background: white;
    border-bottom-color: #742581;
    font-weight: 500;
}

.tab-content {
    display: none;
    padding: 20px;
}

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

/* 置顶区域 */
#pinned-section {
    margin-bottom: 16px;
}

#pinned-members {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.section-title {
    font-size: 14px;
    font-weight: 300;
    color: #742581;
    margin: 16px 0 12px;
    padding-left: 8px;
    border-left: 3px solid #742581;
}

/* 成员卡片 */
.preset-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preset {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafafa;
    border: 2px solid transparent;
}

.preset:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border-color: #742581;
    background: white;
}

.preset.pinned {
    background: #fffbeb;
    border-color: #fbbf24;
}

.preset-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 12px;
    flex-shrink: 0;
    border: 2px solid #e5e7eb;
    transition: border-color 0.3s;
}

.preset:hover .preset-avatar {
    border-color: #742581;
}

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

.preset-name {
    font-size: 13px;
    font-weight: 300;
    text-align: left;
    color: #374151;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pin-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border: none;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-btn:hover {
    transform: translateY(-50%) scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    background: #fef3c7;
}

.pin-btn:active {
    transform: translateY(-50%) scale(0.95);
    transition: transform 0.1s;
}

.pin-btn.pinned {
    color: #f59e0b;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    box-shadow: 0 3px 8px rgba(245, 158, 11, 0.25);
    font-weight: 300;
    animation: pinBounce 0.5s ease-out;
}

@keyframes pinBounce {
    0% {
        transform: translateY(-50%) scale(1);
    }
    50% {
        transform: translateY(-50%) scale(1.3) rotate(15deg);
    }
    70% {
        transform: translateY(-50%) scale(0.9) rotate(-5deg);
    }
    100% {
        transform: translateY(-50%) scale(1) rotate(0deg);
    }
}

@keyframes pinUnbounce {
    0% {
        transform: translateY(-50%) scale(1);
    }
    50% {
        transform: translateY(-50%) scale(0.7) rotate(-10deg);
    }
    100% {
        transform: translateY(-50%) scale(1) rotate(0deg);
    }
}

.pin-btn.pinned:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.drag-handle {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    cursor: move;
    font-size: 16px;
    color: #9ca3af;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 5;
}

.preset:hover .drag-handle {
    opacity: 1;
}

/* 拖拽时为拖拽手柄留出空间 */
.preset.draggable {
    padding-left: 32px;
}

/* MSG展示区 */
.msg {
    width: 500px;
    margin: 0 auto;
}

.header {
    width: 500px;
    height: 60px;
    color: #ffffff;
    text-align: center;
    padding: 0 60px;
    font-size: 22px;
    font-weight: 300;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(116, 37, 129, 0.15);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.header-icon:hover {
    opacity: 1;
}

.header-icon-left {
    left: 20px;
}

.header-icon-right {
    right: 20px;
}

.header-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
    stroke: white;
}

.chat-container {
    background-color: white;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    padding: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e7eb;
    border-top: none;
}

.chat-box {
    display: flex;
    align-items: flex-start;
    padding: 20px;
    border-bottom: 1px solid #f3f4f6;
    position: relative;
    transition: background 0.2s;
}

.chat-box:hover {
    background: #fafafa;
}

.chat-box:last-child {
    border-bottom: none;
}

.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.chat-box:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    transition: border-color 0.3s;
}

.avatar:hover {
    border-color: #742581;
}

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

.avatar p {
    display: none;
}

.chat-content {
    flex: 1;
    margin-left: 16px;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.chat-name {
    font-weight: 300;
    font-size: 15px;
    color: #374151;
}

.time {
    font-size: 13px;
    color: #9ca3af;
}

.chat-body {
    font-size: 15px;
    line-height: 1.6;
    color: #1f2937;
}

.chat-body p {
    margin: 0;
}

.chat-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-top: 10px;
}

[contenteditable="true"] {
    outline: none;
}

/* 电脑端按钮样式 */
.desktop-buttons {
    display: flex;
    gap: 12px;
    width: 500px;
    margin: 20px auto 60px auto;
}

.desktop-btn {
    flex: 1;
    padding: 14px 20px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.desktop-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.desktop-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* 手机端FAB按钮 */
.fab-container {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
}

.fab-main {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    position: relative;
}

.fab-main:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
}

.fab-main.active {
    transform: rotate(45deg);
}

.fab-main svg {
    width: 24px;
    height: 24px;
    stroke: white;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.fab-actions {
    position: absolute;
    bottom: 70px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.fab-actions.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.fab-action {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.fab-action:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.fab-action svg {
    width: 22px;
    height: 22px;
    stroke: #3b82f6;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.fab-action.download svg {
    stroke: #10b981;
}

.fab-action.image svg {
    stroke: #8b5cf6;
}

.fab-tooltip {
    position: absolute;
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.fab-action:hover .fab-tooltip {
    opacity: 1;
}

/* 响应式：手机端显示FAB，隐藏desktop按钮 */
@media (max-width: 768px) {
    body {
        padding-top: 60px;
        padding-bottom: 100px;
    }
    
    /* 移动端调整.msg最小高度 */
    .msg {
        min-height: calc(100vh - 300px);
        margin-bottom: 40px;
    }
    
    .desktop-buttons {
        display: none;
    }
    
    .fab-container {
        display: block;
    }
    
    /* 宽度调整 */
    .msg,
    .presets-container,
    .member-selection,
    #search-container,
    h1 {
        width: 95%;
        margin-left: auto;
        margin-right: auto;
    }
    
    h1 {
        font-size: 28px;
        margin-top: 20px;
    }
    
    .subtitle {
        font-size: 14px;
        padding: 0 10px;
    }
    
    /* 成员选择器调整 */
    .preset-container {
        width: 95%;
        left: 2.5%;
        max-height: calc(100vh - 180px);
    }
    
    .group-tabs {
        padding: 8px;
        gap: 8px;
    }
    
    .group-tab {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    /* 成员卡片调整 */
    .preset-section {
        padding: 10px;
    }
    
    .preset {
        padding: 8px 10px;
    }
    
    .preset-avatar {
        width: 40px;
        height: 40px;
        margin-right: 10px;
    }
    
    .preset-name {
        font-size: 13px;
    }
    
    /* MSG展示区调整 */
    .header {
        padding: 14px 50px;
        font-size: 18px;
    }
    
    .chat-box {
        padding: 16px;
    }
    
    .avatar {
        width: 50px;
        height: 50px;
        border-width: 1.5px;
    }
    
    .avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
    }
    
    .chat-content {
        margin-left: 10px;
    }
    
    .chat-name {
        font-size: 13px;
    }
    
    .chat-body {
        font-size: 13px;
        line-height: 1.4;
    }
    
    /* 聊天图片优化 */
    .chat-body img {
        max-width: 100% !important;
        height: auto !important;
        border-radius: 8px;
        margin: 4px 0;
    }
    
    /* 图片上传区域优化 */
    .chat-editable {
        min-height: 80px;
        padding: 12px;
        font-size: 13px;
    }
    
    .chat-editable img {
        max-width: 100%;
        height: auto;
        border-radius: 6px;
        margin: 4px 0;
    }
    
    /* 头像上传区域优化 */
    .avatar-dropzone {
        width: 50px;
        height: 50px;
        font-size: 10px;
    }
    
    .avatar-dropzone img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 50%;
    }
    
    /* 导航栏调整 */
    .navbar {
        padding: 0 16px;
        height: 50px;
    }
    
    .navbar-links {
        display: none;
    }
    
    .navbar-logo {
        font-size: 16px;
    }
    
    /* 图片触摸优化 */
    .avatar:hover,
    .preset-avatar:hover {
        transform: none;
        box-shadow: none;
    }
    
    .avatar:active,
    .preset-avatar:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
    
    /* 图片加载优化 */
    img {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* 聊天图片手势支持 */
    .chat-body img {
        touch-action: manipulation;
        -webkit-touch-callout: default;
        -webkit-user-select: auto;
        user-select: auto;
    }
    
    /* 图片预览优化 */
    .chat-body img:hover {
        cursor: zoom-in;
        transition: transform 0.2s;
    }
    
    .chat-body img:active {
        cursor: zoom-out;
    }
    
    /* 响应式图片容器 */
    .image-container {
        position: relative;
        overflow: hidden;
        border-radius: 8px;
        margin: 4px 0;
    }
    
    .image-container img {
        display: block;
        width: 100%;
        height: auto;
    }
    
    /* 小屏幕下的图片尺寸限制 */
    @media (max-width: 480px) {
        .chat-body img {
            max-height: 200px !important;
            object-fit: contain;
        }
        
        .avatar {
            width: 45px;
            height: 45px;
        }
        
        .avatar-dropzone {
            width: 45px;
            height: 45px;
        }
    }
    
    /* 横屏模式优化 */
    @media (max-width: 768px) and (orientation: landscape) {
        .chat-body img {
            max-height: 150px !important;
        }
        
        .avatar {
            width: 40px;
            height: 40px;
        }
    }
    
    .navbar-logo {
        font-size: 16px;
    }
}

/* 电脑端隐藏FAB */
@media (min-width: 769px) {
    .fab-container {
        display: none;
    }
}
