/**
 * 答案交流群 - 聊天室样式
 * 简约美观，动画丝滑
 */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #ec4899;
    --background: #0f0f23;
    --surface: #1a1a2e;
    --surface-light: #252542;
    --surface-hover: #2d2d5a;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 背景动画 */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-animation::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 30%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 70% 70%, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
    animation: bgFloat 20s ease-in-out infinite;
}

@keyframes bgFloat {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(2%, 2%) rotate(120deg); }
    66% { transform: translate(-2%, 1%) rotate(240deg); }
}

/* 登录/注册页面 */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.auth-box {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: slideUp 0.5s ease-out;
}

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

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.auth-footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* 错误提示 */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    animation: shake 0.5s ease-out;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 聊天室主界面 */
.chat-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* 头部 */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.online-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.online-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.btn-logout {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--surface-hover);
}

/* 消息气泡 */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: messageSlide 0.3s ease-out;
}

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

.message-own {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message-content {
    max-width: 60%;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-own .message-header {
    flex-direction: row-reverse;
}

.message-author {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-bubble {
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    word-wrap: break-word;
}

.message-own .message-bubble {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: transparent;
}

.message-text {
    line-height: 1.5;
    font-size: 0.95rem;
}

/* 媒体消息 */
.message-media {
    max-width: 300px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.message-image {
    width: 100%;
    max-width: 300px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.message-image:hover {
    transform: scale(1.02);
}

.message-video {
    width: 100%;
    max-width: 300px;
    border-radius: var(--radius-sm);
}

.message-audio {
    width: 100%;
    max-width: 250px;
}

/* 文件消息 */
.message-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
}

.message-file:hover {
    background: var(--surface-hover);
}

.file-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.file-icon.pdf { color: #ef4444; }
.file-icon.word { color: #3b82f6; }
.file-icon.excel { color: #22c55e; }
.file-icon.powerpoint { color: #f97316; }
.file-icon.image { color: #8b5cf6; }
.file-icon.video { color: #ec4899; }
.file-icon.audio { color: #06b6d4; }
.file-icon.archive { color: #f59e0b; }
.file-icon.text { color: #6b7280; }

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

.file-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* 输入区域 */
.chat-input-area {
    padding: 16px 24px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.input-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface-light);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

.toolbar-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.toolbar-btn input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

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

.message-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    transition: var(--transition);
}

.message-input:focus {
    outline: none;
    border-color: var(--primary);
}

.message-input::placeholder {
    color: var(--text-muted);
}

.btn-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-send:active {
    transform: scale(0.95);
}

/* 录音按钮 */
.btn-record {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--surface-light);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-record.recording {
    background: var(--error);
    color: white;
    animation: recordingPulse 1s infinite;
}

@keyframes recordingPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

/* 录音提示 */
.recording-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    padding: 32px 48px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
    z-index: 1000;
    display: none;
}

.recording-indicator.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.recording-indicator .icon {
    font-size: 3rem;
    color: var(--error);
    margin-bottom: 16px;
    animation: recordingPulse 1s infinite;
}

.recording-indicator p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* 模态框 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

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

.modal-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius);
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--error);
}

/* PDF预览 */
.pdf-preview {
    width: 90vw;
    height: 90vh;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pdf-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
}

.pdf-preview-header h3 {
    font-size: 1rem;
    font-weight: 500;
}

.pdf-preview iframe {
    flex: 1;
    border: none;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--surface-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 新消息提示 */
.new-message-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease-out;
    z-index: 100;
}

.new-message-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* 响应式 */
@media (max-width: 768px) {
    .auth-box {
        padding: 30px 20px;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .chat-logo {
        font-size: 1.2rem;
    }
    
    .user-name {
        display: none;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .message-content {
        max-width: 75%;
    }
    
    .chat-input-area {
        padding: 12px 16px;
    }
}

/* 打字指示器 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
