/* ==========================================================================
   style.css — version optimisée (anti-régression)
   Objectif : garder tes styles tels quels + clarifier/structurer sans chambouler.
   - Ajout de variables (facile à ajuster)
   - Harmonisation légère des formulaires/boutons
   - Inbox : category-form, subject-input, historique (summary/chevron), lisibilité
   ========================================================================== */

:root{
    --bg: #f8f6fc;
    --text: #333;
    --primary: #7f5af0;
    --primary-dark: #6845d9;
    --title: #5a4db2;

    --border: #ddd;
    --border-soft: #e7e7ef;

    --card-bg: #fff;
    --shadow: 0 2px 5px rgba(0,0,0,0.05);

    --success: #4caf50;
    --success-dark: #3e8e41;
    --danger: #e53935;
    --danger-dark: #c62828;

    --soft-primary-bg: #faf9ff;
    --soft-primary-bg-2: #f3f1fd;
    --soft-primary-bg-3: #f7f4ff;
    --soft-success-bg: #f4fff7;

    --radius: 8px;
    --radius-lg: 12px;

    --font: "Segoe UI", sans-serif;
}

*{ box-sizing: border-box; }

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
}

/* === NAVIGATION === */
.nav-menu {
    background-color: var(--primary);
    padding: 12px 20px;
    display: flex;
    gap: 20px;
    justify-content: center;
}

.nav-menu a {
    color: white;
    font-weight: bold;
    text-decoration: none;
}

.nav-menu a:hover,
.nav-menu a.active {
    text-decoration: underline;
}

/* === CONTAINERS === */
.container {
    max-width: 1000px;
    margin: auto;
    padding: 20px;
}

h1, h2 {
    color: var(--title);
    margin-bottom: 20px;
}

/* === FORMULAIRES === */
.test-form,
.faq-form,
.filter-form {
    background-color: var(--card-bg);
    padding: 15px;
    border: 1px solid var(--border);
    margin-bottom: 30px;
    border-radius: var(--radius);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-form select,
.filter-form input[type="text"],
.filter-form input[type="date"],
.test-form textarea,
.manual-form textarea,
.faq-form input,
.faq-form select {
    padding: 8px;
    border: 1px solid #aaa;
    border-radius: 6px;
    font-family: inherit;
    font-size: 15px;
    background-color: #fff;
}

.filter-form input[type="text"],
.filter-form input[type="date"] {
    width: 160px;
}

/* === BOUTONS === */
.test-form button,
.faq-form button,
.manual-form button,
.filter-form button,
.btn {
    background-color: var(--primary);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    text-decoration: none;
    transition: background-color 0.25s ease, transform 0.05s ease;
}

.btn:hover,
.test-form button:hover,
.faq-form button:hover,
.manual-form button:hover,
.filter-form button:hover {
    background-color: var(--primary-dark);
}

.test-form button:active,
.faq-form button:active,
.manual-form button:active,
.filter-form button:active,
.btn:active {
    transform: translateY(1px);
}

.btn.red { background-color: var(--danger); }
.btn.red:hover { background-color: var(--danger-dark); }
.btn-success { background-color: var(--success); }
.btn-success:hover { background-color: var(--success-dark); }
.btn-danger { background-color: var(--danger); }
.btn-danger:hover { background-color: var(--danger-dark); }

.actions,
.bulk-actions {
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.flash {
    background-color: #e8eaf6;
    color: #303f9f;
    padding: 10px;
    border-radius: 6px;
    margin: 20px auto;
    width: fit-content;
}

/* === MESSAGE === */
.message-card {
    background-color: var(--card-bg);
    border: 1px solid #ccc;
    padding: 15px;
    margin-bottom: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 15px;
}

.message-card p {
    margin: 6px 0;
    line-height: 1.4em;
}

.message-card strong {
    color: #2f2b55;
}

/* Neutralisation du rouge et style plus doux */
.message-card.human-required {
    border-left: 6px solid var(--primary);
    background-color: var(--soft-primary-bg-3);
    font-size: 16px;
    font-weight: 600;
    color: inherit;
    box-shadow: 0 2px 8px rgba(127, 90, 240, 0.10);
}

.message-card.replied {
    background-color: var(--soft-success-bg);
    border-left: 6px solid var(--success);
}

/* État pending sans rouge agressif */
.message-card.pending {
    background-color: var(--card-bg);
    border-left: 6px solid #d9d9f2;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

/* === FORMULAIRE RÉPONSE MANUELLE === */
.manual-form {
    margin-top: 12px;
    padding: 12px;
    background-color: var(--soft-primary-bg-2);
    border-left: 4px solid var(--primary);
    border-radius: 6px;
}

.manual-form textarea {
    background-color: #fff;
    border: 1px solid #bbb;
    font-size: 14px;
    width: 100%;
    resize: vertical;
    margin-top: 6px;
}

.manual-form button {
    margin-top: 8px;
    background-color: var(--success);
    white-space: nowrap;
}

/* Hint : plus lisible sans agressivité */
.manual-form .hint {
    font-size: 13px;
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background-color: #fff;
    border: 1px dashed var(--primary);
    color: #4a3f9a;
    font-weight: 600;
}

/* === BLOC RÉPONSE AUTOMATIQUE === */
.reponse-block {
    background-color: var(--soft-primary-bg-2);
    border-left: 4px solid var(--primary);
    padding: 10px;
    margin-top: 12px;
    border-radius: 6px;
}

/* === HISTORIQUE (neutre + lisible) === */
.history-block { 
    border: 1px solid var(--border-soft); 
    background: var(--soft-primary-bg); 
    padding: 10px; 
    border-radius: 10px; 
    margin-top: 10px;
}

.history-block summary {
    cursor: pointer;
    user-select: none;
    padding: 6px 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    list-style: none;
}

.history-block summary::-webkit-details-marker { display: none; }

/* Chevron léger sans dépendance */
.history-block summary:before {
    content: "▸";
    font-weight: 700;
    color: var(--primary);
    margin-right: 4px;
}
.history-block[open] summary:before { content: "▾"; }

.history-block summary small { color: #666; }

.response-item { 
    border-left: 4px solid #d9d9f2;
    background: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    margin: 8px 0;
}

.response-item p { margin: 4px 0; }
.response-item small { color: #666; }

/* Supprime toute coloration spécifique manual/auto */
.response-item.manual,
.response-item.auto {
    border-left-color: #d9d9f2 !important;
    background: #fff !important;
    color: inherit !important;
}

/* === HINT TEXTE (fallback global) === */
.hint {
    font-size: 13px;
    color: #777;
    margin-top: 8px;
}

/* === PAGINATION === */
.pagination {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    font-weight: bold;
    flex-wrap: wrap;
}

.pagination a {
    background-color: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
}

.pagination a:hover {
    background-color: var(--primary-dark);
}

.pagination a:focus {
    outline: 3px solid rgba(127, 90, 240, 0.35);
    outline-offset: 2px;
}

/* === BADGES RÉPONSE === */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    line-height: 1;
    vertical-align: middle;
}

.badge-auto { background-color: var(--primary); }
.badge-manual { background-color: var(--success); }
.badge-faq { background-color: #3f51b5; }
.badge-gpt { background-color: #ff9800; }

/* === MESSAGE PAR SOURCE === */
.message-card[data-source="whatsapp"] { border-left: 6px solid #25D366; }
.message-card[data-source="email"] { border-left: 6px solid #4285F4; }
.message-card[data-source="test"] { border-left: 6px solid #aaa; }
.message-card[data-source="messenger"] { border-left: 6px solid #0084FF; }

/* === NAVBAR RESPONSIVE === */
.navbar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    background-color: #d9b3ff;
    padding: 12px 20px;
    margin-bottom: 20px;
    border-radius: var(--radius-lg);
}

.navbar a {
    text-decoration: none;
    padding: 10px 16px;
    background-color: white;
    border-radius: 8px;
    color: #4b0082;
    font-weight: bold;
    transition: background-color 0.25s, color 0.25s;
}

.navbar a:hover {
    background-color: #f3e6ff;
}

.navbar a.active {
    background-color: #4b0082;
    color: white;
}

/* =======================================================================
   PATCH INBOX (ANTI-RÉGRESSION) — compléments manquants
   ======================================================================= */

.filters { margin-bottom: 18px; }

.filter-form label {
    font-weight: 600;
    color: #4a3f9a;
}

.filter-form button { white-space: nowrap; }

/* Subject input Email (inbox) */
.subject-input {
    width: 100%;
    max-width: 420px;
    padding: 8px;
    border: 1px solid #aaa;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    background-color: #fff;
}

/* Bloc catégorie (set_category) */
.category-form {
    margin-top: 12px;
    padding: 12px;
    background-color: var(--soft-primary-bg);
    border: 1px solid var(--border-soft);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
}

.category-form form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.category-form label {
    font-weight: 600;
    color: #4a3f9a;
}

.category-form select {
    padding: 8px;
    border: 1px solid #aaa;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    background-color: #fff;
}

/* === RESPONSIVE GENERAL === */
@media (max-width: 600px) {
    .container { padding: 10px; }

    .navbar,
    .nav-menu {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .navbar a {
        width: 90%;
        text-align: center;
    }

    .filter-form {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-form select,
    .filter-form input {
        width: 100%;
    }

    .pagination {
        gap: 8px;
    }

    .pagination a,
    .pagination strong {
        padding: 8px 12px;
        font-size: 14px;
    }

    .category-form form {
        flex-direction: column;
        align-items: stretch;
    }

    .category-form select,
    .subject-input {
        max-width: 100%;
        width: 100%;
    }

    .history-block summary {
        align-items: flex-start;
    }

    .history-block summary small {
        display: block;
        width: 100%;
        margin-left: 18px; /* alignement après chevron */
    }
}

/* --- Historique : séparateurs propres entre items --- */
.history-block .response-item {
    margin: 0;
    border-radius: 0;
    padding: 10px 12px;
    border-left: 4px solid #d9d9f2;
}

.history-block .response-item + .response-item {
    border-top: 1px dashed #d9d9f2;  /* ligne en tirets */
}

/* Optionnel : arrondis uniquement aux extrémités pour un rendu "bloc" */
.history-block .response-item:first-of-type {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.history-block .response-item:last-of-type {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.history-sep{
    border: 0;
    border-top: 2px dashed #d9d9f2;
    margin: 12px 0;
}

/* === PATCH HISTORIQUE : séparateurs + thread email === */
.history-sep{
    border-top: 1px dashed #d9d9f2;
    margin: 10px 0;
}

.badge-thread{
    background-color: #607d8b; /* neutre */
}

.response-thread .response-body-thread{
    white-space: pre-wrap;      /* garde les retours à la ligne */
    word-break: break-word;
    color: #444;
}

/* === CONVERSATION (inputs gauche / outputs droite) === */
.conversation {
  margin-top: 10px;
}

.bubble-row {
  display: flex;
  margin: 10px 0;
}

.row-in { justify-content: flex-start; }
.row-out { justify-content: flex-end; }

.bubble {
  width: 100%;
  max-width: 720px;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e7e7ef;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.bubble-in {
  border-left: 5px solid #d9d9f2;
  background: #ffffff;
}

.bubble-out {
  border-left: 5px solid #7f5af0;
  background: #f7f4ff;
}

.bubble-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.bubble-meta {
  color: #666;
  font-size: 12px;
}

.bubble-body {
  white-space: pre-wrap;
  line-height: 1.4em;
}

/* séparateur “ligne Maginot” */
.history-sep {
  border: 0;
  border-top: 2px dashed #d9d9f2;
  margin: 10px 0;
}

/* badge input */
.badge-in { background-color: #3f51b5; }

/* thread badge */
.badge-thread { background-color: #607d8b; }

/* =======================================================================
   PATCH CONVERSATION (INBOX) — à coller EN FIN de style.css
   Objectif :
   - affichage chat : inputs à gauche, outputs à droite
   - historique repliable, séparateurs propres
   - sans casser le design existant
   ======================================================================= */

/* Bloc conversation */
.conversation {
    margin-top: 12px;
    background: #faf9ff;
    border: 1px solid #e7e7ef;
    border-radius: 12px;
    padding: 10px;
}

/* Ligne (row) */
.bubble-row {
    display: flex;
    width: 100%;
    margin: 8px 0;
}

/* Inputs à gauche */
.row-in { justify-content: flex-start; }

/* Outputs à droite */
.row-out { justify-content: flex-end; }

/* Bulles */
.bubble {
    max-width: 78%;
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid #e7e7ef;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

/* Bulle input (client) */
.bubble-in {
    border-left: 4px solid #d9d9f2;
}

/* Bulle output (bot / humain) */
.bubble-out {
    border-left: 4px solid #7f5af0;
    background: #ffffff;
}

/* Header de bulle */
.bubble-head {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

/* Meta (date/canal) */
.bubble-meta {
    color: #666;
    font-size: 12.5px;
}

/* Body */
.bubble-body {
    white-space: pre-wrap; /* conserve retours à la ligne */
    word-break: break-word;
    line-height: 1.45em;
}

/* Badge pour messages reçus */
.badge-in {
    background-color: #6c6c93;
}

/* Badge Thread */
.badge-thread {
    background-color: #607d8b;
    color: #fff;
    display: inline-block;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
}

/* Historique repliable */
.history-toggle {
    margin-top: 10px;
    border-radius: 12px;
    border: 1px solid #e7e7ef;
    background: #f7f4ff;
    padding: 8px 10px;
}

.history-toggle summary {
    cursor: pointer;
    user-select: none;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    font-weight: 700;
    color: #2f2b55;
}

.history-toggle summary::-webkit-details-marker {
    display: none;
}

.history-toggle summary:before {
    content: "▸";
    font-weight: 900;
    color: #7f5af0;
    margin-right: 4px;
}

.history-toggle[open] summary:before {
    content: "▾";
}

/* Séparateur “ligne Maginot” */
.history-sep {
    border: none;
    border-top: 1px dashed #d9d9f2;
    margin: 10px 0;
}

/* Responsive : bulles plus larges */
@media (max-width: 600px) {
    .bubble { max-width: 96%; }
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  width: min(980px, 92vw);
  margin: 32px auto;
}

.card {
  border-radius: 18px;
  padding: 22px;
}

.hero { margin-bottom: 16px; }

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 12px;
}

.title { font-size: 28px; margin: 0 0 8px 0; }
.subtitle { opacity: 0.85; margin: 0 0 18px 0; line-height: 1.45; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

.btn {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 600;
}

.meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

@media (min-width: 720px) {
  .meta { grid-template-columns: 1fr 1fr; }
}

.meta-item {
  padding: 12px;
  border-radius: 14px;
}

.meta-k { font-size: 12px; opacity: 0.75; margin-bottom: 6px; }
.meta-v { font-size: 14px; opacity: 0.95; }

.h2 { margin: 0 0 10px 0; font-size: 18px; }
.list { margin: 0; padding-left: 18px; opacity: 0.9; }
.footer { opacity: 0.55; font-size: 12px; margin-top: 12px; text-align: center; }

/* ===== Thread chat (Inbox) ===== */
.chat-thread {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0;
}

.chat-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  color: rgba(0,0,0,.45);
  font-size: 12px;
}
.chat-sep::before,
.chat-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(0,0,0,.08);
}

.chat-row {
  display: flex;
  margin: 10px 0;
}
.chat-row.left { justify-content: flex-start; }
.chat-row.right { justify-content: flex-end; }

.chat-bubble {
  max-width: 72%;
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 6px 14px rgba(0,0,0,.05);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-row.left .chat-bubble {
  background: #f3f4f6;
}

.chat-row.right .chat-bubble {
  background: #efeaff; /* mauve clair */
  border-color: rgba(90,60,255,.18);
}

.chat-meta {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(0,0,0,.55);
  display: flex;
  gap: 8px;
}
.chat-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.6);
  font-size: 11px;
}


