/* Nzela — assistant conversationnel ProstyCom */

.ai-chat-root {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 9999;
    font-family: inherit;
}

/* ── Bouton flottant ── */
.ai-chat-toggle {
    display: flex;
    align-items: center;
    gap: .65rem;
    background: linear-gradient(135deg, #1E90FF 0%, #1565c0 100%);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: .55rem .95rem .55rem .55rem;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(30, 144, 255, .4), 0 2px 6px rgba(0, 0, 0, .08);
    font-weight: 600;
    transition: transform .2s ease, box-shadow .2s ease;
    position: relative;
}

.ai-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(30, 144, 255, .45), 0 4px 10px rgba(0, 0, 0, .1);
}

.ai-chat-toggle:focus-visible {
    outline: 2px solid #1E90FF;
    outline-offset: 3px;
}

.ai-chat-toggle[aria-expanded="true"] {
    background: #0A2540;
    box-shadow: 0 4px 14px rgba(10, 37, 64, .35);
}

.ai-chat-toggle[aria-expanded="true"] .ai-chat-toggle-label {
    display: none;
}

.ai-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .25);
}

.ai-chat-avatar img,
.ai-chat-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
}

.ai-chat-toggle-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    text-align: left;
}

.ai-chat-toggle-name {
    font-size: .95rem;
    font-weight: 700;
}

.ai-chat-toggle-role {
    font-size: .68rem;
    opacity: .85;
    font-weight: 500;
}

/* Animations avatar */
.nzela-pulse {
    transform-origin: center;
    animation: nzela-pulse-ring 2.8s ease-out infinite;
}

.nzela-bracket--left {
    animation: nzela-bracket-l 3s ease-in-out infinite;
}

.nzela-bracket--right {
    animation: nzela-bracket-r 3s ease-in-out infinite;
}

.nzela-spark {
    animation: nzela-spark 2s ease-in-out infinite;
}

.ai-chat-toggle:not([aria-expanded="true"]) .ai-chat-avatar {
    animation: nzela-float 3s ease-in-out infinite;
}

@keyframes nzela-pulse-ring {
    0%, 100% { transform: scale(1); opacity: .35; }
    50% { transform: scale(1.06); opacity: 0; }
}

@keyframes nzela-bracket-l {
    0%, 100% { transform: translateX(0); opacity: 1; }
    50% { transform: translateX(-1.5px); opacity: .7; }
}

@keyframes nzela-bracket-r {
    0%, 100% { transform: translateX(0); opacity: 1; }
    50% { transform: translateX(1.5px); opacity: .7; }
}

@keyframes nzela-spark {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .4; transform: scale(.6); }
}

@keyframes nzela-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

/* ── Panneau ── */
.ai-chat-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + .85rem);
    width: min(380px, 92vw);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(10, 37, 64, .18), 0 4px 12px rgba(0, 0, 0, .06);
    display: flex;
    flex-direction: column;
    max-height: min(520px, 72vh);
    overflow: hidden;
    border: 1px solid rgba(30, 144, 255, .12);
    transform-origin: bottom right;
    animation: nzela-panel-in .25s ease-out;
}

.ai-chat-panel[hidden] {
    display: none !important;
}

@keyframes nzela-panel-in {
    from { opacity: 0; transform: translateY(12px) scale(.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-chat-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .9rem 1rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #e8f4fd 100%);
    border-bottom: 1px solid #dbeafe;
}

.ai-chat-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
    box-shadow: 0 2px 8px rgba(30, 144, 255, .2);
}

.ai-chat-header-avatar img,
.ai-chat-header-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
}

.ai-chat-header-info {
    flex: 1;
    min-width: 0;
}

.ai-chat-header-info strong {
    display: block;
    font-size: 1rem;
    color: #0A2540;
}

.ai-chat-header-role {
    font-size: .75rem;
    color: #64748b;
    margin-top: .1rem;
}

.ai-chat-status {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .7rem;
    color: #16a34a;
    margin-top: .2rem;
}

.ai-chat-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: nzela-status 2s ease-in-out infinite;
}

@keyframes nzela-status {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

.ai-chat-close {
    background: rgba(100, 116, 139, .1);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    color: #64748b;
    display: grid;
    place-items: center;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}

.ai-chat-close:hover {
    background: rgba(100, 116, 139, .2);
    color: #0A2540;
}

/* ── Messages ── */
.ai-chat-messages {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    background: #fafbfc;
    scroll-behavior: smooth;
}

.ai-chat-row {
    display: flex;
    gap: .5rem;
    align-items: flex-end;
    max-width: 100%;
}

.ai-chat-row--user {
    flex-direction: row-reverse;
}

.ai-chat-row-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
}

.ai-chat-row-avatar img,
.ai-chat-row-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
}

.ai-chat-row--user .ai-chat-row-avatar {
    background: #1E90FF;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    display: grid;
    place-items: center;
}

.ai-chat-msg {
    padding: .7rem .85rem;
    border-radius: 14px;
    font-size: .875rem;
    line-height: 1.5;
    max-width: calc(100% - 36px);
    word-break: break-word;
}

.ai-chat-msg--bot {
    background: #fff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}

.ai-chat-msg--user {
    background: linear-gradient(135deg, #1E90FF, #1976d2);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Indicateur de frappe */
.ai-chat-typing {
    display: flex;
    gap: 4px;
    padding: .15rem 0;
}

.ai-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: nzela-typing 1.2s ease-in-out infinite;
}

.ai-chat-typing span:nth-child(2) { animation-delay: .15s; }
.ai-chat-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes nzela-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Suggestions rapides */
.ai-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    padding: 0 .25rem;
}

.ai-chat-suggestion {
    background: #fff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    border-radius: 999px;
    padding: .35rem .7rem;
    font-size: .75rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    font-family: inherit;
}

.ai-chat-suggestion:hover {
    background: #eff6ff;
    border-color: #1E90FF;
}

/* ── Formulaire ── */
.ai-chat-form {
    padding: .75rem;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    display: flex;
    align-items: flex-end;
    gap: .5rem;
}

.ai-chat-input-wrap {
    flex: 1;
    position: relative;
}

.ai-chat-form textarea {
    width: 100%;
    resize: none;
    min-height: 2.5rem;
    max-height: 6rem;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: .6rem .75rem;
    font: inherit;
    font-size: .875rem;
    line-height: 1.4;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
}

.ai-chat-form textarea:focus {
    outline: none;
    border-color: #1E90FF;
    box-shadow: 0 0 0 3px rgba(30, 144, 255, .15);
}

.ai-chat-form textarea:disabled {
    opacity: .6;
    background: #f8fafc;
}

.ai-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #1E90FF, #1565c0);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: transform .15s, opacity .15s;
}

.ai-chat-send:hover:not(:disabled) {
    transform: scale(1.05);
}

.ai-chat-send:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.ai-chat-hint {
    font-size: .65rem;
    color: #94a3b8;
    padding: 0 .75rem .5rem;
    text-align: center;
}

/* Actions de navigation */
.ai-chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .6rem;
    padding-top: .55rem;
    border-top: 1px dashed #e2e8f0;
}

.ai-chat-action {
    background: linear-gradient(135deg, #eff6ff, #f0f9ff);
    border: 1px solid #93c5fd;
    color: #1d4ed8;
    border-radius: 999px;
    padding: .35rem .75rem;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform .15s, background .15s, box-shadow .15s;
}

.ai-chat-action:hover {
    background: #dbeafe;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 144, 255, .2);
}

.nzela-highlight {
    outline: 3px solid rgba(30, 144, 255, .55);
    outline-offset: 4px;
    border-radius: 8px;
    transition: outline .3s ease;
}

@media (max-width: 480px) {
    .ai-chat-root { right: .75rem; bottom: .75rem; }
    .ai-chat-toggle-text { display: none; }
    .ai-chat-toggle { padding: .5rem; }
    .ai-chat-panel { width: calc(100vw - 1.5rem); right: -.25rem; }
}
