/* /assets/css/style.css */
:root {
  --brand: #2895FF;
  --brand-dark: #1B73D0;
  --brand-soft: #EAF4FF;
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --border: #E7E9ED;
  --border-strong: #D8DBE1;
  --text: #1A1D23;
  --text-soft: #5B6573;
  --text-mute: #8A93A2;
  --green: #10B981; --green-soft: #E7F8F1;
  --amber: #F59E0B; --amber-soft: #FEF4E2;
  --red: #EF4444; --red-soft: #FDECEC;
  --violet: #8B5CF6; --violet-soft: #F1ECFE;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 4px 16px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.12);
  --sidebar-w: 248px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ── Layout ────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 40;
}
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.content { padding: 28px 32px; flex: 1; }

/* ── Sidebar ───────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 22px 18px; }
.brand-logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-mute); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-weight: 500; margin-bottom: 2px; transition: .12s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav-foot { padding: 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); }
.user-chip:hover { background: var(--bg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-dark); display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.user-meta { line-height: 1.25; min-width: 0; }
.user-meta b { font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: 12px; color: var(--text-mute); }

/* ── Topbar ────────────────────────────────────────── */
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 32px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 19px; font-weight: 650; letter-spacing: -.3px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 15px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 550; font-size: 13.5px; transition: .12s; white-space: nowrap;
}
.btn:hover { background: var(--bg); border-color: var(--text-mute); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn-icon { width: 32px; padding: 0; justify-content: center; }

/* ── Cards / panels ────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px;
  border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; font-weight: 650; }
.card-body { padding: 20px; }

/* ── Stat grid ─────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-ic { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; }
.stat-ic svg { width: 18px; height: 18px; }
.stat-val { font-size: 27px; font-weight: 700; letter-spacing: -.6px; margin-top: 12px; }
.stat-lbl { font-size: 13px; color: var(--text-soft); margin-top: 2px; }

/* ── Tables ────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--text-mute); padding: 11px 16px; border-bottom: 1px solid var(--border);
  background: #FbFcFd; white-space: nowrap; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--bg); }
.cell-strong { font-weight: 600; }
.cell-sub { font-size: 12.5px; color: var(--text-mute); }

/* ── Badges ────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 23px; padding: 0 9px;
  border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--green-soft); color: #0E8C66; }
.badge.amber { background: var(--amber-soft); color: #B57608; }
.badge.red { background: var(--red-soft); color: #C53030; }
.badge.blue { background: var(--brand-soft); color: var(--brand-dark); }
.badge.violet { background: var(--violet-soft); color: #6D3FD6; }
.badge.gray { background: var(--bg); color: var(--text-soft); }
.badge.dot-custom::before { background: var(--c, var(--text-mute)); }

/* ── Forms ─────────────────────────────────────────── */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.input, .select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; background: var(--surface); color: var(--text);
  transition: .12s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 78px; }
.input:focus, .select:focus, textarea:focus { outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-mute); }
.search .input { padding-left: 36px; }

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: grid; place-items: center;
  z-index: 80; padding: 20px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%;
  max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; animation: pop .18s ease; }
.modal.wide { max-width: 720px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px;
  border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; font-weight: 650; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
.close-x { width: 30px; height: 30px; border-radius: 7px; border: none; background: transparent; color: var(--text-mute);
  display: grid; place-items: center; font-size: 20px; }
.close-x:hover { background: var(--bg); color: var(--text); }

/* ── Misc ──────────────────────────────────────────── */
.muted { color: var(--text-mute); }
.empty { text-align: center; padding: 48px 20px; color: var(--text-mute); }
.empty svg { width: 38px; height: 38px; margin-bottom: 10px; opacity: .5; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px;
  border-top: 1px solid var(--border); font-size: 13px; color: var(--text-soft); }
.pagination .pages { display: flex; gap: 6px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; padding: 60px; }

/* ── Toasts ────────────────────────────────────────── */
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--text); color: #fff; padding: 12px 16px; border-radius: 9px; font-size: 13.5px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 9px; animation: slideIn .2s ease; max-width: 360px; }
.toast.ok { background: #0E8C66; } .toast.err { background: #C53030; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }

/* ── Login ─────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--brand-soft), var(--bg)); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 34px 32px; }
.auth-card .brand { padding: 0 0 24px; justify-content: center; }
.auth-card h2 { font-size: 20px; font-weight: 650; text-align: center; }
.auth-card p.sub { text-align: center; color: var(--text-soft); margin: 6px 0 26px; }

/* ── Messagerie ────────────────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 60px); }
.chat-list { border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; }
.chat-search { padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.chat-item { display: flex; gap: 11px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.chat-item:hover, .chat-item.active { background: var(--brand-soft); }
.chat-item .avatar { flex-shrink: 0; }
.chat-item .ci-body { min-width: 0; flex: 1; }
.chat-item .ci-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-last { font-size: 12.5px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { display: flex; flex-direction: column; background: var(--bg); }
.chat-head { height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 11px; padding: 0 20px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 62%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.45;
  box-shadow: var(--shadow-sm); }
.bubble .time { font-size: 10.5px; color: var(--text-mute); margin-top: 4px; display: block; }
.bubble.in { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.bubble.out .time { color: rgba(255,255,255,.75); }
.chat-input { padding: 14px 18px; background: var(--surface); border-top: 1px solid var(--border); display: flex; gap: 10px; }
.chat-input .input { flex: 1; }
.wa-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  padding: 5px 11px; border-radius: 20px; }
.wa-pill.on { background: var(--green-soft); color: #0E8C66; }
.wa-pill.off { background: var(--red-soft); color: #C53030; }
.qr-box { text-align: center; }
.qr-box img { width: 240px; height: 240px; border: 1px solid var(--border); border-radius: 12px; padding: 8px; background: #fff; }

/* ── Tabs ──────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab { padding: 10px 14px; font-weight: 550; color: var(--text-soft); border-bottom: 2px solid transparent; }
.tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.tab:hover { color: var(--text); }

/* ── Detail layout ─────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--text-mute); }
.kv b { font-weight: 600; }
.list-row { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.progress { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--green); border-radius: 4px; }

@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; }
}

/* ════════ v2 — médias, pièces jointes, kanban, settings ════════ */

/* Bulles média */
.bubble img.b-img { max-width: 240px; border-radius: 9px; display: block; cursor: pointer; }
.bubble video.b-vid { max-width: 260px; border-radius: 9px; display: block; }
.bubble audio.b-aud { width: 230px; display: block; }
.b-doc { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(0,0,0,.04); border-radius: 8px; min-width: 180px; }
.bubble.out .b-doc { background: rgba(255,255,255,.18); }
.b-doc svg { width: 22px; height: 22px; flex-shrink: 0; }
.b-doc .b-doc-name { font-size: 12.5px; font-weight: 600; word-break: break-word; }
.b-caption { margin-top: 6px; }

/* Barre de saisie chat enrichie */
.chat-input .btn-attach { width: 40px; padding: 0; justify-content: center; }
.chat-typing { font-size: 12px; color: var(--green); padding: 2px 20px 0; height: 16px; }

/* Aperçu média avant envoi */
.media-preview { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 9px; margin-bottom: 12px; }
.media-preview img { width: 54px; height: 54px; object-fit: cover; border-radius: 7px; }
.media-preview .mp-meta { flex: 1; min-width: 0; }
.media-preview .mp-meta b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 120; display: grid; place-items: center; padding: 30px; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* Pièce jointe (paiements) */
.attach-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 6px;
  background: var(--brand-soft); color: var(--brand-dark); font-size: 12px; font-weight: 600; cursor: pointer; }
.attach-chip svg { width: 13px; height: 13px; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 9px; padding: 22px; text-align: center;
  color: var(--text-mute); cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }

/* Kanban pipeline */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kanban-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 280px; flex-shrink: 0; max-height: calc(100vh - 200px); display: flex; flex-direction: column; }
.kanban-col-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; font-weight: 650; font-size: 13.5px; position: sticky; top: 0; background: var(--surface); }
.kanban-col-head .k-count { background: var(--bg); color: var(--text-soft); border-radius: 20px; padding: 1px 9px; font-size: 12px; }
.kanban-body { padding: 10px; overflow-y: auto; flex: 1; min-height: 60px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px;
  margin-bottom: 9px; box-shadow: var(--shadow-sm); cursor: grab; }
.kanban-card:hover { border-color: var(--border-strong); }
.kanban-card.dragging { opacity: .5; }
.kanban-card .kc-name { font-weight: 600; font-size: 13px; }
.kanban-card .kc-phone { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.kanban-body.drop-target { background: var(--brand-soft); }

/* Toggle vue */
.view-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button { height: 36px; padding: 0 13px; border: none; background: var(--surface); color: var(--text-soft); font-size: 13px; font-weight: 550; }
.view-toggle button.active { background: var(--brand); color: #fff; }

/* Settings */
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border); gap: 20px; }
.setting-row:last-child { border-bottom: none; }
.setting-row .s-info { flex: 1; }
.setting-row .s-info b { font-size: 14px; }
.setting-row .s-info p { font-size: 12.5px; color: var(--text-mute); margin-top: 2px; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 20px; transition: .2s; cursor: pointer; }
.switch .track::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::before { transform: translateX(18px); }

/* Avatar image */
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ════════ v3 — messagerie 3 volets, panneau contact, réponses rapides ════════ */
.chat-layout.with-panel { grid-template-columns: 300px 1fr 330px; }
.contact-panel { border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; display: flex; flex-direction: column; }
.cp-head { padding: 22px 18px 16px; text-align: center; border-bottom: 1px solid var(--border); }
.cp-head .avatar { width: 64px; height: 64px; font-size: 22px; margin: 0 auto 12px; }
.cp-head .cp-name { font-size: 16px; font-weight: 650; }
.cp-head .cp-phone { font-size: 13px; color: var(--text-mute); margin-top: 2px; }
.cp-section { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.cp-section h4 { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mute); margin-bottom: 10px; }
.cp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cp-actions .btn { flex: 1; justify-content: center; }
.cp-sub { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.cp-sub .cps-top { display: flex; justify-content: space-between; align-items: center; }
.cp-sub .cps-meta { font-size: 12px; color: var(--text-mute); margin-top: 3px; }
.toggle-panel-btn { margin-left: auto; }

/* Réponses rapides (popover) */
.qr-pop { position: absolute; bottom: 60px; left: 16px; right: 16px; max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 20; }
.qr-pop-item { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.qr-pop-item:last-child { border-bottom: none; }
.qr-pop-item:hover { background: var(--brand-soft); }
.qr-pop-item b { font-size: 13px; }
.qr-pop-item p { font-size: 12px; color: var(--text-mute); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-input { position: relative; }
.btn-qr { width: 40px; padding: 0; justify-content: center; }

@media (max-width: 1100px) { .chat-layout.with-panel { grid-template-columns: 1fr; } .contact-panel { display: none; } }
