/* ============================================================
   PHONY — Widget diagnostic flottant (bas droite)
============================================================ */

.dwc {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 2200;
    font-family: var(--font-body, Inter, system-ui, sans-serif);
}

/* Bouton flottant */
.dwc-launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border: none;
    border-radius: 999px;
    background: var(--primary-blue, oklch(45% 0.19 260));
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 28px -8px oklch(45% 0.19 260 / 0.65);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.dwc-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px -8px oklch(45% 0.19 260 / 0.75);
}

.dwc-launcher:active { transform: scale(0.97); }

.dwc-launcher.is-open {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.dwc-launcher-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--accent-yellow, oklch(85% 0.21 85));
    border: 2px solid oklch(99% 0 0 / 0.35);
    flex-shrink: 0;
}

.dwc-launcher-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 12%;
    display: block;
}

.dwc-launcher-text {
    text-align: left;
    line-height: 1.2;
    padding-right: 4px;
}

.dwc-launcher-text strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
}

.dwc-launcher-text span {
    display: block;
    font-size: 11px;
    opacity: 0.88;
    font-weight: 500;
}

/* Panneau chat */
.dwc-panel {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: min(380px, calc(100vw - 32px));
    height: min(560px, calc(100dvh - 32px));
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 20px 60px -16px oklch(20% 0.03 260 / 0.45);
    border: 1px solid oklch(90% 0.01 260);
    background: #fff;
    z-index: 2201;
    transform: translateY(16px) scale(0.96);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease, visibility 0.22s;
}

.dwc-panel.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.dwc-panel .dg-chat-card {
    flex: 1;
    border: none;
    border-radius: 0;
    box-shadow: none;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.dwc-panel .dg-chat-card > .dg-form {
    background: #fff;
    border-top: 1px solid var(--gray-100, oklch(94% 0.01 260));
    box-shadow: 0 -4px 16px oklch(20% 0.02 260 / 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.dwc-panel .dg-disclaimer {
    display: none !important;
}

.dwc-panel .dg-gate {
    padding: 8px 10px;
    align-items: flex-start;
}

/* Widget : pas de barre de saisie tant que le chat n'est pas lancé */
.dwc-panel .dg-chat-card.is-locked:has(.dg-chat.is-hidden) .dg-form {
    display: none !important;
}

.dwc-panel .dg-chat-card:has(.dg-chat:not(.is-hidden)) .dg-form {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
    filter: none;
}

.dwc-panel .dg-chat-card > .dg-form {
    border-top: 1px solid var(--gray-100, oklch(94% 0.01 260));
    box-shadow: 0 -4px 16px oklch(20% 0.02 260 / 0.06);
    padding: 0;
    width: 100%;
    gap: 0;
    align-items: stretch;
}

.dwc-panel .dg-form textarea {
    flex: 1;
    min-width: 0;
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-top: none;
    min-height: 48px;
}

.dwc-panel .dg-send {
    width: 52px;
    min-height: 48px;
    height: auto;
    border-radius: 0;
    flex-shrink: 0;
}

.dwc-panel .dg-gate-card {
    padding: 12px 14px;
}

.dwc-panel .dg-gate-card h2 {
    font-size: 15px;
}

.dwc-panel .dg-gate-logos img.dg-gate-phony {
    height: 22px;
}

.dwc-panel .dg-gate-logos .dg-gate-bolt {
    width: 36px;
    height: 36px;
}

.dg-gate-hint {
    font-size: 12px;
    color: var(--primary-blue, oklch(45% 0.19 260));
    font-weight: 600;
    margin: 0 0 8px;
}

.dwc-panel .dg-gate-hint {
    font-size: 11px;
    margin-bottom: 6px;
}

.dwc-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid oklch(99% 0 0 / 0.25);
    border-radius: 8px;
    background: oklch(99% 0 0 / 0.12);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.dwc-panel .dg-chat-head span {
    max-width: none;
}

.dwc-close:hover { background: oklch(99% 0 0 / 0.22); }

/* Décaler le scroll-top au-dessus du bouton */
body.has-dwc .scroll-top {
    bottom: 80px;
}

@media (max-width: 480px) {
    .dwc,
    .dwc-panel {
        right: 0;
        bottom: 0;
        left: 0;
    }

    .dwc-launcher {
        right: 12px;
        bottom: 12px;
        position: fixed;
    }

    .dwc-panel {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .dwc-panel .dg-chat-card > .dg-form {
        padding-bottom: env(safe-area-inset-bottom, 12px);
    }

    .dwc-panel .dg-send {
        min-height: 52px;
    }

    body.has-dwc .scroll-top {
        bottom: 72px;
        right: 12px;
    }
}

html.menu-open .dwc {
    opacity: 0 !important;
    pointer-events: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .dwc-panel,
    .dwc-launcher { transition: none; }
}
