/* --- 全局与重置 --- */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: #f0f2f5;
    color: #1c1e21;
    line-height: 1.5;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* --- 认证页面 (登录/注册) --- */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f0f2f5;
}

.auth-container {
    padding: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-container h2 {
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
}

.auth-container form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-container input {
    padding: 0.75rem;
    border: 1px solid #dddfe2;
    border-radius: 6px;
    font-size: 1rem;
}

.auth-container button {
    padding: 0.75rem;
    border: none;
    border-radius: 6px;
    background-color: #007bff;
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.auth-container button:hover {
    background-color: #0056b3;
}

.auth-container p {
    margin-top: 1rem;
}

.error-message {
    color: #fa383e;
    min-height: 1.2em;
    font-size: 0.9em;
}

/* --- 主应用页面 --- */
#app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    padding-right: 2.5rem; /* 为AI侧边栏手柄留出空间 */
}

header {
    margin-bottom: 2rem;
    position: relative;
}

header .user-info {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.9em;
    color: #606770;
}

header .user-info #logout-btn {
    margin-left: 10px;
    border: none;
    background: transparent;
    color: #007bff;
    cursor: pointer;
    font-size: 1em;
}

header h1 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

#search-box {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1.1rem;
    border: 1px solid #ccc;
    border-radius: 25px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* --- 导航网格 --- */
#navigation-grid .category {
    margin-bottom: 2.5rem;
}

#navigation-grid .category-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e0e0e0;
}

#navigation-grid .sites-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

#navigation-grid .site-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

#navigation-grid .site-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

#navigation-grid .site-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.5rem;
}

#navigation-grid .site-icon {
    width: 32px;
    height: 32px;
}

#navigation-grid .site-name {
    font-size: 1.1rem;
    font-weight: 600;
}

#navigation-grid .site-description {
    font-size: 0.9em;
    color: #606770;
}

/* --- AI 侧边栏 --- */
#ai-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100%;
    background: #ffffff;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

#ai-sidebar.open {
    transform: translateX(0);
}

#ai-sidebar-handle {
    position: absolute;
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 80px;
    background: #007bff;
    color: white;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px 0 0 8px;
    font-weight: bold;
    font-size: 1.1rem;
}

#ai-sidebar-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.ai-header h3 {
    margin: 0;
    text-align: center;
}

#chat-window {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

.chat-message {
    margin-bottom: 1rem;
    max-width: 90%;
}

.chat-message p {
    margin: 0;
    padding: 0.7rem 1rem;
    border-radius: 18px;
    line-height: 1.4;
}

.chat-message.user {
    margin-left: auto;
}

.chat-message.user p {
    background-color: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant p {
    background-color: #e9e9eb;
    color: #1c1e21;
    border-bottom-left-radius: 4px;
}

#chat-input-container {
    display: flex;
    padding: 1rem;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
}

#chat-input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 18px;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    resize: none;
}

#send-btn {
    border: none;
    background-color: #007bff;
    color: white;
    font-weight: bold;
    padding: 0 1rem;
    border-radius: 18px;
    cursor: pointer;
}

/* --- 响应式设计 --- */
@media (max-width: 768px) {
    #app-container {
        padding-right: 1.5rem;
    }
    #ai-sidebar {
        width: 100%;
        transform: translateX(100%);
    }
    #navigation-grid .sites-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}
/* 在 style.css 中添加 */

/* 更新 .ai-header 的样式，使其能容纳头像 */
.ai-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

/* 为头像图片添加新样式 */
.ai-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%; /* 圆形头像 */
    object-fit: cover; /* 防止图片变形 */
    background-color: #f0f2f5; /* 图片加载前的占位颜色 */
}

/* 确保 h3 元素没有额外的边距 */
.ai-header h3 {
    margin: 0;
    text-align: left; /* 取消居中 */
}