/* -------------------- 基础样式 (Grok 风格) -------------------- */
body {
    font-family: 'Roboto Mono', monospace;
    background-color: #121212;
    color: #e0e0e0;
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#main-view {
    display: flex;
    width: 100%;
    max-width: 1400px;
    height: 100%;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    background-color: #1a1a1a;
}

.sidebar {
    width: 250px;
    min-width: 180px; 
    background-color: #191919;
    padding: 20px;
    border-right: 1px solid #222;
    display: flex;
    flex-direction: column; 
}

.logo-text {
    color: #00c7e2;
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 20px;
}
.logo-text.mini {
    font-size: 1.4em;
    margin-bottom: 30px;
}

/* 默认隐藏在移动端收缩的按钮 */
.sidebar-button.mobile-hidden {
    display: block; 
}
#logout-button.mobile-hidden {
    display: none !important;
}


.sidebar-button {
    padding: 12px;
    margin-bottom: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Roboto Mono', monospace;
    transition: background-color 0.3s;
}

.sidebar-button.primary {
    background-color: #00c7e2;
    color: #121212;
}
.sidebar-button.primary:hover {
    background-color: #00a0b8;
}

.sidebar-button.secondary {
    background-color: #2a2a2a;
    color: #e0e0e0;
}
.sidebar-button.secondary:hover {
    background-color: #383838;
}

/* -------------------- 聊天区域样式 -------------------- */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 20px;
}

.chat-container {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 10px; 
}

/* 消息基础样式 */
.message {
    padding: 12px 18px; 
    margin-bottom: 15px;
    max-width: 80%;
    border-radius: 20px; 
    font-size: 0.95em;
    line-height: 1.5;
    word-wrap: break-word;
    animation-duration: 0.5s; 
    animation-fill-mode: forwards;
    opacity: 0; 
}

.message p {
    margin: 0;
}

/* 用户消息 (右侧) */
.message.user {
    background-color: #007bff;
    color: white;
    margin-left: auto;
    border-top-right-radius: 4px;
}

/* AI 助手消息 (左侧) */
.message.assistant {
    background-color: #2a2a2a;
    color: #e0e0e0;
    margin-right: auto;
    border-top-left-radius: 4px; 
    width: 0;
    padding: 12px 0;
    overflow: hidden; 
}

.chat-scroll-sentinel {
    height: 60vh;
    pointer-events: none;
}

/* AI 消息展开动画 */
@keyframes expand-message {
    to {
        width: auto;
        padding: 12px 18px;
        opacity: 1;
        max-width: 80%;
    }
}
.message.assistant.animate-in {
    animation-name: expand-message;
    animation-timing-function: ease-out;
}


/* -------------------- 高级动画效果 -------------------- */

/* 1. 用户消息漂移效果 */
@keyframes fade-in-up {
    0% {
        transform: translateY(30px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}
.message.user {
    animation-name: fade-in-up;
    animation-delay: 0.1s; 
}

/* 2. AI 正在思考 (加载) 消息 - 呼吸动画 */
@keyframes pulse {
    0% { background-color: #202020; border-left-color: #00c7e250; } 
    50% { background-color: #333333; border-left-color: #00c7e2; }
    100% { background-color: #202020; border-left-color: #00c7e250; } 
}

.message.assistant.loading {
    margin-right: auto;
    background-color: #2a2a2a;
    border-left: 3px solid #00c7e2;
    color: #ccc;
    font-style: italic;
    
    animation-name: pulse;
    animation-duration: 1.5s; 
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;

    width: auto;
    opacity: 1;
    padding: 12px 18px;
    border-radius: 20px;
}

.message.assistant.loading .spinner {
    display: none;
}


/* -------------------- 输入区域样式 -------------------- */
.input-area {
    display: flex;
    padding-top: 20px;
    border-top: 1px solid #222;
}

#message-input {
    flex-grow: 1;
    padding: 15px;
    border: 1px solid #333;
    border-radius: 8px;
    background-color: #222;
    color: #e0e0e0;
    font-family: 'Roboto Mono', monospace;
    resize: none;
    max-height: 150px;
}
#message-input:focus {
    border-color: #00c7e2;
    outline: none;
}

.send-button {
    padding: 15px 25px;
    margin-left: 10px;
    border: none;
    border-radius: 8px;
    background-color: #00c7e2;
    color: #121212;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s;
}
.send-button:hover:enabled {
    background-color: #00a0b8;
}
.send-button:disabled {
    background-color: #3a3a3a;
    cursor: not-allowed;
    color: #666;
}

/* -------------------- 错误和管理面板样式 -------------------- */
.message.error {
    background-color: #440000;
    border-left: 3px solid red;
    color: #ffcccc;
    margin-right: auto;
    font-style: italic;
    opacity: 1;
    border-radius: 20px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.card {
    background-color: #1a1a1a;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.login-card {
    width: 350px;
    text-align: center;
    position: relative; 
}

.admin-card {
    width: 90%;
    max-width: 600px;
    position: relative;
}

.neon-title {
    color: #00c7e2;
    text-shadow: 0 0 5px #00c7e280;
    margin-top: 0;
    margin-bottom: 25px;
}

.close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2em;
    color: #888;
    cursor: pointer;
    transition: color 0.3s;
}
.close-button:hover {
    color: #e0e0e0;
}

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

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #ccc;
    font-weight: 700;
}

.input-group input[type="text"],
.input-group input[type="password"],
.input-group input[type="url"],
.input-group input[type="number"],
.input-group textarea,
#login-form input[type="text"],
#login-form input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #333;
    border-radius: 6px;
    background-color: #222;
    color: #e0e0e0;
    font-family: 'Roboto Mono', monospace;
    box-sizing: border-box;
    margin-bottom: 10px; 
    display: block; 
}

.input-group textarea {
    min-height: 100px;
    resize: vertical;
}

.input-group small {
    display: block;
    margin-top: 5px;
    font-size: 0.8em;
    color: #999;
}

.submit-button {
    width: 100%;
    padding: 15px;
    margin-top: 10px;
    border: none;
    border-radius: 8px;
    background-color: #00c7e2;
    color: #121212;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s;
}
.submit-button:hover {
    background-color: #00a0b8;
}

/* -------------------- 响应式设计 (手机支持) -------------------- */
@media (max-width: 768px) {
    body {
        align-items: flex-start;
    }
    
    #main-view {
        width: 100%;
        height: 100%;
        flex-direction: column; 
        max-width: 100%;
    }

    /* 侧边栏：水平排列，收缩功能按钮 */
    .sidebar {
        width: 100%;
        min-width: 100%;
        padding: 15px;
        border-right: none;
        border-bottom: 1px solid #222;
        flex-direction: row; 
        align-items: center;
        justify-content: flex-start; /* 保持 Logo 和配置在左侧 */
        gap: 10px;
    }
    
    .logo-text.mini {
        margin-bottom: 0;
        flex-shrink: 0;
        font-size: 1.2em;
        margin-right: auto; /* Logo 和配置管理之间拉开距离 */
    }

    /* 修复点 1：隐藏手机端的新建对话和登出按钮 */
    .sidebar-button.mobile-hidden, 
    #logout-button {
        display: none !important; 
    }
    
    /* 配置按钮在手机端始终显示 */
    #show-config-button {
        flex-shrink: 0; 
        padding: 8px 10px;
        margin-bottom: 0;
        font-size: 0.9em;
    }
    
    .chat-area {
        padding: 10px;
        flex: 1;
        overflow: hidden; 
    }

    .message {
        max-width: 95%;
    }
    
    .input-area {
        padding: 10px 0;
    }

    #login-form input[type="text"],
    #login-form input[type="password"] {
        margin-bottom: 10px;
    }
    
    #message-input {
        padding: 10px;
        font-size: 1em;
    }

    .send-button {
        padding: 10px 15px;
    }
    
    .admin-card {
        width: 95%;
        padding: 20px;
    }
}
