@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,300&display=swap');

/* ─── Variables (Nouvelle Palette) ──────────────────────────── */
:root {
    /* --- Brand Fulfiller --- */
    --ff-primary:       #D93A2F;
    --ff-primary-dark:  #C73227;
    --ff-primary-light: #E85C52;
    --ff-primary-soft:  rgba(217, 58, 47, 0.12);

    /* --- Neutres --- */
    --ff-white:        #FFFFFF;
    --ff-bg-light:     #F5F6F7;
    --ff-text:         #1F2933;
    --ff-text-muted:   #6B7280;
    --ff-border:       rgba(0,0,0,0.08);

    /* --- UI Elements --- */
    --ff-shadow:       0 8px 24px rgba(0, 0, 0, 0.12),
    0 2px 6px  rgba(0, 0, 0, 0.04);

    --ff-radius-lg:    14px;
    --ff-radius-md:    10px;
    --ff-radius-sm:    6px;
    --ff-radius-pill:  999px;

    --ff-font:         'Outfit', sans-serif;
    --ff-font-body:    'DM Sans', sans-serif;
}

/* ─── Wrapper global ─────────────────────────────────────────── */
#n8n-chat {
    font-family: var(--ff-font);
    color: var(--ff-text);
}

/* ─── Fenêtre chat ───────────────────────────────────────────── */
.n8n-chat .chat-window-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.n8n-chat .chat-window {
    width: 380px;
    max-height: 560px;
    background: var(--ff-white);
    border-radius: var(--ff-radius-lg);
    box-shadow: var(--ff-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--ff-border);
}


/* ─── Layout principal ───────────────────────────────────────── */
.n8n-chat .chat-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* ─── Header ─────────────────────────────────────────────────── */
.n8n-chat .chat-header {
    /* Dégradé riche : Rouge sombre (coin haut gauche) -> Rouge vif -> Rouge éclatant (coin bas droit) */
    background: linear-gradient(135deg, var(--ff-primary-dark) 30%, var(--ff-primary) 50%, var(--ff-primary-light) 100%) !important;
    padding: 20px 22px 18px;
    position: relative;
    overflow: hidden;
    /* Légère ombre sous le header pour le détacher du body */
    box-shadow: 0 4px 12px rgba(217, 58, 47, 0.15);
}

/* Accent décoratif lumineux en haut (effet de verre) */
.n8n-chat .chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.3) 50%,
    rgba(255,255,255,0) 100%
    );
}

/* Cercle déco en fond (subtil) pour casser la linéarité */
.n8n-chat .chat-header::after {
    content: '';
    position: absolute;
    top: -40px;
    right: -20px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    /* Cercle blanc très transparent */
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 65%);
    pointer-events: none;
}

.n8n-chat .chat-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
    position: relative;
    z-index: 2; /* S'assure que le texte passe au-dessus des décos */
}

/* Pastille logo */
.n8n-chat .chat-heading::before {
    content: '⚡'; /* Ou votre icône SVG */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--ff-primary);
    border-radius: var(--ff-radius-sm);
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
}

.n8n-chat .chat-heading h1 {
    font-family: var(--ff-font);
    font-size: 19px; /* Légèrement plus grand */
    font-weight: 700;
    color: var(--ff-white);
    letter-spacing: -0.3px;
    margin: 0;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Meilleure lisibilité */
}

.n8n-chat .chat-header > p {
    font-family: var(--ff-font-body);
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    margin: 2px 0 0 46px; /* Ajusté pour l'alignement */
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 2;
}

/* Indicateur "en ligne" */
.n8n-chat .chat-header > p::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ADE80;
    border: 1.5px solid rgba(255, 255, 255, 0.2); /* Petit contour pour détacher du fond rouge */
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
    animation: ff-pulse-green 2s ease-in-out infinite;
}

@keyframes ff-pulse-green {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* ─── Body / Messages ────────────────────────────────────────── */
.n8n-chat .chat-body {
    flex: 1;
    overflow-y: auto;
    background: var(--ff-bg-light);
    scroll-behavior: smooth;
}

/* Scrollbar custom */
.n8n-chat .chat-body::-webkit-scrollbar {
    width: 4px;
}
.n8n-chat .chat-body::-webkit-scrollbar-track {
    background: transparent;
}
.n8n-chat .chat-body::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: var(--ff-radius-pill);
}
.n8n-chat .chat-body::-webkit-scrollbar-thumb:hover {
    background: var(--ff-primary-light);
}

.n8n-chat .chat-messages-list {
    display: flex;
    flex-direction: column;
    padding: 10px 10px; /* Ajout de padding interne */
}

.n8n-chat .chat-message {
    padding : 0;
    animation-delay: calc(var(--message-index, 0) * 0.05s);
}

.n8n-chat .chat-body {
    min-height: 200px;
    content-visibility: auto;
}

.chat-message.chat-message-from-bot:not(.chat-message-transparent),
.chat-message.chat-message-from-user:not(.chat-message-transparent){
    background-color: transparent !important;
}


/* ─── Animation Messages ────────────────────────────────────── */
.n8n-chat .chat-message {
    display: flex;
    max-width: 85%;
    animation: ff-msgIn 0.28s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

@keyframes ff-msgIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Messages BOT ───────────────────────────────────────────── */
.n8n-chat .chat-message-from-bot {
    align-self: flex-start;
}

.n8n-chat .chat-message-from-bot .chat-message-markdown {
    background: var(--ff-white);
    color: var(--ff-text);
    border-radius: 4px var(--ff-radius-md) var(--ff-radius-md) var(--ff-radius-md);
    padding: 12px 16px;
    font-family: var(--ff-font-body);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.55;
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: relative;
}

/* Triangle bulle bot */
.n8n-chat .chat-message-from-bot .chat-message-markdown::before {
    content: '';
    position: absolute;
    top: 10px;
    left: -6px;
    border-width: 5px 6px 5px 0;
    border-style: solid;
    border-color: transparent var(--ff-white) transparent transparent;
    filter: drop-shadow(-1px 0 0 rgba(0,0,0,0.04));
}

.n8n-chat .chat-message-from-bot .chat-message-markdown p {
    margin: 0;
}

/* ─── Messages USER ──────────────────────────────────────────── */
.n8n-chat .chat-message-from-user {
    align-self: flex-end;
}

.n8n-chat .chat-message-from-user .chat-message-markdown {
    background: linear-gradient(135deg, var(--ff-primary), var(--ff-primary-light));
    color: var(--ff-white);
    border-radius: var(--ff-radius-md) 4px var(--ff-radius-md) var(--ff-radius-md);
    padding: 12px 16px;
    font-family: var(--ff-font-body);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.55;
    /* Ombre rouge subtile */
    box-shadow: 0 4px 10px rgba(217, 58, 47, 0.25);
    position: relative;
}

/* Triangle bulle user */
.n8n-chat .chat-message-from-user .chat-message-markdown::after {
    content: '';
    position: absolute;
    top: 10px;
    right: -6px;
    border-width: 5px 0 5px 6px;
    border-style: solid;
    border-color: transparent transparent transparent var(--ff-primary-light);
}

.n8n-chat .chat-message-from-user .chat-message-markdown p {
    margin: 0;
}

/* ─── Footer / Zone de saisie ────────────────────────────────── */
.n8n-chat .chat-footer {
    background: var(--ff-white) !important;
    border-top: 1px solid var(--ff-border) !important;
    padding: 12px 14px !important;
}

.n8n-chat .chat-input {
    width: 100%;
}

.n8n-chat .chat-inputs {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--ff-bg-light);
    border: 1px solid transparent;
    border-radius: var(--ff-radius-md);
    padding: 8px 8px 8px 14px;
    transition: all 0.2s ease;
}

.n8n-chat .chat-inputs:focus-within {
    background: var(--ff-white);
    border-color: var(--ff-primary);
    box-shadow: 0 0 0 3px var(--ff-primary-soft);
}

.n8n-chat .chat-inputs textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--ff-font-body);
    font-size: 14px;
    font-weight: 400;
    color: var(--ff-text);
    resize: none;
    line-height: 1.5;
    min-height: 22px;
    max-height: 120px;
    padding: 0;
    box-shadow: none;
}

.n8n-chat .chat-inputs textarea::placeholder {
    color: var(--ff-text-muted);
}

/* ─── Bouton d'envoi ─────────────────────────────────────────── */
.n8n-chat .chat-input-send-button {
    flex-shrink: 0;
    width: 36px !important;
    height: 36px !important;
    border-radius: var(--ff-radius-sm);
    border: none !important;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    background: var(--ff-primary) !important;
    color: var(--ff-white) !important;
    box-shadow: 0 2px 6px rgba(217, 58, 47, 0.3);
}

.n8n-chat .chat-input-send-button:not(:disabled):hover {
    background: var(--ff-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(217, 58, 47, 0.4);
}

.n8n-chat .chat-input-send-button:not(:disabled):active {
    transform: scale(0.96);
    box-shadow: 0 1px 3px rgba(217, 58, 47, 0.3);
}

.n8n-chat .chat-input-send-button:disabled {
    background: #E5E7EB;
    color: #9CA3AF;
    cursor: not-allowed;
    box-shadow: none;
}

.n8n-chat .chat-input-send-button svg {
    width: 16px;
    height: 16px;
}

/* ─── Bouton toggle (bulle d'ouverture) ──────────────────────── */
.n8n-chat .chat-window-toggle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    /* Dégradé rouge toggle */
    background: linear-gradient(135deg, var(--ff-primary-dark), var(--ff-primary), var(--ff-primary-light)) !important;
    color: var(--ff-white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(217, 58, 47, 0.4), 0 2px 6px rgba(0,0,0,0.1);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 3px solid rgba(255,255,255,0.2);
    position: relative;
    flex-shrink: 0;
}

/* Typing Box */
.n8n-chat .chat-message-typing .chat-message-typing-body {
    justify-content: center;
    align-items: end;
    display: flex;
    height: 25px;
}

/* Anneau pulsant autour du toggle */
.n8n-chat .chat-window-toggle::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--ff-primary);
    opacity: 0;
    animation: ff-ring-pulse 2.5s ease-in-out infinite;
}

@keyframes ff-ring-pulse {
    0%, 100% { opacity: 0; transform: scale(1); }
    40%      { opacity: 0.4; transform: scale(1.08); }
    60%      { opacity: 0.1; }
}

.n8n-chat .chat-window-toggle:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 25px rgba(217, 58, 47, 0.5);
    background-color: var(--ff-primary-light);
}

.n8n-chat .chat-window-toggle:active {
    transform: scale(0.96);
}

.n8n-chat .chat-window-toggle svg {
    width: 26px;
    height: 26px;
    transition: transform 0.3s ease;
}

/* ─── Typing indicator (si présent) ─────────────────────────── */
.n8n-chat .chat-message-typing .chat-message-markdown {
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.n8n-chat .chat-message-typing .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ff-primary);
    animation: ff-typing 1.2s ease-in-out infinite;
}
.n8n-chat .chat-message-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.n8n-chat .chat-message-typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ff-typing {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40%           { opacity: 1;   transform: translateY(-4px); }
}

/* ─── Links dans les messages ────────────────────────────────── */
.n8n-chat .chat-message-markdown a {
    color: var(--ff-primary);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid var(--ff-primary-soft);
    transition: border-color 0.15s;
}
.n8n-chat .chat-message-markdown a:hover {
    border-color: var(--ff-primary);
}

/* ─── Code inline ────────────────────────────────────────────── */
.n8n-chat .chat-message-markdown code {
    background: var(--ff-bg-light);
    color: var(--ff-primary-dark);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    border: 1px solid rgba(0,0,0,0.05);
}

/* ─── Responsive mobile ──────────────────────────────────────── */
@media (max-width: 440px) {
    .n8n-chat .chat-window {
        width: calc(100vw - 32px);
        max-height: calc(100dvh - 100px);
    }
    .n8n-chat .chat-window-wrapper {
        bottom: 16px;
        right: 16px;
    }
}
