/* 客服聊天泡泡樣式 */

/* 聊天泡泡按鈕 */
.chat-bubble-btn {
    position: fixed;
    width: 60px;
    height: 60px;
    background-color: transparent;
    border-radius: 50%;
    box-shadow: none;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: background-color 0.2s ease, box-shadow 0.2s ease,
                left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                right 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                top 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    /* 位置由 JS 控制，初始先藏到左下 */
    left: 16px;
    bottom: 24px;
    top: auto;
    right: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* 防止 touch 拖曳時頁面滾動 */
}

.chat-bubble-btn:active {
    cursor: grabbing;
}

.chat-bubble-btn:hover {
    background-color: transparent;
    box-shadow: none;
    opacity: 0.85;
}

.chat-bubble-btn i,
.chat-bubble-btn svg {
    color: #000000;
    font-size: 32px;
    width: 32px;
    height: 32px;
    pointer-events: none; /* 防止 icon 干擾拖曳事件 */
}

/* 對話框 */
.chat-bubble-speech {
    position: absolute;
    bottom: calc(100% + 10px);
    background-color: #ffffff;
    border: 1.5px solid #d0d0d0;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 500;
    color: #333333;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 對話框尾巴（三角形，朝下） */
.chat-bubble-speech::after {
    content: '';
    position: absolute;
    top: 100%;
    border: 6px solid transparent;
    border-top-color: #ffffff;
    filter: drop-shadow(0 1px 0 #d0d0d0);
}

/* 左側停靠：尾巴靠左 */
.chat-bubble-speech.speech-left::after {
    left: 16px;
}

/* 右側停靠：尾巴靠右 */
.chat-bubble-speech.speech-right::after {
    right: 16px;
}

/* 三個動畫點 */
.chat-bubble-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.chat-bubble-dots span {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background-color: #008F77;
    animation: bubbleDotPulse 1.4s infinite ease-in-out;
}

.chat-bubble-dots span:nth-child(1) { animation-delay: -0.32s; }
.chat-bubble-dots span:nth-child(2) { animation-delay: -0.16s; }
.chat-bubble-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes bubbleDotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* 聊天視窗開啟時隱藏對話框 */
.chat-bubble-speech.hidden {
    display: none;
}

/* 未讀訊息徽章 */
.chat-bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: #FFA400;
    color: #ffffff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    display: none;
    pointer-events: none;
}

.chat-bubble-badge.show {
    display: flex;
}

/* 聊天視窗 */
.chat-window {
    position: fixed;
    width: 360px;
    height: 500px;
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    /* 位置由 JS 動態計算 */
    transition: left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                right 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                top 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.chat-window.show {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 聊天視窗標題列 */
.chat-window-header {
    background-color: #005245;
    color: #ffffff;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    cursor: default;
}

.chat-window-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    pointer-events: none;
}

.chat-window-close {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.chat-window-close:hover {
    opacity: 0.8;
}

/* 聊天訊息區域 */
.bubble-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background-color: #f5f5f5;
    position: relative;
}

/* 訊息泡泡 */
.bubble-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

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

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

.bubble-message-bubble {
    max-width: 75%;
    padding: 10px 12px;
    border-radius: 10px;
    word-wrap: break-word;
}

.bubble-message.user .bubble-message-bubble {
    background-color: #005245;
    color: #ffffff;
}

.bubble-message.assistant .bubble-message-bubble {
    background-color: #ffffff;
    color: #333333;
    border: 1px solid #e0e0e0;
}

.bubble-message-time {
    font-size: 11px;
    color: #7C7979;
    margin-top: 4px;
}

/* 輸入區域 */
.bubble-input-area {
    padding: 16px;
    background-color: #ffffff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
}

.bubble-input-area input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Noto Sans TC', sans-serif;
}

.bubble-input-area input:focus {
    outline: none;
    border-color: #005245;
    box-shadow: 0px 0px 0px 2px rgba(0, 82, 69, 0.2);
}

.bubble-input-area button {
    flex-shrink: 0;
    align-self: stretch;
    aspect-ratio: 1;
    background-color: #008F77;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.bubble-input-area button:hover {
    background-color: #006d5e;
}

.bubble-input-area button:disabled {
    background-color: #BDBDBD;
    cursor: not-allowed;
}

/* 歡迎訊息 */
.bubble-welcome {
    text-align: center;
    padding: 24px 16px;
    color: #7C7979;
}

.bubble-welcome i {
    font-size: 48px;
    color: #008F77;
    margin-bottom: 12px;
}

.bubble-welcome h6 {
    font-size: 16px;
    font-weight: 500;
    color: #333333;
    margin-bottom: 8px;
}

.bubble-welcome p {
    font-size: 14px;
    margin: 0;
}

/* 新訊息按鈕 */
.bubble-new-message-btn {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #008F77;
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 143, 119, 0.4);
    display: none;
    align-items: center;
    gap: 6px;
    z-index: 10;
    transition: all 0.2s;
}

.bubble-new-message-btn:hover {
    background-color: #006d5e;
    box-shadow: 0 6px 16px rgba(0, 143, 119, 0.5);
    transform: translateX(-50%) translateY(-2px);
}

.bubble-new-message-btn i {
    font-size: 12px;
}

/* 打字指示器 */
.bubble-typing-indicator .bubble-message-bubble {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    padding: 12px 16px;
}

.bubble-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.bubble-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #008F77;
    animation: bubbleTypingAnimation 1.4s infinite ease-in-out;
}

.bubble-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.bubble-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bubbleTypingAnimation {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 響應式：手機版聊天視窗改為全寬 */
@media (max-width: 767.98px) {
    .chat-window {
        left: 16px !important;
        right: 16px !important;
        width: auto !important;
        max-width: none !important;
    }
}
