/* =============================================
   Smartypilot Product Q&A Widget
   ============================================= */

.smp-qa-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    box-sizing: border-box;
    background: #f7f8fa;
    border: 1px solid #e4e6ea;
    border-radius: 12px;
    margin-top: 25px;
    padding: 18px 20px;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
}

/* Header */
.smp-qa-header {
    font-weight: 600;
    font-size: 14px;
    color: #222;
    margin-bottom: 12px;
}

/* Input + bottone — riga form */
.smp-qa-form {
    display: flex;
    align-items: stretch;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Wrapper input + clear button */
.smp-qa-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
}

.smp-qa-form input[type="text"] {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 34px 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    color: #333;
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
}

.smp-qa-form input[type="text"]::placeholder {
    color: #b0b8c1;
}

/* Pulsante clear (×) dentro il campo */
.smp-qa-clear-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #c0c8d0;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.15s ease;
}

.smp-qa-clear-btn:hover {
    color: #555;
}

.smp-qa-clear-btn.smp-qa-visible {
    display: flex;
}

/* Pulsante Chiedi */
.smp-qa-form button:not(.smp-qa-clear-btn) {
    flex-shrink: 0;
    border: none;
    border-left: 1px solid #d0d5dd;
    background: #fff;
    color: var(--smp-qa-accent, #2563eb);
    padding: 0 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.smp-qa-form button:not(.smp-qa-clear-btn):hover:not(:disabled) {
    background: var(--smp-qa-accent, #2563eb);
    color: #fff;
}

.smp-qa-form button:disabled,
.smp-qa-form input[type="text"]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Area risposta */
.smp-qa-answer {
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.smp-qa-answer:empty {
    margin-top: 0;
}

.smp-qa-answer p {
    margin: 4px 0;
}

.smp-qa-answer ul,
.smp-qa-answer ol {
    margin: 6px 0;
    padding-left: 20px;
}

.smp-qa-answer li {
    margin-bottom: 3px;
}

.smp-qa-answer strong {
    font-weight: 600;
}

/* Messaggio di errore inline */
.smp-qa-error {
    color: #c0392b;
    font-size: 13px;
}

/* Footer disclaimer AI — inizialmente nascosto, compare dopo la risposta */
.smp-qa-footer {
    margin-top: 8px;
    font-size: 11px;
    color: #b0b8c1;
    line-height: 1.4;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.4s ease, max-height 0.4s ease;
}

.smp-qa-footer--visible {
    opacity: 1;
    max-height: 60px;
}

/* Cursore lampeggiante durante l'animazione typewriter */
.smp-qa-answer--typing::after {
    content: '|';
    display: inline-block;
    margin-left: 1px;
    color: var(--smp-qa-accent, #2563eb);
    animation: smp-qa-blink 0.7s infinite;
}

@keyframes smp-qa-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* Loading dots */
.smp-qa-loader {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 4px 0;
}

.smp-qa-loader span {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--smp-qa-accent, #2563eb);
    border-radius: 50%;
    animation: smp-qa-bounce 1.2s infinite ease-in-out;
    opacity: 0.4;
}

.smp-qa-loader span:nth-child(2) { animation-delay: 0.2s; }
.smp-qa-loader span:nth-child(3) { animation-delay: 0.4s; }

@keyframes smp-qa-bounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    40% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Loader mentre le domande predefinite vengono generate in background */
.smp-qa-chips-loading {
    margin-top: 16px;
}

/* ── Sezione chips (label + chips), posizionata in fondo al widget ─────── */

.smp-qa-chips-section {
    margin-top: 16px;
}

.smp-qa-chips-label {
    font-size: 11px;
    font-weight: 600;
    color: #b0b8c1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.smp-qa-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}
.smp-qa-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--smp-qa-accent, --smp-qa-accent);
    border-radius: 20px;
    padding: 5px 13px;
    font-size: 13px;
    font-family: inherit;
    color: #000000;
    background: #fff;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.4;
    text-align: left;
    max-width: 100%;
}

.smp-qa-chip:hover:not(:disabled) {
    background: var(--smp-qa-accent, #2563eb);
    color: #fff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.smp-qa-chip--active {
    background: var(--smp-qa-accent, #2563eb);
    color: #fff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.smp-qa-chip:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Credits "powered by Smartypilot" */
.smp-qa-credits {
    text-align: right;
    margin-top: 8px;
    margin-right: 2px;
}

.smp-qa-credits a {
    display: inline-flex;
    align-items: center;
    color: #c8cdd3;
    font-size: 10px;
    text-decoration: none;
    transition: color 0.15s ease;
}
.smp-qa-credits a:hover {
    color: #777;
}

.smp-qa-credits a svg {
    width: auto;
}
.smp-qa-credits a svg path {
    fill: #c8cdd3;
    transition: fill 0.15s ease;
}

.smp-qa-credits a:hover svg path {
    fill: #777;
}

/* Mobile */
@media (max-width: 480px) {
    .smp-qa-container {
        padding: 14px;
        border-radius: 10px;
    }

    .smp-qa-form button:not(.smp-qa-clear-btn) {
        padding: 0 12px;
        font-size: 13px;
    }

    .smp-qa-chip {
        font-size: 12px;
        padding: 4px 11px;
    }
}
