/* livechat.css - Custom Live Chat Widget */

#livechat-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    font-family: 'Microsoft JhengHei', 'Segoe UI', sans-serif;
}

/* Toggle button */
#chat-toggle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #ED6E00;
    border: none;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 18px rgba(237,110,0,.45);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
    margin-left: auto;
}
#chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(237,110,0,.55);
}

/* Unread badge on toggle button */
#chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat window */
#chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 340px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideIn .25s ease;
}
@keyframes chatSlideIn {
    from { opacity:0; transform:translateY(16px) scale(.97); }
    to   { opacity:1; transform:translateY(0) scale(1); }
}

/* Header */
#chat-header {
    background: linear-gradient(135deg, #ED6E00 0%, #ff8c30 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
}
#chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
#chat-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 13px; letter-spacing: 1px;
}
#chat-title { font-size: 14px; font-weight: 700; }
#chat-status-text { font-size: 11px; opacity: .8; }

#chat-minimize {
    background: rgba(255,255,255,.2);
    border: none; color: #fff; cursor: pointer;
    width: 28px; height: 28px; border-radius: 50%;
    font-size: 16px; display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
#chat-minimize:hover { background: rgba(255,255,255,.35); }

/* Messages */
#chat-messages-area {
    flex: 1;
    overflow-y: auto;
    min-height: 220px;
    max-height: 300px;
    padding: 12px;
    background: #f8f9fa;
}
#chat-messages-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual message bubble */
.chat-msg {
    display: flex;
    max-width: 82%;
}
.chat-msg.visitor { align-self: flex-end; }
.chat-msg.admin   { align-self: flex-start; }

.chat-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-msg.visitor .chat-bubble {
    background: #ED6E00;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.admin .chat-bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.chat-msg-time {
    font-size: 10px;
    color: #bbb;
    margin-top: 3px;
    text-align: right;
}
.chat-msg.admin .chat-msg-time { text-align: left; }

/* Typing indicator */
.chat-typing {
    display: flex; align-items: center; gap: 4px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.typing-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #bbb; animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
    0%,60%,100% { transform: translateY(0); }
    30%          { transform: translateY(-5px); }
}

@media (max-width: 480px) {
    #chat-window {
        width: calc(100vw - 20px);
        right: -14px;
        bottom: 68px;
        border-radius: 12px;
    }
    #livechat-widget { bottom: 16px; right: 16px; }
}
