/* =========================================================
   OrChatBot - stile widget chat moderno
   ========================================================= */
#orchatbot-root {
    --orc-primary: #2563eb;
    --orc-secondary: #1d4ed8;
    --orc-radius: 16px;
    --orc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: fixed;
    bottom: 24px;
    z-index: 99999;
    font-family: var(--orc-font);
}

#orchatbot-root.orchatbot-pos-right { right: 24px; }
#orchatbot-root.orchatbot-pos-left { left: 24px; }

/* Bolla flottante */
#orchatbot-bubble {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--orc-primary), var(--orc-secondary));
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform .2s ease, box-shadow .2s ease;
}
#orchatbot-bubble:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 30px rgba(0,0,0,.28);
}
.orchatbot-bubble-icon {
    font-size: 28px;
    line-height: 1;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.15));
}
.orchatbot-bubble-icon img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.orchatbot-bubble-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
}

/* Finestra chat */
#orchatbot-window {
    position: absolute;
    bottom: 78px;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: 75vh;
    background: #fff;
    border-radius: var(--orc-radius);
    box-shadow: 0 16px 48px rgba(0,0,0,.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity .18s ease, transform .18s ease;
    opacity: 1;
    transform: scale(1) translateY(0);
}
#orchatbot-root.orchatbot-pos-right #orchatbot-window { right: 0; transform-origin: bottom right; }
#orchatbot-root.orchatbot-pos-left #orchatbot-window { left: 0; transform-origin: bottom left; }

#orchatbot-window.orchatbot-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(.92) translateY(12px);
}

/* Header */
#orchatbot-header {
    background: linear-gradient(135deg, var(--orc-primary), var(--orc-secondary));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.orchatbot-header-info { display: flex; align-items: center; gap: 10px; }
.orchatbot-header-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}
.orchatbot-header-icon img { width: 100%; height: 100%; object-fit: cover; }
.orchatbot-header-title { font-weight: 600; font-size: 15px; }
.orchatbot-header-status { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 5px; }
.orchatbot-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }
#orchatbot-close {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
#orchatbot-close:hover { background: rgba(255,255,255,.28); }

/* Area messaggi */
#orchatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f7f8fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#orchatbot-messages::-webkit-scrollbar { width: 6px; }
#orchatbot-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

.orc-msg { max-width: 82%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; animation: orc-fade-in .15s ease; }
@keyframes orc-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.orc-msg.orc-bot {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.orc-msg.orc-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--orc-primary), var(--orc-secondary));
    color: #fff;
    border-bottom-right-radius: 4px;
}
.orc-msg.orc-error {
    align-self: center;
    background: #fee2e2;
    color: #991b1b;
    font-size: 12px;
}

/* Indicatore "sta scrivendo" */
.orc-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #fff; border-radius: 14px; border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.orc-typing span { width: 6px; height: 6px; border-radius: 50%; background: #9ca3af; animation: orc-blink 1.2s infinite ease-in-out; }
.orc-typing span:nth-child(2) { animation-delay: .2s; }
.orc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes orc-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* Risposte rapide */
#orchatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 10px;
    background: #f7f8fa;
    flex-shrink: 0;
}
#orchatbot-quick-replies:empty { display: none; }
.orc-quick-btn {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: var(--orc-primary);
    font-size: 12.5px;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.orc-quick-btn:hover { background: #eff4ff; border-color: var(--orc-primary); }

/* Form input */
#orchatbot-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #eef0f2;
    flex-shrink: 0;
}
#orchatbot-input {
    flex: 1;
    resize: none;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--orc-font);
    max-height: 90px;
    outline: none;
    transition: border-color .15s;
}
#orchatbot-input:focus { border-color: var(--orc-primary); }
#orchatbot-send {
    background: linear-gradient(135deg, var(--orc-primary), var(--orc-secondary));
    border: none;
    color: #fff;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform .12s;
}
#orchatbot-send:hover { transform: scale(1.06); }
#orchatbot-send:disabled { opacity: .5; cursor: default; transform: none; }

@media (max-width: 480px) {
    #orchatbot-window { width: calc(100vw - 24px); height: calc(100vh - 120px); bottom: 76px; }
}
