/* AI Chat Widget */
.ai-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1080;
    font-family: "Microsoft JhengHei", Arial, sans-serif;
}

.ai-chat-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    background: #4e73df;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    font-weight: 700;
}

.ai-chat-toggle:hover,
.ai-chat-toggle:focus {
    background: #2e59d9;
    outline: none;
}

.ai-chat-panel {
    position: absolute;
    right: 0;
    bottom: 64px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #4e73df;
    color: #fff;
}

.ai-chat-title {
    font-size: 1rem;
    font-weight: 700;
}

.ai-chat-subtitle {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 2px;
}

.ai-chat-close {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
}

.ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8f9fc;
}

.ai-message {
    max-width: 82%;
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-message-user {
    margin-left: auto;
    background: #4e73df;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-message-assistant {
    margin-right: auto;
    background: #fff;
    color: #333;
    border: 1px solid #e3e6f0;
    border-bottom-left-radius: 4px;
}

.ai-message-system {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    background: transparent;
    color: #858796;
    font-size: 0.85rem;
}

.ai-chat-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e3e6f0;
    background: #fff;
}

.ai-chat-input {
    flex: 1;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    border: 1px solid #d1d3e2;
    border-radius: 10px;
    padding: 9px 10px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.ai-chat-input:focus {
    border-color: #4e73df;
    outline: none;
    box-shadow: 0 0 0 0.15rem rgba(78, 115, 223, 0.18);
}

.ai-chat-send {
    min-width: 64px;
    border: 0;
    border-radius: 10px;
    background: #1cc88a;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.ai-chat-send:disabled {
    background: #b7b9cc;
    cursor: not-allowed;
}

@media (max-width: 576px) {
    .ai-chat-widget {
        right: 16px;
        bottom: 16px;
    }

    .ai-chat-panel {
        right: -4px;
        bottom: 60px;
        width: calc(100vw - 24px);
        height: calc(100vh - 110px);
    }

    .ai-chat-toggle span {
        display: none;
    }
}