/**
 * Styles du widget chatbot.
 * Préfixe "cv-chat" pour éviter les conflits avec le thème WordPress.
 */

#cv-chat-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

/* === BOUTON TOGGLE === */
#cv-chat-toggle {
    position: fixed;
    bottom: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#cv-chat-toggle:hover {
    transform: scale(1.08);
}
#cv-chat-toggle svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    transition: opacity 0.2s;
}
#cv-chat-toggle .cv-chat-icon-close {
    display: none;
}
#cv-chat-toggle.open .cv-chat-icon-open {
    display: none;
}
#cv-chat-toggle.open .cv-chat-icon-close {
    display: block;
}

/* Position */
.cv-chat-pos-bottom-right #cv-chat-toggle { right: 24px; }
.cv-chat-pos-bottom-left #cv-chat-toggle { left: 24px; }

/* === FENÊTRE === */
#cv-chat-window {
    position: fixed;
    bottom: 100px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
#cv-chat-window.open {
    display: flex;
    animation: cv-chat-slide-up 0.25s ease-out;
}

.cv-chat-pos-bottom-right #cv-chat-window { right: 24px; }
.cv-chat-pos-bottom-left #cv-chat-window { left: 24px; }

@keyframes cv-chat-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* === HEADER === */
#cv-chat-header {
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#cv-chat-header-info h3 {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}
#cv-chat-header-info span {
    font-size: 12px;
    opacity: 0.85;
}
#cv-chat-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 22px;
    padding: 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}
#cv-chat-close:hover {
    opacity: 1;
}

/* === MESSAGES === */
#cv-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.cv-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
}
.cv-chat-msg-bot {
    background: #f1f5f9;
    color: #1e293b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.cv-chat-msg-user {
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.cv-chat-msg-bot a {
    text-decoration: underline;
}
.cv-chat-msg-bot ul,
.cv-chat-msg-bot ol {
    margin: 6px 0 6px 20px;
}
.cv-chat-msg-bot li {
    margin-bottom: 2px;
}
.cv-chat-msg-bot strong {
    font-weight: 600;
}

/* === CARTE VIDÉO === */
.cv-chat-video-card {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 4px;
    align-self: flex-start;
    max-width: 85%;
    font-size: 13px;
}
.cv-chat-video-card a {
    font-weight: 600;
    text-decoration: none;
}
.cv-chat-video-card a:hover {
    text-decoration: underline;
}
.cv-chat-video-card p {
    margin-top: 4px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
}

/* === TYPING INDICATOR === */
.cv-chat-typing {
    display: flex;
    gap: 5px;
    padding: 10px 14px;
    align-self: flex-start;
}
.cv-chat-typing span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: cv-chat-bounce 1.2s infinite;
}
.cv-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.cv-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cv-chat-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* === INPUT === */
#cv-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
#cv-chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
    color: #1e293b;
}
#cv-chat-input:focus {
    border-color: var(--cv-chat-primary, #2563eb);
}
#cv-chat-send {
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: opacity 0.2s;
}
#cv-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === CONSENTEMENT RGPD === */
#cv-chat-consent {
    padding: 14px 16px;
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    font-size: 12px;
    color: #92400e;
    text-align: center;
    line-height: 1.5;
    flex-shrink: 0;
}
#cv-chat-consent-btn {
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 20px;
    margin-top: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

/* === POWERED BY === */
#cv-chat-footer {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #94a3b8;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

/* === RESPONSIVE === */
@media (max-width: 480px) {
    #cv-chat-window {
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    #cv-chat-toggle {
        bottom: 16px;
    }
    .cv-chat-pos-bottom-right #cv-chat-toggle { right: 16px; }
    .cv-chat-pos-bottom-left #cv-chat-toggle { left: 16px; }
}
