/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

body.private-mode {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='%23ff6b8b' d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E") 12 12, auto;
}

/* 页面容器 */
.page {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.page.active {
    display: flex;
}

/* 登录页面样式 */
.login-container {
    background: white;
    padding: 40px 35px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
}

.logo i {
    font-size: 48px;
    color: #ff6b8b;
    margin-bottom: 15px;
}

.logo h1 {
    color: #333;
    font-size: 28px;
    font-weight: 600;
}

.subtitle {
    color: #666;
    font-size: 14px;
    margin-bottom: 30px;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group i {
    position: absolute;
    left: 15px;
    color: #999;
    font-size: 18px;
}

#login-form input {
    width: 100%;
    padding: 15px 15px 15px 45px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s;
    background: #f8f9fa;
}

#login-form input:focus {
    border-color: #667eea;
    background: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-btn {
    background: linear-gradient(to right, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 14px rgba(102, 126, 234, 0.2);
}

.login-btn:active {
    transform: translateY(0);
}

.hint {
    margin-top: 25px;
    color: #888;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* 聊天页面样式 */
.chat-header {
    background: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid #f0f0f0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.3s;
}

.avatar:hover {
    transform: scale(1.1);
}

.user-info h3 {
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.status {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 10px;
}

.status.online {
    background: #e8f5e9;
    color: #4caf50;
}

/* 头部操作按钮 */
.header-actions {
    display: flex;
    gap: 10px;
}

.settings-btn {
    background: #f0f0f0;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #667eea;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
}

.settings-btn:hover {
    background: #e0e0e0;
}

.logout-btn {
    background: #fff5f5;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #ff6b6b;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: #ffeaea;
}

/* 消息区域 */
.chat-main {
    flex: 1;
    overflow: hidden;
    background: #f8f9fa;
    position: relative;
}

.messages-container {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 消息气泡 */
.message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
    line-height: 1.5;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received {
    align-self: flex-start;
    background: white;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-bottom-left-radius: 4px;
}

.message.system {
    align-self: center;
    background: #f0f0f0;
    color: #666;
    font-size: 13px;
    max-width: 90%;
    text-align: center;
    border-radius: 12px;
    padding: 8px 16px;
}

/* 图片消息 */
.message.has-image {
    max-width: 85%;
}

.message-image {
    max-width: 100%;
    border-radius: 10px;
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.3s;
}

.message-image:hover {
    transform: scale(1.02);
}

.image-container {
    position: relative;
}

.image-caption {
    margin-top: 5px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
}

.message.received .image-caption {
    color: rgba(0, 0, 0, 0.6);
}

.message .sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    opacity: 0.9;
}

.message .time {
    font-size: 11px;
    margin-top: 8px;
    opacity: 0.7;
    text-align: right;
}

/* 消息状态 */
.message.sending { opacity: 0.8; }
.message.sending .sending-status { 
    color: rgba(255, 255, 255, 0.7); 
    font-size: 11px; 
    margin-left: 5px; 
}
.message.cached { 
    border-left: 2px solid #ff9800; 
}
.message.cached .cache-status { 
    margin-left: 5px; 
    font-size: 10px; 
}
.message.sent .time:after { 
    content: " ✓"; 
    color: #4CAF50; 
}
.message.failed { 
    opacity: 0.6; 
    border-left: 3px solid #f44336; 
}
.message .error { 
    color: #f44336; 
    font-size: 10px; 
    margin-top: 5px; 
}

/* 输入区域 */
.chat-footer {
    background: white;
    padding: 15px 20px;
    border-top: 1px solid #f0f0f0;
}

.input-container {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

#message-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    font-size: 16px;
    transition: border-color 0.3s;
    background: #f8f9fa;
}

#message-input:focus {
    border-color: #667eea;
    background: white;
    outline: none;
}

#send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.2s;
}

#send-btn:hover {
    transform: scale(1.05);
}

.footer-hint {
    text-align: center;
    color: #888;
    font-size: 12px;
}

/* 设置弹窗样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-modal:hover {
    background: #f5f5f5;
    color: #333;
}

.modal-body {
    padding: 20px;
}

.setting-item {
    margin-bottom: 25px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

#nickname-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

#nickname-input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-hint {
    margin-top: 5px;
    color: #888;
    font-size: 13px;
}

.emoji-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.emoji-option {
    font-size: 28px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
}

.emoji-option:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

.emoji-option.active {
    border-color: #667eea;
    background: #f0f4ff;
    transform: scale(1.1);
}

.save-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(to right, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: transform 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.save-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.save-btn:active {
    transform: translateY(0);
}

/* 纪念日列表 */
#anniversary-list, #codeword-list, #note-list {
    max-height: 150px;
    overflow-y: auto;
    margin-top: 10px;
    border: 1px solid #eee;
    border-radius: 5px;
    padding: 10px;
}

.anniversary-item-list, .codeword-item-list, .note-item-list {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.anniversary-item-list:last-child, .codeword-item-list:last-child, .note-item-list:last-child {
    border-bottom: none;
}

.delete-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
}

/* 快捷表情栏 */
.quick-emoji-bar.active {
    display: flex;
}

/* 滚动条美化 */
.messages-container::-webkit-scrollbar,
.modal-content::-webkit-scrollbar,
#anniversary-list::-webkit-scrollbar,
#codeword-list::-webkit-scrollbar,
#note-list::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track,
#anniversary-list::-webkit-scrollbar-track,
#codeword-list::-webkit-scrollbar-track,
#note-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb,
#anniversary-list::-webkit-scrollbar-thumb,
#codeword-list::-webkit-scrollbar-thumb,
#note-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover,
#anniversary-list::-webkit-scrollbar-thumb:hover,
#codeword-list::-webkit-scrollbar-thumb:hover,
#note-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* PWA全屏模式适配 */
@media (display-mode: standalone) {
    .chat-header {
        padding-top: max(15px, env(safe-area-inset-top));
    }
    
    .chat-footer {
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
}

/* 响应式设计 */
@media (max-width: 480px) {
    .login-container {
        padding: 30px 20px;
        margin: 15px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .chat-header,
    .chat-footer {
        padding: 12px 15px;
    }
    
    .emoji-option {
        font-size: 24px;
        width: 45px;
        height: 45px;
    }
    
    .header-actions {
        gap: 5px;
    }
    
    .quick-btn, .settings-btn, .logout-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    #send-btn {
        width: 45px;
        height: 45px;
    }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
    .page:not(#login-page) {
        background: #1a1a1a;
    }
    
    .chat-main {
        background: #1a1a1a;
    }
    
    .message.received {
        background: #2d2d2d;
        color: #e0e0e0;
    }
    
    #message-input {
        background: #2d2d2d;
        border-color: #404040;
        color: #e0e0e0;
    }
    
    .modal-content {
        background: #2d2d2d;
        color: #e0e0e0;
    }
    
    .modal-header h3 {
        color: #e0e0e0;
    }
    
    .setting-item label {
        color: #e0e0e0;
    }
    
    #nickname-input {
        background: #3d3d3d;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .emoji-option {
        background: #3d3d3d;
    }
    
    .emoji-option:hover {
        background: #4d4d4d;
    }
    
    .cache-btn {
        background: #3d3d3d;
        color: #e0e0e0;
    }
    
    .cache-btn:hover {
        background: #4d4d4d;
    }
}