/* Chatbot AI Widget Styles */

.chatbot-ai-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.chatbot-ai-widget.bottom-right {
    bottom: 20px;
    right: 20px;
}

.chatbot-ai-widget.bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Pulsante di apertura */
.chatbot-ai-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary-color, #667eea) 0%, var(--chatbot-secondary-color, #764ba2) 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
    font-size: 26px;
}

.chatbot-ai-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.chatbot-ai-toggle i {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Finestra chat */
.chatbot-ai-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-ai-window.open {
    display: flex;
}

.chatbot-ai-widget.bottom-right .chatbot-ai-window {
    right: 0;
}

.chatbot-ai-widget.bottom-left .chatbot-ai-window {
    left: 0;
}

/* Header */
.chatbot-ai-header {
    background: linear-gradient(135deg, var(--chatbot-primary-color, #667eea) 0%, var(--chatbot-secondary-color, #764ba2) 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-ai-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 18px;
}

.chatbot-ai-header-icon {
    font-size: 24px;
}

.chatbot-ai-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    padding: 0;
    flex-shrink: 0;
}

.chatbot-ai-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messaggi */
.chatbot-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chatbot-ai-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-ai-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chatbot-ai-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chatbot-ai-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Messaggio */
.chatbot-ai-message {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-ai-message.user {
    justify-content: flex-end;
}

.chatbot-ai-message.bot {
    justify-content: flex-start;
}

.chatbot-ai-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.chatbot-ai-message.user .chatbot-ai-message-content {
    background: linear-gradient(135deg, var(--chatbot-primary-color, #667eea) 0%, var(--chatbot-secondary-color, #764ba2) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-ai-message.bot .chatbot-ai-message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

/* Formattazione messaggi bot */
.chatbot-ai-message.bot .chatbot-ai-message-content strong {
    font-weight: 600;
    color: var(--chatbot-primary-color, #667eea);
}

.chatbot-ai-message.bot .chatbot-ai-message-content ul {
    list-style: none;
    padding-left: 0;
    margin: 10px 0;
}

.chatbot-ai-message.bot .chatbot-ai-message-content li {
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
    line-height: 1.6;
}

.chatbot-ai-message.bot .chatbot-ai-message-content li:before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--chatbot-primary-color, #667eea);
    font-weight: bold;
    font-size: 1.1em;
}

/* Indicatore di typing */
.chatbot-ai-typing {
    display: none;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 75%;
}

.chatbot-ai-typing.active {
    display: block;
}

.chatbot-ai-typing-dots {
    display: flex;
    gap: 4px;
}

.chatbot-ai-typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.chatbot-ai-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-ai-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Input area */
.chatbot-ai-input-area {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-ai-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.chatbot-ai-input:focus {
    border-color: var(--chatbot-primary-color, #667eea);
}

.chatbot-ai-send {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--chatbot-primary-color, #667eea) 0%, var(--chatbot-secondary-color, #764ba2) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chatbot-ai-send:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.chatbot-ai-send:active {
    transform: scale(1);
}

.chatbot-ai-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.chatbot-ai-send svg {
    width: 24px;
    height: 24px;
}

/* Responsive */
@media (max-width: 768px) {
    .chatbot-ai-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        bottom: 80px;
    }
    
    .chatbot-ai-widget.bottom-right,
    .chatbot-ai-widget.bottom-left {
        right: 20px;
    }
    
    .chatbot-ai-widget.bottom-right .chatbot-ai-window,
    .chatbot-ai-widget.bottom-left .chatbot-ai-window {
        right: 0;
        left: 0;
    }
}

/* Badge powered by */
.chatbot-ai-powered {
    padding: 10px;
    text-align: center;
    font-size: 11px;
    color: #999;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.chatbot-ai-powered a {
    color: var(--chatbot-primary-color, #667eea);
    text-decoration: none;
}

.chatbot-ai-powered a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {

  /* Widget: sempre in basso a destra */
  .chatbot-ai-widget.bottom-right,
  .chatbot-ai-widget.bottom-left {
    right: 20px;
    left: auto; /* importantissimo */
  }

  /* Finestra: ancorata a destra */
  .chatbot-ai-widget.bottom-right .chatbot-ai-window,
  .chatbot-ai-widget.bottom-left .chatbot-ai-window {
    right: 0;
    left: auto; /* evita che si sposti/si centri */
  }
}

.chatbot-ai-message.bot .chatbot-ai-message-content a {
  font-size: 11px;
  color: #667eea;
  text-decoration: underline;
}