/* 重置和基础样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 50%, #e0f7fa 100%);
    color: #334155;
    height: 100vh;
    overflow: hidden;
}

/* 加载屏幕 */
#loading {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner {
    width: 40px; height: 40px;
    border: 3px solid #cbd5e1;
    border-top: 3px solid #0ea5e9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}

/* 主应用容器 */
#app { 
    display: none; 
    height: 100vh; 
    height: 100dvh;
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
}

/* 顶部状态栏 */
.status-bar {
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(203, 213, 225, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.online-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #10b981;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    position: relative;
    display: inline-block;
}

.status-dot::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
}

.status-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
    animation-delay: 0.5s;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

.status-text {
    font-size: 11px;
    color: #10b981;
    font-weight: 600;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.action-btn {
    padding: 8px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

/* 聊天区域 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 0;
}

.welcome-screen {
    text-align: center;
    max-width: 500px;
    margin: 80px auto 0;
}

.welcome-icon {
    width: 72px;
    height: 72px;
    /* background: linear-gradient(135deg, #0ea5e9, #06b6d4); */
    border-radius: 20px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.25);
}

.welcome-title {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #0f172a;
}

.welcome-subtitle {
    font-size: 15px;
    color: #64748b;
    line-height: 1.6;
}

/* 消息样式 */
.message {
    max-width: 85%;
    margin-bottom: 20px;
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.6;
    animation: fadeIn 0.3s ease;
    font-size: 14px;
    position: relative;
}

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

.user-message {
    background: linear-gradient(135deg, #0ea5e9, #06b6d4);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
}

.assistant-message {
    background: white;
    color: #334155;
    margin-right: auto;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(203, 213, 225, 0.5);
}

.message-content {
    word-wrap: break-word;
}

.message-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.message-action {
    padding: 4px 8px;
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 4px;
    color: inherit;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.8;
}

.message-action:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.3);
}

/* 输入区域 */
.input-area {
    padding: 20px 24px 24px;
    background: rgba(255, 255, 255, 0.8);
    border-top: 1px solid rgba(203, 213, 225, 0.5);
    flex-shrink: 0;
    backdrop-filter: blur(10px);
}

.input-container {
    position: relative;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 6px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.input-container:focus-within {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.message-input {
    width: 100%;
    padding: 14px 160px 14px 20px;
    background: transparent;
    border: none;
    border-radius: 20px;
    color: #334155;
    font-size: 15px;
    resize: none;
    min-height: 52px;
    max-height: 200px;
    line-height: 1.6;
    font-family: inherit;
    outline: none;
}

.message-input::placeholder {
    color: #94a3b8;
    font-size: 14px;
}

.input-controls {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-btn {
    padding: 8px 14px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: #e2e8f0;
    color: #475569;
}

.mode-btn.active {
    background: linear-gradient(135deg, #0ea5e9, #06b6d4);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.icon-round-btn {
    width: 44px;
    height: 44px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    color: #64748b;
    font-size: 22px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-round-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #475569;
    transform: scale(1.05);
}

.icon-round-btn:active {
    transform: scale(0.98);
}

.icon-round-btn span {
    margin-top: -2px;
}

.send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #0ea5e9, #06b6d4);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #0284c7, #0891b2);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.45);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

/* 发送按钮图标 */
.send-btn::before {
    content: '➤';
    font-size: 14px;
    margin-left: 2px;
}

/* 打字指示器 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #cbd5e1;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

/* 流式输出光标 */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: #0ea5e9;
    margin-left: 2px;
    vertical-align: middle;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 错误消息样式 */
.error-message {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: white !important;
}

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

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

.chat-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #app {
        max-width: 100%;
    }
    
    .status-bar {
        padding: 12px 16px;
    }
    
    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .message {
        max-width: 90%;
        padding: 12px 16px;
    }
    
    .chat-container {
        padding: 16px;
    }
    
    .input-area {
        padding: 14px 16px 18px;
    }
    
    .input-container {
        border-radius: 20px;
    }
    
    .message-input {
        padding: 12px 150px 12px 16px;
        font-size: 14px;
        min-height: 48px;
    }
    
    .icon-round-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .input-controls {
        right: 6px;
        bottom: 6px;
        gap: 6px;
    }
    
    .mode-btn {
        padding: 7px 12px;
        font-size: 11px;
    }
    
    .send-btn {
        width: 40px;
        height: 40px;
    }
    
    .welcome-icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
    
    .welcome-title {
        font-size: 22px;
    }
}

/* 更窄屏幕的适配 */
@media (max-width: 480px) {
    .status-bar {
        padding: 10px 14px;
    }
    
    .logo {
        font-size: 16px;
    }
    
    .action-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .chat-container {
        padding: 12px;
    }
    
    .message {
        max-width: 92%;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .input-area {
        padding: 12px 14px 16px;
    }
    
    .message-input {
        padding: 10px 130px 10px 14px;
    }
    
    .mode-btn {
        padding: 6px 10px;
        font-size: 10px;
    }
    
    .icon-round-btn {
        width: 34px;
        height: 34px;
        font-size: 18px;
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
    }
}
