﻿/* AI 客服聊天室樣式 */
.ai-chatroom-container {
    max-width: 1200px;
    margin: 0 auto;
    height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 聊天室頭部 */
.ai-chatroom-header {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-chatroom-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ai-chatroom-back-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

    .ai-chatroom-back-btn:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: translateX(-2px);
    }

    .ai-chatroom-back-btn svg {
        width: 20px;
        height: 20px;
        color: #ffffff;
    }

.ai-chatroom-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chatroom-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

    .ai-chatroom-avatar svg {
        width: 24px;
        height: 24px;
        color: #ffffff;
    }

.ai-chatroom-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-chatroom-title {
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.3px;
}

.ai-chatroom-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    margin: 0;
}

.ai-chatroom-status-dot {
    width: 8px;
    height: 8px;
    background: #4ADE80;
    border-radius: 50%;
    animation: aiChatroomPulse 2s ease-in-out infinite;
}

@keyframes aiChatroomPulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.ai-chatroom-header-right {
    display: flex;
    gap: 8px;
}

.ai-chatroom-clear-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .ai-chatroom-clear-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    .ai-chatroom-clear-btn svg {
        width: 18px;
        height: 18px;
        color: #ffffff;
    }

/* 聊天訊息區域 */
.ai-chatroom-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #F8F9FA;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

    .ai-chatroom-messages::-webkit-scrollbar {
        width: 8px;
    }

    .ai-chatroom-messages::-webkit-scrollbar-track {
        background: #F1F3F5;
    }

    .ai-chatroom-messages::-webkit-scrollbar-thumb {
        background: #D1D5DB;
        border-radius: 4px;
    }

        .ai-chatroom-messages::-webkit-scrollbar-thumb:hover {
            background: #9CA3AF;
        }

/* 歡迎訊息 */
.ai-chatroom-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.ai-chatroom-welcome-avatar {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: 0 8px 24px rgba(74, 144, 226, 0.3);
}

    .ai-chatroom-welcome-avatar svg {
        width: 40px;
        height: 40px;
        color: #ffffff;
    }

.ai-chatroom-welcome-title {
    font-size: 24px;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 12px 0;
}

.ai-chatroom-welcome-text {
    font-size: 16px;
    color: #6B7280;
    line-height: 1.6;
    margin: 0;
    max-width: 500px;
}

/* 訊息樣式 */
.ai-chatroom-message {
    display: flex;
    gap: 12px;
    animation: aiChatroomMessageSlideIn 0.3s ease-out;
}

@keyframes aiChatroomMessageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chatroom-message-bot {
    flex-direction: row;
}

.ai-chatroom-message-user {
    flex-direction: row-reverse;
}

    .ai-chatroom-message-user .ai-chatroom-message-header {
        text-align: right;
    }

    .ai-chatroom-message-user .ai-chatroom-message-content {
        align-items: flex-end;
    }

.ai-chatroom-message-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .ai-chatroom-message-avatar svg {
        width: 22px;
        height: 22px;
        color: #ffffff;
    }

.ai-chatroom-message-avatar-user {
    background: linear-gradient(135deg, #6B7280 0%, #4B5563 100%);
}

.ai-chatroom-message-content {
    flex: 1;
    min-width: 0;
    max-width: 70%;
}

.ai-chatroom-message-header {
    margin-bottom: 6px;
    padding: 0 4px;
}

.ai-chatroom-message-sender {
    font-size: 13px;
    font-weight: 600;
    color: #6B7280;
}

.ai-chatroom-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
}

.ai-chatroom-message-bubble-bot {
    background: #ffffff;
    color: #1F2937;
    border: 1px solid #E5E7EB;
    border-top-left-radius: 4px;
}

.ai-chatroom-message-bubble-user {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    color: #ffffff;
    border-top-right-radius: 4px;
}

/* 正在輸入指示器 */
.ai-chatroom-typing {
    display: flex;
    gap: 12px;
    align-items: center;
}

.ai-chatroom-typing-dots {
    background: #ffffff;
    padding: 16px 20px;
    border-radius: 16px;
    border-top-left-radius: 4px;
    border: 1px solid #E5E7EB;
    display: flex;
    gap: 6px;
}

    .ai-chatroom-typing-dots span {
        width: 8px;
        height: 8px;
        background: #9CA3AF;
        border-radius: 50%;
        animation: aiChatroomTypingDot 1.4s ease-in-out infinite;
    }

        .ai-chatroom-typing-dots span:nth-child(1) {
            animation-delay: 0s;
        }

        .ai-chatroom-typing-dots span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .ai-chatroom-typing-dots span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes aiChatroomTypingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* 輸入區域 */
.ai-chatroom-input-area {
    background: #ffffff;
    border-top: 1px solid #E5E7EB;
    padding: 16px 24px;
    flex-shrink: 0;
}

.ai-chatroom-input-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.ai-chatroom-input {
    flex: 1;
    min-height: 48px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    transition: all 0.2s ease;
    line-height: 1.5;
}

    .ai-chatroom-input:focus {
        outline: none;
        border-color: #4A90E2;
        box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
    }

    .ai-chatroom-input::placeholder {
        color: #9CA3AF;
    }

    .ai-chatroom-input:disabled {
        background: #F3F4F6;
        cursor: not-allowed;
    }

.ai-chatroom-send-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

    .ai-chatroom-send-btn:hover:not(:disabled) {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
    }

    .ai-chatroom-send-btn:active:not(:disabled) {
        transform: translateY(0);
    }

    .ai-chatroom-send-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .ai-chatroom-send-btn svg {
        width: 20px;
        height: 20px;
        color: #ffffff;
    }

.ai-chatroom-input-hint {
    margin-top: 8px;
    font-size: 13px;
    color: #9CA3AF;
    text-align: center;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .ai-chatroom-container {
        height: 100vh;
        max-width: 100%;
        box-shadow: none;
    }

    .ai-chatroom-header {
        padding: 12px 16px;
    }

    .ai-chatroom-title {
        font-size: 16px;
    }

    .ai-chatroom-messages {
        padding: 16px;
    }

    .ai-chatroom-message-content {
        max-width: 80%;
    }

    .ai-chatroom-input-area {
        padding: 12px 16px;
    }

    .ai-chatroom-welcome {
        padding: 32px 16px;
    }

    .ai-chatroom-welcome-title {
        font-size: 20px;
    }

    .ai-chatroom-welcome-text {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .ai-chatroom-header {
        padding: 10px 12px;
    }

    .ai-chatroom-back-btn {
        width: 36px;
        height: 36px;
    }

    .ai-chatroom-avatar {
        width: 40px;
        height: 40px;
    }

    .ai-chatroom-title {
        font-size: 15px;
    }

    .ai-chatroom-status {
        font-size: 12px;
    }

    .ai-chatroom-messages {
        padding: 12px;
    }

    .ai-chatroom-message-avatar {
        width: 36px;
        height: 36px;
    }

        .ai-chatroom-message-avatar svg {
            width: 18px;
            height: 18px;
        }

    .ai-chatroom-message-content {
        max-width: 85%;
    }

    .ai-chatroom-message-bubble {
        font-size: 14px;
        padding: 10px 14px;
    }

    .ai-chatroom-input-area {
        padding: 10px 12px;
    }

    .ai-chatroom-input {
        font-size: 14px;
        padding: 10px 14px;
        min-height: 44px;
    }

    .ai-chatroom-send-btn {
        width: 44px;
        height: 44px;
    }

    .ai-chatroom-input-hint {
        font-size: 12px;
    }
}

/* =============================================================================
   獨立頁 AI 回覆 Markdown 元素樣式(AI 客服升級 2026)
   範圍鎖定:.ai-chatroom-message-bubble-bot 內(AI 回覆已是後端 Markdig sanitize 過的 HTML)
   - 與 widget 內嵌 chat 樣式對齊(AICustomerServiceEmbeddedChat.css)
   ============================================================================= */
.ai-chatroom-message-bubble-bot h1,
.ai-chatroom-message-bubble-bot h2,
.ai-chatroom-message-bubble-bot h3,
.ai-chatroom-message-bubble-bot h4 {
    margin: 8px 0 4px 0;
    font-weight: 700;
    color: #111827;
}

.ai-chatroom-message-bubble-bot h1 { font-size: 18px; }
.ai-chatroom-message-bubble-bot h2 { font-size: 17px; }
.ai-chatroom-message-bubble-bot h3 { font-size: 16px; }
.ai-chatroom-message-bubble-bot h4 { font-size: 15px; }

.ai-chatroom-message-bubble-bot p {
    margin: 4px 0;
}

.ai-chatroom-message-bubble-bot ul,
.ai-chatroom-message-bubble-bot ol {
    margin: 6px 0;
    padding-left: 22px;
}

.ai-chatroom-message-bubble-bot li {
    margin: 2px 0;
}

.ai-chatroom-message-bubble-bot strong {
    font-weight: 700;
    color: #111827;
}

.ai-chatroom-message-bubble-bot em {
    font-style: italic;
    color: #4B5563;
}

/* 內聯 code(綠 pill 樣式,仿後台 AI 教練) */
.ai-chatroom-message-bubble-bot code {
    display: inline-block;
    padding: 1px 6px;
    background: #10B981;
    color: #ffffff;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13px;
}

.ai-chatroom-message-bubble-bot blockquote {
    margin: 6px 0;
    padding: 6px 12px;
    border-left: 3px solid #4A90E2;
    background: #F3F4F6;
    color: #4B5563;
    font-style: italic;
}

/* GFM pipe table 邊線(Markdig UseAdvancedExtensions 已啟用) */
.ai-chatroom-message-bubble-bot table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.ai-chatroom-message-bubble-bot th,
.ai-chatroom-message-bubble-bot td {
    border: 1px solid #D1D5DB;
    padding: 6px 10px;
    text-align: left;
}

.ai-chatroom-message-bubble-bot th {
    background: #F3F4F6;
    font-weight: 700;
}

.ai-chatroom-message-bubble-bot tr:nth-child(even) td {
    background: #FAFBFC;
}

/* 連結 — 綠 pill + 外部箭頭 icon(訪客可點擊頁面跳轉)
   Gemini prompt 規定提到頁面時用 Markdown link `[名稱](絕對路徑)`,前端統一渲染為這個樣式 */
.ai-chatroom-message-bubble-bot a {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: #10B981;
    color: #ffffff !important;
    border-radius: 6px;
    text-decoration: none;
    margin: 0 2px;
    font-size: 13px;
    transition: background 0.15s ease;
}

.ai-chatroom-message-bubble-bot a:hover {
    background: #059669;
}

.ai-chatroom-message-bubble-bot a::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 4px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/><polyline points='15 3 21 3 21 9'/><line x1='10' y1='14' x2='21' y2='3'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
}

