/* YH Chatbot Widget v2 */
#yhc-root {
    --yhc-accent:   #b8933a;
    --yhc-header:   #1a1a17;
    --yhc-htext:    #ffffff;
    --yhc-abg:      #b8933a;
    --yhc-atext:    #1a1a17;
    --yhc-btn:      #1a1a17;
    --yhc-btntext:  #ffffff;
    --yhc-bg:       #f4f3ef;
    --yhc-surface:  #ffffff;
    --yhc-border:   #e2e0d8;
    --yhc-mid:      #9a9790;
    --yhc-ink:      #1a1a17;
    --yhc-shadow:   0 8px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Bubble launcher ── */
#yhc-launcher-bubble {
    position: fixed;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--yhc-btn);
    color: var(--yhc-btntext);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    z-index: 9998;
    transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
}
#yhc-launcher-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,.3); }
#yhc-launcher-bubble.yhc-right { right: 24px; }
#yhc-launcher-bubble.yhc-left  { left:  24px; }
#yhc-launcher-bubble.yhc-open .yhc-launcher-icon  { display: none; }
#yhc-launcher-bubble.yhc-open .yhc-launcher-close { display: flex; }
.yhc-launcher-close { display: none; font-size: 18px; font-weight: 300; line-height: 1; }

/* ── Tab launcher ── */
#yhc-launcher-tab {
    position: fixed;
    bottom: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--yhc-btn);
    color: var(--yhc-btntext);
    border: none;
    border-radius: 12px 12px 0 0;
    padding: 10px 20px 10px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    z-index: 9998;
    box-shadow: 0 -2px 16px rgba(0,0,0,.15);
    transition: background .15s;
    -webkit-appearance: none;
    appearance: none;
    display: none; /* shown by JS when launcher_style = 'tab' */
}
#yhc-launcher-tab.yhc-right { right: 32px; }
#yhc-launcher-tab.yhc-left  { left:  32px; }
#yhc-launcher-tab:hover { filter: brightness(1.12); }
.yhc-tab-icon { font-size: 16px; }

/* ── Panel ── */
#yhc-panel {
    position: fixed;
    bottom: 90px;
    width: 370px;
    max-height: 580px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    background: var(--yhc-surface);
    border-radius: 18px;
    box-shadow: var(--yhc-shadow);
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
    transform: translateY(16px) scale(.97);
    pointer-events: none;
    transition: opacity .25s ease, transform .28s cubic-bezier(.22,.68,0,1.15);
}
#yhc-panel.yhc-right { right: 24px; }
#yhc-panel.yhc-left  { left:  24px; }
#yhc-panel.yhc-tab-mode { bottom: 54px; }
#yhc-panel.yhc-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

/* ── Header ── */
#yhc-header {
    background: var(--yhc-header);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.yhc-header-avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    background: var(--yhc-abg);
    color: var(--yhc-atext);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}
.yhc-header-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.yhc-header-info { flex: 1; min-width: 0; }
.yhc-header-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--yhc-htext);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.yhc-header-status {
    font-size: 11px;
    color: rgba(255,255,255,.65);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.yhc-status-dot {
    width: 6px;
    height: 6px;
    min-width: 6px;
    background: #4ade80;
    border-radius: 50%;
    animation: yhcPulse 2.4s infinite;
}
@keyframes yhcPulse { 0%,100%{opacity:1} 50%{opacity:.35} }
#yhc-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.6);
    font-size: 17px;
    cursor: pointer;
    padding: 5px 7px;
    border-radius: 6px;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
}
#yhc-close-btn:hover { color: #fff; background: rgba(255,255,255,.1); }

/* ── Messages ── */
#yhc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--yhc-bg);
    scroll-behavior: smooth;
}
#yhc-messages::-webkit-scrollbar { width: 3px; }
#yhc-messages::-webkit-scrollbar-thumb { background: var(--yhc-border); border-radius: 4px; }

.yhc-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: yhcFadeUp .18s ease;
}
@keyframes yhcFadeUp { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:translateY(0)} }
.yhc-msg.yhc-user { flex-direction: row-reverse; }

.yhc-msg-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: var(--yhc-abg);
    color: var(--yhc-atext);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}
.yhc-msg-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.yhc-msg.yhc-user .yhc-msg-avatar { background: var(--yhc-btn); color: var(--yhc-btntext); }

.yhc-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}
.yhc-msg.yhc-bot .yhc-bubble {
    background: var(--yhc-surface);
    color: var(--yhc-ink);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.yhc-msg.yhc-user .yhc-bubble {
    background: var(--yhc-btn);
    color: var(--yhc-btntext);
    border-bottom-right-radius: 4px;
}
/* Markdown in bubbles */
.yhc-bubble strong { font-weight: 600; }
.yhc-bubble ul, .yhc-bubble ol { margin: 6px 0 4px 18px; padding: 0; }
.yhc-bubble li { margin-bottom: 3px; }
.yhc-bubble a { color: var(--yhc-accent); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.yhc-bubble p { margin: 0 0 6px; }
.yhc-bubble p:last-child { margin: 0; }
/* Streaming cursor */
.yhc-bubble.yhc-streaming::after {
    content: '▍';
    display: inline-block;
    opacity: 1;
    animation: yhcCursor .55s steps(1) infinite;
    margin-left: 1px;
    color: var(--yhc-accent);
}
@keyframes yhcCursor { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Typing indicator ── */
.yhc-typing {
    background: var(--yhc-surface);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.yhc-typing span {
    width: 6px; height: 6px;
    background: var(--yhc-mid);
    border-radius: 50%;
    animation: yhcBounce 1.1s infinite;
}
.yhc-typing span:nth-child(2) { animation-delay:.18s; }
.yhc-typing span:nth-child(3) { animation-delay:.36s; }
@keyframes yhcBounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

/* ── Suggestions ── */
#yhc-suggestions {
    padding: 8px 12px 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--yhc-bg);
    border-top: 1px solid var(--yhc-border);
    flex-shrink: 0;
}
.yhc-suggestion {
    background: var(--yhc-surface);
    border: 1.5px solid var(--yhc-accent);
    border-radius: 20px;
    padding: 5px 13px;
    font-size: 12px;
    color: var(--yhc-accent);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
}
.yhc-suggestion:hover { background: var(--yhc-accent); color: #fff; }
.yhc-suggestion.yhc-active { background: var(--yhc-accent); color: #fff; }

/* ── Quick links ── */
#yhc-links {
    padding: 6px 12px 8px;
    background: var(--yhc-bg);
    border-top: 1px solid var(--yhc-border);
    flex-shrink: 0;
}
.yhc-links-heading {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--yhc-mid);
    margin-bottom: 6px;
}
.yhc-links-row { display: flex; flex-wrap: wrap; gap: 5px; }
.yhc-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--yhc-surface);
    border: 1px solid var(--yhc-border);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    font-family: inherit;
    color: var(--yhc-ink);
    text-decoration: none;
    white-space: nowrap;
    transition: all .15s;
    cursor: pointer;
}
.yhc-link-btn::before { content: '→'; font-size: 11px; color: var(--yhc-accent); }
.yhc-link-btn:hover { background: var(--yhc-accent); color: #fff; border-color: var(--yhc-accent); text-decoration: none; }
.yhc-link-btn:hover::before { color: #fff; }

/* ── Input area ── */
#yhc-input-area {
    padding: 10px 12px;
    background: var(--yhc-surface);
    border-top: 1px solid var(--yhc-border);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
#yhc-input {
    flex: 1;
    border: 1.5px solid var(--yhc-border);
    border-radius: 22px;
    padding: 9px 15px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: none;
    line-height: 1.4;
    max-height: 80px;
    overflow-y: auto;
    background: var(--yhc-bg);
    color: var(--yhc-ink);
    transition: border-color .18s;
}
#yhc-input:focus { border-color: var(--yhc-accent); background: #fff; }
#yhc-send {
    width: 38px; height: 38px;
    min-width: 38px; min-height: 38px;
    max-width: 38px; max-height: 38px;
    background: var(--yhc-btn);
    color: var(--yhc-btntext);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background .15s, transform .15s;
    -webkit-appearance: none;
    appearance: none;
}
#yhc-send:hover { filter: brightness(1.15); transform: scale(1.05); }
#yhc-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
#yhc-send svg { width: 16px; height: 16px; display: block; }

/* ── Powered by footer ── */
#yhc-footer {
    padding: 6px 14px;
    text-align: center;
    background: var(--yhc-surface);
    border-top: 1px solid var(--yhc-border);
    flex-shrink: 0;
}
#yhc-footer span { font-size: 10px; color: var(--yhc-mid); }
#yhc-footer a { color: var(--yhc-accent); text-decoration: none; }
#yhc-footer a:hover { text-decoration: underline; }

/* ── Mobile ── */
@media (max-width: 480px) {
    #yhc-panel { width: 100vw; right: 0!important; left: 0!important; border-radius: 18px 18px 0 0; bottom: 0!important; max-height: 80vh; }
    #yhc-launcher-bubble { right: 16px!important; left: auto!important; bottom: 16px!important; }
    #yhc-launcher-bubble.yhc-left { left: 16px!important; right: auto!important; }
}
