/* AI 聊天 Widget 樣式 */

/* 容器位置設定 */
.chat-widget-position-bottom-right .chat-widget-toggle-btn {
    bottom: 20px;
    right: 20px;
}

.chat-widget-position-bottom-right .chat-widget-window {
    bottom: 80px;
    right: 20px;
}

.chat-widget-position-bottom-left .chat-widget-toggle-btn {
    bottom: 20px;
    left: 20px;
}

.chat-widget-position-bottom-left .chat-widget-window {
    bottom: 80px;
    left: 20px;
}

.chat-widget-position-top-right .chat-widget-toggle-btn {
    top: 20px;
    right: 20px;
}

.chat-widget-position-top-right .chat-widget-window {
    top: 80px;
    right: 20px;
}

.chat-widget-position-top-left .chat-widget-toggle-btn {
    top: 20px;
    left: 20px;
}

.chat-widget-position-top-left .chat-widget-window {
    top: 80px;
    left: 20px;
}

/* AI 客服按鈕 */
.chat-widget-toggle-btn {
    position: fixed;
    padding: 12px 20px;
    background-color: #4285f4;
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.chat-widget-toggle-btn:hover {
    background-color: #3367d6;
    transform: translateY(-2px);
}

/* 對話視窗 */
.chat-widget-window {
    position: fixed;
    width: min(900px, calc(100vw - 24px));
    max-width: 760px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: all 0.3s ease;
}

.chat-widget-window.hidden {
    display: none;
}

.chat-widget-window.single-column {
    width: 350px;
    max-width: calc(100vw - 24px);
}

.chat-widget-window.fullscreen {
    top: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    left: 12px !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    border-radius: 12px;
    z-index: 1100;
}

.chat-widget-header {
    padding: 15px;
    background: #4285f4;
    color: white;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-widget-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-widget-panel-toggle-btn,
.chat-widget-fullscreen-btn,
.chat-widget-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-panel-toggle-btn:hover,
.chat-widget-fullscreen-btn:hover,
.chat-widget-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-widget-panel-toggle-btn.hidden {
    display: none;
}

.chat-widget-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: #f5f5f5;
}

.chat-widget-conversation-panel {
    flex: 6;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.chat-widget-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
}

.chat-widget-quick-panel {
    flex: 4;
    min-width: 240px;
    max-width: 360px;
    border-left: 1px solid #e5e7eb;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.chat-widget-quick-panel.hidden {
    display: none;
}

.chat-widget-quick-panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    color: #262626;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
}

.chat-widget-quick-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-widget-quick-panel-list::-webkit-scrollbar {
    width: 6px;
}

.chat-widget-quick-panel-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget-quick-panel-list::-webkit-scrollbar-thumb {
    background: #d9d9d9;
    border-radius: 3px;
}

.chat-widget-quick-panel-list::-webkit-scrollbar-thumb:hover {
    background: #bfbfbf;
}

.chat-widget-quick-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-widget-quick-group-title {
    margin: 0;
    color: #0077c8;
    font-size: 15px;
    line-height: 1.35;
    font-weight: 700;
}

.chat-widget-quick-question {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    text-align: left;
    margin: 0;
    border: none;
    background: transparent;
    color: #262626;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    padding: 2px 0;
    transition: color 0.2s ease;
}

.chat-widget-quick-question:hover {
    color: #005fa3;
    text-decoration: none;
}

.chat-widget-message {
    margin-bottom: 15px;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.chat-widget-message.bot {
    align-items: flex-start;
}

.chat-widget-message.user {
    align-items: flex-end;
}

.chat-widget-message-time {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.chat-widget-bubble-container {
    max-width: 80%;
    display: inline-block;
}

.chat-widget-bubble {
    padding: 10px 15px;
    border-radius: 18px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    word-wrap: break-word;
}

.chat-widget-message.user .chat-widget-bubble {
    background: #4285f4;
    color: white;
}

.chat-widget-voice-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #4CAF50;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-widget-voice-btn:hover {
    background: #45a049;
}

.chat-widget-voice-btn.recording {
    background: #f44336;
    animation: chat-widget-pulse 1.5s infinite;
}

@keyframes chat-widget-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.chat-widget-input {
    padding: 15px;
    display: flex;
    gap: 10px;
    border-top: 1px solid #eee;
    background: #fff;
}

.chat-widget-input textarea {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

.chat-widget-input button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #4285f4;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-widget-input button:hover {
    background: #3367d6;
}

/* Markdown 樣式 */
.chat-widget-markdown-body {
    color: inherit;
    line-height: 1.6;
}

.chat-widget-markdown-body p {
    margin: 0 0 10px 0;
}

.chat-widget-markdown-body p:last-child {
    margin-bottom: 0;
}

.chat-widget-markdown-body code {
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    font-family: monospace;
}

.chat-widget-markdown-body pre {
    padding: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow-x: auto;
    margin: 10px 0;
}

.chat-widget-markdown-body pre code {
    background: none;
    padding: 0;
}

.chat-widget-markdown-body ul, 
.chat-widget-markdown-body ol {
    margin: 10px 0;
    padding-left: 20px;
}

.chat-widget-markdown-body blockquote {
    margin: 10px 0;
    padding-left: 10px;
    border-left: 3px solid #ccc;
    color: #666;
}

.chat-widget-markdown-body h1, 
.chat-widget-markdown-body h2, 
.chat-widget-markdown-body h3, 
.chat-widget-markdown-body h4, 
.chat-widget-markdown-body h5, 
.chat-widget-markdown-body h6 {
    margin: 10px 0;
    font-weight: 600;
}

/* 調整氣泡內的連結樣式 */
.chat-widget-message.bot .chat-widget-markdown-body a {
    color: #4285f4;
    text-decoration: none;
}

.chat-widget-message.user .chat-widget-markdown-body a {
    color: white;
    text-decoration: underline;
}

/* 調整表格樣式 */
.chat-widget-markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}

.chat-widget-markdown-body th,
.chat-widget-markdown-body td {
    padding: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.chat-widget-markdown-body th {
    background: rgba(0, 0, 0, 0.05);
}

/* 載入動畫 */
.chat-widget-loading {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 12px 0;
    min-height: 30px;
}

.chat-widget-loading .dot {
    width: 10px;
    height: 10px;
    background-color: #999;
    border-radius: 50%;
    display: inline-block;
    animation: chat-widget-bounce 1.4s infinite ease-in-out both;
}

.chat-widget-loading .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.chat-widget-loading .dot:nth-child(2) {
    animation-delay: -0.16s;
}

.chat-widget-loading .dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes chat-widget-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.3);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .chat-widget-window {
        width: calc(100vw - 16px);
        max-width: none;
        height: calc(100vh - 110px);
    }

    .chat-widget-window.single-column {
        width: calc(100vw - 16px);
    }

    .chat-widget-quick-panel {
        min-width: 200px;
    }

    .chat-widget-quick-group-title {
        font-size: 14px;
    }

    .chat-widget-quick-question {
        font-size: 13px;
    }
}
