/* ==========================================================
   NYX AI – CHAT BASE
========================================================== */

.nyx-ai-chat {
    width: 100%;
    height: 100%;
    max-width: none; 
    background: #ffffff;
    border-radius: 12px;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    overflow: hidden;
}

/* Header */
.nyx-ai-header {
    padding: 14px 16px;
    background: var(--nyx-ai-header-bg, #0f172a);
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.nyx-ai-header-left {
    display: flex;
    flex-direction: column;
}

.nyx-ai-subtitle {
    font-size: 12px;
    opacity: 0.8;
}

/* ==========================================================
   MESSAGGI
========================================================== */

.nyx-ai-messages {
    padding: 16px;
    background: #f9fafb;
}

.nyx-ai-message {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    font-size: 14px;
    max-width: 85%;
}

.nyx-ai-message-bot {
    background: #e5e7eb;
    color: #111827;
}

.nyx-ai-message-user {
    background: #0f172a;
    color: #ffffff;
    margin-left: auto;
}

.nyx-ai-answer {
    line-height: 1.55;
    font-size: 15px;
}

.nyx-ai-answer p {
    margin: 0 0 0.9em 0;
}

.nyx-ai-answer p:last-child {
    margin-bottom: 0;
}

.nyx-ai-answer strong {
    font-weight: 600;
}

/* ==========================================================
   LOADING
========================================================== */

#nyx-ai-loading {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 96px;
    padding: 10px 0;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    z-index: 10;
    display: none;
}

#nyx-ai-loading.is-visible {
    display: block;
}

.nyx-ai-loading-text {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
}

.nyx-ai-loading-dots {
    display: flex;
    justify-content: center;
}

.nyx-ai-loading .dot {
    font-size: 20px;
    margin: 0 3px;
    color: #666;
    animation: nyx-dot-blink 1.4s infinite both;
}

.nyx-ai-loading .dot:nth-child(1) { animation-delay: 0s; }
.nyx-ai-loading .dot:nth-child(2) { animation-delay: .2s; }
.nyx-ai-loading .dot:nth-child(3) { animation-delay: .4s; }

@keyframes nyx-dot-blink {
    0% { opacity: .2; }
    20% { opacity: 1; }
    100% { opacity: .2; }
}

/* ==========================================================
   INPUT
========================================================== */

.nyx-ai-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

.nyx-ai-input input {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
}

.nyx-ai-input button {
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    background: var(--nyx-ai-button-bg, #0f172a);
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
}

/* ==========================================================
   RESET BUTTON
========================================================== */

.nyx-ai-reset {
    border: none;
    background: transparent;
    color: #ffffff;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    opacity: 0.8;
}

.nyx-ai-reset:hover {
    opacity: 1;
    background: rgba(255,255,255,.12);
}

.nyx-ai-reset-icon {
    width: 30px;
    height: 30px;
    fill: currentColor;
    transform: rotate(55deg);
}

/* ==========================================================
   CHATBOT FLOTTANTE – FAB
========================================================== */

#nyx-chatbot-fab {
    position: fixed;
    z-index: 9999;
}

/* FAB */
#nyx-chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--nyx-ai-fab-bg, #2f4872);
    color: #ffffff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

/* ==========================================================
   PANEL FLOTTANTE (ANCORATO AL FAB)
========================================================== */

#nyx-chatbot-panel {
    position: absolute;
    width: var(--nyx-ai-width-desktop, 45vw);
    height: var(--nyx-ai-height-desktop, 70vh);
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,.25);
    overflow: hidden;
    display: none;
}

#nyx-chatbot-fab.is-open #nyx-chatbot-panel {
    display: block;
}

/* ==========================================================
   POSIZIONI – LOGICA INTELLIGENTE
========================================================== */

/* BOTTOM RIGHT */
#nyx-chatbot-fab.nyx-chatbot-pos-bottom-right {
    right: 15px;
    bottom: 24px;
}
#nyx-chatbot-fab.nyx-chatbot-pos-bottom-right #nyx-chatbot-panel {
    right: 0;
    bottom: 66px;
}

/* BOTTOM LEFT */
#nyx-chatbot-fab.nyx-chatbot-pos-bottom-left {
    left: 15px;
    bottom: 24px;
}
#nyx-chatbot-fab.nyx-chatbot-pos-bottom-left #nyx-chatbot-panel {
    left: 0;
    bottom: 66px;
}

/* CENTER RIGHT */
#nyx-chatbot-fab.nyx-chatbot-pos-center-right {
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
}
#nyx-chatbot-fab.nyx-chatbot-pos-center-right #nyx-chatbot-panel {
    right: 66px;
    top: 50%;
    transform: translateY(-50%);
}

/* CENTER LEFT */
#nyx-chatbot-fab.nyx-chatbot-pos-center-left {
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
}
#nyx-chatbot-fab.nyx-chatbot-pos-center-left #nyx-chatbot-panel {
    left: 66px;
    top: 50%;
    transform: translateY(-50%);
}

/* ==========================================================
   STRUTTURA INTERNA PANEL
========================================================== */

#nyx-chatbot-panel .nyx-ai-chat {
    height: 100%;
    position: relative;
}

#nyx-chatbot-panel .nyx-ai-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    z-index: 2;
}

#nyx-chatbot-panel .nyx-ai-input {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    z-index: 2;
}

#nyx-chatbot-panel .nyx-ai-messages {
    position: absolute;
    top: 64px;
    bottom: 64px;
    left: 0;
    right: 0;
    overflow-y: auto;
}


/* ==========================================================
   NYX AI – INPUT A 2 RIGHE (PATCH MINIMA)
========================================================== */

#nyx-chatbot-panel .nyx-ai-input {
    height: 96px;
    flex-direction: column;
    gap: 4px;
}

.nyx-ai-input-row {
    display: flex;
    gap: 8px;
}

.nyx-ai-input-meta {
    font-size: 12px;
    color: #666;
    text-align: center;
    line-height: 1.2;
    padding-top:8px
}

#nyx-chatbot-panel .nyx-ai-messages {
    bottom: 92px;
}

/* ==========================================================
   MOBILE
========================================================== */

@media (max-width: 576px) {

    #nyx-chatbot-fab {
        right: 15px;
        bottom: 24px;
        left: auto;
        top: auto;
        transform: none;
    }

  #nyx-chatbot-panel {
    width: var(--nyx-ai-width-mobile, 90vw);
    height: var(--nyx-ai-height-mobile, 80vh);
    right: 0;
    left: auto;
    bottom: 66px;
    top: auto;
    transform: none;
}
}