/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Thinkify Robot — Plugin Autonome
   Mascotte flottante + panneau chat n8n intégré
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */


/* ═══════════════════════════════════════════════
   Écran de consentement RGPD
═══════════════════════════════════════════════ */
.tk-consent {
    /* Enfant flex du panel — prend toute la hauteur restante après le header */
    flex:            1;
    min-height:      0;
    background:      #0D1420;
    display:         flex;
    flex-direction:  column;
    justify-content: center;
    padding:         2rem 1.75rem;
    animation:       tkConsentIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes tkConsentIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0);    }
}

.tk-consent--exit {
    animation: tkConsentOut 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

@keyframes tkConsentOut {
    from { opacity: 1; transform: translateY(0);    }
    to   { opacity: 0; transform: translateY(-12px);}
}

/* ── Texte avec bordure teal ─── */
.tk-consent__text {
    border-left:   2px solid rgba(0, 180, 166, 0.42);
    padding-left:  1.1rem;
    color:         rgba(216, 224, 239, 0.76);
    font-family:   'DM Sans', system-ui, sans-serif;
    font-size:     0.82rem;
    line-height:   1.72;
    margin-bottom: 1.75rem;
}

.tk-consent__text a {
    color:                  #00B4A6;
    text-decoration:        underline;
    text-underline-offset:  2px;
}

/* ── Label checkbox ─── */
.tk-consent__label {
    display:        flex;
    align-items:    center;
    gap:            0.75rem;
    cursor:         pointer;
    margin-bottom:  1.2rem;
    color:          #d8e0ef;
    font-family:    'DM Sans', system-ui, sans-serif;
    font-size:      0.83rem;
    font-weight:    500;
    letter-spacing: 0.01em;
    user-select:    none;
    -webkit-user-select: none;
}

/* ── Checkbox custom ─── */
.tk-consent__check {
    appearance:         none;
    -webkit-appearance: none;
    width:              18px;
    height:             18px;
    border:             1.5px solid rgba(0, 180, 166, 0.35);
    border-radius:      3px;
    background:         transparent;
    cursor:             pointer;
    flex-shrink:        0;
    position:           relative;
    transition:         border-color 0.2s, background 0.2s;
}

.tk-consent__check:hover {
    border-color: rgba(0, 180, 166, 0.7);
}

.tk-consent__check:checked {
    background:   #00B4A6;
    border-color: #00B4A6;
}

.tk-consent__check:checked::after {
    content:      '';
    position:     absolute;
    top:          2px;
    left:         5px;
    width:        5px;
    height:       9px;
    border:       2px solid #0D1420;
    border-top:   none;
    border-left:  none;
    transform:    rotate(45deg);
}

.tk-consent__check:focus-visible {
    outline:        2px solid #00B4A6;
    outline-offset: 2px;
}

/* ── Bouton CTA ─── */
.tk-consent__btn {
    width:           100%;
    padding:         0.85rem 1rem;
    background:      rgba(0, 180, 166, 0.1);
    color:           rgba(148, 163, 184, 0.5);
    border:          1px solid rgba(0, 180, 166, 0.16);
    border-radius:   8px;
    font-family:     'DM Sans', system-ui, sans-serif;
    font-size:       0.78rem;
    font-weight:     700;
    letter-spacing:  0.09em;
    text-transform:  uppercase;
    cursor:          not-allowed;
    transition:      background 0.25s, color 0.25s, border-color 0.25s, transform 0.2s;
    display:         flex;
    align-items:     center;
    justify-content: center;
    gap:             0.5rem;
}

.tk-consent__btn:not([disabled]),
.tk-consent__btn--ready {
    background:   #00B4A6 !important;
    color:        #0D1420 !important;
    border-color: #00B4A6 !important;
    cursor:       pointer !important;
}

.tk-consent__btn:not([disabled]):hover,
.tk-consent__btn--ready:hover {
    background:   #00cec0 !important;
    border-color: #00cec0 !important;
    transform:    translateY(-1px);
}

.tk-consent__btn:not([disabled]):active,
.tk-consent__btn--ready:active {
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .tk-consent,
    .tk-consent--exit { animation: none !important; }
}

/* ─── Conteneur principal ───────────────────────── */
.tk-robot-wrap {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.6rem;
    animation: tkRobotEnter 0.7s 1.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes tkRobotEnter {
    from { opacity: 0; transform: translateY(48px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Si l'animation est désactivée (accessibilité), rendre visible immédiatement */
@media (prefers-reduced-motion: reduce) {
    .tk-robot-wrap {
        animation: none;
        opacity: 1;
        transform: none;
    }
}


/* ─── Bulle de dialogue ─────────────────────────── */
.tk-robot-bubble {
    background: #ffffff;
    border-radius: 16px 16px 4px 16px;
    padding: 1rem 1.25rem;
    max-width: 250px;
    min-width: 200px;
    box-shadow:
        0 4px 24px rgba(0,0,0,0.10),
        0 1px 4px rgba(0,0,0,0.06);
    position: relative;
    opacity: 0;
    transform: translateY(6px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}
.tk-robot-bubble.tk-bubble--show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Trait teal en haut */
.tk-robot-bubble::before {
    content: '';
    position: absolute;
    top: 0; left: 16px; right: 16px;
    height: 2px;
    background: #00B4A6;
    border-radius: 0 0 2px 2px;
}

/* Queue pointant vers le robot */
.tk-robot-bubble::after {
    content: '';
    position: absolute;
    bottom: -7px; right: 26px;
    width: 14px; height: 14px;
    background: #ffffff;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    border-radius: 0 0 3px 0;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.05);
}

.tk-robot-bubble__text {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.6;
    color: #0D1420;
    margin: 0 1.5rem 0 0;
    -webkit-font-smoothing: antialiased;
}

.tk-robot-bubble__close {
    position: absolute;
    top: 0.6rem; right: 0.6rem;
    width: 20px; height: 20px;
    border: none; background: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #94a3b8;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    padding: 0; font-size: 14px; line-height: 1;
}
.tk-robot-bubble__close:hover {
    background: #f1f5f9;
    color: #0D1420;
}


/* ─── Bouton robot ──────────────────────────────── */
.tk-robot-btn {
    position: relative;
    width: 72px; height: 72px;
    border-radius: 50%;
    background: #0D1420;
    border: 2px solid #00B4A6;
    box-shadow:
        0 0 0 0 rgba(0,180,166,0.4),
        0 8px 32px rgba(0,0,0,0.25);
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    transition:
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.35s ease,
        border-color 0.3s;
    display: flex; align-items: center; justify-content: center;
}
.tk-robot-btn:hover {
    transform: scale(1.08);
    box-shadow:
        0 0 0 6px rgba(0,180,166,0.15),
        0 12px 40px rgba(0,0,0,0.3);
    border-color: #00cec0;
}
.tk-robot-btn:active { transform: scale(0.97); }

.tk-robot-btn dotlottie-wc {
    width: 88px; height: 88px;
    margin: -8px;
    display: block;
    pointer-events: none;
}


/* ─── Anneaux de pulsation ──────────────────────── */
.tk-robot-pulse {
    position: absolute; inset: -2px;
    border-radius: 50%;
    border: 2px solid #00B4A6;
    opacity: 0;
    animation: tkRobotPulse 3s ease-out infinite;
    pointer-events: none;
}
.tk-robot-pulse--2 { animation-delay: 1s; }
.tk-robot-pulse--3 { animation-delay: 2s; }

@keyframes tkRobotPulse {
    0%   { transform: scale(1);   opacity: 0.7; }
    80%  { transform: scale(1.9); opacity: 0; }
    100% { transform: scale(1.9); opacity: 0; }
}


/* ─── Badge nouveau message ─────────────────────── */
.tk-robot-badge {
    position: absolute; top: 2px; right: 2px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #00B4A6;
    border: 2px solid #0D1420;
    opacity: 0;
    transform: scale(0);
    transition:
        opacity 0.3s,
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}
.tk-robot-badge.tk-badge--show {
    opacity: 1;
    transform: scale(1);
}


/* ─── Bouton masquer ────────────────────────────── */
.tk-robot-hide {
    background: rgba(13,20,32,0.6);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 100px;
    color: rgba(255,255,255,0.4);
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 0.6rem; font-weight: 600;
    letter-spacing: 0.1em; text-transform: uppercase;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    transition: background 0.25s, color 0.25s, border-color 0.25s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    line-height: 1.4;
}
.tk-robot-hide:hover {
    background: rgba(13,20,32,0.85);
    color: rgba(255,255,255,0.7);
    border-color: rgba(255,255,255,0.2);
}


/* ─── Bouton restaurer ──────────────────────────── */
.tk-robot-restore {
    position: fixed; bottom: 2rem; right: 2rem; z-index: 9000;
    background: #0D1420;
    border: 2px solid #00B4A6;
    border-radius: 100px;
    color: #00B4A6;
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 0.65rem; font-weight: 600;
    letter-spacing: 0.12em; text-transform: uppercase;
    padding: 0.5rem 0.9rem;
    cursor: pointer;
    display: none; align-items: center; gap: 0.4rem;
    transition:
        box-shadow 0.3s,
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.tk-robot-restore:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0,180,166,0.25);
}
.tk-robot-restore.tk-restore--show { display: flex; }


/* ─── État chat ouvert ──────────────────────────── */
.tk-robot-wrap.tk-robot--chat-open .tk-robot-btn {
    border-color: #00cec0;
    box-shadow:
        0 0 0 5px rgba(0,180,166,0.18),
        0 8px 32px rgba(0,0,0,0.3);
    transform: scale(1.05);
}
.tk-robot-wrap.tk-robot--chat-open .tk-robot-pulse {
    animation: none;
    opacity: 0;
}
.tk-robot-wrap.tk-robot--chat-open .tk-robot-btn dotlottie-wc {
    filter: drop-shadow(0 0 8px rgba(0,180,166,0.5));
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Panneau chat n8n
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
#tk-chat-panel {
    position: fixed;
    /* au-dessus du robot : bottom_robot + hauteur_robot + gap */
    bottom: calc(2rem + 72px + 18px);
    right: 2rem;
    width: 360px;
    height: 520px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow:
        0 8px 40px rgba(0,0,0,0.18),
        0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 8990;
    transform-origin: bottom right;
    transform: scale(0.92) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition:
        transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
#tk-chat-panel.tk-chat--open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.tk-chat-header {
    background: #0D1420;
    padding: 14px 16px;
    border-bottom: 2px solid #00B4A6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.tk-chat-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 0.9rem; font-weight: 600;
    letter-spacing: 0.02em;
    color: #ffffff;
    display: flex; align-items: center; gap: 0.6rem;
}

/* Indicateur "en ligne" */
.tk-chat-title::before {
    content: '';
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #00B4A6;
    flex-shrink: 0;
    animation: tkChatOnline 2s ease-in-out infinite;
}
@keyframes tkChatOnline {
    0%,100% { box-shadow: 0 0 0 2px rgba(0,180,166,0.25); }
    50%      { box-shadow: 0 0 0 4px rgba(0,180,166,0.12); }
}

.tk-chat-close {
    width: 28px; height: 28px;
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,0.55);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: background 0.2s, color 0.2s;
}
.tk-chat-close:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}

/* Iframe n8n */
#tk-chat-iframe {
    flex: 1;
    border: none;
    width: 100%;
    display: block;
    background: #f7f8fa;
}

/* Message quand l'URL n'est pas configurée */
.tk-chat-unconfigured {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 0.88rem;
    line-height: 1.7;
    color: #64748b;
}
.tk-chat-unconfigured a {
    color: #00B4A6;
    text-decoration: none;
}
.tk-chat-unconfigured a:hover { text-decoration: underline; }


/* ─── Responsive ────────────────────────────────── */
@media (max-width: 600px) {
    .tk-robot-wrap {
        bottom: 1.25rem;
        right: 1.25rem;
    }
    .tk-robot-bubble {
        max-width: 210px;
        min-width: 160px;
    }
    .tk-robot-restore {
        bottom: 1.25rem;
        right: 1.25rem;
    }
    #tk-chat-panel {
        bottom: calc(1.25rem + 72px + 14px);
        right: 1.25rem;
        width: calc(100vw - 2.5rem);
        max-width: 360px;
        height: 70vh;
        border-radius: 18px 18px 12px 12px;
    }
}
