/* ============================================================
   FLIPO Desk - theme Tradentry (sombre / cyan)
   ============================================================ */

:root{
  --bg:#05090F;
  --panel:#0F1830;
  --panel-2:#0A1424;
  --line:#1B2742;
  --line-strong:#2A3A60;
  --text:#F2F6FF;
  --muted:#8A96B4;
  --muted-2:#5A6486;
  --accent:#00E5F0;
  --accent-2:#1FA8FF;
  --ink:#001028;
  --danger:#FF6B86;
  --ok:#3DDC84;
  --warn:#FFAB00;
  --grad:linear-gradient(135deg,#00E5F0 0%,#1FA8FF 100%);
  --radius:10px;
}

*{box-sizing:border-box}
[hidden]{display:none !important}
html,body{margin:0;padding:0}
body{
  background:var(--bg);
  color:var(--text);
  font-family:"DM Sans",ui-sans-serif,system-ui,sans-serif;
  min-height:100vh;
}
body::before{
  content:"";position:fixed;inset:0;z-index:0;pointer-events:none;
  background:
    radial-gradient(820px 520px at 50% -8%, rgba(0,229,240,.14), transparent 60%),
    radial-gradient(680px 460px at 10% 110%, rgba(31,168,255,.09), transparent 60%);
}
body > *{position:relative;z-index:1}

button{font:inherit;cursor:pointer}
::selection{background:rgba(0,229,240,.35)}

/* ---------- Page de connexion ---------- */
.login-page{display:flex;align-items:center;justify-content:center;padding:24px}
.login-card{
  width:min(400px,100%);
  background:linear-gradient(180deg, rgba(15,24,48,.92), rgba(9,14,26,.96));
  border:1px solid var(--line-strong);
  border-radius:20px;
  padding:30px 32px 24px;
  box-shadow:0 40px 90px -34px rgba(0,0,0,.9), 0 0 60px -30px rgba(0,229,240,.55);
  text-align:center;
}
.login-logo img{width:170px;height:auto;filter:drop-shadow(0 6px 22px rgba(0,229,240,.45))}
.login-card h1{
  font-family:"Michroma",sans-serif;font-weight:400;font-size:22px;
  letter-spacing:.04em;margin:14px 0 4px;color:#FFF;
}
.login-card h1 span{color:var(--accent)}
.login-sub{color:var(--muted);font-size:13px;margin:0 0 20px}
.login-error{
  background:rgba(255,107,134,.1);border:1px solid rgba(255,107,134,.35);
  color:#FFB3C2;border-radius:10px;padding:10px 12px;font-size:13px;margin-bottom:14px;
}
.login-card label{
  display:block;text-align:left;margin:0 0 6px;
  color:var(--muted);font-family:"JetBrains Mono",monospace;
  font-size:11px;letter-spacing:.14em;text-transform:uppercase;
}
.login-card input{
  display:block;width:100%;margin:0 0 14px;padding:12px 14px;
  background:var(--panel-2);border:1px solid var(--line);border-radius:12px;
  color:var(--text);font-size:15px;outline:none;
  transition:border-color .15s, box-shadow .15s;
}
.login-card input:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(0,229,240,.16);
}
.login-card button{
  display:block;width:100%;border:0;border-radius:12px;padding:14px;
  background:var(--grad);color:var(--ink);
  font-family:"Michroma",sans-serif;font-size:13px;
  box-shadow:0 12px 30px -10px rgba(31,168,255,.6);
  transition:transform .15s, filter .15s;
}
.login-card button:hover{transform:translateY(-1px);filter:brightness(1.06)}
.login-foot{color:var(--muted-2);font-size:11px;margin:18px 0 0}

/* ---------- Barre du haut ---------- */
.topbar{
  display:flex;align-items:center;justify-content:space-between;
  padding:12px 20px;border-bottom:1px solid var(--line);
  background:rgba(9,14,26,.85);backdrop-filter:blur(8px);
  position:sticky;top:0;z-index:10;
}
.brand{display:flex;align-items:center;gap:12px}
.brand img{height:30px;width:auto}
.brand-name{font-family:"Michroma",sans-serif;font-size:13px;letter-spacing:.05em;color:#DCE7FF}
.brand-name b{color:var(--accent);font-weight:400}
.topbar-right{display:flex;align-items:center;gap:14px}
.agent-pill{
  display:inline-flex;align-items:center;gap:8px;padding:7px 14px;
  background:rgba(15,24,48,.72);border:1px solid rgba(42,58,96,.7);border-radius:999px;
  font-family:"Michroma",sans-serif;font-size:11px;color:#DCE7FF;
}
.agent-pill .dot{width:8px;height:8px;border-radius:50%;background:var(--ok);box-shadow:0 0 10px var(--ok)}
.logout{
  color:var(--accent);text-decoration:none;
  font-family:"JetBrains Mono",monospace;font-size:12px;
}
.logout:hover{color:#7AF4FB}
.notif-btn{
  display:inline-flex;align-items:center;gap:6px;
  padding:7px 12px;border-radius:999px;cursor:pointer;
  background:rgba(255,171,0,.1);border:1px solid rgba(255,171,0,.5);
  color:#FFC04D;font-family:"JetBrains Mono",monospace;font-size:11.5px;
  animation:blink 1.6s infinite;
  transition:background .15s;
}
.notif-btn:hover{background:rgba(255,171,0,.2);animation:none}

/* ---------- Disposition ---------- */
.layout{
  display:grid;grid-template-columns:330px minmax(0,1fr);
  gap:0;height:calc(100vh - 57px);
}

/* ---------- Barre laterale ---------- */
.sidebar{
  border-right:1px solid var(--line);
  display:flex;flex-direction:column;min-height:0;
  background:rgba(10,20,36,.45);
}
.tabs{
  display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:14px;
  border-bottom:1px solid var(--line);
}
.tab{
  display:flex;align-items:center;justify-content:space-between;gap:6px;
  padding:9px 12px;border-radius:9px;
  background:rgba(15,24,48,.6);border:1px solid var(--line);
  color:var(--muted);font-size:12.5px;font-weight:600;
  transition:color .15s, border-color .15s, background .15s;
}
.tab:hover{color:var(--text);border-color:var(--line-strong)}
.tab.active{
  background:rgba(0,229,240,.1);border-color:rgba(0,229,240,.5);color:var(--accent);
}
.count{
  min-width:20px;padding:1px 6px;border-radius:999px;text-align:center;
  background:rgba(0,229,240,.12);color:var(--accent);
  font-family:"JetBrains Mono",monospace;font-size:11px;
}
.tab[data-tab="awaiting"] .count.alert{background:var(--danger);color:#FFF;animation:blink 1.2s infinite}
@keyframes blink{50%{opacity:.5}}
/* onglet "Bot en direct" : pleine largeur sous les 4 autres */
.tab-bot{grid-column:1 / -1;color:#7CC4FF}
.tab-bot .count{background:rgba(31,168,255,.14);color:#7CC4FF}
.tab-bot.active{background:rgba(31,168,255,.12);border-color:rgba(31,168,255,.55);color:#A8D6FF}

.conv-list{flex:1;overflow-y:auto;padding:10px;scrollbar-width:thin;scrollbar-color:var(--accent) transparent}
.conv-item{
  width:100%;text-align:left;display:block;
  background:rgba(15,24,48,.55);border:1px solid var(--line);border-radius:10px;
  padding:11px 13px;margin-bottom:8px;color:var(--text);
  transition:border-color .15s, background .15s, transform .15s;
}
.conv-item:hover{border-color:rgba(0,229,240,.45);transform:translateY(-1px)}
.conv-item.selected{border-color:var(--accent);background:rgba(0,229,240,.08)}
.conv-subject{
  font-size:13.5px;font-weight:600;color:#DCE7FF;
  display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.conv-meta{
  display:flex;justify-content:space-between;gap:8px;margin-top:5px;
  color:var(--muted-2);font-family:"JetBrains Mono",monospace;font-size:10.5px;
}
.empty{color:var(--muted-2);text-align:center;padding:26px 10px;font-size:13px}

/* ---------- Zone de chat ---------- */
.chat{display:flex;flex-direction:column;min-height:0;min-width:0}
.chat-empty{flex:1;display:flex;align-items:center;justify-content:center}
.chat-empty-inner{text-align:center;color:var(--muted)}
.chat-empty-inner h2{font-family:"Space Grotesk",sans-serif;color:#DCE7FF;margin:16px 0 8px}
.chat-empty-inner p{font-size:13.5px;line-height:1.6;margin:0}
.pulse-dot{
  width:14px;height:14px;border-radius:50%;background:var(--accent);
  margin:0 auto;box-shadow:0 0 0 rgba(0,229,240,.5);animation:pulse 2s infinite;
}
@keyframes pulse{
  0%{box-shadow:0 0 0 0 rgba(0,229,240,.45)}
  70%{box-shadow:0 0 0 18px rgba(0,229,240,0)}
  100%{box-shadow:0 0 0 0 rgba(0,229,240,0)}
}

.chat-open{flex:1;display:flex;flex-direction:column;min-height:0}
.chat-head{
  display:flex;align-items:center;justify-content:space-between;gap:14px;
  padding:14px 20px;border-bottom:1px solid var(--line);
}
.chat-head-info{min-width:0}
.chat-head h2{
  font-family:"Space Grotesk",sans-serif;font-size:16px;font-weight:600;margin:0 0 6px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.status-chip{
  display:inline-flex;padding:3px 10px;border-radius:999px;
  font-family:"JetBrains Mono",monospace;font-size:10.5px;letter-spacing:.06em;text-transform:uppercase;
  background:rgba(138,150,180,.15);color:var(--muted);border:1px solid rgba(138,150,180,.3);
}
.status-chip.awaiting_agent{background:rgba(255,171,0,.14);color:#FFC04D;border-color:rgba(255,171,0,.4)}
.status-chip.with_agent{background:rgba(0,229,240,.12);color:var(--accent);border-color:rgba(0,229,240,.4)}
.status-chip.bot{background:rgba(31,168,255,.12);color:#7CC4FF;border-color:rgba(31,168,255,.35)}
.status-chip.closed{background:rgba(255,107,134,.12);color:#FF8FA3;border-color:rgba(255,107,134,.35)}

.chat-head-actions{display:flex;gap:10px;flex:none}
.btn{
  border:0;border-radius:9px;padding:10px 16px;
  font-family:"Michroma",sans-serif;font-size:11px;letter-spacing:.03em;
  transition:transform .15s, filter .15s, background .15s, box-shadow .15s;
}
.btn:hover{transform:translateY(-1px);filter:brightness(1.07)}
.btn-claim{background:var(--grad);color:var(--ink);box-shadow:0 10px 24px -10px rgba(31,168,255,.65)}
.btn-takeover{
  background:rgba(0,229,240,.07);color:var(--accent);
  border:1px solid rgba(0,229,240,.5);
}
.btn-takeover:hover{background:rgba(0,229,240,.14)}
.btn-close{
  background:rgba(255,107,134,.07);color:#FF8FA3;
  border:1px solid rgba(255,107,134,.45);
}
.btn-close:hover{background:rgba(255,107,134,.14)}
.btn-send{background:var(--grad);color:var(--ink);box-shadow:0 10px 24px -10px rgba(31,168,255,.65)}
.btn:disabled{opacity:.5;cursor:not-allowed;transform:none}

/* ---------- Messages ---------- */
.messages{
  flex:1;overflow-y:auto;padding:20px;display:flex;flex-direction:column;gap:12px;
  scrollbar-width:thin;scrollbar-color:var(--accent) transparent;
}
.msg{max-width:72%;display:flex;flex-direction:column;gap:4px}
.msg-bubble{
  padding:11px 14px;border-radius:14px;font-size:14px;line-height:1.55;
  white-space:pre-wrap;word-wrap:break-word;
}
.msg-meta{
  color:var(--muted-2);font-family:"JetBrains Mono",monospace;font-size:10px;letter-spacing:.05em;
}
.msg.visitor{align-self:flex-start}
.msg.visitor .msg-bubble{background:rgba(15,24,48,.85);border:1px solid var(--line-strong);color:#E7EEFF;border-bottom-left-radius:4px}
.msg.agent{align-self:flex-end;text-align:right}
.msg.agent .msg-bubble{background:linear-gradient(135deg, rgba(0,229,240,.2), rgba(31,168,255,.16));border:1px solid rgba(0,229,240,.4);color:#EAFDFF;border-bottom-right-radius:4px;text-align:left}
.msg.bot{align-self:flex-start}
.msg.bot .msg-bubble{background:rgba(31,168,255,.08);border:1px solid rgba(31,168,255,.25);color:#C9DDFF;border-bottom-left-radius:4px}
.msg.system{align-self:center;max-width:90%;text-align:center}
.msg.system .msg-bubble{background:transparent;border:1px dashed var(--line-strong);color:var(--muted);font-size:12px;padding:7px 14px}

/* ---------- Reponses rapides ---------- */
.qr-bar{
  border-top:1px solid var(--line);
  background:rgba(9,14,26,.55);
  padding:10px 20px 4px;
}
.qr-head{display:flex;align-items:center;gap:12px;margin-bottom:8px}
.qr-label{
  color:var(--muted);font-family:"JetBrains Mono",monospace;
  font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;
}
.qr-langs{display:flex;gap:6px;margin-left:auto}
.qr-lang{
  padding:3px 9px;border-radius:999px;cursor:pointer;
  background:rgba(15,24,48,.6);border:1px solid var(--line);
  color:var(--muted);font-family:"JetBrains Mono",monospace;font-size:10.5px;
  transition:color .15s,border-color .15s,background .15s;
}
.qr-lang:hover{color:var(--text);border-color:var(--line-strong)}
.qr-lang.active{background:rgba(0,229,240,.12);border-color:rgba(0,229,240,.5);color:var(--accent)}
.qr-buttons{
  display:flex;flex-wrap:wrap;gap:7px;
  max-height:84px;overflow-y:auto;
  scrollbar-width:thin;scrollbar-color:var(--accent) transparent;
}
.qr-btn{
  padding:6px 12px;border-radius:999px;cursor:pointer;
  background:rgba(0,229,240,.07);border:1px solid rgba(0,229,240,.35);
  color:#9FE9F2;font-size:12px;
  white-space:nowrap;transition:background .15s,transform .15s,box-shadow .15s;
}
.qr-btn:hover{
  background:rgba(0,229,240,.15);transform:translateY(-1px);
  box-shadow:0 8px 18px -12px rgba(0,229,240,.6);
}
.qr-empty{color:var(--muted-2);font-size:12px;font-style:italic}

/* ---------- Zone de reponse ---------- */
.composer{
  display:flex;gap:10px;align-items:flex-end;
  padding:14px 20px;border-top:1px solid var(--line);
  background:rgba(9,14,26,.7);
}
.composer textarea{
  flex:1;resize:none;min-height:48px;max-height:140px;
  background:var(--panel-2);border:1px solid var(--line);border-radius:12px;
  color:var(--text);font:inherit;font-size:14px;padding:12px 14px;outline:none;
  transition:border-color .15s, box-shadow .15s;
  scrollbar-width:thin;
}
.composer textarea:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(0,229,240,.14)}

/* ---------- Mobile ---------- */
@media (max-width:820px){
  .layout{grid-template-columns:1fr;height:auto}
  .sidebar{border-right:0;border-bottom:1px solid var(--line);max-height:45vh}
  .chat{min-height:55vh}
  .msg{max-width:88%}
  .brand img{height:24px}
}

/* ---------- Statistiques ---------- */
.stats-btn{
  background:transparent;border:1px solid var(--line-strong);color:var(--text);
  font:inherit;font-size:13px;font-weight:600;padding:7px 13px;border-radius:9px;
  cursor:pointer;transition:border-color .15s,background .15s,color .15s;
}
.stats-btn:hover{border-color:var(--accent);color:var(--accent)}

.stats-overlay{
  position:fixed;inset:0;z-index:1000;
  background:rgba(3,6,12,.74);backdrop-filter:blur(3px);
  display:flex;align-items:flex-start;justify-content:center;
  padding:34px 18px;overflow:auto;
}
.stats-modal{
  width:100%;max-width:1120px;background:var(--panel);
  border:1px solid var(--line-strong);border-radius:16px;
  box-shadow:0 24px 70px rgba(0,0,0,.55);overflow:hidden;
}
.stats-modal-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:16px 22px;border-bottom:1px solid var(--line);
  background:rgba(9,14,26,.7);position:sticky;top:0;
}
.stats-modal-head h2{margin:0;font-size:18px;font-weight:700}
.stats-modal-actions{display:flex;gap:8px}
.stats-refresh,.stats-close{
  width:34px;height:34px;border-radius:9px;border:1px solid var(--line-strong);
  background:var(--panel-2);color:var(--text);font-size:16px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;transition:border-color .15s,color .15s;
}
.stats-refresh:hover,.stats-close:hover{border-color:var(--accent);color:var(--accent)}
.stats-body{padding:22px}
.stat-loading{padding:60px 10px;text-align:center;color:var(--muted)}

.stat-kpis{display:flex;flex-wrap:wrap;gap:12px;margin-bottom:14px}
.stat-kpi{
  flex:1 1 150px;min-width:140px;background:var(--panel-2);
  border:1px solid var(--line);border-top:3px solid var(--accent);
  border-radius:12px;padding:14px 16px;
}
.stat-kpi-val{font-size:28px;font-weight:700;line-height:1.1;color:var(--text)}
.stat-kpi-lbl{font-size:11px;color:var(--muted);margin-top:4px;text-transform:uppercase;letter-spacing:.04em}
.stat-note{color:var(--muted);font-size:13px;margin:2px 0 20px}

.stat-card{
  background:var(--panel-2);border:1px solid var(--line);
  border-radius:12px;padding:16px 18px;margin-bottom:18px;
}
.stat-card h3{margin:0 0 12px;font-size:14px;font-weight:700;color:var(--text)}
.stat-card--warn{border-color:rgba(255,171,0,.4);border-left:4px solid var(--warn)}
.stat-sub{color:var(--muted);font-size:12px;margin:-6px 0 12px}
.stat-empty,.stat-ok{color:var(--muted);font-size:13px;margin:4px 0}
.stat-ok{color:var(--ok)}
.stat-tip{
  margin-top:18px;padding:12px 14px;border-left:4px solid var(--warn);
  background:rgba(255,171,0,.08);color:var(--text);font-size:13px;border-radius:0 8px 8px 0;
}

.stat-chart{display:flex;align-items:flex-end;gap:5px;height:128px;margin-top:6px}
.stat-chart-col{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end}
.stat-chart-num{font-size:10px;color:var(--muted);margin-bottom:3px}
.stat-chart-bar{width:100%;background:var(--grad);border-radius:4px 4px 0 0;min-height:1px}
.stat-chart-lbl{font-size:9px;color:var(--muted-2);margin-top:5px;transform:rotate(-35deg);white-space:nowrap}

.stat-cols{display:flex;flex-wrap:wrap;gap:18px;align-items:flex-start}
.stat-col{flex:1 1 420px;min-width:300px}

.stat-bar{display:flex;align-items:center;gap:10px;margin:7px 0}
.stat-bar-lbl{flex:0 0 200px;font-size:13px;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.stat-bar-track{flex:1;background:var(--line);border-radius:6px;height:16px;overflow:hidden}
.stat-bar-fill{height:16px;border-radius:6px}
.stat-bar-val{flex:0 0 42px;text-align:right;font-weight:700;font-size:13px}

.stat-table{width:100%;border-collapse:collapse;font-size:13px}
.stat-table th{
  text-align:left;color:var(--muted);font-weight:600;font-size:11px;
  text-transform:uppercase;letter-spacing:.04em;padding:6px 8px;border-bottom:1px solid var(--line);
}
.stat-table td{padding:8px;border-bottom:1px solid var(--line);color:var(--text);vertical-align:top}
.stat-table tr:last-child td{border-bottom:0}
.stat-table .r{text-align:right;font-weight:700;white-space:nowrap}

@media (max-width:820px){
  .stats-body{padding:16px}
  .stat-bar-lbl{flex-basis:120px}
}

/* ---------- Pieces jointes ---------- */
.btn-attach{
  flex:0 0 auto;width:44px;padding:0;font-size:18px;line-height:1;
  background:var(--panel-2);border:1px solid var(--line-strong);color:var(--text);
  border-radius:12px;cursor:pointer;transition:border-color .15s,color .15s;
}
.btn-attach:hover{border-color:var(--accent);color:var(--accent)}
.btn-attach:disabled{opacity:.55;cursor:default}

.msg-attach{display:inline-block;margin-top:2px;max-width:100%}
.msg-attach-img img{
  max-width:240px;max-height:240px;border-radius:10px;display:block;
  border:1px solid var(--line);cursor:zoom-in;
}
.msg-attach-file{
  display:inline-flex;align-items:center;gap:8px;
  background:var(--panel-2);border:1px solid var(--line-strong);border-radius:10px;
  padding:9px 13px;color:var(--accent);text-decoration:none;font-size:13px;font-weight:600;
  max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.msg-attach-file:hover{border-color:var(--accent)}
