/* ─── CUNSE Chatbot – Page dédiée v3.0 ─────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700&family=Roboto:wght@400;500&display=swap');

:root {
    --cunse-blue:   #1E3A8A;
    --cunse-blue2:  #3B82F6;
    --cunse-red:    #DC2626;
    --cunse-yellow: #FACC15;
    --cunse-gray:   #F3F4F6;
    --cunse-border: #E5E7EB;
    --cunse-text:   #1F2937;
    --cunse-muted:  #6B7280;
    --chat-radius:  14px;
    --chat-max:     820px;
}

/* Conteneur principal */
.cunse-chatbot-wrap {
    max-width: var(--chat-max);
    margin: 0 auto 2rem;
    border: 1px solid var(--cunse-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(30,58,138,0.10);
    font-family: 'Roboto', sans-serif;
    background: #fff;
}

/* ─── En-tête ──────────────────────────────────────────────────────────────── */
.cunse-chatbot-header {
    background: var(--cunse-blue);
    padding: 18px 24px;
}

.cunse-chatbot-header-inner {
    display: flex;
    align-items: center;
    gap: 14px;
}

.cunse-chatbot-header-text {
    flex: 1;
    min-width: 0;
}

/* Bouton réinitialiser */
.cunse-chatbot-reset {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.35);
    background: rgba(255,255,255,0.10);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s, transform 0.18s;
}

.cunse-chatbot-reset:hover {
    background: rgba(255,255,255,0.22);
}

.cunse-chatbot-reset:active {
    transform: rotate(-180deg);
}

/* Masquage des suggestions après la 1re question */
.cunse-chatbot-suggestions.cunse-hidden {
    display: none;
}

/* Liens dans les bulles du bot */
.cunse-msg-bot .cunse-msg-bubble a {
    color: var(--cunse-blue2);
    text-decoration: underline;
    word-break: break-word;
}

.cunse-chatbot-avatar img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid var(--cunse-yellow);
    object-fit: cover;
    background: #fff;
}

.cunse-chatbot-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 2px;
}

.cunse-chatbot-subtitle {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.72);
    margin: 0;
}

/* ─── Suggestions ──────────────────────────────────────────────────────────── */
.cunse-chatbot-suggestions {
    background: var(--cunse-gray);
    border-bottom: 1px solid var(--cunse-border);
    padding: 12px 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.cunse-suggestion-label {
    font-size: 0.75rem;
    color: var(--cunse-muted);
    font-weight: 500;
    white-space: nowrap;
}

.cunse-suggestion {
    background: #fff;
    border: 1px solid var(--cunse-border);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.78rem;
    color: var(--cunse-blue);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
}

.cunse-suggestion:hover {
    background: var(--cunse-blue);
    border-color: var(--cunse-blue);
    color: #fff;
}

/* ─── Zone de messages ─────────────────────────────────────────────────────── */
.cunse-chatbot-messages {
    height: 420px;
    overflow-y: auto;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #FAFBFF;
}

/* Message générique */
.cunse-msg {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    max-width: 86%;
}

/* Bot : aligné à gauche */
.cunse-msg-bot {
    align-self: flex-start;
}

/* User : aligné à droite */
.cunse-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cunse-msg-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--cunse-border);
    object-fit: cover;
    flex-shrink: 0;
}

.cunse-msg-bubble {
    padding: 10px 14px;
    border-radius: var(--chat-radius);
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--cunse-text);
}

.cunse-msg-bot .cunse-msg-bubble {
    background: #fff;
    border: 1px solid var(--cunse-border);
    border-bottom-left-radius: 4px;
}

.cunse-msg-user .cunse-msg-bubble {
    background: var(--cunse-blue);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.cunse-msg-typing .cunse-msg-bubble {
    padding: 12px 16px;
}

.cunse-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 16px;
}

.cunse-typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--cunse-muted);
    border-radius: 50%;
    animation: cunse-bounce 1.2s infinite ease-in-out;
}

.cunse-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.cunse-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cunse-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%           { transform: translateY(-6px); opacity: 1; }
}

/* Mise en forme du contenu bot */
.cunse-msg-bot .cunse-msg-bubble ul,
.cunse-msg-bot .cunse-msg-bubble ol {
    margin: 8px 0 0 16px;
    padding: 0;
}

.cunse-msg-bot .cunse-msg-bubble li {
    margin-bottom: 4px;
}

.cunse-msg-bot .cunse-msg-bubble strong {
    color: var(--cunse-blue);
}

/* ─── Zone de saisie ───────────────────────────────────────────────────────── */
.cunse-chatbot-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 14px 16px;
    border-top: 1px solid var(--cunse-border);
    background: #fff;
}

.cunse-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--cunse-border);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: 'Roboto', sans-serif;
    font-size: 0.9rem;
    color: var(--cunse-text);
    line-height: 1.5;
    min-height: 42px;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s;
    background: var(--cunse-gray);
}

.cunse-input:focus {
    outline: none;
    border-color: var(--cunse-blue2);
    background: #fff;
}

.cunse-input::placeholder {
    color: var(--cunse-muted);
}

.cunse-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--cunse-blue);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
}

.cunse-send-btn:hover  { background: var(--cunse-blue2); }
.cunse-send-btn:active { transform: scale(0.94); }
/* ─── Durcissement anti-thème (Astra) — bouton d'envoi & reset ──────────────── */
.cunse-chatbot-wrap .cunse-send-btn {
    width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    min-width: 42px !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    border: none !important;
    border-radius: 10px !important;
    background: var(--cunse-blue) !important;
    color: #fff !important;
    box-shadow: none !important;
    text-shadow: none !important;
    flex: 0 0 42px !important;
    align-self: flex-end !important;
}
.cunse-chatbot-wrap .cunse-send-btn:hover { background: var(--cunse-blue2) !important; }
.cunse-chatbot-wrap .cunse-send-btn svg {
    width: 20px !important;
    height: 20px !important;
    display: block !important;
    fill: #fff !important;
}
.cunse-chatbot-wrap .cunse-send-btn svg path { fill: #fff !important; }

.cunse-chatbot-wrap .cunse-chatbot-reset {
    width: 36px !important;
    height: 36px !important;
    min-height: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    box-shadow: none !important;
    border-radius: 50% !important;
}
.cunse-chatbot-wrap .cunse-chatbot-reset svg { display: block !important; fill: #fff !important; }

/* ─── Icônes en CSS (data-URI) — insensibles au strip du SVG inline ─────────── */
.cunse-chatbot-wrap .cunse-send-btn {
    background-color: var(--cunse-blue) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M2.01 21L23 12 2.01 3 2 10l15 2-15 2z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 20px 20px !important;
}
.cunse-chatbot-wrap .cunse-send-btn:hover { background-color: var(--cunse-blue2) !important; }

.cunse-chatbot-wrap .cunse-chatbot-reset {
    background-color: rgba(255,255,255,0.10) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M12 5V2L7 7l5 5V8c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 18px 18px !important;
}
.cunse-chatbot-wrap .cunse-chatbot-reset:hover { background-color: rgba(255,255,255,0.22) !important; }

/* ─── Rendu markdown : titres et citations ─────────────────────────────────── */
.cunse-msg-bot .cunse-msg-bubble .cunse-h {
    font-weight: 700;
    color: var(--cunse-blue);
    margin: 12px 0 4px;
    font-size: 0.92rem;
}
.cunse-msg-bot .cunse-msg-bubble .cunse-quote {
    border-left: 3px solid var(--cunse-yellow);
    background: var(--cunse-gray);
    padding: 6px 10px;
    margin: 8px 0;
    border-radius: 0 6px 6px 0;
    font-size: 0.86rem;
}
