/* Gemini Chatbot - Glassmorphism 設計 */

:root {
    --chatbot-primary: #4285F4;
    --chatbot-primary-dark: #3367D6;
    --chatbot-bg-light: rgba(255, 255, 255, 0.95);
    --chatbot-bg-dark: rgba(30, 30, 30, 0.95);
    --chatbot-glass-bg: rgba(255, 255, 255, 0.1);
    --chatbot-glass-border: rgba(255, 255, 255, 0.2);
    --chatbot-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --chatbot-shadow-hover: 0 12px 48px rgba(0, 0, 0, 0.15);
}

/* 主容器 */
.gemini-chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 浮動按鈕 */
.chatbot-toggle-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    /* Gradient Border Trick */
    background: linear-gradient(#fff, #fff) padding-box,
        linear-gradient(135deg, #E3F2FD, #2196F3) border-box;
    border: 3px solid transparent;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--chatbot-shadow-hover);
}

.chatbot-toggle-btn img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: var(--chatbot-shadow);
    }

    50% {
        box-shadow: 0 8px 32px rgba(66, 133, 244, 0.4);
    }
}

/* 對話視窗 */
.chatbot-window {
    width: 760px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 110px);
    background: var(--chatbot-bg-light);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 標題列 */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chatbot-header-title {
    font-size: 16px;
    font-weight: 600;
}

.chatbot-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 訊息列表 */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* 歡迎訊息 */
.chatbot-welcome {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

/* 訊息氣泡 */
.chatbot-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.message-bubble {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-message .message-bubble {
    background: var(--chatbot-glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--chatbot-glass-border);
    color: #333;
}

.user-message .message-bubble {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    color: white;
}

.error-message .message-bubble {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: #d32f2f;
}

/* 連結樣式 (v1.2.79) */
.chatbot-link {
    color: var(--chatbot-primary);
    text-decoration: underline;
    font-weight: 500;
    word-break: break-all;
    transition: color 0.2s;
}

.chatbot-link:hover {
    color: var(--chatbot-primary-dark);
}

/* 載入動畫 */
.loading-dots {
    display: flex;
    gap: 6px;
    padding: 4px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* 快速回覆按鈕 */
.chatbot-quick-replies {
    padding: 0 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-reply-btn {
    background: var(--chatbot-glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--chatbot-glass-border);
    color: var(--chatbot-primary);
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    text-align: left;
}

.quick-reply-btn:hover {
    background: rgba(66, 133, 244, 0.1);
    transform: translateX(4px);
}

/* 輸入框 */
.chatbot-input {
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

.chatbot-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    background: white;
    transition: border-color 0.2s;
}

.chatbot-input input:focus {
    border-color: var(--chatbot-primary);
}

.chatbot-input button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chatbot-input button:hover:not(:disabled) {
    background: var(--chatbot-primary-dark);
    transform: scale(1.05);
}

.chatbot-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 手機版適配 */
@media (max-width: 480px) {
    .gemini-chatbot {
        bottom: 0;
        right: 0;
        left: 0;
    }

    .chatbot-window {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    .chatbot-toggle-btn {
        bottom: 20px;
        right: 20px;
    }
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
    :root {
        --chatbot-bg-light: var(--chatbot-bg-dark);
    }

    .chatbot-window {
        background: var(--chatbot-bg-dark);
    }

    .ai-message .message-bubble {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
        color: #e0e0e0;
    }

    .chatbot-input input {
        background: rgba(255, 255, 255, 0.1);
        color: white;
        border-color: rgba(255, 255, 255, 0.2);
    }

    .chatbot-welcome {
        color: #999;
    }
}