/* 全局重置和基础设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: Serif Georgia, sans-serif;
}

/* 背景图片容器 */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('img/bookstory.png');
    background-size: cover;
    background-position: center;
    z-index: -1;
}

/* 打开侧边栏按钮 */
.open-sidebar-btn {
    position: fixed;
    top: 6px;
    left: 18px;
    width: 45px;
    height: 45px;
    background-image: url('img/Edge-Close-Icon.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
    filter: brightness(0) invert(1); /* 转为白色 */
    border: none;
    cursor: pointer;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.open-sidebar-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    top: 0;
    left: -340px; /* 初始隐藏 */
    width: 325px;
    height: 100vh;
    background-color: #ECECEC;
    transition: left 0.3s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.sidebar.expanded {
    left: 0;
}

/* 侧边栏顶部区域 */
.sidebar-header {
    background-color: white;
    padding: 6px 13px;
    display: flex;
    align-items: center;
    height: 50px;
}

.sidebar-logo {
    width: 30px;
    height: 30px;
    margin-right: 13px;
}

.sidebar-title {
    font-size: 16px;
    color: #33404d;
    font-weight: bold;
    flex: 1;
}

.close-sidebar-btn {
    width: 42px;
    height: 42px;
    background-image: url('img/Edge-Close-Icon.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
    border: none;
    cursor: pointer;
    margin-right: 8px;
}

/* 侧边栏分隔线 */
.sidebar-divider {
    width: 100%;
    height: 1px;
    background-color: black;

}

.sidebar-divider-top {
    margin-top: 0px;
}

.sidebar-divider-bottom {
    margin-top: auto;
    margin-bottom: 0;
}

/* 选项区域 */
.sidebar-options {
    padding: 5px 0;
}

.sidebar-option {
    position: relative;
    display: flex;
    align-items: center;
    padding: 8px 30px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.sidebar-option:not(:first-child) {
    margin-top: 10px;
}

.sidebar-option.selected {
    color: white;
}

.sidebar-option.selected .option-text {
    color: white;
}

.sidebar-option::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 305px;
    height: 47px;
    background-color:#c04147;
    border-radius: 25px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: -1;
}

.sidebar-option.selected::before {
    opacity: 1;
}

.option-icon {
    width: 25px;
    height: 25px;
    margin-right: 10px;
}

.option-text {
    font-size: 15px;
    color: #33404d;
}

/* 最近对话标题 */
.recent-conversations-title {
    padding: 5px 20px;
    color: #33404da3;
    font-size: 14px;
}

/* 最近对话列表 */
.recent-conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
    margin-bottom: 5px;
}

.recent-conversation-item {
    padding: 5px 0;
    font-size: 14px;
    color: #33404d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 290px;
    cursor: pointer;
}

.recent-conversation-item::before {
    content: '·';
    margin-right: 10px;
}

/* 用户登录区域 */
.user-profile-area {
    background-color: white;
    padding: 6px 25px;
    display: flex;
    align-items: center;
    height: 50px;
}

.user-avatar-btn {
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    margin-right: 25px;
}

.user-avatar {
    width: 27px;
    height: 27px;
}

.username {
    font-size: 14px;
    color: black;
    margin-right: 95px;
}

.upgrade-btn {
    width: 88px;
    height: 24px;
    background-color: #ffffff;
    border-radius: 999px;
    border: 1px solid #e3e3e3;
    color: #33404d;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 角色图像 */
.character-image-container {
    position: fixed;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%)scale(2.9);
    transition: transform 0.3s ease;
    z-index: 50;

}

.character-image-container.sidebar-expanded {
    transform: translate(calc(-50% + 180px), -50%)scale(2.9);
}

.character-image {
    width: 200px;
    height: auto;
    object-fit: contain;
    display: block;
    transition: opacity 0.5s ease;
}

/* 备用视频元素样式 */
#backup-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.5s ease;
}

/* 角色交互对话框 */
.character-dialogue-box {
    position: fixed;
    bottom: 210px;
    left: 50%;
    transform: translateX(-50%);
    width: 1040px;
    height: 50px;
    background-color: #df444cc0;
    border-radius: 25px;
    padding: 12.5px 20px;
    z-index: 60;
    transition: all 0.3s ease;
    color: white;
}

.character-dialogue-box.sidebar-expanded {
    width: calc(1040px - 130px);
    transform: translateX(calc(-50% + 180px));
}

/* 强调文本样式 */
strong {
    font-weight: bold;
    color: #ffffff;
    font-size: 1.05em;
}

/* 用户交互对话框 */
.user-dialogue-box {
    position: fixed;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%);
    width: 1040px;
    height: 96px;
    background-color: #f6f6f6f3;
    border-radius: 25px;
    display: flex;
    align-items: center;
    padding: 20px;
    z-index: 70;
    transition: all 0.3s ease;
}

.user-dialogue-box.sidebar-expanded {
    width: calc(1040px - 130px);
    transform: translateX(calc(-50% + 180px));
}

.user-input {
    flex: 1;
    height: 100%;
    border: none;
    background: none;
    outline: none;
    font-size: 16px;
    color: rgb(0, 0, 0);
}

.send-btn {
    width: 30px;
    height: 30px;
    background-image: url('img/Black-Cat-Button.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
    cursor: pointer;
    margin-left: auto;

    /* 添加相对定位并下移 */
    position: relative;
    top: 20px; /* 根据需要调整下移距离 */
}

.hidden {
    display: none !important;
}

/* 可拖拽按钮 */
.draggable-btn {
    position: fixed;
    top: 6px;
    right: 18px;
    width: 40px;
    height: 40px;
    background-image: url('img/Q-Style.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
    border: none;
    cursor: grab;
    z-index: 160;
}

.draggable-btn:active {
    cursor: grabbing;
}

/* 卡牌仓库按钮 */
.card-wareHouse-btn {
    position: fixed;
    top: 6px;
    right: 75px;
    width: 30px;
    height: 40px;
    background-image: url('img/card-wareHouse-btn.jpeg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
    cursor: pointer;
    z-index: 160;
}

/* 历史记录对话框 */
.history-dialog {
    position: fixed;
    top: 50px;
    right: 50px;
    width: 259px;
    height: 338px;
    background-color: #f8f8f8;
    border-radius: 20px;
    z-index: 250;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    resize: both;
    min-width: 200px;
    min-height: 200px;
}

.history-dialog-header {
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.history-dialog-title {
    font-size: 16px;
    color: #000;
    text-align: center;
}

.history-dialog-close {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.history-dialog-divider {
    width: 100%;
    height: 1px;
    background-color: #ddd;
    margin-bottom: 10px;
}

.history-dialog-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* 历史消息样式 */
.message {
    display: flex;
    margin-bottom: 15px;
}

.message.ai {
    justify-content: flex-start;
}

.message.user {
    justify-content: flex-end;
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
}

.message-bubble {
    max-width: 130px;
    background-color: #c04147;
    color: white;
    padding: 10px;
    border-radius: 25px;
    margin: 0 8px;
    word-wrap: break-word;
    font-size: 14px;
}

.message.ai .message-bubble {
    border-bottom-left-radius: 5px;
}

.message.user .message-bubble {
    border-bottom-right-radius: 5px;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .character-dialogue-box,
    .user-dialogue-box {
        width: 90%;
        max-width: 1040px;
    }
    
    .character-dialogue-box.sidebar-expanded,
    .user-dialogue-box.sidebar-expanded {
        width: calc(90% - 330px);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        left: -100%;
    }
    
    .character-dialogue-box.sidebar-expanded,
    .user-dialogue-box.sidebar-expanded {
        width: 90%;
        transform: translateX(-50%);
    }
    
    .character-image-container.sidebar-expanded {
        transform: translate(-50%, -50%);
    }
}

/* 滚动条样式 */
.recent-conversations-list::-webkit-scrollbar,
.history-dialog-content::-webkit-scrollbar {
    width: 6px;
}

.recent-conversations-list::-webkit-scrollbar-track,
.history-dialog-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.recent-conversations-list::-webkit-scrollbar-thumb,
.history-dialog-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.recent-conversations-list::-webkit-scrollbar-thumb:hover,
.history-dialog-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

