/* ── Trigger (floating avatar) ── */
#hiveiq-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9100;
    display: none;
}

#hiveiq-widget-trigger {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid #f77e0f;
    padding: 0;
    cursor: pointer;
    background: #fff;
    box-shadow: 0 4px 18px rgba(0,0,0,0.22);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    animation: hiveiq-widget-bob 9s ease-in-out infinite;
}

#hiveiq-widget-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(247,126,15,0.35);
}

#hiveiq-widget-trigger.is-open {
    animation: none;
    box-shadow: 0 6px 24px rgba(247,126,15,0.45);
}

#hiveiq-widget-trigger img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    display: block;
}

@keyframes hiveiq-widget-bob {
    0%, 72%, 100% { transform: translateY(0); }
    76%  { transform: translateY(-11px); }
    81%  { transform: translateY(5px); }
    86%  { transform: translateY(-7px); }
    91%  { transform: translateY(3px); }
    96%  { transform: translateY(-2px); }
}

/* ── Panel ── */
#hiveiq-widget-panel {
    position: absolute;
    right: 0;
    bottom: 90px;
    width: 360px;
    max-height: 540px;
    min-height: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateX(12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#hiveiq-widget-panel.is-open {
    opacity: 1;
    pointer-events: all;
    transform: translateX(0);
}

/* ── Panel header ── */
#hiveiq-widget-header {
    background: #111;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.hiveiq-widget-header__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.hiveiq-widget-header__info {
    flex: 1;
    min-width: 0;
}

.hiveiq-widget-header__name {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
}

.hiveiq-widget-header__sub {
    color: #f77e0f;
    font-size: 0.72rem;
}

.hiveiq-widget-header__actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hiveiq-widget-header__actions button,
.hiveiq-widget-header__actions a {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
    text-decoration: none;
}

.hiveiq-widget-header__actions button:hover,
.hiveiq-widget-header__actions a:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.hiveiq-widget-header__actions svg {
    width: 16px;
    height: 16px;
}

/* ── Messages ── */
#hiveiq-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f8fc;
}

#hiveiq-widget-messages::-webkit-scrollbar { width: 4px; }
#hiveiq-widget-messages::-webkit-scrollbar-track { background: transparent; }
#hiveiq-widget-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.hiveiq-widget-msg {
    display: flex;
    max-width: 88%;
}

.hiveiq-widget-msg--user {
    align-self: flex-end;
}

.hiveiq-widget-msg--assistant {
    align-self: flex-start;
}

.hiveiq-widget-msg__bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.55;
    word-break: break-word;
}

.hiveiq-widget-msg--user .hiveiq-widget-msg__bubble {
    background: #f77e0f;
    color: #fff;
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}

.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble {
    background: #fff;
    color: #2a2a4a;
    border: 1px solid #e8eaf0;
    border-bottom-left-radius: 4px;
}

/* Markdown in assistant bubbles */
.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble p { margin: 0 0 0.5em; }
.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble p:last-child { margin-bottom: 0; }
.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble ul,
.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble ol { margin: 0.3em 0; padding-left: 1.4em; }
.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble li { margin-bottom: 0.2em; }
.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble code {
    background: #f0f1f5;
    padding: 0.1em 0.3em;
    border-radius: 4px;
    font-size: 0.85em;
}
.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 8px 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.4em 0;
    font-size: 0.82em;
}
.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble pre code {
    background: none;
    padding: 0;
}
.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble a { color: #f77e0f; }
.hiveiq-widget-msg--assistant .hiveiq-widget-msg__bubble strong { font-weight: 600; }

/* Typing indicator */
.hiveiq-widget-typing .hiveiq-widget-msg__bubble {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 14px;
}

.hiveiq-widget-typing span {
    width: 6px;
    height: 6px;
    background: #bbb;
    border-radius: 50%;
    animation: hiveiq-widget-dot 1.2s infinite;
}

.hiveiq-widget-typing span:nth-child(2) { animation-delay: 0.2s; }
.hiveiq-widget-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes hiveiq-widget-dot {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Empty state */
.hiveiq-widget-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    gap: 12px;
}

.hiveiq-widget-empty-state__text {
    font-size: 0.88rem;
    color: #555;
    font-weight: 500;
    margin: 0;
}

.hiveiq-widget-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.hiveiq-widget-chip {
    background: #fff;
    border: 1px solid #e0e2ea;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.78rem;
    color: #555;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.hiveiq-widget-chip:hover {
    border-color: #f77e0f;
    color: #f77e0f;
}

/* ── Input footer ── */
#hiveiq-widget-footer {
    padding: 10px 12px;
    border-top: 1px solid #e8eaf0;
    background: #fff;
    flex-shrink: 0;
}

#hiveiq-widget-input-row {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

#hiveiq-widget-input {
    flex: 1;
    border: 1px solid #dde0e8;
    border-radius: 10px;
    padding: 8px 11px;
    font-size: 0.85rem;
    resize: none;
    outline: none;
    line-height: 1.45;
    max-height: 100px;
    overflow-y: auto;
    font-family: inherit;
    color: #2a2a4a;
    transition: border-color 0.15s;
}

#hiveiq-widget-input:focus { border-color: #f77e0f; }
#hiveiq-widget-input::placeholder { color: #aaa; }

.hiveiq-widget-icon-btn {
    background: #f5f5f8;
    border: 1px solid #dde0e8;
    border-radius: 9px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    color: #666;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.hiveiq-widget-icon-btn:hover { background: #ffe8d0; border-color: #f77e0f; color: #f77e0f; }

.hiveiq-widget-icon-btn.is-recording,
.hiveiq-widget-icon-btn.is-speaking {
    background: #f77e0f;
    color: #fff;
    border-color: #f77e0f;
    animation: hiveiq-widget-pulse 1.5s infinite;
}

.hiveiq-widget-icon-btn.is-active {
    background: #fff3e6;
    color: #f77e0f;
    border-color: #f77e0f;
}

.hiveiq-widget-icon-btn:disabled,
.hiveiq-widget-icon-btn.is-loading {
    background: #e8e8e8;
    color: #bbb;
    border-color: #e0e0e0;
    cursor: not-allowed;
}

.hiveiq-widget-icon-btn svg { width: 16px; height: 16px; }

#hiveiq-widget-send {
    background: #f77e0f;
    border-color: #f77e0f;
    color: #fff;
}

#hiveiq-widget-send:hover:not(:disabled) { background: #e06800; border-color: #e06800; }

@keyframes hiveiq-widget-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(247,126,15,0.4); }
    50% { box-shadow: 0 0 0 5px rgba(247,126,15,0); }
}

#hiveiq-widget-error {
    display: none;
    margin-top: 6px;
    background: #fff0f0;
    border: 1px solid #f4c2c2;
    color: #c0392b;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.78rem;
}

/* ── Mobile ── */
@media (max-width: 640px) {
    #hiveiq-widget {
        right: 12px;
        bottom: 12px;
    }

    #hiveiq-widget-panel {
        position: fixed;
        right: 12px;
        bottom: 88px;
        left: 12px;
        width: auto;
        max-height: 70vh;
        min-height: 320px;
    }
}
