/* ============================================================
   AI Agent Chat — Stylesheet
   Modifica --aiac-color per cambiare il colore principale
   ============================================================ */

:root {
    --aiac-color: #b8924a;
    --aiac-color-dark: #9a7838;
    --aiac-color-light: rgba(184, 146, 74, 0.1);
    --aiac-radius: 16px;
    --aiac-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
}

/* ── WIDGET BUBBLE ── */
#aiac-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#aiac-bubble {
    width: 58px;
    height: 58px;
    background: var(--aiac-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s;
    position: relative;
    border: none;
    outline: none;
}

#aiac-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

#aiac-bubble.aperto {
    background: #555;
}

.aiac-bubble-icon {
    width: 26px;
    height: 26px;
    fill: white;
    transition: opacity 0.2s, transform 0.2s;
}

.aiac-bubble-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #e53e3e;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* ── FINESTRA WIDGET ── */
#aiac-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    background: #ffffff;
    border-radius: var(--aiac-radius);
    box-shadow: var(--aiac-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e8e4de;
    animation: aiacSlideUp 0.25s cubic-bezier(.34,1.56,.64,1) forwards;
}

#aiac-window.aperta {
    display: flex;
}

@keyframes aiacSlideUp {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.aiac-win-header {
    background: var(--aiac-color);
    color: white;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aiac-win-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.aiac-win-mark {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.25);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
}

.aiac-win-nome {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.aiac-win-sub {
    font-size: 11px;
    opacity: 0.8;
    font-weight: 400;
}

.aiac-win-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
    padding: 4px;
    line-height: 1;
    transition: opacity 0.2s;
}
.aiac-win-close:hover { opacity: 1; }

.aiac-win-messages {
    height: 340px;
    overflow-y: auto;
    padding: 14px;
    background: #f7f6f3;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.aiac-win-messages::-webkit-scrollbar { width: 3px; }
.aiac-win-messages::-webkit-scrollbar-thumb { background: #d8d3cc; border-radius: 2px; }

.aiac-win-input-area {
    padding: 10px 14px 14px;
    background: white;
    border-top: 1px solid #ede9e3;
}

/* ── PAGINA INTERA ── */
.aiac-pagina-wrapper {
    background: #ffffff;
    border: 1px solid #e8e4de;
    border-radius: var(--aiac-radius);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    max-width: 100%;
}

.aiac-pagina-header {
    background: var(--aiac-color);
    color: white;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aiac-pagina-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aiac-pagina-mark {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.25);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
}

.aiac-pagina-nome {
    font-size: 17px;
    font-weight: 600;
}

.aiac-pagina-sub {
    font-size: 12px;
    opacity: 0.8;
}

.aiac-pagina-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    background: rgba(255,255,255,0.15);
    padding: 4px 12px;
    border-radius: 20px;
}

.aiac-status-dot {
    width: 7px;
    height: 7px;
    background: #7dffb0;
    border-radius: 50%;
    animation: aiacBlink 2s infinite;
}

@keyframes aiacBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.aiac-pagina-messages {
    overflow-y: auto;
    padding: 24px;
    background: #f7f6f3;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.aiac-pagina-messages::-webkit-scrollbar { width: 4px; }
.aiac-pagina-messages::-webkit-scrollbar-thumb { background: #d8d3cc; border-radius: 2px; }

.aiac-pagina-input-area {
    padding: 14px 20px 18px;
    background: white;
    border-top: 1px solid #ede9e3;
}

.aiac-input-footer {
    text-align: center;
    font-size: 11px;
    color: #b8b2aa;
    margin-top: 6px;
}

/* ── WELCOME SCREEN ── */
.aiac-pagina-welcome,
.aiac-win-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    padding: 24px 16px;
    animation: aiacFadeUp 0.4s ease;
}

.aiac-welcome-icon {
    width: 52px;
    height: 52px;
    background: var(--aiac-color-light);
    border: 2px solid var(--aiac-color);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--aiac-color);
}

.aiac-pagina-welcome h3,
.aiac-win-welcome h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1814;
    margin: 0;
}

.aiac-pagina-welcome p,
.aiac-win-welcome p {
    font-size: 13px;
    color: #6b6560;
    margin: 0;
    max-width: 320px;
    line-height: 1.6;
}

.aiac-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 4px;
}

.aiac-suggestion {
    background: white;
    border: 1px solid #d8d3cc;
    color: #6b6560;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.aiac-suggestion:hover {
    border-color: var(--aiac-color);
    color: var(--aiac-color);
    background: var(--aiac-color-light);
}

/* ── MESSAGGI ── */
.aiac-msg-row {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    animation: aiacFadeUp 0.2s ease;
}

.aiac-msg-row.aiac-user {
    flex-direction: row-reverse;
}

.aiac-avatar {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    margin-top: 3px;
}

.aiac-avatar.aiac-av-agent {
    background: var(--aiac-color);
    color: white;
    font-weight: 700;
}

.aiac-avatar.aiac-av-user {
    background: #1e2a3a;
    color: #8baed4;
    font-weight: 600;
}

.aiac-msg-content {
    flex: 1;
    max-width: calc(100% - 40px);
}

.aiac-msg-row.aiac-user .aiac-msg-content {
    display: flex;
    justify-content: flex-end;
}

.aiac-bubble {
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.6;
    word-wrap: break-word;
}

.aiac-bubble.aiac-agent {
    background: white;
    border: 1px solid #e8e4de;
    color: #1a1814;
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.aiac-bubble.aiac-user-msg {
    background: #1e2a3a;
    color: #e8eef5;
    max-width: 260px;
    border-bottom-right-radius: 3px;
}

.aiac-bubble strong { color: var(--aiac-color); font-weight: 600; }
.aiac-bubble a { color: var(--aiac-color); }
.aiac-bubble p { margin: 0 0 6px; }
.aiac-bubble p:last-child { margin-bottom: 0; }

/* ── TYPING ── */
.aiac-typing-row {
    display: flex;
    gap: 8px;
    padding: 6px 0;
}

.aiac-typing-dots {
    display: flex;
    gap: 3px;
    padding: 10px 13px;
    background: white;
    border: 1px solid #e8e4de;
    border-radius: 12px;
    border-bottom-left-radius: 3px;
}

.aiac-typing-dots span {
    width: 5px;
    height: 5px;
    background: #b8b2aa;
    border-radius: 50%;
    animation: aiacDot 1.4s infinite;
}
.aiac-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.aiac-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiacDot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
    30% { opacity: 1; transform: scale(1.3); }
}

/* ── INPUT ── */
.aiac-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f7f6f3;
    border: 1px solid #d8d3cc;
    border-radius: 12px;
    padding: 8px 10px;
    transition: border-color 0.2s;
}

.aiac-input-wrapper:focus-within {
    border-color: var(--aiac-color);
}

.aiac-textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #1a1814;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.5;
    resize: none;
    min-height: 22px;
    max-height: 100px;
    overflow-y: auto;
}

.aiac-textarea::placeholder { color: #b8b2aa; }

.aiac-send-btn {
    background: var(--aiac-color);
    border: none;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    min-width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}
.aiac-send-btn:hover { background: var(--aiac-color-dark); }
.aiac-send-btn:disabled { background: #d8d3cc; cursor: not-allowed; }
.aiac-send-btn svg { width: 14px; height: 14px; fill: white; }

/* ── ANIMAZIONI ── */
@keyframes aiacFadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
    #aiac-window {
        width: calc(100vw - 32px);
        right: 0;
        bottom: 72px;
    }
    .aiac-pagina-messages {
        height: 400px !important;
    }
}
