/* 2. INTERFACE UTILISATEUR (UI)
   Panneaux, Boutons, Modales, File d'attente, Responsive UI
*/

/* ==========================================================================
   MODALE DE CONNEXION & NOTIFICATION TOAST
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 400px;
}

.modal-content h2 {
  margin-top: 0;
  color: #386641;
}

#passwordInput {
  width: 100%;
  padding: 10px;
  margin: 15px 0;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-sizing: border-box;
}

#loginButton {
  background-color: #6a994e;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#loginButton:hover {
  background-color: #386641;
}

/* --- Notification Toast --- */
.toast-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateY(100px);
  background-color: #386641;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  z-index: 2001;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  will-change: transform, opacity;
}

.toast-notification.error {
  background-color: #c5221f;
}

.toast-notification.show {
  transform: translate(-50%, -50%) translateY(0);
  opacity: 1;
}

/* ==========================================================================
   NOUVEAU HEADER (BARRE SUPÉRIEURE)
   ========================================================================== */
.app-header {
    height: 50px;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
    z-index: 100;
    min-width: 800px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 800;
    color: #386641;
    font-size: 1.1rem;
}

.app-version {
    font-size: 0.65rem;
    background: #eee;
    padding: 2px 6px;
    border-radius: 4px;
    color: #666;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.header-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    position: relative;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-btn:hover {
    background-color: #f0f2f5;
    color: #386641;
}

.header-btn svg {
    display: block;
}

/* Bouton Admin Spécifique */
.header-btn.admin {
    background-color: #333;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    gap: 6px;
    padding: 6px 12px;
    margin-right: 10px;
}

.header-btn.admin:hover {
    background-color: #000;
    transform: translateY(-1px);
}

.header-btn.logout {
    color: #c5221f;
}

.header-btn.logout:hover {
    background-color: #fee2e2;
}

.header-sep {
    width: 1px;
    height: 20px;
    background-color: #ddd;
    margin: 0 5px;
}

.badge-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: #c5221f;
    border: 2px solid white;
    border-radius: 50%;
}

/* ==========================================================================
   STRUCTURE PRINCIPALE (LAYOUT)
   ========================================================================== */
body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 0;
    gap: 0;
    min-height: 0;
    background-color: #f0f2f5;
    overflow-x: auto;
}

.main-content {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    gap: 10px;
    padding: 10px;
    overflow: hidden;
    min-height: 0;
    min-width: 900px; 
}

/* --- Wrapper de Droite --- */
.preview-wrapper-vertical {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 300px;
    height: 100%;
}

.preview-area-refined {
    flex-grow: 1;
    background-color: #e5e7eb;
    border-radius: 5px;
    position: relative;
    /* FIX MARGES : overflow auto pour permettre l'affichage des ombres/marges */
    overflow: auto; 
    /* FIX MARGES : Padding réduit (10px au lieu de 40px) pour optimiser l'espace */
    padding: 10px; 
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #ddd;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.05);
}

/* FIX CRITIQUE : Empêcher l'affiche d'être écrasée par Flexbox */
.preview-area-refined #affiche {
    flex-shrink: 0 !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0; /* Centre l'affiche dans le padding */
    transition: transform 0.1s ease-out;
}

/* Toolbar PDF Horizontale */
.pdf-toolbar {
    flex: 0 0 auto;
    background: white;
    padding: 8px 15px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    border: 1px solid #eee;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-label {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: #555;
    font-size: 0.85rem;
    white-space: nowrap;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
}

/* --- Styles des Panneaux Latéraux --- */
.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: #333333;
  padding: 15px;
  border-radius: 5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  height: 100%;
  overflow-y: auto;
  font-family: 'Open Sans', sans-serif;
  min-height: 0;
  position: relative;
  border: 1px solid #eee;
}

.config-panel {
  flex: 0 0 190px;
  background-color: #fdfdfd;
}

.input-panel {
  flex: 0 0 420px;
  background-color: #ffffff;
  transition: flex-basis 0.3s ease;
  min-width: 420px;
}

/* PANEL PARAMETRES */
.settings-panel {
    display: none;
    flex: 0 0 360px;
    background-color: #EBF6FF;
	border-radius: 0;
    overflow-y: auto;
    animation: slideInRight 0.3s ease-out;
}
.settings-panel.active { display: flex; }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 12px;
}
.close-settings-btn {
    background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #666;
}
.close-settings-btn:hover { color: #c5221f; }

/* TITRES */
.panel-group-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: #333333;
  margin: 0 0 10px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mini-settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: #888;
    transition: color 0.2s, transform 0.2s;
    padding: 2px 5px;
    border-radius: 4px;
}
.mini-settings-btn:hover {
    color: #386641;
    background-color: #e6f4ea;
    transform: rotate(30deg);
}

/* CONTROLES SETTINGS */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 6px;
}
.setting-label { font-size: 0.85rem; font-weight: 600; }
.setting-input-color { width: 35px; height: 25px; border: none; padding: 0; background: none; cursor: pointer; }
.setting-select { padding: 4px; border-radius: 4px; border: 1px solid #ccc; font-size: 0.85rem; width: 100%; }

.visibility-list { display: flex; flex-direction: column; gap: 4px; }
.visibility-item { display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem; padding: 4px 0; border-bottom: 1px dashed #eee; }

/* Switch */
.switch { position: relative; display: inline-block; width: 30px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 12px; width: 12px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #386641; }
input:checked + .slider:before { transform: translateX(12px); }

/* ==========================================================================
   ÉLÉMENTS DE PANNEAU
   ========================================================================== */
.panel-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: #386641;
  margin: 0 0 10px 0;
  text-align: center;
}

.panel-group {
  padding-bottom: 12px;
  margin-bottom: 5px;
}

.panel-group:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  margin-bottom: 8px;
}

.control-group:last-child { margin-bottom: 0; }

.panel label {
  font-family: 'Open Sans', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: #333333;
}

.label-wrapper { display: flex; justify-content: space-between; align-items: center; margin-bottom: -3px; }

/* Champs */
#plantSearch, #plantSelect, .poster-type-controls input, .poster-type-controls select, .poster-type-controls textarea, .panel input, .panel select, .panel textarea {
  font-family: 'Roboto', sans-serif; font-weight: 400; font-size: 0.95rem; padding: 8px; border-radius: 6px; border: 1px solid #ccc; width: 100%; transition: border-color 0.2s, box-shadow 0.2s, padding-left 0.2s; -moz-appearance: none; appearance: none;
}

.panel select, .poster-type-controls select {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat; background-position: right 0.7em top 50%; background-size: 0.65em auto; padding-right: 1.5em;
}

.input-panel input[type="text"], .input-panel textarea { text-transform: uppercase; }
.input-panel #plantSearch { text-transform: none; }
.input-panel #promoDisclaimer { text-transform: none; }

#plantSearch:focus, #plantSelect:focus, .poster-type-controls input:focus, .poster-type-controls select:focus, .poster-type-controls textarea:focus, .panel input:focus, .panel select:focus, .panel textarea:focus {
  outline: none; border-color: #386641; box-shadow: 0 0 0 2px rgba(56, 102, 65, 0.2);
}

.input-error { border-color: #e53e3e !important; box-shadow: 0 0 0 2px rgba(229, 62, 62, 0.4) !important; padding-left: 28px !important; }
.control-group .input-error::before { content: '!'; position: absolute; left: 10px; top: 50%; transform: translateY(2px); font-size: 1.3rem; font-weight: bold; color: #e53e3e; z-index: 2; line-height: 1; }
.control-group textarea.input-error::before { top: 18px; transform: translateY(0); }
.control-group select.input-error::before { top: 50%; transform: translateY(2px); }

.calculated-price-display { display: inline-block; padding: 8px; background: #eee; border: 1px solid #ccc; border-radius: 6px; font-weight: bold; min-width: 60px; text-align: right; font-size: 0.95rem; color: #333333; }
.poster-type-controls { display: flex; flex-direction: column; gap: 10px; }
#promoTypeInputs { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

/* ==========================================================================
   BOUTONS DE CONFIGURATION (TOGGLES)
   ========================================================================== */
.toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
}

.toggle-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  background-color: #f0f0f0;
  color: #555;
  user-select: none;
  text-align: center;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  height: auto;
  aspect-ratio: 1 / 1;
  padding: 5px;
  min-width: 0;
  overflow: hidden;
}

.toggle-btn:hover { border-color: #888; }
.toggle-btn.selected { border-color: #386641; background-color: #386641; color: #ffffff; font-weight: 700; box-shadow: 0 0 8px 2px rgba(56, 102, 65, 0.4); }

.icon-toggle-btn { flex-direction: column; gap: 4px; }
.icon-toggle-btn .icon-char { font-size: 1.4rem; line-height: 1.1; font-family: 'Montserrat', sans-serif; font-weight: 700; }
.icon-char .icone { height: 35px; width: auto; object-fit: contain; }
.icon-toggle-btn .icon-label { font-size: 0.5rem; line-height: 1; font-weight: 600; text-transform: uppercase; font-family: 'Poppins', sans-serif; word-break: break-word; }
.icon-toggle-btn[data-type="conseil"] .icon-char { font-style: italic; font-family: serif; font-weight: bold; font-size: 1.6rem; }
.icon-orient-port { width: 12px; height: 18px; border: 2px solid currentColor; border-radius: 2px; }
.icon-orient-land { width: 18px; height: 12px; border: 2px solid currentColor; border-radius: 2px; }

.toggle-btn.enseigne-btn { padding: 4px; }
.enseigne-btn img { width: 100%; height: 100%; object-fit: contain; border-radius: 4px; display: block; }
.toggle-btn.enseigne-btn.selected { background-color: #fff; }

.horaires-toggle-group { grid-template-columns: 1fr 1fr 1fr; margin-bottom: 15px; }
.horaires-toggle-group .toggle-btn { aspect-ratio: auto; height: 35px; font-size: 0.75rem; }

/* ==========================================================================
   INPUTS QUANTITÉ & ACTIONS
   ========================================================================== */
.quantity-input { display: flex; align-items: center; width: 100%; }
.quantity-input.compact { width: auto; }
.quantity-input input[type="number"] { width: 100%; text-align: center; font-weight: 700; font-size: 1rem; border-radius: 0; border-left: none; border-right: none; padding: 8px 5px; -moz-appearance: textfield; }
.quantity-input.compact input[type="number"] { width: 45px; padding: 4px; font-size: 0.95rem; height: 32px; }
.quantity-input input[type="number"]::-webkit-outer-spin-button, .quantity-input input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.quantity-btn { flex: 0 0 40px; height: 40px; border: 1px solid #ccc; background-color: #f0f0f0; font-size: 1.3rem; font-weight: 600; color: #555; cursor: pointer; transition: background-color 0.2s; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); }
.quantity-input.compact .quantity-btn { flex: 0 0 32px; height: 32px; font-size: 1.1rem; padding: 0; }
.quantity-btn:hover { background-color: #e0e0e0; }
#quantityDecrease { border-radius: 8px 0 0 8px; } #quantityIncrease { border-radius: 0 8px 8px 0; }

.action-btn { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1rem; padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; transition: all 0.2s; width: 100%; margin-top: 10px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); }
.action-btn.compact { margin-top: 0; padding: 6px 15px; font-size: 0.85rem; width: auto; height: 32px; }
.action-btn:active { transform: scale(0.98); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
.add-btn { background-color: #D75000; color: white; } .add-btn:hover { background-color: #b34200; }
.queue-btn { background-color: #386641; color: white; } .queue-btn:hover { background-color: #6a994e; }

/* Queue Modal */
.queue-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); display: none; justify-content: center; align-items: center; z-index: 2000; }
.queue-modal-content { background: white; border-radius: 12px; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25); width: 90%; max-width: 900px; display: flex; flex-direction: column; max-height: 80vh; }
.queue-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid #eee; }
.queue-modal-header .panel-group-title { border-bottom: none; margin: 0; padding: 0; }
.queue-modal-body { overflow-y: auto; padding: 10px; background: #fdfdfd; flex-grow: 1; min-height: 0; }
.queue-modal-footer { padding: 15px 20px; border-top: 1px solid #eee; background: #f9f9f9; border-radius: 0 0 12px 12px; }
.queue-empty-msg { text-align: center; color: #888; padding: 20px; font-size: 0.9rem; }
.queue-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid #eee; }
.queue-item:last-child { border-bottom: none; }
.queue-item-details { display: flex; flex-direction: column; flex-grow: 1; gap: 2px; }
.queue-item-format { font-size: 0.75rem; font-weight: 600; color: #555; text-transform: uppercase; }
.queue-item-name { font-size: 0.95rem; font-weight: 600; }
.queue-item-controls { display: flex; align-items: center; gap: 8px; }
.modal-queue-btn { font-family: 'Poppins', sans-serif; border: none; border-radius: 5px; cursor: pointer; transition: all 0.2s; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); }
.modal-queue-btn.quantity-btn { background-color: #f0f0f0; color: #333; font-weight: bold; width: 28px; height: 28px; font-size: 1.2rem; padding-bottom: 2px; }
.modal-queue-btn.quantity-btn:hover { background-color: #ddd; }
.queue-item-quantity { font-size: 1rem; font-weight: 700; min-width: 20px; text-align: center; }
.modal-queue-btn.delete { background-color: #fce8e6; color: #c5221f; font-weight: bold; width: 30px; height: 30px; margin-left: 10px; }
.modal-queue-btn.delete:hover { background-color: #e53e3e; color: white; }
.queue-actions { display: flex; gap: 10px; }
.modal-queue-btn.generate, .modal-queue-btn.clear { flex: 1; font-size: 0.9rem; font-weight: 700; padding: 10px; }
.modal-queue-btn.generate { background-color: #386641; color: white; } .modal-queue-btn.generate:hover { background-color: #6a994e; }
.modal-queue-btn.clear { background-color: #eee; color: #555; } .modal-queue-btn.clear:hover { background-color: #ddd; }

/* ==========================================================================
   CONTROLES SPÉCIFIQUES & MESSAGERIE
   ========================================================================== */
#plantSelect { display: block; } #plantSelectList { display: none; }
.input-panel.conseil-list-active #plantControls { flex-grow: 1; display: flex; flex-direction: column; min-height: 12em; overflow: hidden;}
.input-panel.conseil-list-active #plantControls .control-group:last-child { flex-grow: 1; display: flex; flex-direction: column; }
.input-panel.conseil-list-active #plantSelect { display: none; }
.input-panel.conseil-list-active #plantSelectList { display: block; flex-grow: 1; padding: 5px; margin-top: 5px; overflow: hidden; background-color:white;}
.plant-select-item { padding: 8px 10px; cursor: pointer; border-radius: 4px; font-size: 0.95rem; }
.plant-select-item:hover { background-color: #f0f0f0; }
.plant-select-item.selected { background-color: #386641; color: white; font-weight: 600; }
.plant-select-item strong { font-weight: 700; color: inherit; }
.plant-select-item em { font-style: italic; font-size: 1em; color: #386641; }
.plant-select-item.selected em { color: white; opacity: 0.8; }

.font-size-toggle { display: flex; align-items: center; gap: 4px; }
.diameter-btn { width: 22px; height: 22px; border: 1px solid #ccc; border-radius: 4px; background: #f9f9f9; cursor: pointer; display: flex; align-items: center; justify-content: center; font-weight: bold; user-select: none; margin-right: 5px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
.font-size-btn { width: 22px; height: 22px; border: 1px solid #ccc; border-radius: 4px; background: #f9f9f9; cursor: pointer; display: flex; align-items: center; justify-content: center; font-weight: bold; padding-bottom: 2px; user-select: none; transition: all 0.2s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
.font-size-btn:hover { background: #eee; }
.font-size-btn.small { font-size: 9px; } .font-size-btn.medium { font-size: 12px; } .font-size-btn.large { font-size: 15px; }
.font-size-btn.selected { background-color: #386641; color: white; border-color: #386641; }

.messaging-window { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: #f5f5f5; z-index: 5000; display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1); }
.messaging-window.active { transform: translateY(0); }
.messaging-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 30px; background: #fff; border-bottom: 1px solid #eee; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.messaging-title { font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 1.4rem; color: #333; margin: 0; }
.close-messaging-btn { background: none; border: none; font-size: 2rem; cursor: pointer; color: #666; transition: color 0.2s; }
.close-messaging-btn:hover { color: #c5221f; }
.messaging-body-split { display: flex; height: 100%; overflow: hidden; background-color: #fff; width: 100%; max-width: 1200px; margin: 20px auto; border-radius: 12px; box-shadow: 0 5px 25px rgba(0,0,0,0.1); border: 1px solid #eee; }
.msg-sidebar { width: 300px; border-right: 1px solid #eee; background-color: #fbfbfb; display: flex; flex-direction: column; flex-shrink: 0; }
.msg-sidebar-header { padding: 20px; font-size: 0.85rem; color: #666; text-transform: uppercase; font-weight: 700; letter-spacing: 1px; background-color: #f5f5f5; border-bottom: 1px solid #eee; }
.msg-subjects-list { flex-grow: 1; overflow-y: auto; }
.msg-subject-item { padding: 15px 20px; cursor: pointer; font-size: 1rem; color: #444; border-left: 4px solid transparent; transition: all 0.2s; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #f0f0f0; }
.msg-subject-item:hover { background-color: #fff; }
.msg-subject-item.active { background-color: #fff; border-left-color: #386641; color: #386641; font-weight: 700; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.msg-unread-badge { width: 10px; height: 10px; background-color: #c5221f; border-radius: 50%; display: inline-block; }
.msg-chat-area { flex-grow: 1; display: flex; flex-direction: column; background-color: white; position: relative; }
.chat-header-subject { padding: 15px 30px; border-bottom: 1px solid #eee; font-weight: 700; font-size: 1.1rem; color: #333; font-family: 'Poppins', sans-serif; background-color: #fff; }
.chat-history { flex-grow: 1; overflow-y: auto; padding: 30px; display: flex; flex-direction: column; gap: 20px; background-color: #fff; align-items: center; }
.user-msg-bubble { width: 100%; max-width: 700px; padding: 20px; border-radius: 12px; font-family: 'Open Sans', sans-serif; font-size: 1rem; line-height: 1.5; box-shadow: 0 1px 2px rgba(0,0,0,0.1); position: relative; }
.user-msg-bubble.me { margin-left: auto; margin-right: 0; background-color: #dcfce7; border: 1px solid #bbf7d0; }
.user-msg-bubble.admin { margin-right: auto; margin-left: 0; background-color: #E3F2FD; border: 1px solid #BBDEFB; color: #0D47A1; }
.bubble-meta { font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; opacity: 0.9; display: block; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 5px; }
.user-msg-bubble.admin .bubble-meta { color: #1565C0; }
.bubble-content { color: #333; }
.chat-input-wrapper { padding: 20px 30px; border-top: 1px solid #eee; display: flex; align-items: flex-end; gap: 15px; background: #fcfcfc; justify-content: center; }
.chat-input-wrapper textarea { flex-grow: 1; max-width: 800px; border: 1px solid #ccc; border-radius: 24px; padding: 12px 20px; font-family: inherit; resize: none; min-height: 45px; max-height: 120px; line-height: 1.4; outline: none; font-size: 1rem; box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); }
.chat-input-wrapper textarea:focus { border-color: #386641; box-shadow: 0 0 0 2px rgba(56, 102, 65, 0.1); }
.chat-send-btn { width: 45px; height: 45px; border-radius: 50%; background-color: #386641; color: white; border: none; cursor: pointer; display: flex; justify-content: center; align-items: center; transition: transform 0.2s, background-color 0.2s; flex-shrink: 0; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.chat-send-btn:hover { background-color: #2e5235; transform: scale(1.05); }

/* ==========================================================================
   BARRE D'OUTILS RICHE (INPUT TOOLBAR)
   ========================================================================== */
.control-group {
    position: relative; /* Nécessaire pour le positionnement des popups */
}

.input-toolbar {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
    padding: 4px;
    background: #f8f9fa;
    width: fit-content;
}

.toolbar-btn {
    width: 28px;
    height: 28px;
    padding: 4px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.toolbar-btn:hover, .toolbar-btn.active {
    background-color: #e2e6ea;
    color: #386641;
    border-color: #dbeafe;
}

.toolbar-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* POPUPS (Sliders, Grid, Color) */
.toolbar-popup {
    position: absolute;
    bottom: 100%; /* Au-dessus de l'input */
    right: 0;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    padding: 10px;
    border-radius: 6px;
    z-index: 50;
    display: none;
    min-width: 200px;
    margin-bottom: 8px;
}

.toolbar-popup.show {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: fadeIn 0.2s ease-out;
}

.popup-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: #666;
}

.popup-slider {
    flex-grow: 1;
    cursor: pointer;
}

.popup-value {
    font-weight: bold;
    color: #386641;
    min-width: 30px;
    text-align: right;
}

/* Grille Caractères Spéciaux */
.char-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.char-btn {
    width: 24px;
    height: 24px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.char-btn:hover {
    background: #386641;
    color: white;
    border-color: #386641;
}

/* Color Picker intégré */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}
.color-picker-input {
    border: none;
    width: 40px;
    height: 30px;
    cursor: pointer;
    background: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Flèche du popup */
.toolbar-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 15px;
    border-width: 6px;
    border-style: solid;
    border-color: white transparent transparent transparent;
}