/* 苹果风格深色主题 */
:root {
    --bg-primary: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --bg-tertiary: #3a3a3c;
    --text-primary: #ffffff;
    --text-secondary: #98989d;
    --text-tertiary: #6c6c70;
    --accent-blue: #0a84ff;
    --accent-green: #30d158;
    --accent-red: #ff453a;
    --accent-orange: #ff9f0a;
    --border-color: #38383a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body.dark-theme {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

/* 侧边栏样式 */
.sidebar {
    width: 320px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-info {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 28px;
    color: var(--text-secondary);
}

.user-details h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

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

.search-box {
    padding: 16px 20px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 40px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
}

.search-box i {
    position: absolute;
    left: 36px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    z-index: 1;
}

.nav-tabs {
    display: flex;
    padding: 0 20px;
    margin-bottom: 10px;
}

.nav-btn {
    flex: 1;
    padding: 12px 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.nav-btn.active {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-btn:hover {
    background-color: var(--bg-tertiary);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s;
    margin-bottom: 4px;
}

.chat-item:hover {
    background-color: var(--bg-tertiary);
}

.chat-item.active {
    background-color: rgba(10, 132, 255, 0.1);
}

.chat-item-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 22px;
    color: var(--text-secondary);
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between;
}

.chat-item-last-message {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.chat-item-unread {
    background-color: var(--accent-blue);
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

/* 主聊天区域 */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-secondary);
    z-index: 10;
}

.chat-partner {
    display: flex;
    align-items: center;
}

.partner-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 24px;
    color: var(--text-secondary);
}

.partner-info h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 2px;
}

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

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

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background-color: var(--accent-blue);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.message {
    display: flex;
    max-width: 70%;
}

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.message.received .message-avatar {
    margin-right: 12px;
}

.message.sent .message-avatar {
    margin-left: 12px;
}

.message-content {
    background-color: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    position: relative;
}

.message.sent .message-content {
    background-color: var(--accent-blue);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.message.received .message-content {
    border-bottom-left-radius: var(--radius-sm);
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
}

.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
    text-align: right;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.chat-input-area {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

.input-tools {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tool-btn:hover {
    background-color: var(--bg-tertiary);
}

.message-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input-wrapper textarea {
    flex: 1;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 12px 16px;
    font-size: 15px;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    line-height: 1.4;
}

.message-input-wrapper textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--accent-blue);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background-color: #007aff;
}

/* 语音通话界面 */
.call-interface {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.call-container {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.call-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 60px;
    color: var(--text-secondary);
}

.call-container h3 {
    font-size: 24px;
    margin-bottom: 8px;
}

.call-status {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.call-timer {
    font-size: 32px;
    font-weight: 600;
    margin: 24px 0;
    color: var(--accent-green);
}

.call-controls {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 40px;
}

.call-control-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-control-btn:hover {
    transform: scale(1.1);
}

.call-control-btn.decline {
    background-color: var(--accent-red);
    color: white;
}

.call-control-btn.accept {
    background-color: var(--accent-green);
    color: white;
}

/* 侧边栏 */
.contacts-sidebar,
.files-sidebar {
    width: 320px;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: -320px;
    bottom: 0;
    transition: right 0.3s;
    z-index: 100;
}

.contacts-sidebar.active,
.files-sidebar.active {
    right: 0;
}

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

.sidebar-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.close-sidebar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-sidebar:hover {
    background-color: var(--bg-tertiary);
}

.contacts-list,
.files-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s;
    margin-bottom: 8px;
}

.contact-item:hover {
    background-color: var(--bg-tertiary);
}

.contact-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: auto;
}

.contact-status.online {
    background-color: var(--accent-green);
}

.contact-status.offline {
    background-color: var(--text-tertiary);
}

/* 移动端样式：显示顶部的联系人按钮并调整布局 */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .action-btn#openContactsBtn { display: flex; }
    .main-chat { padding-top: 0; }
    .app-container { max-width: 100%; }
}

/* 文件上传模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.close-modal {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background-color: var(--bg-tertiary);
}

.modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
    margin-bottom: 24px;
}

.upload-area:hover {
    border-color: var(--accent-blue);
}

.upload-area i {
    font-size: 48px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.upload-area p {
    font-size: 16px;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-bottom: 20px;
}

.upload-btn {
    background-color: var(--accent-blue);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius-md);
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.upload-btn:hover {
    background-color: #007aff;
}

.file-preview {
    margin-top: 20px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.file-icon {
    width: 40px;
    height: 40px;
    background-color: var(--accent-blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: white;
}

.file-info {
    flex: 1;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

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

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.welcome-message i {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.5;
}

.welcome-message h3 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 16px;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: fixed;
        top: 0;
        left: -100%;
        bottom: 0;
        transition: left 0.3s;
        z-index: 100;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .contacts-sidebar,
    .files-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .contacts-sidebar.active,
    .files-sidebar.active {
        right: 0;
    }
    
    .app-container {
        flex-direction: column;
    }
    
    .message {
        max-width: 85%;
    }
}