/* 基础样式 & 布局 - Odoo 18 原生风格 */
body {
    background: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    font-size: 14px;
    line-height: 1.5;
    color: #212529;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    box-sizing: border-box;
}

/* 应用容器 - 无缝嵌入Odoo */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    margin: 0;
    background: #ffffff;
    border: none;
    box-shadow: none;
}

/* 侧边栏 - Odoo 18 原生风格 */
.sidebar {
    width: 260px;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 10;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

/* 侧边栏遮罩层（仅移动端） */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    background: #ffffff;
    display: flex;
    gap: 8px;
}

.new-session-btn {
    flex: 1;
    padding: 8px 12px;
    background: #875A7B;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.new-session-btn:hover {
    background: #714B67;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.new-session-btn .icon {
    font-size: 18px;
    font-weight: bold;
}

.toggle-sidebar-btn {
    padding: 6px 10px;
    background: transparent;
    color: #6c757d;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s ease;
}

.toggle-sidebar-btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #495057;
}

/* 桌面端展开按钮（侧边栏收起时显示） */
.desktop-expand-btn {
    display: none;
    padding: 6px 10px;
    background: transparent;
    color: #875A7B;
    border: 1px solid #875A7B;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
    transition: all 0.15s ease;
}

.desktop-expand-btn:hover {
    background: #875A7B;
    color: white;
}

.sidebar.collapsed ~ .chat-container .desktop-expand-btn {
    display: block;
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    background: #ffffff;
}

.session-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.session-item:hover {
    background: #f8f9fa;
    border-color: #dee2e6;
}

.session-item.active {
    background: #e7e3e6;
    border-color: #875A7B;
    border-left: 3px solid #875A7B;
}

.session-item-title {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #212529;
}

.session-item.active .session-item-title {
    color: #875A7B;
    font-weight: 600;
}

.session-item-time {
    font-size: 11px;
    color: #6c757d;
}

.session-item.active .session-item-time {
    color: #875A7B;
}

.session-item-delete {
    float: right;
    color: #dc3545;
    font-size: 14px;
    display: none;
    transition: color 0.15s ease;
    opacity: 0.7;
}

.session-item:hover .session-item-delete {
    display: inline;
}

.session-item-delete:hover {
    color: #c82333;
    opacity: 1;
}

.session-item.active .session-item-delete {
    color: #875A7B;
    opacity: 0.8;
}

/* 主聊天容器 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
}

/* 头部样式 - Odoo 18 原生风格 */
.chat-header {
    background-color: #ffffff;
    color: #212529;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    color: #212529;
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: #6c757d;
    font-size: 20px;
    cursor: pointer;
    padding: 6px 8px;
    margin-right: 8px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.mobile-menu-btn:hover {
    background: #f8f9fa;
    color: #495057;
}

#connection-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
}

#connection-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.status-connected {
    color: #28a745;
    border-color: #c3e6cb;
    background: #d4edda;
}
.status-connected::before {
    background-color: #28a745;
    animation: pulse 2s infinite;
}

.status-disconnected {
    color: #dc3545;
    border-color: #f5c6cb;
    background: #f8d7da;
}
.status-disconnected::before {
    background-color: #dc3545;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

/* 聊天框样式 */
.chat-box {
    flex-grow: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: #ffffff;
    border-bottom: 1px solid #dee2e6;
}

.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    max-width: 75%;
}

.message .sender {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 6px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message .content {
    padding: 10px 14px;
    border-radius: 8px;
    line-height: 1.5;
    font-size: 14px;
}

.user-message {
    align-self: flex-end;
    align-items: flex-end;
}

.user-message .content {
    background-color: #875A7B;
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message {
    align-self: flex-start;
    align-items: flex-start;
}

.bot-message .sender {
    color: #6c757d;
}

.bot-message .content {
    background-color: #f8f9fa;
    color: #212529;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 4px;
}

/* 新增: AI思考中样式 */
.thinking .content {
    display: flex;
    align-items: center;
}

.thinking .content .dot-flashing {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 4px;
    background-color: #6c757d;
    color: #6c757d;
    animation: dotFlashing 1s infinite linear alternate;
    animation-delay: .5s;
}

.thinking .content .dot-flashing::before, .thinking .content .dot-flashing::after {
    content: '';
    display: inline-block;
    position: absolute;
    top: 0;
}

.thinking .content .dot-flashing::before {
    left: -12px;
    width: 8px;
    height: 8px;
    border-radius: 4px;
    background-color: #6c757d;
    color: #6c757d;
    animation: dotFlashing 1s infinite alternate;
    animation-delay: 0s;
}

.thinking .content .dot-flashing::after {
    left: 12px;
    width: 8px;
    height: 8px;
    border-radius: 4px;
    background-color: #6c757d;
    color: #6c757d;
    animation: dotFlashing 1s infinite alternate;
    animation-delay: 1s;
}

@keyframes dotFlashing {
    0% {
        background-color: #6c757d;
    }
    50%,
    100% {
        background-color: #dee2e6;
    }
}


.system-message .content {
    font-style: italic;
    color: #6c757d;
    text-align: center;
    background-color: transparent;
    padding: 4px 0;
    font-size: 12px;
}


/* 输入区域样式 */
.chat-input-area {
    display: flex;
    padding: 12px 16px;
    background-color: #ffffff;
    border-top: 1px solid #dee2e6;
    align-items: flex-end;
    gap: 8px;
}

#message-input {
    flex-grow: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    min-height: 38px;
    max-height: 120px;
}

#message-input:focus {
    outline: none;
    border-color: #875A7B;
    box-shadow: 0 0 0 0.2rem rgba(135, 90, 123, 0.25);
}

#send-button {
    padding: 8px 20px;
    background-color: #875A7B;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s ease;
    white-space: nowrap;
    min-height: 38px;
}

#send-button:hover:not(:disabled) {
    background-color: #714B67;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#send-button:disabled {
    background-color: #adb5bd;
    cursor: not-allowed;
    opacity: 0.65;
}

/* 响应式设计 - 移动端 */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    .app-container {
        max-width: 100%;
        overflow: hidden;
    }

    /* 移动端侧边栏 */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        transform: translateX(-100%); /* 默认隐藏 */
    }

    .sidebar:not(.collapsed) {
        transform: translateX(0); /* 显示时滑入 */
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    /* 隐藏桌面端的收起按钮 */
    .toggle-sidebar-btn {
        display: none;
    }

    /* 显示移动端菜单按钮 */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        color: #2d5016;
        font-size: 24px;
        cursor: pointer;
        padding: 0;
        margin-right: 10px;
    }

    /* 隐藏桌面端展开按钮 */
    .desktop-expand-btn {
        display: none !important;
    }

    /* 聊天容器占满屏幕 */
    .chat-container {
        width: 100%;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .chat-header {
        padding: 12px 15px;
        flex-shrink: 0;
    }

    .chat-header h2 {
        font-size: 1.1em;
        margin: 0;
    }

    /* 聊天框自适应高度 */
    .chat-box {
        padding: 10px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 输入区域优化 */
    .chat-input-area {
        padding: 10px;
        flex-shrink: 0;
        background: #ffffff;
        border-top: 1px solid #d0e0d0;
    }

    #message-input {
        padding: 10px 12px;
        font-size: 16px; /* 防止 iOS 自动缩放 */
        min-height: 44px; /* iOS 最小触摸目标 */
        max-height: 120px;
        resize: none;
    }

    #send-button {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px;
    }

    /* 消息气泡优化 */
    .message {
        max-width: 85%;
        font-size: 14px;
    }

    .message-content {
        padding: 10px 14px;
    }

    /* 会话列表项优化 */
    .session-item {
        padding: 10px 12px;
        margin-bottom: 6px;
    }

    .session-item-title {
        font-size: 14px;
    }

    .session-item-time {
        font-size: 11px;
    }
}

/* 评分容器 */
.rating-container {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rating-label {
    font-size: 12px;
    color: #6c757d;
    font-weight: 500;
}

.rating-stars {
    display: flex;
    gap: 2px;
}

.star {
    font-size: 18px;
    color: #dee2e6;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    line-height: 1;
}

.star:hover,
.star.hover {
    color: #ffc107;
    transform: scale(1.1);
}

.star.selected {
    color: #ffc107;
}

.rating-status {
    font-size: 12px;
    margin-left: 8px;
    font-weight: 500;
    color: #28a745;
}

/* 桌面端优化 */
@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
}

