/* =========================================================
   AI PANEL
========================================================= */

/* =========================================================
   AI PANEL
   AI 助手面板：蓝色边框 + 柔和阴影
   ========================================================= */

.ai-panel {
    /* 浅蓝色边框，让面板更加醒目 */
    border: 1px solid #93b4ff;

    /* 圆角 */
    border-radius: 12px;

    /* 白色背景 */
    background: #ffffff;

    /* 隐藏超出圆角的内容 */
    overflow: hidden;

    /* 柔和的蓝色阴影，突出面板 */
    box-shadow:
        0 0 0 2px rgba(86, 103, 232, 0.06),
        0 4px 16px rgba(59, 104, 210, 0.10);

    /* 平滑过渡 */
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

/* 鼠标悬停时加深边框 */
.ai-panel:hover {
    border-color: #667eea;

    box-shadow:
        0 0 0 2px rgba(86, 103, 232, 0.08),
        0 6px 20px rgba(59, 104, 210, 0.14);
}


/* =========================================================
   AI HEADER
========================================================= */

.ai-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    padding: 13px 14px;

    border-bottom: 1px solid #edf0f4;
}

.ai-panel-head>div {
    min-width: 0;
}

.ai-panel-head h3 {
    margin: 2px 0 0;

    font-size: 14px;
    line-height: 1.3;

    font-weight: 700;

    color: #202532;
}

.ai-panel-head .icon-btn {
    flex: 0 0 auto;
}


/* =========================================================
   AI BODY
========================================================= */

.ai-panel-body {
    display: flex;
    flex-direction: column;

    min-height: 0;
}


/* =========================================================
   CURRENT CONTEXT
========================================================= */

.ai-context {
    display: flex;
    align-items: center;

    gap: 7px;

    padding: 9px 13px;

    font-size: 11px;

    color: #7a8290;

    background: #fafbfc;

    border-bottom: 1px solid #edf0f4;
}

.ai-context>span:last-child {
    color: #4d5665;
    font-weight: 600;
}

.ai-context-dot {
    width: 6px;
    height: 6px;

    flex: 0 0 auto;

    border-radius: 50%;

    background: #6675e8;
}


/* =========================================================
   MESSAGE LIST
========================================================= */

.ai-messages {
    display: flex;
    flex-direction: column;

    gap: 10px;

    max-height: 300px;

    padding: 12px;

    overflow-y: auto;
}


/* =========================================================
   MESSAGE
========================================================= */

.ai-message {
    display: flex;
    flex-direction: column;

    gap: 4px;

    width: 100%;
}

.ai-message-role {
    font-size: 10px;

    line-height: 1.2;

    font-weight: 700;

    color: #6675e8;

    text-transform: uppercase;

    letter-spacing: .04em;
}

.ai-message-content {
    max-width: 88%;

    padding: 9px 10px;

    border-radius: 9px;

    font-size: 12px;

    line-height: 1.65;

    color: #454d5b;

    background: #f5f6f9;

    word-break: break-word;
}


/* =========================================================
   USER MESSAGE
========================================================= */

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

.ai-message.user .ai-message-role {
    color: #7b8492;
}

.ai-message.user .ai-message-content {
    color: #ffffff;

    background: #6675e8;

    border-radius: 9px 9px 3px 9px;
}


/* =========================================================
   ASSISTANT MESSAGE
========================================================= */

.ai-message.assistant {
    align-items: flex-start;
}

.ai-message.assistant .ai-message-content {
    border-radius: 9px 9px 9px 3px;
}


/* =========================================================
   AI ACTION CARD
========================================================= */

.ai-action-message {
    width: 100%;

    box-sizing: border-box;
}


/* 卡片 */

.ai-action-card {
    width: 100%;

    box-sizing: border-box;

    padding: 13px;

    background: #ffffff;

    border: 1px solid #e1e5ed;

    border-radius: 10px;

    box-shadow:
        0 3px 12px rgba(32, 42, 64, .05);
}


/* =========================================================
   ACTION TITLE
========================================================= */

.ai-action-title {
    display: flex;
    align-items: center;

    margin-bottom: 5px;

    color: #202532;

    font-size: 12px;

    line-height: 1.4;

    font-weight: 700;
}

.ai-action-title::before {
    content: "";

    width: 3px;
    height: 15px;

    flex: 0 0 auto;

    margin-right: 7px;

    border-radius: 2px;

    background: #6675e8;
}


/* =========================================================
   ACTION DESCRIPTION
========================================================= */

.ai-action-description {
    margin-bottom: 10px;

    color: #687283;

    font-size: 11px;

    line-height: 1.55;
}


/* =========================================================
   ACTION DETAILS
========================================================= */

.ai-action-details {
    display: flex;
    flex-direction: column;

    gap: 0;

    margin-bottom: 11px;

    padding: 7px 10px;

    background: #f7f8fa;

    border: 1px solid #edf0f4;

    border-radius: 7px;
}

.ai-action-details>div {
    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: 24px;

    border-bottom: 1px solid #eceff3;
}

.ai-action-details>div:last-child {
    border-bottom: 0;
}

.ai-action-details span {
    color: #8a93a2;

    font-size: 10px;
}

.ai-action-details b {
    max-width: 65%;

    overflow: hidden;

    color: #3f4857;

    font-size: 11px;

    font-weight: 600;

    text-align: right;

    text-overflow: ellipsis;

    white-space: nowrap;
}


/* =========================================================
   ACTION BUTTONS
========================================================= */

.ai-action-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 7px;

    min-height: 30px;
}

.ai-action-buttons button {
    height: 30px;

    padding: 0 12px;

    border-radius: 7px;

    font-family: inherit;

    font-size: 10px;

    font-weight: 600;

    cursor: pointer;

    transition:
        background .15s ease,
        border-color .15s ease,
        color .15s ease,
        box-shadow .15s ease,
        transform .1s ease;
}


/* =========================================================
   CANCEL
========================================================= */

.ai-action-cancel {
    color: #697384;

    background: #ffffff;

    border: 1px solid #dfe3ea;
}

.ai-action-cancel:hover {
    color: #414a59;

    background: #f7f8fa;

    border-color: #cbd1db;
}


/* =========================================================
   CONFIRM
========================================================= */

.ai-action-confirm {
    color: #ffffff;

    background: #6675e8;

    border: 1px solid #6675e8;

    box-shadow:
        0 3px 8px rgba(102, 117, 232, .18);
}

.ai-action-confirm:hover {
    background: #5969dc;

    border-color: #5969dc;

    box-shadow:
        0 4px 10px rgba(102, 117, 232, .24);
}

.ai-action-confirm:active {
    transform: translateY(1px);

    box-shadow: none;
}


/* =========================================================
   ACTION SUCCESS
========================================================= */

.ai-action-success {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;

    height: 30px;

    box-sizing: border-box;

    color: #16835b;

    background: #eefaf5;

    border: 1px solid #ccefe0;

    border-radius: 7px;

    font-size: 10px;

    font-weight: 600;
}


/* =========================================================
   QUICK ACTIONS
========================================================= */

.ai-quick-actions {
    display: flex;

    gap: 6px;

    padding: 0 12px 10px;

    overflow-x: auto;

    scrollbar-width: thin;
}

.ai-quick-actions button {
    flex: 0 0 auto;

    padding: 6px 9px;

    border: 1px solid #e2e6ed;

    border-radius: 7px;

    background: #ffffff;

    color: #596272;

    font-size: 11px;

    line-height: 1;

    cursor: pointer;

    transition:
        border-color .15s ease,
        background .15s ease,
        color .15s ease;
}

.ai-quick-actions button:hover {
    border-color: #cbd1f5;

    background: #f7f8ff;

    color: #5d6bdd;
}


/* =========================================================
   INPUT AREA
========================================================= */

.ai-input-wrap {
    padding: 10px;

    border-top: 1px solid #edf0f4;

    background: #ffffff;
}

.ai-input {
    display: block;

    width: 100%;

    min-height: 66px;
    max-height: 140px;

    resize: vertical;

    box-sizing: border-box;

    padding: 9px 10px;

    border: 1px solid #dfe3ea;

    border-radius: 8px;

    outline: none;

    background: #fafbfc;

    color: #303744;

    font-family: inherit;

    font-size: 12px;

    line-height: 1.55;

    transition:
        border-color .15s ease,
        box-shadow .15s ease,
        background .15s ease;
}

.ai-input::placeholder {
    color: #a0a7b3;
}

.ai-input:focus {
    border-color: #8993e8;

    background: #ffffff;

    box-shadow:
        0 0 0 3px rgba(102, 117, 232, .08);
}


/* =========================================================
   INPUT FOOTER
========================================================= */

.ai-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 8px;

    margin-top: 7px;
}

.ai-hint {
    min-width: 0;

    color: #9aa1ad;

    font-size: 10px;

    line-height: 1.3;
}


/* =========================================================
   SEND BUTTON
========================================================= */

.ai-send-btn {
    flex: 0 0 auto;

    min-width: 52px;

    height: 30px;

    padding: 0 12px;

    border: 0;

    border-radius: 7px;

    background: #6675e8;

    color: #ffffff;

    font-size: 11px;

    font-weight: 600;

    cursor: pointer;

    transition:
        background .15s ease,
        transform .15s ease,
        opacity .15s ease;
}

.ai-send-btn:hover {
    background: #5969dc;
}

.ai-send-btn:active {
    transform: translateY(1px);
}

.ai-send-btn:disabled {
    cursor: wait;

    opacity: .55;
}


/* =========================================================
   COLLAPSED
========================================================= */

.ai-panel.collapsed .ai-panel-body {
    display: none;
}


/* =========================================================
   SCROLLBAR
========================================================= */

.ai-messages::-webkit-scrollbar {
    width: 5px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {

    border-radius: 10px;
}

.ai-messages::-webkit-scrollbar-thumb:hover {
    background: #c6ccd7;
}

/* =========================================================
   Tutorial Studio · Mobile AI Panel
   手机端 AI 助手面板
========================================================= */

/*
 * 手机端弹窗打开时，
 * AI 面板不再受桌面右侧栏宽度限制。
 */
#mobileAiSheet .ai-panel {
    display: flex;
    flex-direction: column;

    width: 100%;
    max-width: none;
    min-width: 0;

    height: 100%;
    max-height: none;

    margin: 0;
    padding: 0;

    overflow: hidden;

    border: none;
    border-radius: 0;

    box-shadow: none;
    background: #ffffff;
}

/*
 * 标题区域
 */
#mobileAiSheet .ai-panel-head {
    flex-shrink: 0;

    padding: 18px 16px;

    border-bottom: 1px solid #e6eaf0;
}

/*
 * 聊天内容区域
 */
#mobileAiSheet .ai-panel-body {
    display: flex;
    flex: 1;
    flex-direction: column;

    min-height: 0;

    overflow: hidden;
}

/*
 * 消息列表占据剩余空间。
 */
#mobileAiSheet .ai-messages {
    flex: 1;

    min-height: 100px;
    max-height: none;

    overflow-x: hidden;
    overflow-y: auto;

    overscroll-behavior: contain;

    -webkit-overflow-scrolling: touch;
}

/*
 * 输入区域始终保持可见。
 */
#mobileAiSheet .ai-input-wrap {
    flex-shrink: 0;

    padding: 12px 14px;

    background: #ffffff;

    border-top: 1px solid #e6eaf0;
}

/*
 * 手机上适当增大输入框。
 */
#mobileAiSheet .ai-input {
    width: 100%;
    min-height: 84px;

    font-size: 16px;
    line-height: 1.6;

    resize: vertical;
}

/*
 * 手机上按钮更容易点击。
 */
#mobileAiSheet .ai-send-btn {
    min-height: 42px;
    min-width: 64px;

    padding: 0 18px;
}

/*
 * 聊天消息文字。
 */
#mobileAiSheet .ai-message-content {
    overflow-wrap: anywhere;
    word-break: break-word;

    line-height: 1.7;
}

/*
 * 避免弹窗中的 AI 面板被折叠按钮隐藏。
 * 手机端通过弹窗右上角的关闭按钮关闭整个窗口。
 */
#mobileAiSheet .ai-panel.collapsed .ai-panel-body {
    display: flex;
}

/*
 * 手机横屏或小高度屏幕时，
 * 给输入区域留出更多空间。
 */
@media (max-height: 560px) {
    #mobileAiSheet .ai-panel-head {
        padding: 10px 14px;
    }

    #mobileAiSheet .ai-input-wrap {
        padding: 8px 12px;
    }

    #mobileAiSheet .ai-input {
        min-height: 56px;
    }
}

/* 默认在桌面端隐藏手机 AI 助手标题栏 */
.mobile-ai-header {
    display: none;
}

/* 默认隐藏手机 AI 助手关闭按钮 */
.mobile-ai-close {
    display: none;
}