/**
 * Styles du widget de chat Tom — design minimaliste
 *
 * @package Tom
 */

/* Container principal */
.tom-chat-widget {
    max-width: 800px;
    margin: 0 auto;
    background: transparent;
    border-radius: 4px;
    border: none;
    overflow: hidden;
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Corps du chat */
.tom-chat-body {
    padding: 24px;
    overflow-y: auto;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar */
.tom-chat-body::-webkit-scrollbar {
    width: 4px;
}

.tom-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.tom-chat-body::-webkit-scrollbar-thumb {
    background: #e5e2dd;
    border-radius: 2px;
}

.tom-chat-body::-webkit-scrollbar-thumb:hover {
    background: #c9a96e;
}

/* Messages */
.tom-message {
    display: flex;
    gap: 12px;
    animation: tom-fadeIn 0.2s ease-out;
}

@keyframes tom-fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tom-message-assistant {
    align-items: flex-start;
}

.tom-message-user {
    flex-direction: row-reverse;
}

.tom-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.87em;
    flex-shrink: 0;
}

.tom-message-assistant .tom-message-avatar {
    background-color: transparent;
    background-image: url('../images/tom-avatar.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: transparent;
    font-size: 0;
}

.tom-message-user .tom-message-avatar {
    display: none;
}

.tom-message-content {
    flex: 1;
    min-width: 0;
}

.tom-message-text {
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 0.87em;
    line-height: 1.65;
    word-wrap: break-word;
    text-align: left;
}

/* Réponses de TOM : fond blanc, bords arrondis, contour plus marqué */
.tom-message-assistant .tom-message-text {
  background: #fff !important;
  border: 2px solid #e5e2dd !important;
  border-radius: 12px !important;
}

.tom-message-user .tom-message-text {
    background: #ffffff;
    color: #1a1a1a;
    border: 1px solid #e5e2dd;
    max-width: 80%;
    margin-left: auto;
}

/* Sources */
.tom-message-sources {
    margin-top: 8px;
    padding-top: 8px;
    text-align: left;
}

.tom-message-sources-title {
    font-size: 0.73em;
    font-weight: 600;
    color: #8a8480;
    margin-bottom: 4px;
    letter-spacing: 0.05em;
    display: none;
}

.tom-message-sources-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}

.tom-message-source-link {
    font-size: 0.75em;
    color: #c9a96e;
    text-decoration: none !important;
    display: block;
    text-align: left;
    /* Retrait pendant : la seconde ligne s'aligne sur le texte, pas sous la puce. */
    padding-left: 12px;
    text-indent: -12px;
}

/* Puce d'ouverture et flèche de fin : dans le flux du texte, donc la flèche
   suit le dernier mot même lorsque le titre passe à la ligne. */
.tom-message-source-link::before {
    content: '\2022\00a0';
}

.tom-message-source-link::after {
    content: '\00a0\2192';
}

.tom-message-source-link:hover {
    text-decoration: underline !important;
}

/* Liens inline dans le corps du texte : le segment de phrase devient cliquable */
.tom-source-link-inline {
    text-decoration: underline !important;
    text-underline-offset: 2px;
    cursor: pointer;
}

.tom-source-link-inline:hover {
    opacity: 0.75;
}


/* Zone de saisie */
.tom-chat-input-container {
    padding: 16px 24px;
    background: #faf9f7;
    border-top: 1px solid #e5e2dd;
}

.tom-chat-welcome {
    margin: 0 0 12px 0;
    font-size: 0.85em;
    line-height: 1.6;
    color: #5a5753;
    text-align: center;
}

.tom-chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: #ffffff;
    border: 1px solid #e5e2dd;
    border-radius: 24px;
    padding: 14px 20px;
    transition: border-color 0.15s;
}

.tom-chat-input-wrapper:focus-within {
    border-color: #c9a96e;
}

.tom-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 0.93em;
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
    min-height: 48px;
    outline: none;
    color: #1a1a1a;
}

.tom-chat-input::placeholder {
    color: #b5b0aa;
}

.tom-chat-send-btn {
    /* Reset anti-thème */
    all: unset;
    box-sizing: border-box !important;
    /* Dimensions fixes */
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    /* Style */
    border: none !important;
    border-radius: 3px !important;
    background: #1a1a1a !important;
    color: #faf9f7 !important;
    opacity: 1 !important;
    visibility: visible !important;
    /* Layout */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    /* Interaction */
    cursor: pointer !important;
    transition: background-color 0.15s !important;
    /* Touch mobile */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.tom-chat-send-btn:hover {
    background: #c9a96e !important;
}

.tom-chat-send-btn:active {
    background: #b8924a !important;
}

.tom-chat-send-btn:disabled {
    background: #e5e2dd !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

/* S'assurer que le SVG à l'intérieur ne bloque pas les clics */
.tom-chat-send-btn svg {
    display: block;
    pointer-events: none;
    flex-shrink: 0;
}

/* Loader */
.tom-chat-loader {
    padding: 16px;
    display: flex;
    justify-content: flex-start;
}

.tom-chat-loader-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tom-chat-loader-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c9a96e;
    animation: tom-bounce 1.4s infinite ease-in-out both;
}

.tom-chat-loader-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.tom-chat-loader-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes tom-bounce {
    0%, 80%, 100% {
        transform: scale(0.5);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Erreur */
.tom-error {
    padding: 14px 16px;
    background: #faf9f7;
    border: 1px solid #e5e2dd;
    border-left: 3px solid #c9a96e;
    border-radius: 4px;
    color: #5a5753;
    font-size: 0.93em;
}

.tom-error a {
    color: #c9a96e;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .tom-chat-widget {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .tom-chat-body {
        padding: 20px 16px;
    }

    .tom-chat-input-container {
        padding: 12px 16px;
    }

    .tom-chat-input-wrapper {
        padding: 10px 12px;
        gap: 8px;
        align-items: center;
    }

    .tom-chat-input {
        font-size: 16px; /* evite le zoom auto sur iOS */
        min-height: 28px;
    }

    /* Bouton plus grand pour un meilleur tap sur mobile */
    .tom-chat-send-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        border-radius: 4px !important;
    }

    .tom-message-user .tom-message-text {
        max-width: 90%;
    }
}

/* Filet + bords arrondis sur la zone de saisie */
.tom-chat-input-container {
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 16px;
    overflow: hidden;
}

/* Liens intégrés directement dans les réponses TOM */
.tom-message-text .tom-inline-source-link {
    color: inherit;
    text-decoration: underline !important;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.tom-message-text .tom-inline-source-link:hover {
    opacity: 0.8;
}

.tom-inline-source-note {
    font-size: 0.92em;
    opacity: 0.9;
}

/* Mention unique — avant saisie + fiabilité, fusionnées en un seul paragraphe */
.tom-chat-ai-notice {
    margin: 10px 0 0 0;
    padding: 0;
    font-size: 12px;
    line-height: 1.55;
    color: #8a8480;
}

/* Traitement des liens strictement identique sur tout le bas du widget,
   y compris "Propulsé par" — même couleur, même comportement au survol. */
.tom-chat-ai-notice a,
.tom-chat-ai-notice .tom-disclosure-link {
    color: #c9a96e;
    text-decoration: none;
}

.tom-chat-ai-notice a:hover,
.tom-chat-ai-notice .tom-disclosure-link:hover {
    text-decoration: underline;
}

/* ─────────────────────────────────────────────
   Tom+ — Signalement d'une information inexacte
   Traitement volontairement discret : le signalement
   ne doit jamais concurrencer visuellement la réponse.
   ───────────────────────────────────────────── */

.tom-message-report {
    margin-top: 6px;
    text-align: left;
}

/* Les trois contrôles sont des <button> : les thèmes (Astra notamment) leur
   appliquent un fond et une ombre au survol et au focus. On neutralise donc
   tous les états, pas seulement l'état par défaut. */
.tom-chat-widget .tom-report-trigger,
.tom-chat-widget .tom-report-send,
.tom-chat-widget .tom-report-cancel,
.tom-chat-widget .tom-report-trigger:hover,
.tom-chat-widget .tom-report-send:hover,
.tom-chat-widget .tom-report-cancel:hover,
.tom-chat-widget .tom-report-trigger:focus,
.tom-chat-widget .tom-report-send:focus,
.tom-chat-widget .tom-report-cancel:focus,
.tom-chat-widget .tom-report-trigger:active,
.tom-chat-widget .tom-report-send:active,
.tom-chat-widget .tom-report-cancel:active {
    font-family: inherit;
    font-size: 0.72em;
    -webkit-appearance: none;
    appearance: none;
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none;
    padding: 0 !important;
    margin: 0;
    cursor: pointer;
    text-decoration: none;
}

/* La sélection de texte (double-clic) sur un <button> laisse apparaître le
   fond de sélection du navigateur, très visible sur un texte gris clair.
   Ces contrôles se comportent comme des liens : on désactive la sélection. */
.tom-chat-widget .tom-report-trigger,
.tom-chat-widget .tom-report-send,
.tom-chat-widget .tom-report-cancel {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.tom-chat-widget .tom-report-trigger::selection,
.tom-chat-widget .tom-report-send::selection,
.tom-chat-widget .tom-report-cancel::selection {
    background: transparent;
}

.tom-chat-widget .tom-report-trigger,
.tom-chat-widget .tom-report-cancel {
    color: #8a8480 !important;
}

.tom-chat-widget .tom-report-trigger:hover,
.tom-chat-widget .tom-report-cancel:hover,
.tom-chat-widget .tom-report-trigger:focus-visible,
.tom-chat-widget .tom-report-cancel:focus-visible {
    color: #6a6560 !important;
    text-decoration: underline;
}

.tom-report-form {
    margin-top: 6px;
}

/* Rappel de la réponse contestée. L'encadré teinté porte la citation intégrale
   puis le champ de saisie, pour que le visiteur garde sous les yeux ce qu'il
   conteste pendant qu'il rédige. */
.tom-report-quote {
    background: #f4ede0;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
}

.tom-report-quote-label {
    font-size: 0.72em;
    font-weight: 600;
    color: #a8874a;
    margin-bottom: 4px;
}

.tom-report-quote-text {
    font-size: 0.78em;
    line-height: 1.5;
    color: #6a6560;
    /* Conserve les retours à la ligne de la réponse d'origine */
    white-space: pre-wrap;
}

/* Enveloppe du champ : reprend trait pour trait le champ de saisie principal
   (.tom-chat-input-wrapper), bordure et réaction au focus comprises. */
.tom-report-comment-wrapper {
    display: flex;
    align-items: flex-end;
    background: #ffffff;
    border: 1px solid #e5e2dd;
    border-radius: 24px;
    padding: 14px 20px;
    margin-top: 10px;
    transition: border-color 0.15s;
}

.tom-report-comment-wrapper:focus-within {
    border-color: #c9a96e;
}

.tom-report-comment {
    flex: 1;
    width: 100%;
    box-sizing: border-box;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 0.93em;
    line-height: 1.5;
    color: #1a1a1a;
    outline: none;
    padding: 0;
    min-height: 48px;
    max-height: 120px;
}

.tom-report-comment::placeholder {
    color: #b5b0aa;
}

.tom-report-comment:focus {
    outline: none;
}

.tom-report-actions {
    display: flex;
    gap: 12px;
    margin-top: 6px;
}

.tom-chat-widget .tom-report-send {
    color: #c9a96e !important;
    font-weight: 600;
}

.tom-chat-widget .tom-report-send:hover,
.tom-chat-widget .tom-report-send:focus-visible {
    color: #b8965a !important;
    text-decoration: underline;
}

.tom-chat-widget .tom-report-send:disabled,
.tom-chat-widget .tom-report-cancel:disabled {
    opacity: 0.5;
    cursor: default;
    text-decoration: none;
}

/* Confirmation d'envoi : le remerciement est mis en évidence, le récapitulatif
   de ce qui a été transmis vient ensuite dans l'encadré teinté. */
.tom-report-done {
    margin-top: 8px;
}

.tom-report-thanks {
    font-size: 1.15em;
    font-weight: 600;
    line-height: 1.4;
    color: #3a3733;
    margin: 0 0 10px;
}

/* Séparation entre la réponse signalée et le commentaire dans le récapitulatif */
.tom-report-comment-label {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e6dcc8;
}

.tom-report-error {
    font-size: 0.72em;
    color: #8a8480;
    margin: 6px 0 0;
}
