/* 即时聊天 - 微信/TIM 风格 */
.chat-app-mode .community-main {
    padding: 0;
    max-width: none;
}

.chat-app-mode .community-header,
.chat-app-mode .community-footer {
    display: none;
}

.chat-app {
    display: flex;
    height: calc(100vh - 0px);
    min-height: 520px;
    background: #f0f2f5;
    margin: 0 auto;
    max-width: 1400px;
}

.chat-sidebar {
    width: 56px;
    background: #2e2e2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    flex-shrink: 0;
}

.chat-sidebar-item {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    border-radius: 8px;
    margin-bottom: 8px;
    text-decoration: none;
}

.chat-sidebar-item:hover,
.chat-sidebar-item.active {
    background: #3a3a3a;
    color: #fff;
}

.chat-sidebar-bottom {
    margin-top: auto;
}

.chat-sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
}

.chat-session-panel {
    width: 280px;
    background: #fff;
    border-right: 1px solid #e8e8e8;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.chat-left-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.chat-left-view.hidden {
    display: none !important;
}

.chat-contacts-panel-list {
    flex: 1;
    overflow-y: auto;
}

.chat-contacts-groups {
    flex-shrink: 0;
    border-bottom: 1px solid #f0f0f0;
}

.chat-contacts-groups-head {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: #fff;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.chat-contacts-groups-head:hover {
    background: #f9f9f9;
}

.chat-contacts-groups-head.is-expanded .chat-contacts-groups-arrow {
    transform: rotate(90deg);
}

.chat-contacts-groups-title {
    font-weight: 600;
}

.chat-contacts-groups-count {
    margin-left: 6px;
    font-size: 12px;
    color: #999;
    font-weight: normal;
}

.chat-contacts-groups-arrow {
    margin-left: auto;
    color: #bbb;
    transition: transform 0.2s;
}

.chat-contacts-groups-body {
    border-top: 1px solid #f5f5f5;
}

.chat-contacts-groups-body.hidden {
    display: none !important;
}

.chat-contacts-friends .chat-contacts-groups-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.chat-contacts-friends {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-bottom: none;
}

#chat-contacts-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-contacts-groups-body .chat-contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 12px 24px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
}

.chat-contacts-groups-body .chat-contact-item:hover {
    background: #eef0ff;
}

.chat-contacts-groups-body .chat-contact-item img,
.chat-contacts-groups-body .chat-contact-item > i.fa-user {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-contacts-groups-body .chat-contact-item > i.fa-user {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8e8e8;
    color: #999;
    font-size: 20px;
}

.chat-contacts-group-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 10px 24px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
}

.chat-contacts-group-item:hover {
    background: #eef0ff;
}

.chat-contacts-group-item img,
.chat-contacts-group-item .chat-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-contacts-group-item .chat-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8e8e8;
    color: #999;
}

.chat-contacts-group-body {
    flex: 1;
    min-width: 0;
}

.chat-contacts-group-name {
    display: block;
    font-size: 14px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-contacts-group-badge {
    display: inline-block;
    margin-top: 2px;
    padding: 0 6px;
    font-size: 11px;
    line-height: 18px;
    border-radius: 3px;
    background: #fff3e0;
    color: #f57c00;
}

.chat-session-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 8px;
}

.chat-session-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.chat-search-wrap {
    padding: 0 12px 12px;
}

.chat-search-input {
    border-radius: 6px;
    background: #f5f5f5;
    border: none;
    box-shadow: none;
}

.chat-session-list {
    flex: 1;
    overflow-y: auto;
}

.chat-session-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    position: relative;
}

.chat-session-item:hover,
.chat-session-item.active {
    background: #eef0ff;
}

.chat-session-avatar {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8e8e8;
    color: #999;
}

.chat-session-body {
    flex: 1;
    min-width: 0;
}

.chat-session-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.chat-session-name {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-session-time {
    font-size: 11px;
    color: #999;
    flex-shrink: 0;
}

.chat-session-preview {
    font-size: 12px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 4px;
}

.chat-session-unread {
    position: absolute;
    right: 12px;
    bottom: 12px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #f56c6c;
    color: #fff;
    font-size: 11px;
    text-align: center;
}

.chat-main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f6f8;
    min-width: 0;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #bbb;
}

.chat-empty-state i {
    font-size: 64px;
    margin-bottom: 12px;
}

.chat-room {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-room-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.chat-room-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.chat-room-status {
    font-size: 12px;
    color: #999;
}

.chat-room-tools .btn-link {
    color: #666;
    font-size: 16px;
}

.chat-back-btn {
    border: none;
    background: none;
    font-size: 22px;
    padding: 0 8px 0 0;
}

.chat-message-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    background: #e8ecf1;
}

.chat-date-divider {
    display: flex;
    justify-content: center;
    margin: 16px 0;
    pointer-events: none;
}

.chat-date-divider-label {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.12);
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chat-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 6px;
}

.chat-msg-self {
    justify-content: flex-end;
}

.chat-msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.chat-msg-bubble {
    max-width: min(420px, 72%);
    padding: 6px 8px 5px 10px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.chat-msg-bubble-media {
    padding: 3px;
    overflow: hidden;
}

.chat-msg-content-wrap {
    display: block;
}

.chat-msg-content-wrap::after {
    content: '';
    display: table;
    clear: both;
}

.chat-msg-time {
    float: right;
    margin: 4px 0 0 10px;
    font-size: 11px;
    line-height: 1.2;
    opacity: 0.55;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

.chat-msg-time:hover {
    opacity: 0.85;
    text-decoration: underline;
}

.chat-msg-other .chat-msg-bubble {
    background: #fff;
    color: #111;
    border-top-left-radius: 4px;
}

.chat-msg-self .chat-msg-bubble {
    background: #effdde;
    color: #111;
    border-top-right-radius: 4px;
}

.chat-msg-self .chat-msg-time {
    color: #5c8a4a;
}

.chat-msg-image {
    display: block;
    max-width: 260px;
    max-height: 320px;
    border-radius: 10px;
}

.chat-msg-video {
    display: block;
    max-width: 260px;
    max-height: 240px;
    border-radius: 10px;
}

.chat-msg-bubble-media .chat-msg-content-wrap {
    position: relative;
    display: inline-block;
}

.chat-msg-bubble-media .chat-msg-time {
    position: absolute;
    right: 8px;
    bottom: 6px;
    float: none;
    margin: 0;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    opacity: 1;
}

.chat-msg-bubble-media .chat-msg-content-wrap::after {
    display: none;
}

.chat-msg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    max-width: 280px;
    text-decoration: none;
    color: inherit;
}

.chat-msg-file:hover,
.chat-msg-file:focus {
    text-decoration: none;
    color: inherit;
}

.chat-msg-file-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #4facfe;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-msg-file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-msg-file-name {
    display: block;
    font-size: 14px;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-msg-file-size {
    display: block;
    font-size: 12px;
    opacity: 0.55;
}

.chat-date-jump-current {
    font-size: 13px;
    margin-bottom: 12px;
}

.chat-date-jump-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.chat-date-jump-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fff;
    text-align: left;
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.chat-date-jump-item:hover {
    background: #f5f7ff;
    border-color: #d8dcff;
}

.chat-date-jump-item.active {
    background: #eef0ff;
    border-color: #7b61ff;
    color: #7b61ff;
}

.chat-msg-redpacket,
.chat-msg-transfer,
.chat-msg-call,
.chat-msg-voice,
.chat-msg-location {
    cursor: pointer;
}

.chat-input-area {
    background: #fff;
    border-top: 1px solid #eee;
    padding: 8px 12px 12px;
    position: relative;
}

.chat-input-toolbar {
    display: flex;
    gap: 4px;
    padding-bottom: 6px;
}

.chat-emoji-panel {
    position: absolute;
    left: 12px;
    bottom: calc(100% - 8px);
    margin-bottom: 6px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 10px;
    width: 320px;
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    z-index: 20;
}

.chat-emoji-item {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 36px;
    padding: 0;
    cursor: pointer;
    border-radius: 6px;
}

.chat-emoji-item:hover {
    background: #f5f5f5;
}

.chat-input-toolbar .btn-link {
    color: #666;
    font-size: 18px;
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-text-input {
    flex: 1;
    resize: none;
    border-radius: 6px;
    min-height: 38px;
    max-height: 120px;
}

.btn-chat-send,
.btn-chat-primary {
    background: #7b61ff;
    border-color: #7b61ff;
    color: #fff;
}

.btn-chat-send:hover,
.btn-chat-primary:hover {
    background: #6a52e8;
    border-color: #6a52e8;
    color: #fff;
}

#btn-chat-mobile-send {
    flex-shrink: 0;
    padding: 6px 14px;
    font-size: 14px;
    line-height: 1.2;
    border: none;
    border-radius: 4px;
}

.chat-mobile-panel {
    padding-top: 12px;
}

.chat-mobile-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.chat-mobile-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 4px;
    border: none;
    background: #f5f5f5;
    border-radius: 10px;
    font-size: 12px;
    color: #666;
}

.chat-mobile-item i {
    font-size: 22px;
}

.chat-contacts-list {
    max-height: 360px;
    overflow-y: auto;
    margin-top: 12px;
}

.chat-contacts-panel-list .chat-contact-item {
    padding: 12px 16px;
    border-radius: 0;
    border-bottom: 1px solid #f5f5f5;
}

.chat-contacts-panel-list .chat-contact-item:hover {
    background: #eef0ff;
}

.chat-contacts-panel-list .chat-contact-item img,
.chat-contacts-panel-list .chat-contact-item > i.fa-user {
    width: 44px;
    height: 44px;
    border-radius: 6px;
}

.chat-contacts-panel-list .chat-contact-item > i.fa-user {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8e8e8;
    color: #999;
    font-size: 20px;
}

.chat-contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    cursor: pointer;
    border-radius: 6px;
}

.chat-contact-item:hover {
    background: #f5f5f5;
}

.chat-contact-item img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-contact-check {
    margin: 0 4px 0 0;
}

.chat-group-create-fields {
    margin-bottom: 12px;
}

.chat-group-tip {
    font-size: 12px;
    margin: 8px 0 0;
}

.chat-contacts-selected {
    margin-top: 8px;
    font-size: 13px;
}

.chat-group-members {
    max-height: 280px;
    overflow-y: auto;
    margin: 12px 0;
}

.chat-group-member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.chat-group-member-item img,
.chat-group-member-item > i {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
}

.chat-group-member-body {
    flex: 1;
}

.chat-group-role {
    margin-left: 6px;
    font-size: 11px;
    color: #07c160;
    background: #e8f8ef;
    padding: 1px 6px;
    border-radius: 4px;
}

.chat-group-meta {
    font-size: 13px;
    color: #999;
}

.chat-msg-audio {
    max-width: 200px;
    height: 32px;
}

.chat-msg-voice-dur {
    display: block;
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.chat-msg-location {
    color: inherit;
    text-decoration: none;
}

.chat-msg-location:hover {
    color: #07c160;
}

.chat-voice-recording {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-voice-recording-inner {
    background: rgba(0,0,0,.75);
    color: #fff;
    padding: 24px 32px;
    border-radius: 12px;
    text-align: center;
}

.chat-voice-recording-inner i {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

/* PC 语音录制弹窗 */
.chat-voice-modal .modal-header {
    border-bottom: none;
    padding-bottom: 0;
}

.chat-voice-modal-body {
    text-align: center;
    padding: 10px 20px 20px;
}

.chat-voice-visual {
    margin-bottom: 12px;
}

.chat-voice-headphone {
    position: relative;
    display: inline-block;
    width: 120px;
    height: 100px;
    color: #ddd;
}

.chat-voice-headphone > .fa-headphones {
    font-size: 100px;
    line-height: 1;
}

.chat-voice-bars {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -55%);
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 36px;
}

.chat-voice-bars span {
    display: block;
    width: 5px;
    height: 8px;
    border-radius: 2px;
    background: #07c160;
    opacity: 0.35;
}

.chat-voice-modal.is-recording .chat-voice-bars span {
    opacity: 1;
    animation: chat-voice-bar 0.8s ease-in-out infinite;
}

.chat-voice-modal.is-recording .chat-voice-bars span:nth-child(1) { background: #ff6b6b; animation-delay: 0s; }
.chat-voice-modal.is-recording .chat-voice-bars span:nth-child(2) { background: #ffa94d; animation-delay: 0.1s; }
.chat-voice-modal.is-recording .chat-voice-bars span:nth-child(3) { background: #4dabf7; animation-delay: 0.2s; }
.chat-voice-modal.is-recording .chat-voice-bars span:nth-child(4) { background: #748ffc; animation-delay: 0.3s; }
.chat-voice-modal.is-recording .chat-voice-bars span:nth-child(5) { background: #da77f2; animation-delay: 0.4s; }

@keyframes chat-voice-bar {
    0%, 100% { height: 8px; }
    50% { height: 32px; }
}

.chat-voice-timer {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.chat-voice-status {
    font-size: 13px;
    color: #999;
}

.chat-voice-modal-footer {
    border-top: 1px solid #eee;
    padding: 12px 16px 16px;
    text-align: center;
}

.chat-voice-panel {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.chat-voice-panel.hidden {
    display: none !important;
}

.btn-voice-action {
    flex: 1;
    min-width: 100px;
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 13px;
    border: none;
    color: #fff;
}

.btn-voice-action .fa {
    margin-right: 4px;
}

.btn-voice-pause {
    background: #ff922b;
}

.btn-voice-pause:hover,
.btn-voice-pause:focus {
    background: #fd7e14;
    color: #fff;
}

.btn-voice-stop {
    background: #ff6b6b;
}

.btn-voice-stop:hover,
.btn-voice-stop:focus {
    background: #fa5252;
    color: #fff;
}

.btn-voice-play {
    background: #51cf66;
}

.btn-voice-play:hover,
.btn-voice-play:focus {
    background: #40c057;
    color: #fff;
}

.chat-location-coords {
    font-size: 12px;
    margin-top: 10px;
}

.chat-call-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.75);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-call-box {
    text-align: center;
    color: #fff;
}

.chat-call-local,
.chat-call-remote {
    width: 280px;
    max-height: 200px;
    border-radius: 8px;
    margin: 12px auto;
}

.chat-call-actions .btn {
    border-radius: 50%;
    width: 56px;
    height: 56px;
}

@media (max-width: 767px) {
    .chat-app {
        height: 100vh;
    }

    .chat-session-panel {
        width: 100%;
    }

    .chat-main-panel {
        display: none;
    }

    .chat-app.chat-has-room .chat-session-panel {
        display: none;
    }

    .chat-app.chat-has-room .chat-main-panel {
        display: flex;
        width: 100%;
    }
}

@media (min-width: 768px) {
    .chat-app-mode .community-body {
        padding-top: 0;
    }
}
