* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Open Sans, geomanist, Helvetica, Arial, sans-serif;
    position: relative;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(to bottom, #EEF8FE, #F6F6F6);
    overflow: hidden;
}

.background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(180deg, #7FA1F9 0%, #F3F6FC 21.71%);
}

.chat-container {
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative; 
}

.chat-header {
    color: #ffffff;
    padding-bottom: 30px;
    text-align: center;
    position: relative;
}

.chat-header .close-button {
    display: none;
    position: absolute;
    left: 16px;
    top: calc(17px);
    width: 24px;
    height: 24px;
    background: url(https://images.noviai.ai/noviaien/assets/ai_consultation/return-icon.svg);
    border: none;
}

.chat-header .close-button:hover {
    background: url(https://images.noviai.ai/noviaien/assets/ai_consultation/return-icon.svg);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.header-content h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    padding: 30px 20px;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    width: 100%;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
    background-color: transparent;
}

.chat-messages::-webkit-scrollbar-track {
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #E3E8F3;
    border-radius: 20px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #E3E8F3;
}

.chat-messages::-webkit-scrollbar-corner {
    background: #179a16;
}

.message {
    margin-bottom: 14px !important;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: calc(100%);
}

.message.user {
    flex-direction: row-reverse;
}

/* 不显示用户头像 */
.message.user .message-avatar {
    display: none !important;
}

.message-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar img {
    width: 52px;
    height: 52px;
}

.message-content {
    max-width: 70%;
    position: relative;
}

.message .message-content .message-text {
    border-top-left-radius: 0;
    border-radius: 10px;
    padding: 16px 20px;
    background: #F9FBFE;
    color: #191F37;
    font-size: 16px;
}

.message.user .message-content .message-text {
    border-radius: 10px;
    color: #FFFFFF;
    background: #217AFF;
}

.message-content .message-text ul,
.message-content .message-text ol {
    list-style-type: disc;
    padding-left: 24px;
    margin: 6px 0 6px 0;
}

.message-content .message-text li {
    margin-bottom: 3px;
    line-height: 1.7;
}

.message-actions {
    display: flex;
    margin-top: 8px;
    opacity: 1;
    transition: opacity 0.2s;
    justify-content: flex-end;
}

.message.bot:hover .message-actions {
    opacity: 1;
}

.action-button {
    background: none;
    border: none;
    margin: 0 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #191F37;
}

.action-button svg {
    display: none;
    width: 18px;
    height: 18px;
}

.action-button svg:first-child {
    display: block;
}

.action-button svg:last-child {
    display: none;
}

.action-button.active svg:first-child {
    display: none;
}

.action-button.active svg:last-child {
    display: block;
}

.action-button:hover svg:first-child {
    display: none;
}

.action-button:hover svg:last-child {
    display: block;
}

.action-button.processing {
    opacity: 0.5;
    pointer-events: none;
}

.action-button.disabled,
.send-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.faq-suggestions {
    margin-top: 15px;
    background: #F9FBFE;
    padding: 16px 20px;
    border-radius: 10px;
}

.faq-title {
    font-size: 16px;
    color: #2068F4;
    margin-bottom: 12px;
    font-weight: 500;
}

.faq-item {
    border-top: 1px solid rgba(216, 225, 242, 0.5);
    border-radius: 8px;
    padding: 9px 9px 9px 0;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
    color: #191F37;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-input-container {
    padding: 10px 0px 32px 0px;
    background: transparent;
    border-radius: 20px;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: #FFFFFF;
    border-radius: 12px;
    height: 86px;
    padding: 10px 18px;
}

.message-input {
    flex: 1;
    border: 0;
    outline: none;
    font-size: 14px;
    background: transparent;
    height: 100%;
    resize: none;
    font-family: SF Pro Text;
}

.message-input::placeholder {
    color: #ADAEB5;
}

.send-button {
    width: 36px;
    height: 36px;
    background: #2068F4;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    padding: 0;
    position: relative;
}

.send-button:not(.disabled) {
    background: #2068F4;
}

.send-button.disabled {
    background: transparent !important;
    cursor: not-allowed;
}

.send-button:disabled {
    background: transparent !important;
    cursor: not-allowed;
}

.send-button .send-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.send-button:not(.disabled) .send-icon.active {
    display: block;
}

.send-button.disabled .send-icon.disabled {
    display: block;
}

.send-button:disabled .send-icon.disabled {
    display: block;
}

.typing-indicator {
    height: 56px;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #191F37;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* 加载更多消息样式 */
.loading-more {
    text-align: center;
    padding: 10px;
    color: #666;
    font-size: 14px;
    background-color: #f5f5f5;
    border-radius: 10px;
    margin: 10px 0;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-10px);
    }
}

@media (max-width: 768px) {
    /* 更严格的 CSS 规则 */
    html {
        -webkit-text-size-adjust: 100% !important;
        text-size-adjust: 100% !important;
        touch-action: pan-x pan-y !important;
        -webkit-touch-callout: none !important;
        -webkit-user-drag: none !important;
        overscroll-behavior: none !important;
    }

    body {
        touch-action: pan-x pan-y !important;
        overscroll-behavior: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    html {
        height: 100vh;
        overflow: hidden !important;
    }

    body {
        align-items: flex-start;
        height: 100vh;
        overflow: hidden !important;
    }

    .chat-container {
        height: 100%;
        border-radius: 15px;
        overflow: hidden !important;
    }

    /* 移动端不需要这个header标题 */
    .chat-header {
        flex-shrink: 0;
        display: none;
        padding: 20px 12px;
    }

    .chat-header .close-button {
        display: block;
    }

    .header-content h1 {
        font-size: 1rem;
    }

    .chat-messages {
        margin-top: 0px;
        padding: 0px 16px 16px 16px;
        background: transparent;
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
        flex: 1;
        min-height: 0;
    }

    .message-content {
        max-width: calc(100% - 32px);
        padding: 0;
        font-size: 14px;
    }

    .message-avatar img {
        width: 30px;
        height: 30px;
    }

    .message .message-content .message-text {
        padding: 12px;
        font-size: 14px;
    }

    .action-button svg {
        width: 18px;
        height: 18px;
    }

    .typing-indicator {
        height: 38px;
    }

    .chat-input-container {
        /*position: fixed;*/
        flex-shrink: 0;
        /* 防止被压缩 */
        margin-top: auto;
        bottom: 0;
        width: 100vw;
        height: fit-content;
    }

    @supports (-webkit-touch-callout: none) {
        .chat-input-container {
            bottom: constant(safe-area-inset-bottom);
            bottom: env(safe-area-inset-bottom);
        }
    }

    .input-wrapper {
        display: flex;
        gap: 12px;
        align-items: center;
        background: #FFFFFF;
        border-radius: 12px;
        height: 42px;
        padding: 0px 3px 0px 0px;
        justify-content: center;
        width: 100%;
        max-width: calc(100% - 32px);
        margin: 0 16px;
    }

    .message-input {
        border-radius: 12px;
        height: 42px;
        padding: 5px 18px;
        line-height: calc(42px - 10px);
    }

    .faq-suggestions {
        padding: 12px;
        margin-top: 12px;
    }

    .faq-title {
        font-size: 14px;
        font-weight: 600;
    }

    .faq-item {
        font-size: 14px;
        font-weight: 400;
    }

    .typing-dot {
        width: 5px;
        height: 5px;
    }

}

/* Markdown样式优化 */
.message-content .message-text {
    line-height: 1.6 !important;
    font-size: 16px !important;
    width: calc(100%);
}

/* 标题样式 */
.message-content .message-text h1,
.message-content .message-text h2,
.message-content .message-text h3,
.message-content .message-text h4,
.message-content .message-text h5,
.message-content .message-text h6 {
    margin: 20px 0 12px 0 !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
}

.message-content .message-text h1 {
    font-size: 1.8em !important;
    border-bottom: 1px solid #eaecef !important;
    padding-bottom: 8px !important;
}

.message-content .message-text h2 {
    font-size: 1.5em !important;
    border-bottom: 1px solid #eaecef !important;
    padding-bottom: 6px !important;
}

.message-content .message-text h3 {
    font-size: 1.3em !important;
}

/* 段落和文字间距 */
.message-content .message-text p {
    font-size: 14px;
    font-weight: 400;
    margin: 12px 0 !important;
    line-height: 1.4 !important;
    word-wrap: break-word !important;
}

/* 列表样式优化 */
.message-content .message-text ul,
.message-content .message-text ol {
    max-width: 100%;
    margin: 12px 0 !important;
    padding-left: 28px !important;
}

.message-content .message-text li {
    margin-bottom: 8px !important;
    line-height: 1.4 !important;
}

.message-content .message-text li>p {
    margin: 6px 0 !important;
}

/* 代码块样式 */
.message-content .message-text pre {
    background-color: #f6f8fa !important;
    border-radius: 8px !important;
    padding: 16px !important;
    margin: 16px 0 !important;
    overflow-x: auto !important;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Droid Sans Mono', 'Courier New', monospace !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

.message-content .message-text code {
    background-color: #f1f3f4 !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    font-family: 'SF Mono', Monaco, Inconsolata, 'Fira Code', monospace !important;
    font-size: 14px !important;
    color: #e74c3c !important;
}

.message-content .message-text pre code {
    background-color: transparent !important;
    padding: 0 !important;
    color: inherit !important;
}

/* 引用样式 */
.message-content .message-text blockquote {
    border-left: 4px solid #4E5BFF !important;
    margin: 16px 0 !important;
    padding: 12px 16px !important;
    background-color: #f8f9ff !important;
    color: #555 !important;
    border-radius: 0 8px 8px 0 !important;
}

.message-content .message-text blockquote p {
    margin: 0 !important;
}

/* 表格样式 */
.message-content .message-text table {
    border-collapse: collapse !important;
    margin: 16px 0 !important;
    width: 100% !important;
}

.message-content .message-text th,
.message-content .message-text td {
    border: 1px solid #ddd !important;
    padding: 10px 12px !important;
    text-align: left !important;
}

.message-content .message-text th {
    background-color: #f6f8fa !important;
    font-weight: 600 !important;
}

/* 水平线 */
.message-content .message-text hr {
    margin: 24px 0 !important;
    border: none !important;
    border-top: 1px solid #eaecef !important;
}

/* 链接样式 */
.message-content .message-text a {
    word-wrap: break-word !important;
    color: #4E5BFF !important;
    text-decoration: none !important;
    transition: color 0.2s !important;
}

.message-content .message-text a:hover {
    color: #3442EF !important;
    text-decoration: underline !important;
}

/* 强调文本 */
.message-content .message-text strong {
    font-weight: 600 !important;
}

.message-content .message-text em {
    font-style: italic !important;
}

/* 消息内容内的额外间距 */
.message-content .message-text>*:first-child {
    margin-top: 0 !important;
}

.message-content .message-text>*:last-child {
    margin-bottom: 0 !important;
}

/* 移动端响应式调整 */
@media (max-width: 768px) {
    .message-content .message-text {
        font-size: 14px !important;
        font-weight: 400px !important;
        line-height: 1.2 !important;
    }

    .message-content .message-text h1 {
        font-size: 1.5em !important;
    }

    .message-content .message-text h2 {
        font-size: 1.3em !important;
    }

    .message-content .message-text h3 {
        font-size: 1.2em !important;
    }

    .message-content .message-text pre {
        font-size: 13px !important;
        padding: 12px !important;
    }

    .message-content .message-text code {
        font-size: 13px !important;
    }

    .message-content .message-text ul,
    .message-content .message-text ol {
        padding-left: 20px !important;
    }

    .message-content .message-text li {
        margin-bottom: 6px !important;
    }
}

/* 增强代码块的可读性 */
.message-content .message-text pre::-webkit-scrollbar {
    height: 6px !important;
}

.message-content .message-text pre::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 3px !important;
}

.message-content .message-text pre::-webkit-scrollbar-thumb {
    background: #c1c1c1 !important;
    border-radius: 3px !important;
}

.message-content .message-text pre::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8 !important;
}