/* 聊天页面样式 */
.chat-page {
    background: #f5f5f5;
    min-height: 100vh;
}

.chat-page .app-main {
    padding-bottom: 0;
}

.chat-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 44px);
    background: #f5f5f5;
    padding-bottom: 70px;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 44px;
    z-index: 10;
}

.chat-back {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    cursor: pointer;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-info {
    flex: 1;
    margin-left: 12px;
}

.chat-name {
    font-weight: 600;
    font-size: 15px;
    color: #333;
}

.chat-status {
    font-size: 12px;
    color: #28a745;
}

.chat-actions {
    display: flex;
    gap: 16px;
}

.chat-action-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.message-item {
    display: flex !important;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
    align-items: flex-end;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-item.me {
    justify-content: flex-end;
}

.message-item.other {
    justify-content: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message-content {
    max-width: 70%;
    margin: 0 8px;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
}

.message-item.me .message-content {
    align-items: flex-end !important;
    justify-content: flex-end !important;
}

.message-item.other .message-content {
    align-items: flex-start !important;
    justify-content: flex-start !important;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-all;
}

.message-item.me .message-bubble {
    background: var(--primary-color);
    color: #fff;
    border-radius: 18px 4px 18px 18px;
}

.message-item.other .message-bubble {
    background: var(--card-color);
    color: var(--text-color);
    border-radius: 4px 18px 18px 18px;
    border: 1px solid var(--border-color);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary-color);
    margin-top: 4px;
    text-align: right;
    width: 100%;
    min-height: 16px;
    display: block;
}

.message-item.other .message-time {
    text-align: left;
}

.message-status {
    font-size: 12px;
    font-weight: bold;
}

.message-status.unread {
    color: #999;
}

.message-status.read {
    color: #28a745;
}

.message-menu {
    background: rgba(40, 40, 40, 0.95);
    border-radius: 12px;
    padding: 6px;
    transform: translate(-50%, -100%) scale(0.9);
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    min-width: 100px;
}

.message-menu.show {
    transform: translate(-50%, -100%) scale(1);
    opacity: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.menu-item:hover {
    background: rgba(255,255,255,0.15);
}

.menu-item:active {
    background: rgba(255,255,255,0.25);
}

.menu-item.recall {
    color: #5bc0de;
}

.menu-item.recall .menu-icon {
    color: #5bc0de;
}

.menu-item.delete {
    color: #ff6b6b;
}

.menu-item.delete .menu-icon {
    color: #ff6b6b;
}

.menu-icon {
    font-size: 16px;
}

.recalled-text {
    font-style: italic;
    color: #999;
}

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

.input-actions {
    display: flex;
    gap: 4px;
}

.input-action-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary-color);
    font-size: 24px;
}

.message-input {
    flex: 1;
    height: 44px;
    padding: 0 20px;
    background: #e9e9eb;
    border: none;
    border-radius: 22px;
    font-size: 15px;
    outline: none;
}

.send-btn {
    width: 44px;
    height: 44px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
}

.send-btn:hover {
    opacity: 0.9;
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 微信风格功能面板 */
.action-panel {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    background: var(--card-color);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 99;
    animation: slideUp 0.3s ease;
    padding: 20px 0;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.action-panel-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 0 16px;
    gap: 16px;
}

.action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 12px 0;
    border-radius: 12px;
    transition: background 0.2s;
}

.action-item:hover {
    background: rgba(0,0,0,0.05);
}

.action-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #fff;
}

.action-item:nth-child(2) .action-icon {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.action-item:nth-child(3) .action-icon {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.action-item:nth-child(4) .action-icon {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.action-item:nth-child(5) .action-icon {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.action-item:nth-child(6) .action-icon {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
}

.action-item:nth-child(7) .action-icon {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.action-item:nth-child(8) .action-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.action-label {
    font-size: 12px;
    color: var(--text-color);
}

.panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 98;
    display: none;
}

.panel-overlay.show {
    display: block;
}

.loading-more {
    text-align: center;
    padding: 12px;
    color: var(--text-secondary-color);
    font-size: 13px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

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

.cursor-pointer {
    cursor: pointer;
}

.profile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.profile-modal {
    background: var(--card-color);
    border-radius: 16px;
    width: 85%;
    max-width: 320px;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.profile-header {
    position: relative;
    padding: 32px 24px 24px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
}

.profile-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.5);
    margin-bottom: 12px;
}

.profile-name {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.profile-content {
    padding: 20px;
}

.profile-stats {
    display: flex;
    justify-content: space-around;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

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

.profile-actions {
    display: flex;
    gap: 12px;
}

.profile-btn {
    flex: 1;
    height: 44px;
    border-radius: 22px;
    border: none;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.profile-btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.profile-btn-primary:hover {
    opacity: 0.9;
}

.profile-btn-secondary {
    background: var(--background-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

/* 表情选择器样式 */
.emoji-picker {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-color);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 199;
    height: 280px;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom);
}

.emoji-picker.show {
    transform: translateY(0);
}

/* 输入区域固定在底部 */
.chat-input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--card-color);
    border-top: 1px solid var(--border-color);
    padding: 8px 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    transition: bottom 0.3s ease;
}

/* 表情选择器显示时，输入区域上移 */
body.emoji-open .chat-input-area {
    bottom: 280px;
}

.emoji-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.emoji-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

.emoji-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-secondary-color);
    cursor: pointer;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    padding: 8px;
    gap: 4px;
    max-height: 350px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 24px;
    padding: 4px;
    text-align: center;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

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

/* 聊天图片样式 */
.chat-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
}

/* 聊天视频样式 */
.chat-video {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    background: #000;
}

/* 媒体查看器样式 */
.media-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.media-viewer-overlay.show {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.media-viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.media-viewer-content {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    animation: fadeIn 0.2s ease;
}

.media-viewer-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
    display: block;
}

.media-viewer-video {
    width: 100%;
    height: 100vh;
    object-fit: contain;
    background: #000;
}

/* 视频消息样式 */
.chat-video-wrapper {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    margin: 4px 0;
    width: 200px;
    height: 150px;
    max-width: 280px;
    max-height: 420px;
    background: var(--background-color);
    flex-shrink: 0;
}

.chat-video-thumb {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
}

.chat-video-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    padding-left: 3px;
}

.video-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.media-viewer-close {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    font-weight: 500;
    cursor: pointer;
    z-index: 1001;
    border: 1px solid rgba(255,255,255,0.2);
}

.image-viewer-close {
    position: absolute;
    top: max(env(safe-area-inset-top), 20px);
    right: 20px;
    width: 44px;
    height: 44px;
    background: #e53935;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border: none;
    box-shadow: 0 2px 8px rgba(229, 57, 53, 0.4);
}

.image-viewer-close svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.image-viewer-indicator {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(0,0,0,0.6);
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
}

/* 旋转动画 */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}