/* assets/css/chatbot-frontend.css */

#llm-chatbot-container {
    position: fixed;
    bottom: 0px;
    right: 5%;
    width: 170px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    z-index: 9999;
    transition: width 0.5s ease, height 0.5s ease;
}
#llm-chatbot-container.expanded{
    width: 90%;
}

#llm-chatbot-container.expanded .hide-when-expanded{
    /*display: none !important;*/
    visibility: hidden;
}


#llm-chatbot-header {
    /* background: var(--fs-color-primary); */ /* #007cba; */
    background: linear-gradient(123deg,#37008f,#cc0003,#efb802,#16a103,#03a1a1);
    /* linear-gradient(300deg,#1c2435,#7f89a1,#1c2435);*/
  background-size: 180% 180%;
  animation: gradient-animation 18s ease infinite;
    color: white;
    padding: 15px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.expanded #llm-chatbot-header{
    background: linear-gradient(300deg,#1c2435,#7f89a1,#1c2435);
}
@keyframes gradient-animation {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

#llm-chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #FFFFFF;
}


#llm-chatbot-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    transition: background-color 0.2s;
}
.expanded #llm-chatbot-toggle{
    display: block;
}

#llm-chatbot-toggle:hover {
    background-color: rgba(255,255,255,0.1);
}

#llm-chatbot-window {
    background: white;
    border: 1px solid #e1e1e1;
    border-top: none;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-height:calc(100vh - 295px);
    min-height: 300px;
    /*height: 400px;*/
    display: flex;
    flex-direction: column;
}

#llm-chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    border-bottom: 1px solid #e1e1e1;
    background: #f8f9fa;
}

.chatbot-message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    animation: slideIn 0.3s ease-out;
}

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

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

.chatbot-message-content {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.3;
    word-wrap: break-word;
}

.chatbot-message.bot{
    gap: 5px;
}

.chatbot-message.user .chatbot-message-content {
    background: var(--fs-color-primary);/* #007cba; */
    color: white;
    border-bottom-right-radius: 2px;
}

.chatbot-message.bot .chatbot-message-content {
    background: white;
    color: #333;
    border: 1px solid #e1e1e1;
    border-top-left-radius: 2px;

    display: flex;
    gap: 1.1rem;
}

@media (max-width: 767px) {
    .chatbot-message.bot .chatbot-message-content {
        display: block;
    }
}



.chatbot-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.chatbot-message.user .chatbot-avatar {
    display: none;
    background: #0073aa;
    color: white;
    order: 1;
}

.chatbot-message.bot .chatbot-avatar {
    background: #f0f0f0;
    color: #666;
}

#llm-chatbot-input-container {
    padding: 15px;
    display: flex;
    gap: 10px;
    background: white;
}

#llm-chatbot-input {
    flex: 1;
    padding: 20px 15px;
    margin: 0;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#llm-chatbot-input:focus {
    border-color:  var(--fs-color-primary);/* #007cba; */
}

#llm-chatbot-send {
    background: var(--fs-color-primary);/* #007cba; */
    color: white;
    border: none;
    padding: 5px 15px;
    margin: 0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

#llm-chatbot-send:hover:not(:disabled) {
    background: #005a87;
}

#llm-chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#llm-chatbot-loading {
    padding: 15px;
    text-align: center;
    background: white;
    border-top: 1px solid #e1e1e1;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    background: var(--fs-color-primary);/* #007cba; */
    border-radius: 50%;
    display: inline-block;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 480px) {
    #llm-chatbot-container {
        width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
    }
    
    #llm-chatbot-window {
        height: 350px;
    }
}

/* Stili per i link ai capitoli */
.chatbot-chapter-links {
    margin-top: 15px;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 13px;
}

.chatbot-chapter-links strong {
    color: #495057;
    margin-bottom: 8px;
    display: block;
}

.chatbot-chapter-link {
    display: inline-block;
    background: var(--fs-color-primary);/* #007cba; */
    color: white !important;
    text-decoration: none;
    padding: 6px 12px;
    margin: 4px 4px 4px 0;
    border-radius: 15px;
    font-size: 12px;
    transition: all 0.2s ease;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chatbot-chapter-link:hover {
    background: #005a87;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chatbot-chapter-title {
    display: inline-block;
    background: #6c757d;
    color: white;
    padding: 6px 12px;
    margin: 4px 4px 4px 0;
    border-radius: 15px;
    font-size: 12px;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive per mobile */
@media (max-width: 480px) {
    .chatbot-chapter-link,
    .chatbot-chapter-title {
        max-width: 200px;
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* Scrollbar personalizzata */
#llm-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

#llm-chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#llm-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}