/* =====================================================
   AI Chatbox – Frontend Widget Styles
   ===================================================== */

/* ── Container ── */
#aichatbox-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── Toggle bubble ── */
#aichatbox-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, .45);
    transition: transform .2s, box-shadow .2s;
    outline: none;
}

#aichatbox-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(102, 126, 234, .55);
}

/* Unread badge */
#aichatbox-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    animation: aichatbox-pop .25s ease;
}

@keyframes aichatbox-pop {
    0%   { transform: scale(0); }
    80%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ── Widget panel ── */
#aichatbox-widget {
    position: fixed;
    bottom: 98px;
    right: 24px;
    width: 360px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: aichatbox-slide-in .25s ease;
}

@keyframes aichatbox-slide-in {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ── Header ── */
#aichatbox-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#aichatbox-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#aichatbox-avatar {
    font-size: 28px;
    line-height: 1;
}

#aichatbox-header-info strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

#aichatbox-status {
    font-size: 11px;
    opacity: .85;
}

#aichatbox-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#aichatbox-delete {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .85;
    transition: opacity .15s, background .15s;
}

#aichatbox-delete:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.25);
}

#aichatbox-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: .8;
    transition: opacity .15s;
}

#aichatbox-close:hover { opacity: 1; }

/* ── Messages area ── */
#aichatbox-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f6f7fb;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

/* Scrollbar */
#aichatbox-messages::-webkit-scrollbar { width: 5px; }
#aichatbox-messages::-webkit-scrollbar-track { background: transparent; }
#aichatbox-messages::-webkit-scrollbar-thumb { background: #c5c9d6; border-radius: 3px; }

/* ── Message bubbles ── */
.aichatbox-message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.aichatbox-message.user  { flex-direction: row-reverse; }

.aichatbox-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.aichatbox-message.user .aichatbox-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.aichatbox-message.assistant .aichatbox-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e4e6ef;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* ── Typing indicator ── */
#aichatbox-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px 4px;
    flex-shrink: 0;
}

#aichatbox-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #764ba2;
    animation: aichatbox-bounce 1.2s infinite ease-in-out;
}

#aichatbox-typing span:nth-child(2) { animation-delay: .2s; }
#aichatbox-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes aichatbox-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Input area ── */
#aichatbox-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #e9ebf0;
    flex-shrink: 0;
}

#aichatbox-input {
    flex: 1;
    border: 1px solid #d8dbe6;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    resize: none;
    outline: none;
    line-height: 1.4;
    max-height: 100px;
    overflow-y: auto;
    font-family: inherit;
    transition: border-color .2s;
}

#aichatbox-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, .15);
}

#aichatbox-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .2s, transform .15s;
    outline: none;
}

#aichatbox-send:hover  { opacity: .88; transform: scale(1.06); }
#aichatbox-send:active { transform: scale(.96); }

#aichatbox-send:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    #aichatbox-widget {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 84px;
        max-height: calc(100dvh - 110px);
    }

    #aichatbox-toggle {
        right: 10px;
        bottom: 10px;
    }

    #aichatbox-container {
        right: 10px;
        bottom: 10px;
    }
}

