/* ==================================
1. 全局重置与专属绿色网格背景
================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    /* 基础背景颜色 */
    background-color: #e2e8f0;

    /* 核心网格线逻辑 */
    background-image:
      linear-gradient(rgba(22, 163, 74, 0.06) 1px, transparent 1px),
      linear-gradient(90deg, rgba(22, 163, 74, 0.06) 1px, transparent 1px);
    
    /* 网格尺寸大小 */
    background-size: 2.75rem 2.75rem;

    /* 让背景保持不动的核心设置 */
    background-attachment: fixed;
    background-repeat: repeat;
    
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* ==================================
2. 登录鉴权全屏弹窗 (修复了定位与高级毛玻璃感)
================================== */
.auth-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(226, 232, 240, 0.4); /* 自然融入网格背景 */
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    width: 100vw;
    height: 100vh;
}

.auth-modal {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 24px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 28px;
    animation: fadeIn 0.5s ease-out forwards;
}

.auth-header { text-align: center; }
.auth-header h2 { 
    font-size: 28px; 
    color: #1e293b; 
    margin-bottom: 8px; 
    font-weight: 600;
    background: linear-gradient(90deg, #16a34a, #0d9488);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.auth-header p { font-size: 14px; color: #64748b; }

.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-form input {
    width: 100%;
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.6);
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
}
.auth-form input:focus { 
    border-color: #16a34a; 
    background: #fff; 
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.1);
}

.auth-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

.btn-primary {
    background: #16a34a;
    color: white;
    border: none;
    border-radius: 14px;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.2);
}
.btn-primary:hover { background: #15803d; }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: rgba(255, 255, 255, 0.8);
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 14px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover { background: #f8fafc; color: #1e293b; border-color: #94a3b8; }

.auth-message {
    text-align: center;
    font-size: 13px;
    color: #ef4444;
    min-height: 20px;
    font-weight: 500;
}

/* ==================================
3. 主工作区大容器 (修复了百分比高度坍塌)
================================== */
.app-container {
    width: 95vw;
    height: 95vh;
    max-width: 1500px;
    background: rgba(255, 255, 255, 0.45); /* 半透出网格底色 */
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    box-shadow: 0 12px 48px rgba(31, 41, 55, 0.06);
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ==================================
4. 左侧侧边栏组件设计
================================== */
.sidebar {
    width: 280px;
    background: rgba(248, 250, 252, 0.5); 
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex-shrink: 0; /* 防止被挤压 */
}

.logo-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
}
.logo-area h2 {
    font-size: 18px;
    color: #1e293b;
    font-weight: 600;
}
.user-badge {
    font-size: 11px;
    background: rgba(22, 163, 74, 0.1);
    color: #16a34a;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.new-chat-btn {
    background: rgba(255, 255, 255, 0.8);
    color: #334155;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}
.new-chat-btn:hover {
    background: #f1f5f9;
    color: #16a34a;
    border-color: rgba(22, 163, 74, 0.2);
}

.history-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}
.history-title {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    padding-left: 8px;
}
.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.05); border-radius: 4px; }

.history-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.02);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
}
.history-item:hover {
    background: rgba(22, 163, 74, 0.08);
    border-color: rgba(22, 163, 74, 0.15);
}
.history-item-text {
    font-size: 13.5px;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.history-item-time {
    font-size: 11px;
    color: #94a3b8;
    font-family: monospace;
}

/* ==================================
5. 右侧主内容聊天区域
================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background: transparent;
}

.chat-history-box {
    flex: 1;
    overflow-y: auto;
    padding: 40px 24px 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    scroll-behavior: smooth;
}
.chat-history-box::-webkit-scrollbar { width: 6px; }
.chat-history-box::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.08); border-radius: 10px; }

.greeting-area { margin: auto 0; text-align: center; }
.greeting-area h1 {
    font-size: 32px;
    color: #334155;
    font-weight: 500;
    background: linear-gradient(90deg, #16a34a, #0d9488);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 对话气泡 */
.message-row {
    width: 100%;
    max-width: 900px;
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s ease-out forwards;
}
.message-user { align-items: flex-end; }
.message-user .bubble {
    background: #f1f5f9;
    color: #1e293b;
    padding: 12px 20px;
    border-radius: 18px 18px 4px 18px;
    font-size: 15px;
    line-height: 1.5;
    max-width: 80%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.01);
}

.message-ai { align-items: center; }
.message-ai .image-container {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 300px;
    min-height: 200px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.03);
}
.message-ai img {
    max-width: 100%;
    max-height: 600px;
    border-radius: 8px;
    object-fit: contain;
}

/* ==================================
6. 底部固定输入区控制台
================================== */
.fixed-input-area {
    padding: 0 24px 24px 24px;
    display: flex;
    justify-content: center;
    background: linear-gradient(to top, rgba(226, 232, 240, 1) 0%, rgba(226, 232, 240, 0) 100__);
}

.input-wrapper {
    width: 100%;
    max-width: 900px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.05); 
    border: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.input-main {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    align-items: flex-end;
}

#prompt-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 16px;
    min-height: 50px;
    max-height: 200px;
    line-height: 1.5;
    background: transparent;
    color: #0f172a;
}

#generate-btn {
    background: #16a34a;
    color: white;
    border: none;
    border-radius: 14px;
    padding: 0 24px;
    height: 44px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
#generate-btn:hover { background: #15803d; }
#generate-btn:active { transform: scale(0.98); }
#generate-btn:disabled { background: #cbd5e1; cursor: not-allowed; }

.input-toolbar {
    display: flex;
    gap: 20px;
    padding: 10px 20px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    align-items: center;
}

.toolbar-item { display: flex; align-items: center; gap: 6px; }
.toolbar-item .icon { font-size: 13px; color: #64748b; font-weight: 500; }
.toolbar-item select {
    border: none;
    background: transparent;
    font-size: 13px;
    color: #334155;
    outline: none;
    cursor: pointer;
    padding: 4px 0;
    font-weight: 500;
}
.toolbar-item select:hover { color: #16a34a; }

/* ==================================
7. 交互动画关键帧
================================== */
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; color: #16a34a; }
    100% { opacity: 0.6; }
}

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