/* ============================================================
   i-Tech Chat Widget — intégrable sur tout le site
   ============================================================ */

/* ----- Conteneur principal de la bulle ----- */
#itech-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--signal, #FF6B1A);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(255, 107, 26, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.35s cubic-bezier(.22,1,.36,1),
                box-shadow 0.35s cubic-bezier(.22,1,.36,1),
                background 0.35s cubic-bezier(.22,1,.36,1);
}
#itech-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(255, 107, 26, 0.6);
    background: #ff7d38;
}
#itech-chat-bubble:active {
    transform: scale(0.94);
}
#itech-chat-bubble svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* ----- Panneau du chat ----- */
#itech-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 9998;
    width: 380px;
    max-height: 560px;
    background: var(--graphite-2, #1B2127);
    border: 1px solid rgba(139, 152, 165, 0.2);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.35s cubic-bezier(.22,1,.36,1),
                transform 0.35s cubic-bezier(.22,1,.36,1);
    font-family: var(--font-body, 'IBM Plex Sans', sans-serif);
}
#itech-chat-panel.itech-chat-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ----- En-tête du chat ----- */
#itech-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--graphite, #14181C);
    border-bottom: 1px solid rgba(139, 152, 165, 0.15);
    flex-shrink: 0;
}
#itech-chat-header span {
    font-family: var(--font-display, 'Chakra Petch', sans-serif);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--paper, #EDE9E1);
    letter-spacing: 0.02em;
}
#itech-chat-header span::before {
    content: "● ";
    color: var(--signal, #FF6B1A);
}
#itech-chat-close {
    background: none;
    border: none;
    color: var(--steel, #8B98A5);
    font-size: 1.6rem;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    transition: color 0.25s ease;
}
#itech-chat-close:hover {
    color: var(--paper, #EDE9E1);
}

/* ----- Zone des messages (CORRECTION ICI) ----- */
#itech-chat-messages {
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--graphite-2, #1B2127);
    min-height: 200px;
    /* EMPÊCHE LE SCROLL DE PROPAGER À LA PAGE */
    overscroll-behavior: contain;
    touch-action: pan-y; /* optimise le tactile */
}
#itech-chat-messages::-webkit-scrollbar {
    width: 4px;
}
#itech-chat-messages::-webkit-scrollbar-track {
    background: rgba(139, 152, 165, 0.08);
}
#itech-chat-messages::-webkit-scrollbar-thumb {
    background: var(--steel-dim, #5B6672);
    border-radius: 4px;
}

/* ----- Messages individuels ----- */
.itech-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.92rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: fadeSlideIn 0.3s cubic-bezier(.22,1,.36,1);
}
@keyframes fadeSlideIn {
    0% { opacity: 0; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}

.itech-msg-user {
    align-self: flex-end;
    background: var(--signal, #FF6B1A);
    color: var(--graphite, #14181C);
    border-bottom-right-radius: 4px;
}
.itech-msg-bot {
    align-self: flex-start;
    background: var(--graphite, #14181C);
    color: var(--paper, #EDE9E1);
    border: 1px solid rgba(139, 152, 165, 0.15);
    border-bottom-left-radius: 4px;
}
.itech-msg-bot strong {
    color: var(--signal, #FF6B1A);
}
.itech-msg-loading {
    color: var(--steel, #8B98A5);
    font-style: italic;
    animation: pulse 1.4s infinite ease-in-out;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ----- Barre de saisie ----- */
#itech-chat-inputbar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 16px 16px;
    background: var(--graphite, #14181C);
    border-top: 1px solid rgba(139, 152, 165, 0.12);
    flex-shrink: 0;
}
#itech-chat-input {
    flex: 1;
    resize: none;
    border: none;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 10px 14px;
    font-family: var(--font-body, 'IBM Plex Sans', sans-serif);
    font-size: 0.92rem;
    color: var(--paper, #EDE9E1);
    line-height: 1.4;
    max-height: 100px;
    min-height: 44px;
    transition: background 0.3s ease;
}
#itech-chat-input::placeholder {
    color: var(--steel-dim, #5B6672);
}
#itech-chat-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.07);
}
#itech-chat-input::-webkit-scrollbar {
    width: 4px;
}
#itech-chat-input::-webkit-scrollbar-thumb {
    background: var(--steel-dim, #5B6672);
    border-radius: 4px;
}

#itech-chat-send {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--signal, #FF6B1A);
    color: var(--graphite, #14181C);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.25s ease;
}
#itech-chat-send:hover {
    background: #ff7d38;
    transform: scale(1.04);
}
#itech-chat-send:active {
    transform: scale(0.92);
}
#itech-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: scale(1);
}
#itech-chat-send svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ----- Responsive (mobile) ----- */
@media (max-width: 480px) {
    #itech-chat-bubble {
        width: 52px;
        height: 52px;
        bottom: 16px;
        right: 16px;
    }
    #itech-chat-panel {
        width: calc(100vw - 32px);
        max-height: 70vh;
        bottom: 80px;
        right: 16px;
        border-radius: 10px;
    }
    #itech-chat-header {
        padding: 12px 16px;
    }
    #itech-chat-messages {
        padding: 12px 16px;
    }
    #itech-chat-inputbar {
        padding: 8px 12px 12px;
        gap: 8px;
    }
    #itech-chat-input {
        font-size: 0.88rem;
        padding: 8px 12px;
        min-height: 40px;
    }
    #itech-chat-send {
        width: 40px;
        height: 40px;
    }
    #itech-chat-send svg {
        width: 18px;
        height: 18px;
    }
    .itech-msg {
        font-size: 0.88rem;
    }
}

/* ----- Mode « reduced motion » ----- */
@media (prefers-reduced-motion: reduce) {
    #itech-chat-panel,
    #itech-chat-bubble,
    .itech-msg,
    #itech-chat-send {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}