/*===================================*\
  Section « Silwane .Net dans votre messagerie » (_ChatDemo.cshtml + js/chat-demo.js)
\*===================================*/
.cd-section {
    position: relative;
    overflow: hidden;
    padding: clamp(64px, 6vw, 110px) 0;
    background: #fff;
}

.cd-wrap {
    display: grid;
    grid-template-columns: 1fr;
    gap: 48px;
    align-items: center;
    max-width: 1180px;
    margin: 0 auto;
    padding-inline: 24px;
}

@media (min-width: 992px) {
    .cd-wrap {
        grid-template-columns: 1.05fr 1fr;
        gap: 72px;
    }
}

/* Texte */
.cd-eyebrow {
    display: inline-flex !important;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: hsl(228, 69%, 45%);
}

    .cd-eyebrow::before {
        content: "";
        width: 28px;
        height: 2px;
        border-radius: 2px;
        background: currentColor;
    }

.cd-title {
    margin: 0 0 18px;
    font-size: clamp(3.2rem, 2rem + 2.4vw, 5rem) !important;
    font-weight: 800 !important;
    line-height: 1.08 !important;
    letter-spacing: -0.03em !important;
    color: hsl(240, 14%, 9%);
}

    .cd-title span {
        display: inline !important;
        background: linear-gradient(120deg, #1E40AF, #2F5BEA);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }

.cd-lead {
    max-width: 520px;
    margin: 0 0 24px;
    font-size: 1.7rem;
    line-height: 1.7;
    color: hsl(240, 6%, 40%);
}

    .cd-lead b {
        color: hsl(240, 14%, 9%);
    }

.cd-points {
    margin: 0;
    padding: 0;
    list-style: none;
}

    .cd-points li {
        position: relative;
        padding: 8px 0 8px 30px;
        font-size: 1.55rem;
        color: hsl(240, 8%, 30%);
    }

        .cd-points li::before {
            content: "\2713";
            position: absolute;
            left: 0;
            top: 9px;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #25D366;
            color: #fff;
            font-size: 1.1rem;
            font-weight: 700;
            line-height: 20px;
            text-align: center;
        }

        .cd-points li b {
            color: hsl(240, 14%, 9%);
        }

/* Téléphone */
.cd-phone-zone {
    position: relative;
    display: flex;
    justify-content: center;
}

.cd-glow {
    position: absolute;
    inset: 10% 15%;
    z-index: 0;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(37, 211, 102, 0.22), rgba(47, 91, 234, 0.12) 60%, transparent);
    filter: blur(30px);
}

.cd-phone {
    position: relative;
    z-index: 1;
    width: 330px;
    height: 640px;
    padding: 12px;
    border-radius: 48px;
    background: #0E0F14;
    box-shadow: inset 0 0 0 2px #2A2C34, 0 50px 90px -40px rgba(10, 26, 60, 0.6);
    animation: cd-float 7s ease-in-out infinite;
}

@keyframes cd-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.cd-notch {
    position: absolute;
    top: 20px;
    left: 50%;
    z-index: 3;
    width: 96px;
    height: 26px;
    border-radius: 999px;
    background: #0E0F14;
    transform: translateX(-50%);
}

.cd-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: 38px;
    background: #EFE7DE;
}

/* Barre du haut */
.cd-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 50px 14px 12px;
    background: #075E54;
    color: #fff;
}

.cd-back {
    display: inline !important;
    font-size: 2.4rem;
    line-height: 1;
    opacity: 0.9;
}

.cd-avatar {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1E40AF, #2F5BEA);
    font-size: 1.5rem;
    font-weight: 800;
}

.cd-who {
    display: flex !important;
    flex-direction: column;
    line-height: 1.2;
}

    .cd-who strong { font-size: 1.45rem; }
    .cd-who small { font-size: 1.1rem; opacity: 0.8; }

/* Conversation */
.cd-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 12px;
    overflow: hidden;
    background-color: #EFE7DE;
    background-image: radial-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px);
    background-size: 14px 14px;
}

.cd-msg {
    position: relative;
    max-width: 84%;
    padding: 7px 10px 18px;
    border-radius: 12px;
    font-size: 1.3rem;
    line-height: 1.4;
    color: #111B21;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
    animation: cd-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cd-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.cd-me {
    align-self: flex-end;
    background: #D9FDD3;
    border-top-right-radius: 4px;
}

.cd-bot {
    align-self: flex-start;
    background: #fff;
    border-top-left-radius: 4px;
}

.cd-time {
    position: absolute;
    right: 8px;
    bottom: 3px;
    display: inline !important;
    font-size: 0.95rem;
    color: #667781;
}

    .cd-time em { font-style: normal; color: #53BDEB; }

/* Indicateur de saisie */
.cd-typing {
    display: inline-flex;
    gap: 4px;
    padding: 10px 12px;
}

    .cd-typing i {
        display: block;
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: #9AA5AC;
        animation: cd-dot 1s ease-in-out infinite;
    }

        .cd-typing i:nth-child(2) { animation-delay: 0.15s; }
        .cd-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes cd-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Cartes de réponse */
.cd-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 210px;
}

    .cd-card small { font-size: 1.05rem; color: #667781; }

.cd-big {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #111B21;
}

.cd-up {
    display: inline !important;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1FA855;
}

.cd-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 44px;
    margin-top: 6px;
}

    .cd-bars i {
        display: block;
        flex: 1;
        height: var(--h);
        border-radius: 3px;
        background: #D7DCE0;
        animation: cd-grow 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
    }

        .cd-bars i.on { background: linear-gradient(180deg, #2F5BEA, #1E40AF); }

@keyframes cd-grow {
    from { height: 0; }
}

.cd-top,
.cd-alerts {
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: cd;
}

    .cd-top li {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 4px 0;
        border-bottom: 1px solid #EEF1F3;
        font-size: 1.2rem;
        counter-increment: cd;
    }

        .cd-top li:last-child { border-bottom: 0; }

        .cd-top li span::before {
            content: counter(cd) ". ";
            color: #667781;
        }

    .cd-alerts li {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 3px 0;
        font-size: 1.2rem;
    }

        .cd-alerts li i {
            display: block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
        }

            .cd-alerts li i.r { background: #EF4444; }
            .cd-alerts li i.o { background: #F59E0B; }

.cd-hint {
    display: inline !important;
    margin-top: 4px;
    font-size: 1.15rem;
    font-weight: 600;
    color: #075E54;
}

/* Champ de saisie */
.cd-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 16px;
    background: #EFE7DE;
}

.cd-field {
    flex: 1;
    display: block !important;
    min-height: 36px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #fff;
    font-size: 1.25rem;
    color: #8696A0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .cd-field.is-typing { color: #111B21; }

.cd-send {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #00A884;
    color: #fff;
    font-size: 1.4rem;
}

@media (prefers-reduced-motion: reduce) {
    .cd-phone, .cd-msg, .cd-bars i, .cd-typing i { animation: none !important; }
}

/* Barres : animation par échelle verticale (plus fiable que l'animation de hauteur) */
.cd-bars i {
    min-height: 4px;
    transform-origin: bottom;
    animation: cd-grow2 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cd-grow2 {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

/* Fond : prolonge le dégradé du héros (lueurs orange / rose / violet), puis s'estompe vers le blanc en bas */
.cd-section {
    background:
        radial-gradient(42% 55% at 6% 0%, rgba(56, 189, 248, 0.16), transparent 72%),
        radial-gradient(36% 45% at 50% 0%, rgba(47, 91, 234, 0.09), transparent 72%),
        radial-gradient(40% 60% at 94% 10%, rgba(47, 91, 234, 0.14), transparent 72%),
        radial-gradient(35% 45% at 78% 70%, rgba(37, 211, 102, 0.06), transparent 72%),
        linear-gradient(180deg, #F8FAFF 0%, #FFFFFF 92%);
}

/* Effet au défilement (piloté par --p de 0 à 1, js/chat-demo.js) */
.cd-section {
    --p: 1;
}

.cd-phone-zone {
    perspective: 1400px;
}

.cd-phone {
    transform:
        translateY(calc((1 - var(--p)) * 90px))
        rotateX(calc((1 - var(--p)) * 22deg))
        rotateZ(calc((1 - var(--p)) * -6deg))
        scale(calc(0.86 + var(--p) * 0.14));
    animation: none;
    transition: transform 0.08s linear;
    will-change: transform;
}

.cd-glow {
    opacity: calc(0.3 + var(--p) * 0.7);
    transform: scale(calc(0.7 + var(--p) * 0.3));
}

.cd-text {
    opacity: calc(0.15 + var(--p) * 0.85);
    transform: translateX(calc((1 - var(--p)) * -60px));
    will-change: transform, opacity;
}

    .cd-points li {
        opacity: calc(var(--p) * 1.6 - 0.4);
    }

@media (prefers-reduced-motion: reduce) {
    .cd-section { --p: 1 !important; }
}

/* La section démarre sur la teinte de jonction, puis les lueurs réapparaissent un peu plus bas */
.cd-section {
    background:
        radial-gradient(42% 50% at 6% 22%, rgba(56, 189, 248, 0.13), transparent 72%),
        radial-gradient(40% 55% at 94% 30%, rgba(47, 91, 234, 0.12), transparent 72%),
        radial-gradient(35% 45% at 78% 75%, rgba(37, 211, 102, 0.06), transparent 72%),
        linear-gradient(180deg, #F8FAFF 0%, #FFFFFF 92%);
}

/* Haut de la section totalement uni (jonction invisible), lueurs plus bas */
.cd-section {
    background:
        radial-gradient(40% 42% at 6% 48%, rgba(56, 189, 248, 0.12), transparent 72%),
        radial-gradient(38% 45% at 94% 45%, rgba(47, 91, 234, 0.11), transparent 72%),
        radial-gradient(35% 40% at 78% 80%, rgba(37, 211, 102, 0.06), transparent 72%),
        linear-gradient(180deg, #F8FAFF 0%, #F8FAFF 8%, #FFFFFF 95%);
}

/* Phrase courte du bot au-dessus de sa carte (darija) */
.cd-say {
    display: block !important;
    margin-bottom: 6px;
    font-size: 1.3rem;
    color: #111B21;
}

/* Message vocal */
.cd-is-voice {
    min-width: 220px;
}

.cd-voice {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cd-play {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex: none;
    border-radius: 50%;
    background: #00A884;
    color: #fff;
    font-size: 1rem;
}

.cd-wave {
    display: flex !important;
    align-items: center;
    gap: 2px;
    flex: 1;
    height: 26px;
}

    .cd-wave i {
        display: block;
        flex: 1;
        height: var(--h);
        min-height: 3px;
        border-radius: 2px;
        background: #5E8E7C;
        animation: cd-wave 1.1s ease-in-out var(--d) infinite;
    }

@keyframes cd-wave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.45); }
}

.cd-vdur {
    display: inline !important;
    font-size: 1.05rem;
    color: #667781;
}

.cd-mic {
    display: inline !important;
    font-size: 1.2rem;
}

.cd-transcript {
    display: block !important;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 1.15rem;
    font-style: italic;
    color: #3B4A54;
}

/* Champ pendant l'enregistrement */
.cd-field.is-rec {
    color: #E11D48 !important;
    font-weight: 600;
}

.cd-rec {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 4px;
    border-radius: 50%;
    background: #E11D48;
    animation: cd-blink 1s ease-in-out infinite;
}

@keyframes cd-blink {
    50% { opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
    .cd-wave i, .cd-rec { animation: none !important; }
}

/* ---------- Carte « créances clients par ville » (1er échange, en darija) ---------- */
.cd-ar {
    font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
    text-align: right;
    font-size: 1.35rem;
}

.cd-card--map { min-width: 0; width: 214px; }

.cd-map {
    display: block;
    width: 100%;
    height: auto;
    margin: 4px 0 2px;
    border-radius: 8px;
    overflow: hidden;
}

    .cd-map text {
        font: 600 6.6px/1 'Inter', 'Inter Fallback', system-ui, sans-serif;
        fill: #3C4148;
        paint-order: stroke;
        stroke: rgba(255, 255, 255, 0.85);
        stroke-width: 2px;
    }

    .cd-map .cd-map__sea {
        font-style: italic;
        font-weight: 500;
        fill: #6FA3BF;
        stroke: none;
        letter-spacing: 0.04em;
    }

.cd-pin {
    opacity: 0;
    animation: cd-pin-in 0.45s var(--d, 0s) cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transform-box: fill-box;
    transform-origin: center bottom;
}

.cd-pin__ring {
    opacity: 0.22;
    transform-box: fill-box;
    transform-origin: center;
    animation: cd-pulse 2s calc(var(--d, 0s) + 0.4s) ease-out infinite;
}

@keyframes cd-pin-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.6); }
    to { opacity: 1; transform: none; }
}

@keyframes cd-pulse {
    0% { transform: scale(0.5); opacity: 0.35; }
    100% { transform: scale(1.4); opacity: 0; }
}

.cd-debts {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: grid;
    gap: 3px;
}

    .cd-debts li {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 1.15rem;
        color: #3C4148;
    }

        .cd-debts li i {
            width: 7px;
            height: 7px;
            border-radius: 50%;
            flex: none;
        }

        .cd-debts li span { flex: 1; display: inline !important; }
        .cd-debts li b { font-weight: 700; color: #111B21; }

.cd-debts__total {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #D7DCE0;
    font-size: 1.15rem;
    color: #667781;
}

    .cd-debts__total span { display: inline !important; }
    .cd-debts__total b { color: #E5484D; font-weight: 800; }

@media (prefers-reduced-motion: reduce) {
    .cd-pin { animation: none; opacity: 1; }
    .cd-pin__ring { animation: none; }
}

/* Section WhatsApp : largeur contenue et moins d'espace au-dessus */
@media (min-width: 992px) {
    .cd-section .cd-wrap {
        box-sizing: border-box !important;
        width: 100%;
        max-width: 1100px !important;
        padding-inline: 15px !important;
        grid-template-columns: 1fr auto;
        gap: 56px;
    }
}

.hx-stage .cd-section {
    padding-top: 24px;
}

/* Après le premier calcul de position (classe cd-ready), les changements glissent doucement */
.cd-ready .cd-phone {
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.cd-ready .cd-text,
.cd-ready .cd-glow {
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.6s ease;
}

/* Titre WhatsApp aligné sur le titre du héros */
@media (min-width: 1367px) {
    .cd-section .cd-title { font-size: clamp(36px, 2.5vw, 46px) !important; }
}

@media (min-width: 761px) and (max-width: 1366px) {
    .cd-section .cd-title { font-size: clamp(30px, 2.9vw, 42px) !important; }
}

@media (max-width: 760px) {
    .cd-section .cd-title { font-size: 30px !important; }
}

/* Section WhatsApp alignée sur le conteneur du site (mêmes marges que l'en-tête) */
@media (min-width: 1370px) {
    .cd-section .cd-wrap { max-width: 1400px !important; }
}

@media (min-width: 992px) {
    .cd-section .cd-wrap { justify-content: space-between; }
    .cd-section .cd-phone-zone { justify-content: flex-end; }
}

/* Tablette : section WhatsApp centrée comme le héros */
@media (min-width: 761px) and (max-width: 991.98px) {
    .cd-section .cd-wrap {
        box-sizing: border-box !important;
        max-width: 720px !important;
        margin-inline: auto !important;
        padding-inline: 24px !important;
        justify-items: center;
        text-align: center;
    }

    .cd-section .cd-text {
        max-width: 620px;
        margin-inline: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .cd-section .cd-lead { margin-inline: auto; }
    .cd-section .cd-phone-zone { justify-content: center; }
}

@media (min-width: 761px) and (max-width: 991.98px) {
    .cd-section .cd-phone { text-align: left; }
}
