/* Tech by Giusi – AI Agent Widget v2.2.0 */

#tbg-agent-root {
    --tbg-accent:       #18181b;
    --tbg-accent-text:  #ffffff;
    --tbg-bg:           #ffffff;
    --tbg-bot-bg:       #f3f4f6;
    --tbg-text:         #111111;
    --tbg-border:       #e5e7eb;
    --tbg-muted:        #6b7280;
    --tbg-radius:       10px;
    --tbg-radius-sm:    7px;
    --tbg-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --tbg-shadow:       0 4px 24px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
    --tbg-fab-shadow:   0 2px 14px rgba(0,0,0,0.25);
    position: fixed;
    z-index: 99999;
    font-family: var(--tbg-font);
}

#tbg-agent-root.bottom-right { bottom: 24px; right: 24px; }
#tbg-agent-root.bottom-left  { bottom: 24px; left:  24px; }

#tbg-fab {
    width: 50px; height: 50px; border-radius: 50%;
    background: var(--tbg-accent); color: var(--tbg-accent-text);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--tbg-fab-shadow);
    transition: transform 0.18s ease; line-height: 1;
}
#tbg-fab:hover  { transform: scale(1.07); }
#tbg-fab:active { transform: scale(0.96); }

#tbg-chat-window {
    position: absolute; bottom: 62px;
    width: 348px; height: 510px;
    background: var(--tbg-bg);
    border: 1px solid var(--tbg-border);
    border-radius: var(--tbg-radius);
    box-shadow: var(--tbg-shadow);
    display: flex; flex-direction: column; overflow: hidden;
    opacity: 0; transform: translateY(10px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#tbg-agent-root.bottom-right #tbg-chat-window { right: 0; }
#tbg-agent-root.bottom-left  #tbg-chat-window { left: 0; }
#tbg-chat-window.tbg-open { opacity: 1; transform: none; pointer-events: all; }

#tbg-header {
    background: var(--tbg-accent); color: var(--tbg-accent-text);
    padding: 14px 16px;
    display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
#tbg-header-title {
    flex: 1; font-size: 16px; font-weight: 700;
    letter-spacing: -0.2px; color: var(--tbg-accent-text);
}
.tbg-online-dot { width: 7px; height: 7px; border-radius: 50%; background: #86efac; flex-shrink: 0; }
#tbg-close-btn {
    background: rgba(255,255,255,0.14); border: none;
    color: var(--tbg-accent-text); cursor: pointer;
    padding: 3px 8px; border-radius: 5px; font-size: 17px; line-height: 1;
    transition: background 0.15s; flex-shrink: 0;
}
#tbg-close-btn:hover { background: rgba(255,255,255,0.26); }

#tbg-messages {
    flex: 1; overflow-y: auto;
    padding: 14px; display: flex; flex-direction: column; gap: 9px;
    scroll-behavior: smooth;
}
#tbg-messages::-webkit-scrollbar { width: 3px; }
#tbg-messages::-webkit-scrollbar-thumb { background: var(--tbg-border); border-radius: 2px; }

.tbg-msg {
    max-width: 88%; font-size: 13.5px; line-height: 1.6;
    padding: 9px 12px; border-radius: var(--tbg-radius-sm); word-break: break-word;
}
.tbg-msg.tbg-bot {
    align-self: flex-start;
    background: var(--tbg-bot-bg); color: var(--tbg-text);
    border: 1px solid var(--tbg-border); border-bottom-left-radius: 2px;
}
.tbg-msg.tbg-user {
    align-self: flex-end;
    background: var(--tbg-accent); color: var(--tbg-accent-text);
    border-bottom-right-radius: 2px;
}
.tbg-msg.tbg-bot strong { font-weight: 600; }
.tbg-msg.tbg-bot em     { font-style: italic; }
.tbg-msg.tbg-bot code {
    font-family: 'SFMono-Regular', Consolas, monospace; font-size: 12px;
    background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px;
}
.tbg-msg.tbg-bot ul { margin: 6px 0 2px 0; padding-left: 18px; }
.tbg-msg.tbg-bot li { margin-bottom: 3px; }
.tbg-msg.tbg-bot a  { color: var(--tbg-accent); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }

.tbg-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.tbg-chip {
    font-size: 11.5px; padding: 4px 10px; border-radius: 20px;
    background: var(--tbg-bg); border: 1px solid var(--tbg-border);
    color: var(--tbg-muted); cursor: pointer;
    transition: border-color 0.15s, color 0.15s; font-family: var(--tbg-font);
}
.tbg-chip:hover { border-color: var(--tbg-accent); color: var(--tbg-accent); }

.tbg-typing { display: flex; align-items: center; gap: 4px; padding: 10px 12px; }
.tbg-typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--tbg-muted); animation: tbg-bounce 1.2s infinite; }
.tbg-typing span:nth-child(2) { animation-delay: 0.2s; }
.tbg-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tbg-bounce { 0%,80%,100%{opacity:0.3;transform:translateY(0)} 40%{opacity:1;transform:translateY(-3px)} }

#tbg-notice { font-size: 10.5px; color: var(--tbg-muted); text-align: center; padding: 3px 12px 6px; opacity: 0.65; }

#tbg-input-row {
    border-top: 1px solid var(--tbg-border);
    padding: 9px 11px; display: flex; gap: 7px; align-items: center;
    background: var(--tbg-bg); flex-shrink: 0;
}
#tbg-input {
    flex: 1; border: 1px solid var(--tbg-border);
    border-radius: var(--tbg-radius-sm); padding: 7px 11px;
    font-size: 13.5px; background: var(--tbg-bg);
    color: var(--tbg-text); outline: none;
    font-family: var(--tbg-font); transition: border-color 0.15s;
}
#tbg-input::placeholder { color: var(--tbg-muted); }
#tbg-input:focus { border-color: var(--tbg-accent); }

#tbg-send {
    background: var(--tbg-accent); color: var(--tbg-accent-text);
    border: none; border-radius: var(--tbg-radius-sm);
    padding: 7px 13px; font-size: 15px; cursor: pointer;
    font-family: var(--tbg-font); transition: opacity 0.15s; line-height: 1;
}
#tbg-send:disabled { opacity: 0.4; cursor: not-allowed; }
#tbg-send:not(:disabled):hover { opacity: 0.82; }

@media (max-width: 600px) {
    #tbg-agent-root.bottom-right,
    #tbg-agent-root.bottom-left {
        bottom: 0; right: 0; left: 0;
        width: 100%;
    }
    #tbg-fab {
        position: fixed;
        bottom: 16px; right: 16px;
        left: auto;
        z-index: 100000;
    }
    #tbg-chat-window {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%; height: 100%;
        border-radius: 0;
        border: none;
        transform: translateY(100%);
        transition: transform 0.25s ease, opacity 0.25s ease;
        opacity: 1;
    }
    #tbg-chat-window.tbg-open {
        transform: translateY(0);
        opacity: 1;
    }
    #tbg-fab { bottom: 16px; right: 16px; }
    #tbg-messages { padding: 12px; }
    .tbg-msg { max-width: 92%; font-size: 14px; }
    #tbg-header { padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); }
    #tbg-input-row { padding: 10px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    #tbg-input { font-size: 16px; }
}
