/* === Widget de chat live === */
.dskg-chat {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    color: #1f2937;
}

/* Bulle déclencheur */
.dskg-chat-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary, #dc2626), #b91c1c);
    border: 0;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(220, 38, 38, .35), 0 2px 8px rgba(0, 0, 0, .12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
    transition: transform .2s, box-shadow .2s;
    position: relative;
}
.dskg-chat-launcher:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 10px 30px rgba(220, 38, 38, .45);
}
.dskg-chat-launcher:active { transform: scale(.96); }
.dskg-chat-launcher .dskg-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #fff;
    color: var(--primary, #dc2626);
    border-radius: 999px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
    border: 2px solid var(--primary, #dc2626);
}
.dskg-chat-launcher.dskg-hidden { display: none; }

/* Hint proactif */
.dskg-chat-hint {
    position: absolute;
    bottom: 75px;
    right: 0;
    background: #fff;
    border-radius: 14px;
    padding: 10px 14px 10px 16px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    border: 1px solid #e5e7eb;
}
.dskg-chat-hint.dskg-show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.dskg-chat-hint::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 22px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}
.dskg-chat-hint button.dskg-hint-close {
    background: transparent;
    border: 0;
    margin-left: 6px;
    color: #9ca3af;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
}

/* Panneau ouvert */
.dskg-chat-panel {
    width: 360px;
    max-width: calc(100vw - 28px);
    height: 540px;
    max-height: calc(100vh - 50px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25), 0 4px 12px rgba(0, 0, 0, .08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: dskg-pop .25s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes dskg-pop {
    0%   { transform: scale(.6) translateY(40px); opacity: 0; }
    100% { transform: scale(1) translateY(0);    opacity: 1; }
}

/* Header */
.dskg-chat-header {
    background: linear-gradient(135deg, var(--primary, #dc2626), #991b1b);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.dskg-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex: 0 0 auto;
}
.dskg-chat-titles { flex: 1; min-width: 0; }
.dskg-chat-titles strong { font-size: 15px; display: block; line-height: 1.3; }
.dskg-chat-titles small { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 5px; }
.dskg-chat-titles small::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, .3);
    animation: dskg-pulse 2s infinite;
}
@keyframes dskg-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(74, 222, 128, .3); }
    50%      { box-shadow: 0 0 0 5px rgba(74, 222, 128, .15); }
}
.dskg-chat-close {
    background: rgba(255, 255, 255, .15);
    border: 0;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.dskg-chat-close:hover { background: rgba(255, 255, 255, .3); }

/* Body / messages */
.dskg-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.dskg-msg {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    animation: dskg-msg-in .22s ease-out;
}
@keyframes dskg-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.dskg-msg-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.dskg-msg-meta {
    font-size: 10.5px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

/* Visiteur (à droite) */
.dskg-msg-visitor { align-self: flex-end; }
.dskg-msg-visitor .dskg-msg-bubble {
    background: var(--primary, #dc2626);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.dskg-msg-visitor .dskg-msg-meta { text-align: right; }

/* Admin / system (à gauche) */
.dskg-msg-admin .dskg-msg-bubble,
.dskg-msg-system .dskg-msg-bubble {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.dskg-msg-system .dskg-msg-bubble {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e3a8a;
    font-style: italic;
}

/* Form info */
.dskg-info-form {
    position: relative;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    margin: 6px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dskg-info-form label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}
.dskg-info-form input {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    box-sizing: border-box;
}
.dskg-info-form input:focus {
    outline: 0;
    border-color: var(--primary, #dc2626);
}
.dskg-info-form button[type="submit"] {
    background: var(--primary, #dc2626);
    color: #fff;
    border: 0;
    padding: 9px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    margin-top: 4px;
}
.dskg-info-form button[type="submit"]:hover { background: #b91c1c; }

/* Croix de fermeture en haut à droite */
.dskg-info-form .dskg-info-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: 0;
    color: #9ca3af;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.dskg-info-form .dskg-info-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Lien "Non merci" sous le bouton Enregistrer */
.dskg-info-form .dskg-info-skip {
    background: transparent;
    border: 0;
    color: #9ca3af;
    font-size: 12px;
    cursor: pointer;
    margin: 2px 0 0;
    padding: 6px;
    text-decoration: underline;
    text-decoration-color: #d1d5db;
}
.dskg-info-form .dskg-info-skip:hover { color: #6b7280; }

/* Footer / input */
.dskg-chat-footer {
    border-top: 1px solid #e5e7eb;
    padding: 10px 12px;
    background: #fff;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.dskg-chat-input {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 18px;
    padding: 9px 14px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color .15s;
}
.dskg-chat-input:focus { outline: 0; border-color: var(--primary, #dc2626); }
.dskg-chat-send {
    background: var(--primary, #dc2626);
    color: #fff;
    border: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .15s;
}
.dskg-chat-send:hover:not(:disabled) { background: #b91c1c; transform: scale(1.05); }
.dskg-chat-send:disabled { opacity: .35; cursor: not-allowed; }
.dskg-chat-send svg { width: 18px; height: 18px; }

.dskg-chat-branding {
    text-align: center;
    font-size: 10.5px;
    color: #9ca3af;
    padding: 4px 0 6px;
    background: #fff;
}

/* Mobile : panneau compact qui ne prend pas tout l'écran */
@media (max-width: 480px) {
    .dskg-chat { right: 12px; bottom: 12px; }
    .dskg-chat-panel {
        width: min(340px, calc(100vw - 24px));
        height: min(480px, 70vh);
        bottom: 0;
    }
    .dskg-chat-launcher { width: 54px; height: 54px; font-size: 22px; }
}

/* Très petits écrans (≤ 360 px) : adaptation finale */
@media (max-width: 360px) {
    .dskg-chat-panel {
        width: calc(100vw - 20px);
        height: 65vh;
    }
}

/* Quand le sticky CTA mobile est visible, on remonte la bulle chat pour éviter le chevauchement */
@media (max-width: 900px) {
    body.has-sticky-cta .dskg-chat {
        bottom: 88px;
        transition: bottom .25s ease;
    }
}
.dskg-chat { transition: bottom .25s ease; }
