/* Chat widget */
.chat-widget {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: var(--z-chat, 600);
}

.chat-bar[hidden],
.chat-panel[hidden] {
    display: none !important;
}

/* Barre compacte (fermée) */
.chat-bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 200px;
    padding: 0.7rem 1rem 0.7rem 0.85rem;
    border: none;
    border-radius: var(--radius);
    background: #1f1f1f;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.chat-bar:hover {
    background: #262626;
}

.chat-bar-waves {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.chat-bar-waves span {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(242, 31, 3, 0.4);
    border-radius: var(--radius);
    animation: chatWave 2.8s ease-out infinite;
}

.chat-bar-waves span:nth-child(2) {
    animation-delay: 0.9s;
}

.chat-bar-waves span:nth-child(3) {
    animation-delay: 1.8s;
}

@keyframes chatWave {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

.chat-bar-icon {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #ffffff;
    flex-shrink: 0;
}

.chat-bar-label {
    position: relative;
    z-index: 1;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Fenêtre ouverte */
.chat-panel {
    width: min(380px, calc(100vw - 2rem));
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    max-height: min(520px, calc(100vh - 2.5rem));
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}

.chat-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.9rem 1rem;
    background: #1f1f1f;
    color: #ffffff;
    border-bottom: 3px solid var(--primary);
}

.chat-panel-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

.chat-panel-brand > div {
    min-width: 0;
}

.chat-panel-head strong {
    display: block;
    font-size: 0.86rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.25;
}

.chat-panel-head span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.72);
    margin-top: 0.12rem;
}

.chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34d058;
    flex-shrink: 0;
}

.chat-panel-minimize {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: var(--radius);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    padding: 0.35rem;
    flex-shrink: 0;
}

.chat-panel-minimize:hover {
    background: rgba(255, 255, 255, 0.14);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: linear-gradient(180deg, #fafafa 0%, #f5f5f5 100%);
    min-height: 240px;
}

.chat-bubble {
    max-width: 86%;
    padding: 0.72rem 0.9rem;
    font-size: 0.86rem;
    line-height: 1.5;
    border-radius: var(--radius);
}

.chat-bubble--bot {
    align-self: flex-start;
    background: #ffffff;
    color: var(--text-dark);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: var(--radius-sm);
}

.chat-bubble--user {
    align-self: flex-end;
    background: var(--primary);
    color: #ffffff;
    border-bottom-right-radius: var(--radius-sm);
}

.chat-form {
    display: flex;
    gap: 0.55rem;
    padding: 0.85rem;
    border-top: 1px solid var(--border-light);
    background: #ffffff;
}

.chat-form input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.75rem 0.9rem;
    font-family: inherit;
    font-size: 0.86rem;
    color: var(--text-dark);
    background: #fafafa;
}

.chat-form input:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
}

.chat-form button {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: var(--primary);
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-form button:hover {
    background: var(--primary-hover);
}

.chat-widget.is-open .chat-bar-waves {
    opacity: 0;
}

@media (max-width: 1024px) {
    .chat-widget {
        right: 0.85rem;
        bottom: 0.85rem;
        max-width: calc(100vw - 1.7rem);
    }

    .chat-bar {
        min-width: 0;
        max-width: 100%;
        padding-right: 0.85rem;
    }

    .chat-panel {
        max-width: min(380px, calc(100vw - 1.7rem));
    }
}
