@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    --primary: #4CAF50;
    --primary-hover: #388E3C;
    --neutral-100: #F5F7FA;
    --neutral-200: #E4E7EB;
    --neutral-300: #CBD2D9;
    --neutral-400: #9AA5B1;
    --neutral-500: #7B8794;
    --neutral-600: #616E7C;
    --neutral-700: #52606D;
    --neutral-800: #3E4C59;
    --neutral-900: #1F2933;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--neutral-100);
    color: var(--neutral-800);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

header p {
    color: var(--neutral-500);
    margin: 0;
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .grid-container {
        grid-template-columns: 1fr 1fr;
    }
}

.input-section, .output-section {
    background-color: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.input-section:hover, .output-section:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

h2 {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--neutral-800);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

h2 i {
    color: var(--primary);
    margin-right: 0.5rem;
    transition: color 0.3s ease;
}

/* 输入区域样式 */
.textarea-wrapper {
    position: relative;
    border: 1px solid var(--neutral-200);
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 1rem;
    transition: border-color 0.3s ease;
}

.textarea-wrapper:hover {
    border-color: rgba(76, 175, 80, 0.5);
}

textarea {
    width: 100%;
    height: 10rem;
    padding: 1rem;
    resize: none;
    outline: none;
    border: none;
    font-family: inherit;
    background-color: transparent;
    transition: all 0.3s ease;
}

textarea:focus {
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.5);
}

.char-counter {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
    color: var(--neutral-400);
    pointer-events: none;
    transition: color 0.3s ease;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem; 
}

@media (min-width: 640px) {
    .controls {
        flex-direction: row;
    }
}

.select-wrapper {
    position: relative;
    flex: 1;
}

select {
    width: 100%;
    appearance: none;
    border: 1px solid var(--neutral-200);
    border-radius: 0.5rem;
    padding: 0.625rem 1rem;
    padding-right: 2rem;
    outline: none;
    font-family: inherit;
    background-color: white;
    transition: all 0.3s ease;
}

select:focus {
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.5);
}

.select-arrow {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--neutral-400);
}

.select-arrow i {
    font-size: 0.75rem;
}

button {
    background-color: var(--primary);
    color: white;
    padding: 0.625rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    transition: all 0.3s ease;
}

button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

button i {
    margin-right: 0.5rem;
}

/* 文件拖放区域 */
.dropzone {
    border: 1px dashed var(--neutral-300);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    transition: all 0.3s ease;
    background-color: var(--neutral-50);
    cursor: pointer;
}

.dropzone:hover {
    border-color: rgba(76, 175, 80, 0.5);
}

.dropzone i {
    font-size: 1.5rem;
    color: var(--neutral-400);
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.dropzone p {
    font-size: 0.875rem;
    color: var(--neutral-500);
    margin: 0;
}

.dropzone label {
    display: inline-block;
    cursor: pointer;
    margin-top: 0.5rem;
}

.dropzone label span {
    display: inline-block;
    background-color: white;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    border: 1px solid rgba(76, 175, 80, 0.3);
    transition: all 0.3s ease;
}

.dropzone label span:hover {
    background-color: rgba(76, 175, 80, 0.05);
}

.dropzone input[type="file"] {
    display: none;
}

/* 输出区域样式 */
.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

#statusIndicator {
    display: none;
    align-items: center;
    font-size: 0.75rem;
    color: var(--neutral-500);
}

.pulse-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: var(--primary);
    margin-right: 0.25rem;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.chat-container {
    border: 1px solid var(--neutral-200);
    border-radius: 0.5rem;
    overflow: hidden;
    height: 25rem;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: var(--neutral-50);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* 自定义滚动条 */
.chat-messages::-webkit-scrollbar {
    width: 0.375rem;
}

.chat-messages::-webkit-scrollbar-track {
    background-color: var(--neutral-100);
    border-radius: 0.25rem;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--neutral-300);
    border-radius: 0.25rem;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: var(--neutral-400);
}

/* 消息气泡样式 */
.message-bubble {
    /* 移除固定max-width */
    max-width: min(85%, 800px); /* 设置上限防止过宽 */
    min-width: 200px; /* 设置最小宽度 */
    width: fit-content; /* 根据内容自适应 */
    padding: 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word; /* 智能换行 */
    position: relative;
    transition: all 0.3s ease;
}

/* 长内容特殊样式 */
.message-bubble.long-text {
    max-width: 90%;
    min-width: 280px;
    font-size: 0.875rem;
    padding: 1.2rem;
}

.message-bubble.long-text p {
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    padding-right: 0.8rem;
}

/* 移动端优化 */
@media (max-width: 640px) {
    .message-bubble {
        max-width: 92% !important;
        min-width: 160px !important;
    }
    
    .message-bubble.long-text p {
        max-height: 200px;
    }
}

/* 添加展开/收起功能 */
.message-toggle {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: var(--neutral-500);
    cursor: pointer;
    margin-top: 0.5rem;
}

.message-toggle:hover {
    color: var(--neutral-600);
}

.collapsed {
    max-height: 100px !important;
    overflow: hidden;
    position: relative;
}

.collapsed::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, rgba(255,255,255,0.9));
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-bubble {
    background-color: rgba(76, 175, 80, 0.1);
    color: var(--neutral-800);
    border-top-right-radius: 0;
    margin-left: auto;
}

.bot-bubble {
    background-color: white;
    color: var(--neutral-800);
    border-top-left-radius: 0;
    margin-right: auto;
}

.message-bubble p {
    font-size: 0.875rem;
    margin: 0;
}

.message-meta {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--neutral-400);
    display: flex;
    justify-content: space-between;
}

.chat-footer {
    border-top: 1px solid var(--neutral-200);
    padding: 0.75rem;
    background-color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--neutral-500);
}

#clearChat {
    background: none;
    border: none;
    color: var(--neutral-400);
    padding: 0;
    font-size: 0.875rem;
    transition: color 0.3s ease;
}

#clearChat:hover {
    color: var(--neutral-600);
    transform: none;
}

#clearChat i {
    margin-right: 0.25rem;
}

/* 页脚样式 */
footer {
    margin-top: 2.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--neutral-400);
}

/* 加载动画 */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 0.5rem;
}

.cute-bubble {
    background: linear-gradient(135deg, #FFB6C1 0%, #FF69B4 100%);
    color: white !important;
    border-radius: 18px !important;
    position: relative;
    width: fit-content;
    min-width: 200px;
}

.cute-bubble::after {
    content: "";
    position: absolute;
    bottom: -10px;
    right: -10px;
    width: 40px;
    height: 40px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="white" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z"/></svg>');
    opacity: 0.1;
}

@media (max-width: 640px) {
    .cute-bubble {
        min-width: 160px;
    }
}

/* 输入框抖动动画 */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    50% { transform: translateX(8px); }
    75% { transform: translateX(-4px); }
    100% { transform: translateX(0); }
}

.animate-shake {
    animation: shake 0.4s ease-in-out;
}