/* --- STYLES GLOBAUX --- */
:root{--bg:#0f1724;--surface:#0b1220;--surface-2:#1a2333;--primary:#7dd3fc;--secondary:#ff6b6b;--green:#4ade80;--muted:#94a3b8;--border-color:rgba(255, 255, 255, 0.08);--radius:12px;font-family:Inter,system-ui,-apple-system,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif}
*{box-sizing:border-box}
html,body{height:100%;margin:0;background:var(--bg);color:#e6eef6;font-size:16px;overflow:hidden}
.hidden{display:none!important}
.btn{padding:.75rem 1.25rem;border:none;border-radius:8px;font-weight:600;cursor:pointer;transition:all .2s}
.btn-primary{background:var(--primary);color:var(--bg)}.btn-primary:hover{filter:brightness(1.1)}
.btn-secondary{background-color:rgba(255,255,255,.1);color:#e6eef6}.btn-secondary:hover{background-color:rgba(255,255,255,.15)}
.btn-success{background:var(--green);color:var(--bg)}.btn-success:disabled{background:var(--muted);cursor:not-allowed;opacity:.6}
.btn:disabled{background:var(--muted)!important;color:var(--surface)!important;cursor:not-allowed;opacity:.6}
@keyframes spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}
.spinner{border-top-color:var(--primary);animation:spin 1s linear infinite;display:inline-block;width:1.25rem;height:1.25rem;border-width:2px;border-style:solid;border-radius:50%}
/* --- ÉCRAN DE CONNEXION --- */
#login-container{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:1.5rem;text-align:center}
#login-container .brand{display:flex;align-items:center;gap:1rem}
#login-container .brand .logo{width:40px;height:40px;border-radius:10px;background:linear-gradient(135deg,var(--primary),var(--secondary));display:flex;align-items:center;justify-content:center;font-weight:700;color:var(--surface)}
#login-container h1{margin:0}
#login-container p{color:var(--muted);max-width:400px}
#login-btn{display:flex;align-items:center;gap:.75rem;background-color:#fff;color:#333;padding:.75rem 1.5rem;font-size:1rem;border-radius:8px;border:1px solid #ccc;cursor:pointer;transition:background-color .2s}
#login-btn:hover{background-color:#f2f2f2}
#login-btn img{width:24px;height:24px}
/* --- STRUCTURE DE L'APP --- */
.app-container{display:flex;height:100vh;flex-direction:column}
.main-layout{display:flex;flex-grow:1;overflow:hidden}
.main-content{flex-grow:1;display:flex;flex-direction:column;position:relative}
/* --- TOP BAR --- */
.top-bar{padding:.75rem 1.5rem;border-bottom:1px solid var(--border-color);display:flex;justify-content:space-between;align-items:center;flex-shrink:0;background:rgba(11,18,32,.8);backdrop-filter:blur(10px);z-index:20;position:relative}
.brand{display:flex;align-items:center;gap:1rem}
.brand .logo{width:40px;height:40px;border-radius:10px;background:linear-gradient(135deg,var(--primary),var(--secondary));display:flex;align-items:center;justify-content:center;font-weight:700;color:var(--surface)}
.top-nav{display:flex;align-items:center;gap:.5rem}
.nav-item{position:relative}
.nav-button{background:transparent;border:0;color:var(--muted);padding:.5rem .75rem;border-radius:6px;font-weight:600;cursor:pointer;font-size:.9rem}
.nav-button:hover,.nav-button.is-active{background:rgba(255,255,255,.05);color:#fff}
#lang-selector{display:flex;gap:.5rem;margin-left:1rem}
#lang-selector button{background:0 0;border:1px solid var(--border-color);color:var(--muted);padding:.4rem .8rem;border-radius:6px;cursor:pointer;transition:all .2s;font-weight:600}
#lang-selector button:hover{color:var(--primary);border-color:var(--primary)}
#lang-selector button.active{background:var(--primary);color:var(--bg);border-color:var(--primary)}
.user-menu .nav-button{display:flex;align-items:center;gap:.5rem}
.user-menu img{width:28px;height:28px;border-radius:50%;background-color:var(--muted)}
.dropdown-menu{position:absolute;right:0;top:100%;margin-top:.5rem;min-width:200px;background:var(--surface-2);border:1px solid var(--border-color);border-radius:8px;padding:.5rem;box-shadow:0 8px 20px rgba(0,0,0,.4);z-index:10;opacity:0;visibility:hidden;transform:translateY(-10px);transition:all .2s ease;pointer-events:none}
.dropdown-menu.is-active{opacity:1;visibility:visible;transform:translateY(0);pointer-events:auto}
.dropdown-link{display:flex;align-items:center;gap:.75rem;padding:.5rem .75rem;border-radius:6px;text-decoration:none;color:var(--muted);font-size:.9rem}
.dropdown-link:hover{background:rgba(255,255,255,.08);color:#fff}
.dropdown-divider{height:1px;background:var(--border-color);margin:.5rem 0}
/* --- SIDEBAR --- */
.sidebar{width:280px;background:var(--surface);border-right:1px solid var(--border-color);padding:1.5rem;display:flex;flex-direction:column;flex-shrink:0}
.sidebar-btn{display:flex;align-items:center;gap:.75rem;width:100%;padding:.75rem;border-radius:8px;border:1px solid var(--border-color);background:transparent;color:inherit;font-weight:600;cursor:pointer;text-align:left;margin-bottom:1rem}
.sidebar-btn:hover{background:rgba(255,255,255,.05)}
.sidebar-section-title{font-size:.75rem;text-transform:uppercase;color:var(--muted);font-weight:600;margin-top:1.5rem;margin-bottom:.75rem;padding:0 .5rem}
.history-list{flex-grow:1;overflow-y:auto;margin-right:-1rem;padding-right:1rem}
.history-item{display:block;padding:.5rem .75rem;border-radius:6px;text-decoration:none;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.history-item:hover{background:rgba(255,255,255,.05);color:#fff}
/* --- CHAT VIEW --- */
.chat-view{display:flex;flex-direction:column;height:100%}
.chat-log{flex-grow:1;padding:1.5rem;overflow-y:auto}
.chat-log-inner{max-width:800px;margin:0 auto;display:flex;flex-direction:column;gap:1.5rem}
.chat-form-container{padding:1.5rem;border-top:1px solid var(--border-color);background:var(--surface-2)}
.chat-form{max-width:800px;margin:0 auto;display:flex;gap:1rem}
#chat-input{flex-grow:1;background:rgba(255,255,255,.05);border:1px solid var(--border-color);border-radius:8px;padding:.75rem;color:inherit;resize:none;font-size:1rem}
#chat-input:focus{outline:0;border-color:var(--primary)}
.chat-message{display:flex;gap:1rem;max-width:85%}
.avatar{width:40px;height:40px;border-radius:50%;background:var(--secondary);color:var(--surface);display:flex;justify-content:center;align-items:center;font-weight:600;flex-shrink:0;background-size:cover;background-position:center}
.message-content{padding:.75rem 1.25rem;border-radius:var(--radius);line-height:1.6;word-break:break-word}
.ai{align-self:flex-start}
.ai .avatar{background-image:url(https://i.ibb.co/hRsvRVY/e382a124-58f5-4328-8f55-ebe64430777e-1.jpg)}
.user{align-self:flex-end;flex-direction:row-reverse}
.user .avatar{background:var(--muted);font-size:1rem}
.user .message-content{background:var(--primary);color:var(--surface);border-top-right-radius:0}
/* --- STREAMING & PROGRESS BARS --- */
.message-content .stream-chunk{opacity:0;transition:opacity .5s ease}
.message-content .stream-chunk.visible{opacity:1}
.progress-container{margin-bottom:.5rem}
.progress-label{font-size:.8rem;color:var(--muted);margin-bottom:.25rem}
.progress-bar-bg{width:100%;background:rgba(255,255,255,.05);border-radius:4px;height:8px;overflow:hidden}
.progress-bar-fg{width:0%;height:100%;background:var(--primary);border-radius:4px;transition:width .5s ease-out}
/* --- MODULES (BP & Entreprise) --- */
.module-container{height:100%;display:flex;flex-direction:column;background:var(--surface)}
.module-header{padding:.75rem 1.5rem;border-bottom:1px solid var(--border-color);display:flex;justify-content:space-between;align-items:center;flex-shrink:0}
.module-header h1{margin:0;font-size:1.1rem}
.module-current-section-header{font-size:1rem;color:var(--muted);font-weight:500}
.module-chat-log{flex-grow:1;padding:1.5rem;overflow-y:auto;display:flex;flex-direction:column;gap:1.5rem}
.module-chat-log .message-content p:last-child,.module-chat-log .message-content ul:last-child,.module-chat-log .message-content ol:last-child{margin-bottom:0}
.module-chat-log .message-content h1,.module-chat-log .message-content h2,.module-chat-log .message-content h3{font-size:1.1rem;color:var(--primary);margin-bottom:.5rem}
.proposal-block{border:1px solid var(--border-color);margin-top:1rem;border-radius:8px;overflow:hidden}
.proposal-text{padding:1rem;background:rgba(0,0,0,.2);white-space:pre-wrap;font-family:'Courier New',Courier,monospace;max-height:200px;overflow-y:auto}
.proposal-actions{padding:.75rem 1rem;background:rgba(255,255,255,.05);text-align:right}
.module-chat-form{padding:1.5rem;border-top:1px solid var(--border-color);display:flex;flex-direction:column;gap:.75rem;flex-shrink:0}
.module-chat-form-main{display:flex;gap:1rem}
.module-user-input{flex-grow:1;background:rgba(255,255,255,.05);border:1px solid var(--border-color);border-radius:8px;padding:.75rem;color:inherit;resize:none;font-size:1rem}
.module-user-input:focus{outline:0;border-color:var(--primary)}
.module-user-input:disabled{background-color:rgba(255,255,255,.02);cursor:not-allowed}
.module-navigation-buttons{display:flex;justify-content:space-between;gap:1rem}
.analysis-block{border:1px solid var(--primary);margin-top:1rem;border-radius:8px;background:rgba(125,211,252,.05)}
.analysis-header{background:rgba(125,211,252,.1);padding:.5rem 1rem;font-weight:700}
.analysis-content{padding:1rem}
/* --- PREVIEW MODAL --- */
.preview-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.7);backdrop-filter:blur(5px);display:flex;justify-content:center;align-items:center;z-index:1000;opacity:0;visibility:hidden;transition:opacity .3s,visibility .3s}
.preview-overlay.visible{opacity:1;visibility:visible}
.preview-modal{width:90%;max-width:900px;height:90vh;background:var(--surface);border:1px solid var(--border-color);border-radius:var(--radius);display:flex;flex-direction:column}
.preview-modal-header{padding:1rem 1.5rem;border-bottom:1px solid var(--border-color);display:flex;justify-content:space-between;align-items:center;flex-shrink:0;gap:1rem}
.preview-modal-header h1{margin:0;font-size:1.25rem;flex-grow:1}
.preview-content-wrapper{flex-grow:1;overflow-y:auto}
.preview-content{padding:2rem;line-height:1.7}
.preview-content h2{color:var(--primary);border-bottom:1px solid var(--border-color);padding-bottom:.5rem;margin-top:1.5rem;margin-bottom:1rem;page-break-after:avoid}
.preview-content .graph-image{max-width:100%;height:auto;margin-top:1rem;margin-bottom:1rem;border-radius:8px;background:#fff;padding:1rem}
.preview-content>div{margin-bottom:1rem;border:1px solid var(--border-color);border-radius:8px;padding:1rem;background:rgba(255,255,255,.02);white-space:pre-wrap;page-break-inside:avoid}
.progress-bar-container{flex-grow:1;background-color:rgba(255,255,255,.05);border-radius:99px;height:10px;overflow:hidden}
.progress-bar{width:0%;height:100%;background:linear-gradient(90deg,var(--primary),var(--secondary));border-radius:99px;transition:width .5s ease-out}
.word-count{font-size:.875rem;color:var(--muted)}
/* ============================================== */
/* === STYLES POUR L'HISTORIQUE DES PROJETS === */
/* ============================================== */

.history-item-container {
  display: flex; /* La magie opère ici : aligne les enfants sur une ligne */
  justify-content: space-between; /* Pousse les enfants aux extrémités (nom à gauche, poubelle à droite) */
  align-items: center; /* Centre les enfants verticalement */
  width: 100%;
}

.history-item {
  /* Le lien prend toute la place disponible à gauche */
  flex-grow: 1; 
  /* On s'assure qu'il ne dépasse pas pour laisser la place à la poubelle */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.5rem 0.75rem; /* On remet le padding ici */
  display: block; /* On s'assure qu'il se comporte bien */
}

.history-item-delete {
  cursor: pointer; /* Montre que la poubelle est cliquable */
  padding: 0.5rem;
  opacity: 0.5; /* La rend discrète par défaut */
  transition: opacity 0.2s ease-in-out;
}

.history-item-container:hover .history-item-delete {
  opacity: 1; /* La poubelle devient visible quand on passe la souris sur la ligne */
}