/* AI Widget (floating) */
.ai-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
}

/* FAB (Floating Action Button) when collapsed */
.ai-widget-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--colore-accento), var(--colore-accento-secondario));
    box-shadow: 0 4px 16px rgba(var(--colore-accento-rgb), 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-widget-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(var(--colore-accento-rgb), 0.5);
}

.ai-widget-fab:active {
    transform: scale(0.96);
}

.ai-widget-fab .material-symbols-rounded {
    font-size: 28px;
    color: #fff;
}

.ai-widget-panel {
    width: 320px;
}

@media (max-width: 480px) {
    .ai-widget {
        right: 12px;
        bottom: 12px;
    }

    .ai-widget-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
    }

    .ai-widget-fab {
        width: 48px;
        height: 48px;
    }

    .ai-widget-fab .material-symbols-rounded {
        font-size: 24px;
    }
}

.ai-widget-panel {
    background: var(--colore-container);
    border: 1px solid var(--colore-bordo);
    border-radius: 12px;
    box-shadow: var(--ombra-media);
    overflow: hidden;
}

.ai-widget-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    max-height: 600px;
    opacity: 1;
    transition: max-height 180ms ease, opacity 180ms ease;
}

.ai-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--colore-sfondo);
    border-bottom: 1px solid var(--colore-bordo);
    user-select: none;
    cursor: pointer;
}

.ai-widget-body {
    padding: 10px 12px;
    max-height: 520px;
    overflow: hidden;
    opacity: 1;
    transition: max-height 180ms ease, opacity 180ms ease, padding 180ms ease;
}

.ai-widget-body--collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

.ai-widget-output {
    max-height: 220px;
    overflow-y: auto;
    border-top: 1px solid var(--colore-bordo);
    padding-top: 8px;
    font-size: 14px;
}

/* Markdown content inside widget */
.ai-widget-markdown {
    color: #e5e7eb;
}

.ai-widget-markdown a {
    color: var(--colore-accento);
    text-decoration: none;
}

.ai-widget-markdown a:hover {
    text-decoration: underline;
}

.ai-widget-markdown h1,
.ai-widget-markdown h2,
.ai-widget-markdown h3,
.ai-widget-markdown h4,
.ai-widget-markdown h5,
.ai-widget-markdown h6 {
    margin: 0.5rem 0;
    font-weight: 700;
}

.ai-widget-markdown h1 { font-size: 1.1rem; }
.ai-widget-markdown h2 { font-size: 1.05rem; }
.ai-widget-markdown h3 { font-size: 1.0rem; }

.ai-widget-markdown p {
    margin: 0.4rem 0;
}

.ai-widget-markdown ul,
.ai-widget-markdown ol {
    padding-left: 1.2rem;
    margin: 0.4rem 0;
}

.ai-widget-markdown li {
    margin: 0.2rem 0;
}

.ai-widget-markdown blockquote {
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--colore-accento);
    background: var(--colore-sfondo);
    border-radius: 8px;
}

.ai-widget-markdown hr {
    border: none;
    border-top: 1px solid var(--colore-bordo);
    margin: 0.6rem 0;
}

.ai-widget-markdown code {
    background: var(--colore-sfondo);
    border: 1px solid var(--colore-bordo);
    padding: 0.1rem 0.3rem;
    border-radius: 6px;
}

.ai-widget-markdown pre {
    background: var(--colore-sfondo);
    border: 1px solid var(--colore-bordo);
    border-radius: 10px;
    padding: 10px;
    margin: 0.6rem 0;
}

.ai-widget-markdown pre code {
    background: transparent;
    border: none;
    padding: 0;
}

.ai-widget-markdown img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--colore-bordo);
}

/* AI widget tweaks (scoped) */

/* Evita il blu Bootstrap nel widget */
.ai-widget .btn-primary {
    background: linear-gradient(135deg, var(--colore-accento), var(--colore-accento-secondario));
    border-color: transparent;
    color: #fff;
}

.ai-widget .btn-primary:hover,
.ai-widget .btn-primary:focus {
    filter: brightness(1.05);
    box-shadow: 0 6px 18px rgba(var(--colore-accento-rgb), 0.25);
}

.ai-widget .btn-primary:active {
    filter: brightness(0.98);
}
