/* ============================================================
   訊息服務中心 Widget — chat-widget.css
   ============================================================ */

/* ---------- FAB 浮動按鈕 ---------- */
.cw-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--text, #2A2A2A);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-sans, 'Noto Sans TC', sans-serif);
    letter-spacing: 0.5px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transition: transform 0.3s var(--ease, ease), box-shadow 0.3s;
}
.cw-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0,0,0,0.2);
}
.cw-fab-icon { font-size: 1.1rem; }
.cw-fab-label { white-space: nowrap; }

/* 未讀 badge */
.cw-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #e74c3c;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    border-radius: 10px;
    animation: cw-bounce 0.4s ease;
}
@keyframes cw-bounce {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.cw-badge:empty, .cw-badge[data-count="0"] { display: none; }

/* ---------- 對話面板 ---------- */
.cw-panel {
    position: fixed;
    bottom: 90px;
    right: 28px;
    z-index: 10001;
    width: 380px;
    max-height: 520px;
    display: flex;
    flex-direction: column;
    background: var(--bg, #FAFAF7);
    border: 1px solid var(--hairline, #E0DED8);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.12);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s var(--ease, ease), transform 0.3s var(--ease, ease);
}
.cw-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ---------- Header ---------- */
.cw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hairline, #E0DED8);
    border-radius: 16px 16px 0 0;
    background: var(--bg-alt, #F0EFEB);
}
.cw-header-info { flex: 1; }
.cw-header-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text, #2A2A2A);
    margin: 0;
    font-family: var(--font-sans, 'Noto Sans TC', sans-serif);
}
.cw-header-sub {
    font-size: 0.7rem;
    color: var(--text-muted, #888);
    margin-top: 2px;
}
.cw-header-identity {
    font-size: 0.7rem;
    color: var(--text-dim, #999);
    margin-top: 1px;
}
.cw-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted, #888);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}
.cw-close:hover { color: var(--text, #2A2A2A); }

/* ---------- 訊息流 ---------- */
.cw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 320px;
}

/* 訊息氣泡 */
.cw-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.6;
    word-break: break-word;
    font-family: var(--font-sans, 'Noto Sans TC', sans-serif);
}
.cw-msg-user {
    align-self: flex-end;
    background: var(--text, #2A2A2A);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.cw-msg-admin {
    align-self: flex-start;
    background: var(--bg-alt, #F0EFEB);
    color: var(--text, #2A2A2A);
    border: 1px solid var(--hairline, #E0DED8);
    border-bottom-left-radius: 4px;
}
.cw-msg-system {
    align-self: center;
    background: transparent;
    color: var(--text-muted, #888);
    font-size: 0.78rem;
    text-align: center;
    padding: 6px 12px;
}
.cw-msg-time {
    font-size: 0.65rem;
    color: var(--text-ghost, #B5B2AB);
    margin-top: 4px;
}
.cw-msg-user .cw-msg-time { text-align: right; color: rgba(255,255,255,0.6); }
.cw-msg-sender {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted, #888);
    margin-bottom: 2px;
}
.cw-msg-failed {
    color: #e74c3c;
    font-size: 0.75rem;
    cursor: pointer;
    margin-top: 4px;
    text-align: right;
}

/* 等待回覆提示 */
.cw-pending {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-ghost, #B5B2AB);
    padding: 8px 0;
}

/* ---------- FAQ 快捷區 ---------- */
.cw-faq {
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cw-faq-title {
    font-size: 0.72rem;
    color: var(--text-muted, #888);
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.cw-faq-btn {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-alt, #F0EFEB);
    border: 1px solid var(--hairline, #E0DED8);
    border-radius: 8px;
    font-size: 0.82rem;
    color: var(--text, #2A2A2A);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s;
    font-family: var(--font-sans, 'Noto Sans TC', sans-serif);
}
.cw-faq-btn:hover {
    border-color: var(--text-muted, #888);
    background: #fff;
}

/* ---------- 登入引導 ---------- */
.cw-login-hint {
    padding: 10px 16px;
    background: var(--bg-alt, #F0EFEB);
    border-top: 1px solid var(--hairline-light, #EDEBE6);
    text-align: center;
}
.cw-login-hint-text {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    margin-bottom: 8px;
    line-height: 1.5;
}
.cw-login-hint-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}
.cw-login-google {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid var(--hairline, #E0DED8);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text, #2A2A2A);
    text-decoration: none;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.cw-login-google:hover {
    border-color: #4285F4;
    box-shadow: 0 1px 4px rgba(66,133,244,0.15);
}
.cw-login-google svg { flex-shrink: 0; }
.cw-login-link {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}
.cw-login-link:hover {
    border-color: var(--text-muted, #888);
}

/* ---------- 輸入區 ---------- */
.cw-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--hairline, #E0DED8);
    border-radius: 0 0 16px 16px;
    background: #fff;
}
.cw-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--hairline, #E0DED8);
    border-radius: 10px;
    font-size: 0.85rem;
    font-family: var(--font-sans, 'Noto Sans TC', sans-serif);
    resize: none;
    min-height: 40px;
    max-height: 100px;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s;
}
.cw-input:focus { border-color: var(--text-muted, #888); }
.cw-input::placeholder { color: var(--text-ghost, #B5B2AB); }

.cw-send {
    padding: 10px 16px;
    background: var(--text, #2A2A2A);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
    font-family: var(--font-sans, 'Noto Sans TC', sans-serif);
}
.cw-send:disabled { opacity: 0.4; cursor: not-allowed; }
.cw-send:hover:not(:disabled) { opacity: 0.85; }

/* ---------- 空狀態 ---------- */
.cw-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    color: var(--text-muted, #888);
    font-size: 0.85rem;
    text-align: center;
    line-height: 1.6;
}
.cw-empty-icon { font-size: 2rem; margin-bottom: 12px; opacity: 0.5; }

/* ---------- honeypot ---------- */
.cw-hp { position: absolute; left: -9999px; }

/* ---------- 響應式 ---------- */
@media (max-width: 480px) {
    .cw-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 16px 16px 0 0;
    }
    .cw-messages { max-height: calc(100vh - 200px); max-height: calc(100dvh - 200px); }
    .cw-fab { bottom: 16px; right: 16px; }
}
