/* Tuttocartucce AI Assistant — Widget Chat */

#tc-chatbot-toggle {
    position: fixed;
    bottom: 50%;
    right: 20px;
    z-index: 99998;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: visible;
    background: #4c5c6b;
    border: 2px solid #f7941d;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(76, 92, 107, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#tc-chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(76, 92, 107, 0.5);
}

#tc-chatbot-toggle svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

#tc-chatbot-toggle .tc-close-icon {
    display: none;
}

#tc-chatbot-toggle.tc-open .tc-chat-icon {
    display: none;
}

#tc-chatbot-toggle.tc-open .tc-close-icon {
    display: block;
}

/* Badge notifica */
#tc-chatbot-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: #e53935;
    border-radius: 50%;
    overflow: visible;
    border: 2px solid #fff;
    display: none;
}

/* Container Chat */
#tc-chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 92px;
    z-index: 99999;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: visible;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

#tc-chatbot-container.tc-visible {
    display: flex;
    animation: tc-slide-up 0.25s ease-out;
}

@keyframes tc-slide-up {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
#tc-chatbot-header {
    background: #4c5c6b;
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#tc-chatbot-header .tc-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#tc-chatbot-header .tc-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

#tc-chatbot-header .tc-header-text h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

#tc-chatbot-header .tc-header-text p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.85;
}

/* Area messaggi */
#tc-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

#tc-chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

#tc-chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* Messaggi */
.tc-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}

.tc-msg-bot {
    background: #fff;
    color: #1a1a1a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tc-msg-user {
    background: #4c5c6b;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Link nei messaggi bot */
.tc-msg-bot a {
    color: #4c5c6b;
    text-decoration: none;
    font-weight: 500;
}

.tc-msg-bot a:hover {
    text-decoration: underline;
}

/* Bold nei messaggi */
.tc-msg-bot strong {
    font-weight: 600;
}

/* Indicatore di digitazione */
.tc-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tc-typing span {
    width: 7px;
    height: 7px;
    background: #b0b0b0;
    border-radius: 50%;
    overflow: visible;
    animation: tc-bounce 1.4s ease-in-out infinite;
}

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

@keyframes tc-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Area input */
#tc-chatbot-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}

#tc-chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

#tc-chatbot-input:focus {
    border-color: #4c5c6b;
}

#tc-chatbot-input::placeholder {
    color: #999;
}

/* Bottone foto */
#tc-chatbot-photo-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: visible;
    border: 2px solid #f7941d;
    background: #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

#tc-chatbot-photo-btn:hover {
    background: #e0e0e0;
}

#tc-chatbot-photo-btn svg {
    width: 18px;
    height: 18px;
    fill: #666;
}

/* Bottone invio */
#tc-chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: visible;
    border: 2px solid #f7941d;
    background: #4c5c6b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, opacity 0.2s;
}

#tc-chatbot-send:hover {
    background: #3d4d5a;
}

#tc-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#tc-chatbot-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* Preview immagine */
#tc-chatbot-image-preview {
    display: none;
    padding: 8px 16px 0;
    background: #fff;
}

#tc-chatbot-image-preview .tc-preview-inner {
    position: relative;
    display: inline-block;
}

#tc-chatbot-image-preview img {
    max-height: 80px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

#tc-chatbot-image-preview .tc-remove-image {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: #e53935;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    overflow: visible;
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

/* Immagine nei messaggi utente */
.tc-msg-user img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
    margin-bottom: 6px;
    display: block;
}

/* Suggerimenti rapidi */
.tc-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tc-suggestion-btn {
    background: #e8edf2;
    color: #4c5c6b;
    border: 2px solid #f7941d;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.tc-suggestion-btn:hover {
    background: #d0d8e0;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #tc-chatbot-container {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    #tc-chatbot-toggle {
        bottom: 76px;
        right: 16px;
    }
    
    #tc-chatbot-container.tc-visible {
        animation: tc-slide-up-mobile 0.2s ease-out;
    }
    
    @keyframes tc-slide-up-mobile {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* File input nascosto */
#tc-chatbot-file-input {
    display: none;
}

/* Ripple animation */
#tc-chatbot-toggle::before,
#tc-chatbot-toggle::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid #f7941d;
    border-radius: 50%;
    animation: tc-ripple 2.5s ease-out infinite;
    pointer-events: none;
}
#tc-chatbot-toggle::after {
    animation-delay: 1.25s;
}
#tc-chatbot-toggle.tc-open::before,
#tc-chatbot-toggle.tc-open::after {
    animation: none;
    opacity: 0;
}
@keyframes tc-ripple {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}
