/* Widget chat - riusa le variabili di site.css (colori, radius, font).
   Nessun gradiente, blur o glow: stessa estetica piatta del resto del sito. */

.resis-chat {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 8;
    font-family: var(--sans);
}

.resis-chat__launcher {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--grad);
    color: #04121c;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(45, 217, 200, 0.32);
    transition: transform 150ms ease, filter 150ms ease;
}

.resis-chat__launcher:hover,
.resis-chat__launcher:focus-visible {
    filter: saturate(1.1);
    transform: translateY(-2px);
    outline: none;
}

:root[data-theme="light"] .resis-chat__launcher {
    color: #ffffff;
}

.resis-chat__launcher svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.resis-chat__launcher.is-hidden {
    display: none;
}

.resis-chat__panel {
    display: none;
    width: min(380px, calc(100vw - 2rem));
    height: min(560px, calc(100vh - 2rem));
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
}

.resis-chat__panel.is-open {
    display: flex;
}

.resis-chat__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.resis-chat__brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--mono);
    font-weight: 800;
    font-size: 0.92rem;
    color: var(--text);
}

.resis-chat__brand img {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    display: block;
}

.resis-chat__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.resis-chat__close:hover,
.resis-chat__close:focus-visible {
    border-color: var(--border);
    color: var(--text);
    outline: none;
}

.resis-chat__intro {
    padding: 1rem 1rem 0.25rem;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.5;
}

.resis-chat__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.6rem 1rem 0.9rem;
}

.resis-chat__chips button {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    background: var(--surface);
    color: var(--text);
    font-size: 0.78rem;
    cursor: pointer;
    transition: border-color 150ms ease;
}

.resis-chat__chips button:hover,
.resis-chat__chips button:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.resis-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    background: var(--bg);
}

.resis-chat__row {
    display: flex;
    margin-bottom: 0.65rem;
}

.resis-chat__row--user {
    justify-content: flex-end;
}

.resis-chat__bubble {
    max-width: 84%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    font-size: 0.88rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.resis-chat__bubble--bot {
    background: var(--surface-2);
    color: var(--text);
}

.resis-chat__bubble--user {
    background: var(--grad);
    border-color: transparent;
    color: #04121c;
}

:root[data-theme="light"] .resis-chat__bubble--user {
    color: #ffffff;
}

.resis-chat__bubble--error {
    background: var(--surface-2);
    border-color: var(--danger);
    color: var(--danger);
}

.resis-chat__typing {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}

.resis-chat__typing span {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--muted);
    animation: resis-chat-typing 1.1s ease-in-out infinite;
}

.resis-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.resis-chat__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes resis-chat-typing {
    0%, 60%, 100% { opacity: 0.35; }
    30% { opacity: 1; }
}

.resis-chat__form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.resis-chat__input {
    flex: 1;
    min-width: 0;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 0.75rem;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
}

.resis-chat__input:focus {
    border-color: var(--accent);
    outline: none;
}

.resis-chat__send {
    height: 42px;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--grad);
    color: #04121c;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

:root[data-theme="light"] .resis-chat__send {
    color: #ffffff;
}

.resis-chat__send:hover,
.resis-chat__send:focus-visible {
    background: var(--accent-strong);
    outline: none;
}

.resis-chat__disclaimer {
    padding: 0 1rem 0.75rem;
    color: var(--faint);
    font-size: 0.72rem;
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    .resis-chat__typing span {
        animation: none;
    }
}

@media (max-width: 640px) {
    .resis-chat {
        bottom: calc(1rem + 48px + 0.75rem);
    }

    .resis-chat__panel.is-open {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
    }
}
