@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600&display=swap');

#di-widget * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Open Sans', sans-serif; }

/* LAUNCHER */
#di-launcher {
    position: fixed;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--di-color, #E8620A);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 99998;
}

#di-launcher.pos-right { right: 24px; }
#di-launcher.pos-left  { left: 24px; }
#di-launcher:hover { transform: scale(1.06); box-shadow: 0 6px 22px rgba(0,0,0,0.3); }
#di-launcher svg { width: 24px; height: 24px; fill: #fff; }
#di-launcher .ico-close { display: none; }
#di-launcher.open .ico-chat  { display: none; }
#di-launcher.open .ico-close { display: block; }

#di-unread {
    position: absolute;
    top: 1px; right: 1px;
    width: 13px; height: 13px;
    background: #00a32a;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}
#di-unread.show { display: block; }

/* WINDOW */
#di-window {
    position: fixed;
    bottom: 92px;
    width: 360px;
    height: 520px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    z-index: 99997;
    transform: scale(0.94) translateY(16px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.34,1.5,0.64,1), opacity 0.18s;
}

#di-window.pos-right { right: 24px; transform-origin: bottom right; }
#di-window.pos-left  { left: 24px;  transform-origin: bottom left; }
#di-window.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

/* HEADER */
#di-header {
    background: var(--di-color, #E8620A);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#di-avatar {
    width: 34px; height: 34px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

#di-header-name {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

#di-header-status {
    font-size: 11px;
    color: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

#di-header-status::before {
    content: '';
    display: block;
    width: 6px; height: 6px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
}

/* MESSAGES */
#di-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9f9f9;
    scroll-behavior: smooth;
}

#di-messages::-webkit-scrollbar { width: 3px; }
#di-messages::-webkit-scrollbar-track { background: #f0f0f0; }
#di-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.di-m {
    display: flex;
    gap: 7px;
    align-items: flex-end;
    animation: di-in 0.18s ease;
}

@keyframes di-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.di-m-ai   { flex-direction: row; }
.di-m-user { flex-direction: row-reverse; }

.di-av {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--di-color, #E8620A);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    flex-shrink: 0;
    font-weight: 600;
}

.di-bubble {
    max-width: 80%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.55;
}

.di-m-ai .di-bubble {
    background: #fff;
    border: 1px solid #e8e8e8;
    color: #1d2327;
    border-bottom-left-radius: 3px;
}

.di-m-user .di-bubble {
    background: var(--di-color, #E8620A);
    color: #fff;
    border-bottom-right-radius: 3px;
}

/* TYPING */
.di-dots { display: flex; gap: 3px; align-items: center; padding: 2px 0; }
.di-dots span {
    width: 5px; height: 5px;
    background: #aaa;
    border-radius: 50%;
    animation: di-dot 1.1s infinite;
}
.di-dots span:nth-child(2) { animation-delay: 0.18s; }
.di-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes di-dot {
    0%,80%,100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-5px); opacity: 1; }
}

/* INPUT */
#di-input-row {
    border-top: 1px solid #e8e8e8;
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: #fff;
}

#di-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-family: 'Open Sans', sans-serif;
    font-size: 13px;
    color: #1d2327;
    resize: none;
    max-height: 96px;
    min-height: 38px;
    line-height: 1.5;
    transition: border-color 0.15s;
    background: #f9f9f9;
}

#di-input:focus { outline: none; border-color: var(--di-color, #E8620A); background: #fff; }
#di-input::placeholder { color: #aaa; }

#di-send {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--di-color, #E8620A);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.1s;
}

#di-send:hover  { opacity: 0.88; }
#di-send:active { transform: scale(0.94); }
#di-send:disabled { opacity: 0.4; cursor: default; }
#di-send svg { width: 16px; height: 16px; fill: #fff; }

/* FOOTER */
#di-footer {
    text-align: center;
    padding: 5px;
    font-size: 10px;
    color: #bbb;
    background: #fff;
    border-top: 1px solid #f3f3f3;
    flex-shrink: 0;
}

/* MOBILE */
@media (max-width: 480px) {
    #di-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 110px);
        right: 10px !important;
        left: 10px !important;
        bottom: 84px;
    }
}
