/* =========================================================================
   GREAT WHATS — V2.1 DESIGN SYSTEM
   Professional B2B SaaS UI · 2026
   - Design tokens (CSS custom properties)
   - Glassmorphism + soft shadows
   - Smooth animations & micro-interactions
   - Full RTL/LTR support
   - Dark sidebar + light workspace
   ========================================================================= */

/* ---------- Design Tokens ---------- */
:root {
    /* Brand palette — WhatsApp-inspired teal + premium indigo accent */
    --brand-50:  #ecfdf5;
    --brand-100: #d1fae5;
    --brand-200: #a7f3d0;
    --brand-300: #6ee7b7;
    --brand-400: #34d399;
    --brand-500: #10b981;
    --brand-600: #059669;
    --brand-700: #047857;
    --brand-800: #065f46;
    --brand-900: #064e3b;

    --accent-50:  #eef2ff;
    --accent-100: #e0e7ff;
    --accent-500: #6366f1;
    --accent-600: #4f46e5;
    --accent-700: #4338ca;

    /* Semantic */
    --bg: #f8fafc;
    --bg-soft: #f1f5f9;
    --panel: #ffffff;
    --panel-glass: rgba(255, 255, 255, 0.72);
    --ink: #0f172a;
    --ink-soft: #334155;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --line: #e2e8f0;
    --line-soft: #f1f5f9;
    --danger: #ef4444;
    --danger-soft: #fee2e2;
    --success: #10b981;
    --success-soft: #d1fae5;
    --warning: #f59e0b;
    --warning-soft: #fef3c7;
    --info: #3b82f6;
    --info-soft: #dbeafe;

    /* Sidebar (dark premium) */
    --sidebar: #0b1220;
    --sidebar-soft: #131c2e;
    --sidebar-ink: #cbd5e1;
    --sidebar-muted: #64748b;
    --sidebar-active: linear-gradient(135deg, var(--brand-600), var(--accent-600));

    /* Radii */
    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-pill: 999px;

    /* Shadows */
    --sh-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --sh-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --sh-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.05);
    --sh-lg: 0 12px 28px -6px rgba(15, 23, 42, 0.12), 0 6px 12px -4px rgba(15, 23, 42, 0.06);
    --sh-xl: 0 24px 48px -12px rgba(15, 23, 42, 0.18);
    --sh-brand: 0 8px 20px -4px rgba(16, 185, 129, 0.35);

    /* Motion */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --t-fast: 120ms;
    --t: 200ms;
    --t-slow: 380ms;

    /* Typography */
    --font-sans: 'Inter', 'Cairo', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;

    /* Spacing scale */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Smooth scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--muted-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; letter-spacing: 0.02em; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[dir="ltr"] .ltr-only { display: inline; }
[dir="rtl"] .ltr-only { display: inline; }

/* Direction-aware helpers (margin-inline auto handled by browser) */
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }

/* =========================================================================
   LAYOUT — App shell with sticky sidebar
   ========================================================================= */
.app-shell { display: flex; min-height: 100vh; }
.app-main {
    flex: 1;
    min-width: 0;
    padding: var(--sp-8) var(--sp-10);
    max-width: 1280px;
    margin: 0 auto;
    animation: fade-in var(--t-slow) var(--ease);
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
   SIDEBAR — Dark premium with active gradient indicator
   ========================================================================= */
.sidebar {
    width: 260px;
    background: var(--sidebar);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    padding: var(--sp-5) var(--sp-4);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-inline-end: 1px solid rgba(255, 255, 255, 0.04);
}
.sidebar-brand {
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3) var(--sp-5);
    letter-spacing: -0.01em;
}
.brand-dot {
    width: 10px; height: 10px;
    background: var(--brand-400);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 12px var(--brand-400);
    animation: brand-pulse 2.4s var(--ease) infinite;
}
@keyframes brand-pulse {
    0%, 100% { box-shadow: 0 0 12px var(--brand-400); transform: scale(1); }
    50% { box-shadow: 0 0 18px var(--brand-400); transform: scale(1.1); }
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav .nav-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-muted);
    padding: var(--sp-4) var(--sp-3) var(--sp-2);
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 10px var(--sp-3);
    border-radius: var(--r-sm);
    color: var(--sidebar-ink);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    transition: background var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease);
}
.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    transform: translateX(2px);
}
[dir="rtl"] .nav-item:hover { transform: translateX(-2px); }
.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: var(--sh-brand);
}
.nav-item .nav-icon {
    width: 20px; height: 20px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.nav-item .nav-icon svg { width: 18px; height: 18px; }
.nav-badge {
    margin-inline-start: auto;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 600;
}
.nav-item.active .nav-badge { background: rgba(255, 255, 255, 0.25); }

.sidebar-footer { padding-top: var(--sp-4); border-top: 1px solid rgba(255, 255, 255, 0.06); margin-top: var(--sp-4); }
.user-chip {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: var(--sp-3);
}
.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-name { font-size: 13.5px; font-weight: 600; color: #fff; line-height: 1.3; }
.user-role { font-size: 11.5px; color: var(--sidebar-muted); text-transform: capitalize; }

.lang-switch {
    display: flex; gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px;
    border-radius: var(--r-pill);
    margin-bottom: var(--sp-3);
}
.lang-item {
    flex: 1;
    text-align: center;
    padding: 6px 8px;
    border-radius: var(--r-pill);
    color: var(--sidebar-muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: all var(--t) var(--ease);
}
.lang-item:hover { color: #fff; }
.lang-item.active {
    background: rgba(255, 255, 255, 0.95);
    color: var(--sidebar);
    box-shadow: var(--sh-sm);
}

/* =========================================================================
   TOPBAR (in-page header)
   ========================================================================= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
    flex-wrap: wrap;
}
.page-header h1 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--ink);
}
.page-header .subtitle { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

/* =========================================================================
   BUTTONS — Unified, modern, with variants & states
   ========================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 9px 16px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--t) var(--ease);
    white-space: nowrap;
    user-select: none;
    position: relative;
    overflow: hidden;
}
.btn:hover {
    background: var(--bg-soft);
    border-color: var(--muted-2);
    transform: translateY(-1px);
    box-shadow: var(--sh-sm);
}
.btn:active { transform: translateY(0) scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent-500); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn .fas, .btn .far, .btn svg { font-size: 14px; }

.btn-primary {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-500));
    color: #fff;
    border-color: transparent;
    box-shadow: var(--sh-brand);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 12px 24px -4px rgba(16, 185, 129, 0.45);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 20px -4px rgba(99, 102, 241, 0.35);
}
.btn-accent:hover {
    background: linear-gradient(135deg, var(--accent-700), var(--accent-600));
    color: #fff;
    border-color: transparent;
}

.btn-ghost {
    background: var(--ink);
    border-color: transparent;
    color: #fff;
    border: 1px solid var(--ink) !important;
}
.btn-ghost:hover { background: var(--bg-muted); color: var(--ink); box-shadow: none; }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: transparent;
}
.btn-danger:hover { background: #dc2626; color: #fff; border-color: transparent; box-shadow: 0 8px 16px -4px rgba(239, 68, 68, 0.4); }

.btn-success { background: var(--success); color: #fff; border-color: transparent; }
.btn-success:hover { background: var(--brand-700); color: #fff; border-color: transparent; }

.btn-outline {
    background: transparent;
    border-color: var(--brand-500);
    color: var(--brand-700);
}
.btn-outline:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-500); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-xs { padding: 4px 10px; font-size: 11.5px; border-radius: var(--r-xs); }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; aspect-ratio: 1; }
.btn-icon.btn-sm { padding: 6px; }

/* Ripple effect */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.3) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.4s var(--ease);
}
.btn:active::after { opacity: 1; transition: opacity 0s; }

/* =========================================================================
   PANELS / CARDS
   ========================================================================= */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
    margin-bottom: var(--sp-5);
    box-shadow: var(--sh-sm);
    transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}
.panel:hover { box-shadow: var(--sh-md); }
.panel h2 { font-size: 1.1rem; font-weight: 700; margin: 0 0 var(--sp-4); letter-spacing: -0.01em; }
.panel h3 { font-size: 1rem; font-weight: 600; margin: 0 0 var(--sp-3); }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.panel-center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); align-items: start; }

.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.check-row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.wrap { flex-wrap: wrap; }
.stack-none { margin: 0; }

/* =========================================================================
   STAT CARDS — Glassmorphism + gradient icons
   ========================================================================= */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-5);
    margin-bottom: var(--sp-6);
}
.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--sp-5) var(--sp-6);
    position: relative;
    overflow: hidden;
    transition: all var(--t) var(--ease);
    box-shadow: var(--sh-sm);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; inset-inline-end: 0;
    width: 100px; height: 100px;
    background: radial-gradient(circle, var(--brand-100) 0%, transparent 70%);
    opacity: 0.7;
    border-radius: 50%;
    transform: translate(40%, -40%);
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--sh-lg);
    border-color: var(--brand-200);
}
.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--r-md);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px;
    margin-bottom: var(--sp-3);
    background: var(--brand-50);
    color: var(--brand-600);
}
.stat-icon.icon-info { background: var(--info-soft); color: var(--info); }
.stat-icon.icon-danger { background: var(--danger-soft); color: var(--danger); }
.stat-icon.icon-warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.icon-accent { background: var(--accent-50); color: var(--accent-600); }
.stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--ink);
    font-feature-settings: 'tnum';
}
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; font-weight: 500; }
.stat-trend {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 600;
    padding: 2px 8px; border-radius: var(--r-pill);
    margin-top: var(--sp-2);
}
.stat-trend.up { background: var(--success-soft); color: var(--success); }
.stat-trend.down { background: var(--danger-soft); color: var(--danger); }

/* =========================================================================
   FORMS
   ========================================================================= */
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field.grow { flex: 1; }
.field-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }

input[type="text"], input[type="tel"], input[type="email"], input[type="password"],
input[type="search"], input[type="date"], input[type="number"], input[type="url"],
input[type="file"], select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--panel);
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--t) var(--ease);
    outline: none;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
    background: #fff;
}
input[type="search"] { padding-inline-start: 36px; background: var(--bg-soft); }
.search-wrap { position: relative; }
.search-wrap::before {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    inset-inline-start: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted-2);
    font-size: 13px;
    pointer-events: none;
}

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--brand-600);
    cursor: pointer;
}

/* =========================================================================
   BADGES & PILLS
   ========================================================================= */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    background: var(--bg-soft);
    color: var(--ink-soft);
    border: 1px solid var(--line);
}
.badge-success { background: var(--success-soft); color: var(--brand-700); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: #92400e; border-color: transparent; }
.badge-muted { background: var(--bg-soft); color: var(--muted); border-color: var(--line); }
.badge-accent { background: var(--accent-50); color: var(--accent-700); border-color: transparent; }
.badge-dot::before {
    content: ''; width: 6px; height: 6px;
    background: currentColor; border-radius: 50%;
    display: inline-block;
}

/* Status dot (connected/disconnected/etc.) */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--muted-2);
    margin-inline-end: 6px;
}
.status-dot.connected { background: var(--success); box-shadow: 0 0 8px var(--success); animation: status-pulse 2s infinite; }
.status-dot.disconnected, .status-dot.failed { background: var(--danger); }
.status-dot.pending, .status-dot.qr, .status-dot.pairing, .status-dot.authenticating { background: var(--warning); animation: status-pulse 1.5s infinite; }
@keyframes status-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

/* =========================================================================
   FLASH MESSAGES
   ========================================================================= */
.flash-stack { margin-bottom: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.flash {
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 13.5px;
    font-weight: 500;
    display: flex; align-items: flex-start; gap: 10px;
    border: 1px solid transparent;
    animation: slide-in var(--t-slow) var(--ease);
}
.flash::before {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 16px;
    flex-shrink: 0;
}
.flash-success { background: var(--success-soft); color: var(--brand-800); border-color: var(--brand-200); }
.flash-success::before { content: '\f00c'; color: var(--success); }
.flash-info { background: var(--info-soft); color: #1e40af; border-color: var(--info-200, #bfdbfe); }
.flash-info::before { content: '\f05a'; color: var(--info); }
.flash-error { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.flash-error::before { content: '\f071'; color: var(--danger); }
/* V5.6.4.2 — avertissement (case OTP sans effet : maître tenant coupé). */
.flash-warning { background: var(--warning-soft, #fef3c7); color: #92400e; border-color: #fde68a; }
.flash-warning::before { content: '\f071'; color: #d97706; }

@keyframes slide-in {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

/* =========================================================================
   TABLES
   ========================================================================= */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table thead th {
    text-align: start;
    padding: 10px 14px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 600;
    border-bottom: 1px solid var(--line);
    background: var(--bg-soft);
}
.table thead th:first-child { border-start-start-radius: var(--r-md); }
.table thead th:last-child { border-start-end-radius: var(--r-md); }
.table tbody td {
    padding: 14px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink-soft);
    vertical-align: middle;
}
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--brand-50); }
.table tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { color: var(--muted); padding: var(--sp-6); text-align: center; font-style: italic; }

/* =========================================================================
   AVATARS
   ========================================================================= */
.avatar-xs { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar-md { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar-initials {
    background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
    color: #fff;
    font-weight: 700;
    font-size: 0.7em;
}
.avatar-xs.avatar-initials { font-size: 11px; }
.avatar-sm.avatar-initials { font-size: 13px; }
.avatar-md.avatar-initials { font-size: 16px; }
.avatar-lg.avatar-initials { font-size: 22px; }

/* =========================================================================
   AUTH (LOGIN) — Split-screen premium
   ========================================================================= */
.auth-body {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--brand-700) 0%, var(--accent-700) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-6);
    position: relative;
    overflow: hidden;
}
.auth-body::before {
    content: '';
    position: absolute;
    top: -50%; inset-inline-start: -20%;
    width: 80%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 60%);
    animation: auth-glow 8s ease-in-out infinite alternate;
}
@keyframes auth-glow {
    from { transform: rotate(0deg) scale(1); }
    to { transform: rotate(20deg) scale(1.1); }
}
.auth-card {
    background: var(--panel);
    border-radius: var(--r-xl);
    padding: var(--sp-10) var(--sp-8);
    width: 100%;
    max-width: 440px;
    box-shadow: var(--sh-xl);
    position: relative;
    z-index: 1;
    animation: auth-pop var(--t-slow) var(--ease-bounce);
}
@keyframes auth-pop {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.auth-brand {
    display: flex; align-items: center; gap: var(--sp-3);
    font-weight: 700; font-size: 17px; color: var(--ink);
    margin-bottom: var(--sp-6);
    justify-content: center;
}
.auth-brand .brand-dot { width: 12px; height: 12px; }
.auth-card h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 4px; text-align: center; letter-spacing: -0.02em; }
.auth-sub { color: var(--muted); font-size: 14px; text-align: center; margin-bottom: var(--sp-6); }
.auth-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.auth-form .btn-primary { padding: 12px; font-size: 15px; }
.auth-note { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: var(--sp-5); }
.auth-lang-switch { justify-content: center; margin-bottom: var(--sp-5); }
.auth-lang-switch .lang-item { color: var(--muted); }
.auth-lang-switch .lang-item.active { color: var(--brand-700); }

/* =========================================================================
   CHAT — Conversation list (left) + room (right)
   ========================================================================= */
.chat-wrap {
    display: grid;
    grid-template-columns: 340px 1fr;
    height: calc(100vh - 120px);
    gap: var(--sp-4);
    background: transparent;
}
@media (max-width: 980px) {
    .chat-wrap { grid-template-columns: 1fr; height: auto; }
}

/* ---- Conversation list panel ---- */
.conv-list-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.conv-list-header { padding: var(--sp-4); border-bottom: 1px solid var(--line); }
.conv-list-header h2 { font-size: 1rem; font-weight: 700; margin: 0 0 var(--sp-3); }
.conv-search { position: relative; }
.conv-search input {
    padding: 9px 12px 9px 36px;
    background: var(--bg-soft);
    border-color: transparent;
    font-size: 13.5px;
}
.conv-search::before {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    inset-inline-start: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted-2);
    font-size: 13px;
}
[dir="rtl"] .conv-search input { padding: 9px 36px 9px 12px; }

.conv-list { overflow-y: auto; flex: 1; }
.conv-item {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    cursor: pointer;
    border-bottom: 1px solid var(--line-soft);
    transition: background var(--t) var(--ease);
    position: relative;
}
.conv-item:hover { background: var(--bg-soft); }
.conv-item.active { background: var(--brand-50); }
.conv-item.active::before {
    content: ''; position: absolute;
    inset-inline-start: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--brand-500);
}
.conv-avatar-wrap { position: relative; flex-shrink: 0; }
.unread-dot {
    position: absolute;
    bottom: -2px; inset-inline-end: -2px;
    width: 14px; height: 14px;
    background: var(--success);
    border: 2px solid var(--panel);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
    animation: dot-pulse 2s infinite;
}
@keyframes dot-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
.conv-meta { flex: 1; min-width: 0; }
.conv-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    display: flex; justify-content: space-between; gap: 8px;
    align-items: baseline;
}
.conv-name .conv-time { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.conv-preview { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conv-preview .preview-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.conv-unread-badge {
    background: var(--success);
    color: #fff;
    border-radius: var(--r-pill);
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

/* ---- Chat room ---- */
.chat-room-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    display: flex; flex-direction: column;
    overflow: hidden;
    /* V3.1 — ancre le .drop-overlay (inset:0) au panneau : avant, il s'ancrait
       au viewport parce qu'aucun ancêtre n'était positionné. */
    position: relative;
}
.chat-header {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-5);
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}
.chat-header-avatar { position: relative; flex-shrink: 0; }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info strong { font-size: 15px; font-weight: 700; display: block; color: var(--ink); }
.chat-header-info .muted { font-size: 12.5px; }

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-5);
    background:
        radial-gradient(circle at 20% 80%, rgba(16,185,129,0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(99,102,241,0.03) 0%, transparent 50%),
        var(--bg);
    display: flex; flex-direction: column; gap: var(--sp-2);
}
.chat-empty {
    margin: auto;
    color: var(--muted-2);
    text-align: center;
    padding: var(--sp-10);
}
.chat-empty i { font-size: 48px; opacity: 0.4; margin-bottom: var(--sp-3); display: block; }

/* ---- Message bubble ---- */
.bubble-row {
    display: flex; gap: var(--sp-2);
    margin-bottom: var(--sp-2);
    animation: bubble-in var(--t-slow) var(--ease);
    max-width: 75%;
}
[dir="ltr"] .bubble-row { align-self: flex-start; }
[dir="rtl"] .bubble-row { align-self: flex-start; }
.bubble-row.mine { align-self: flex-end; flex-direction: row-reverse; }
[dir="rtl"] .bubble-row.mine { flex-direction: row; }

@keyframes bubble-in {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.bubble-avatar { flex-shrink: 0; align-self: flex-end; }

.bubble {
    padding: 10px 14px;
    border-radius: var(--r-md);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--sh-xs);
    position: relative;
    min-width: 80px;
    word-wrap: break-word;
    word-break: break-word;
}
.bubble-their { border-start-start-radius: 4px; background: var(--panel); }
.bubble-mine {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    color: #fff;
    border: none;
    border-start-end-radius: 4px;
    box-shadow: var(--sh-sm);
}
.bubble-unread {
    box-shadow: 0 0 0 2px var(--success), var(--sh-xs);
}
.bubble-sender { font-size: 12px; font-weight: 700; color: var(--accent-600); margin-bottom: 2px; }
.bubble-mine .bubble-sender { color: rgba(255,255,255,0.85); }
.bubble-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.bubble-caption { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 4px; }
.bubble-mine .bubble-caption { color: rgba(255,255,255,0.95); }
.bubble-meta {
    font-size: 11px;
    color: var(--muted-2);
    margin-top: 4px;
    display: flex; align-items: center; gap: 4px;
    justify-content: flex-end;
}
.bubble-mine .bubble-meta { color: rgba(255,255,255,0.75); }
.bubble-author { font-size: 11px; font-style: italic; }

/* Bubble media */
.bubble-media { margin-bottom: 6px; }
.bubble-image img, .bubble-image a img {
    max-width: 280px;
    max-height: 320px;
    border-radius: var(--r-sm);
    display: block;
    cursor: pointer;
    transition: transform var(--t) var(--ease);
}
.bubble-image:hover img { transform: scale(1.02); }
.bubble-video video { width: 300px; max-width: 100%; border-radius: var(--r-sm); }
.bubble-audio audio { width: 260px; max-width: 100%; }
.bubble-ptt { display: flex; align-items: center; gap: 8px; }
.bubble-document a {
    display: flex; align-items: center; gap: 8px;
    text-decoration: none;
    color: inherit;
    padding: 8px 12px;
    background: var(--bg-soft);
    border-radius: var(--r-sm);
    transition: background var(--t) var(--ease);
}
.bubble-mine .bubble-document a { background: rgba(255,255,255,0.15); color: #fff; }
.bubble-document a:hover { background: var(--line); }
.bubble-document .fas { font-size: 20px; }
.bubble-location iframe { border: 0; border-radius: var(--r-sm); }

/* ---- Composer ---- */
.chat-composer {
    border-top: 1px solid var(--line);
    padding: var(--sp-3) var(--sp-4);
    background: var(--panel);
    display: flex; flex-direction: column; gap: var(--sp-2);
    position: relative;
}
.composer-tools-v2 {
    display: flex; gap: 4px; align-items: center;
}
.composer-tool {
    border: 0; background: transparent;
    width: 38px; height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    color: var(--muted);
    display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--t) var(--ease);
    position: relative;
}
.composer-tool:hover {
    background: var(--brand-50);
    color: var(--brand-600);
    transform: scale(1.08);
}
.composer-tool:active { transform: scale(0.94); }
#tool-mic.recording {
    background: var(--danger);
    color: #fff;
    animation: pulse-rec 1.2s infinite;
}
@keyframes pulse-rec {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.6); }
    50% { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
}
.composer-main { display: flex; gap: var(--sp-2); align-items: center; }
/* V3.3 — <textarea> multi-lignes (Shift+Entrée) à la place de <input> : les
   sauts de ligne ne sont plus perdus. Hauteur auto (max ~120px, scroll). */
.composer-main input[type="text"],
.composer-main textarea#composer-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--r-pill);
    background: var(--bg-soft);
    border-color: transparent;
}
.composer-main textarea#composer-input {
    resize: none;
    min-height: 40px;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.45;
    font-family: inherit;
    font-size: inherit;
}
.composer-main input:focus,
.composer-main textarea#composer-input:focus { background: #fff; box-shadow: 0 0 0 4px rgba(16,185,129,0.1); }
.composer-session-select {
    padding: 8px 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--bg-soft);
    font-size: 13px;
}

.composer-attachment-preview {
    display: none; /* V3.1 — visible uniquement via la classe .is-visible (le JS
       l'ajoute quand un fichier est sélectionné). Avant, un inline
       style="display:none" écrasait la classe → l'aperçu n'apparaissait jamais. */
    align-items: center; gap: 10px;
    padding: 8px 12px;
    background: var(--brand-50);
    border: 1px solid var(--brand-200);
    border-radius: var(--r-sm);
}
.composer-attachment-preview.is-visible { display: flex; }
.composer-attachment-preview .attach-info-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }

.composer-recording {
    display: none; /* V3.1 — idem : piloté par .is-visible (chat-room.js). */
    align-items: center; gap: 10px;
    padding: 8px 12px;
    background: var(--danger-soft);
    border-radius: var(--r-sm);
}
.composer-recording.is-visible { display: flex; }
.rec-dot {
    width: 12px; height: 12px;
    background: var(--danger);
    border-radius: 50%;
    animation: blink-rec 1s infinite;
}
@keyframes blink-rec {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.rec-timer { font-family: var(--font-mono); font-size: 14px; font-weight: 600; flex-grow: 1; }

.composer-hint { font-size: 12px; color: var(--muted); padding: 0 4px; }

/* ---- Drop overlay ---- */
.drop-overlay {
    position: absolute; inset: 0;
    background: rgba(16, 185, 129, 0.12);
    border: 3px dashed var(--brand-500);
    border-radius: var(--r-lg);
    display: none; /* V3.1 — piloté par .is-visible pendant un drag & drop. */
    flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px;
    z-index: 50;
    font-size: 18px;
    font-weight: 600;
    color: var(--brand-700);
    backdrop-filter: blur(4px);
}
.drop-overlay.is-visible { display: flex; }
.drop-overlay i { font-size: 48px; }

/* ---- Emoji picker ---- */
.emoji-picker {
    position: absolute;
    /* V3.1 — au-DESSUS du composer (ancre = .chat-composer, position:relative)
       plutôt que bottom:70px qui chevauchait la barre d'outils. */
    bottom: calc(100% + 8px);
    inset-inline-start: var(--sp-3);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--sp-3);
    box-shadow: var(--sh-lg);
    z-index: 30;
    display: none; /* V3.1 — BUGFIX : aucune règle .is-visible n'existait pour ce
       popover. Le Blade le cachait avec un inline style="display:none" qui
       ÉCRASAIT la classe .is-visible togglée par chat-room.js → « au clic rien
       ne se passe ». Le défaut caché + la classe visible vivent maintenant
       uniquement en CSS. */
}
.emoji-picker.is-visible { display: block; animation: popover-in var(--t) var(--ease-bounce); }
@keyframes popover-in {
    from { opacity: 0; transform: translateY(8px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    max-width: 320px;
    max-height: 280px;
    overflow-y: auto;
}
.emoji-item {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent;
    cursor: pointer;
    font-size: 22px;
    border-radius: var(--r-xs);
    transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.emoji-item:hover { background: var(--bg-soft); transform: scale(1.2); }
/* V3.1 — le JS génère des boutons .emoji-cell (pas .emoji-item) : on style la
   classe réellement émise, sinon les emojis apparaissent en boutons natifs. */
.emoji-cell {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent;
    cursor: pointer;
    font-size: 22px;
    font-family: inherit;
    border-radius: var(--r-xs);
    transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.emoji-cell:hover { background: var(--bg-soft); transform: scale(1.2); }

/* ---- Location popover ---- */
.location-popover {
    position: absolute;
    /* V3.1 — même ancrage que .emoji-picker : au-dessus du composer. */
    bottom: calc(100% + 8px);
    inset-inline-start: var(--sp-3);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--sp-4);
    box-shadow: var(--sh-lg);
    z-index: 30;
    width: 260px;
    display: none; /* V3.1 — même bugfix que .emoji-picker (règle .is-visible
       absente + inline style écrasant) : le popover ne s'ouvrait jamais. */
}
.location-popover.is-visible { display: block; animation: popover-in var(--t) var(--ease-bounce); }
.location-popover h3 { margin: 0 0 var(--sp-3); font-size: 14px; }
.location-popover .btn { margin-bottom: 6px; }

/* ---- Modal (trace) ---- */
/* V2.2.5 — BUGFIX CRITIQUE : .modal-overlay était en `display: flex` par
   défaut → le modal de trace s'affichait SUR /chat/{id} au chargement,
   bloquant toute interaction (l'utilisateur ne pouvait plus chatter).
   Maintenant caché par défaut, visible seulement avec la classe .is-visible
   (ajoutée par openTraceModal() dans chat-room.js). */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 100;
    /* V2.2.5 — caché par défaut (display:none) */
    display: none;
    padding: var(--sp-5);
}
/* V2.2.5 — ne montrer que lorsque la classe .is-visible est ajoutée */
.modal-overlay.is-visible {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in var(--t) var(--ease);
}
.modal {
    background: var(--panel);
    border-radius: var(--r-lg);
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--sh-xl);
    display: flex; flex-direction: column;
    animation: modal-pop var(--t-slow) var(--ease-bounce);
}
@keyframes modal-pop {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
.modal-header {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.modal-close {
    border: 0; background: transparent;
    font-size: 24px; cursor: pointer;
    width: 32px; height: 32px;
    border-radius: 50%;
    color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    transition: background var(--t) var(--ease);
}
.modal-close:hover { background: var(--bg-soft); }
.modal-body { padding: var(--sp-5); overflow-y: auto; }

/* ---- Context menu (right-click on message) ---- */
.context-menu {
    position: fixed;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-lg);
    padding: 4px;
    z-index: 90;
    min-width: 180px;
    animation: popover-in var(--t-fast) var(--ease);
}
.context-menu button, .context-menu a {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    text-align: start;
    cursor: pointer;
    border-radius: var(--r-xs);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--t-fast) var(--ease);
}
.context-menu button:hover, .context-menu a:hover { background: var(--bg-soft); color: var(--ink); }
.context-menu .divider { height: 1px; background: var(--line); margin: 4px 0; }

/* ---- Session tabs (WhatsApp accounts) ---- */
.session-tabs { display: flex; flex-direction: column; gap: var(--sp-2); }
.session-tab {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border: 1.5px solid var(--line);
    border-radius: var(--r-md);
    text-decoration: none;
    color: var(--ink-soft);
    background: var(--panel);
    transition: all var(--t) var(--ease);
    cursor: pointer;
}
.session-tab:hover { border-color: var(--brand-300); background: var(--brand-50); transform: translateX(2px); }
[dir="rtl"] .session-tab:hover { transform: translateX(-2px); }
.session-tab.active {
    border-color: var(--brand-500);
    background: linear-gradient(135deg, var(--brand-50), var(--accent-50));
    box-shadow: var(--sh-sm);
}
.session-tab-avatar { flex-shrink: 0; }
.session-tab-name { flex: 1; min-width: 0; }
.session-tab-name strong { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }

/* ---- Session tabs horizontal (multi-account picker) ---- */
.session-tabs-horizontal {
    display: flex; gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.session-tab-h {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-pill);
    text-decoration: none;
    background: var(--panel);
    color: var(--ink-soft);
    white-space: nowrap;
    transition: all var(--t) var(--ease);
    font-size: 13.5px;
    font-weight: 500;
}
.session-tab-h:hover { border-color: var(--brand-300); background: var(--brand-50); }
.session-tab-h.active {
    background: linear-gradient(135deg, var(--brand-600), var(--accent-600));
    color: #fff;
    border-color: transparent;
    box-shadow: var(--sh-brand);
}
.session-picker { margin-bottom: var(--sp-5); padding: var(--sp-4) var(--sp-5); }

/* ---- QR Zone ---- */
.qr-zone {
    width: 280px; height: 280px;
    margin: 0 auto;
    border-radius: var(--r-lg);
    background: var(--bg-soft);
    display: flex; align-items: center; justify-content: center;
    position: relative;
    overflow: hidden;
}
.qr-zone img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.qr-placeholder { text-align: center; color: var(--muted); padding: var(--sp-4); }
.qr-placeholder .fa-spinner { font-size: 32px; color: var(--brand-500); margin-bottom: var(--sp-3); }
.pairing-code {
    font-family: var(--font-mono);
    font-size: 24px;
    font-weight: 700;
    color: var(--brand-700);
    letter-spacing: 0.1em;
}

/* ---- Rename form ---- */
.rename-form { background: var(--bg-soft); border-radius: var(--r-md); padding: var(--sp-4); }
.rename-form .field-row { display: flex; gap: var(--sp-3); align-items: flex-end; }

/* ---- User chip (small, in tables) ---- */
.user-chip-sm { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Activity log timeline ---- */
.timeline { display: flex; flex-direction: column; gap: var(--sp-3); }
.timeline-item {
    display: flex; gap: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--panel);
    transition: all var(--t) var(--ease);
}
.timeline-item:hover { border-color: var(--brand-200); box-shadow: var(--sh-sm); }
.timeline-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
}

/* ---- Filters form ---- */
.filters-form { padding: var(--sp-4) var(--sp-5); }
.filter-row { display: flex; gap: var(--sp-3); align-items: flex-end; flex-wrap: wrap; }
.filter-row .field { min-width: 140px; }

/* ---- API key plain ---- */
.api-key-plain {
    display: block;
    margin-top: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    background: #0b1220;
    color: #7dd3fc;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-family: var(--font-mono);
    direction: ltr;
    text-align: start;
    overflow-wrap: anywhere;
    user-select: all;
}
.api-key-masked { direction: ltr; display: inline-block; font-size: 13px; font-family: var(--font-mono); }
.code-block {
    background: #0b1220;
    color: #e2e8f0;
    padding: var(--sp-4) var(--sp-5);
    border-radius: var(--r-md);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    direction: ltr;
    text-align: start;
    font-family: var(--font-mono);
}
.code-block code { white-space: pre; }

/* ---- Plans grid ---- */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--sp-5);
}
.plan-card {
    border: 1.5px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
    background: var(--panel);
    transition: all var(--t) var(--ease);
    position: relative;
}
.plan-card:hover { border-color: var(--brand-300); box-shadow: var(--sh-lg); transform: translateY(-2px); }
.plan-card.plan-featured { border-color: var(--brand-500); box-shadow: var(--sh-brand); }
.plan-card .plan-price { font-size: 1.8rem; font-weight: 800; margin: var(--sp-2) 0; letter-spacing: -0.02em; }
.plan-features { list-style: none; padding: 0; margin: 0 0 var(--sp-3); font-size: 13.5px; }
.plan-features li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; align-items: center; gap: 8px; }
.plan-features li::before { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: var(--success); font-size: 12px; }
.plan-inactive { opacity: 0.55; }

/* ---- Realtime indicator ---- */
#realtime-indicator {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px;
    color: var(--muted);
    padding: 4px 10px;
    border-radius: var(--r-pill);
    background: var(--bg-soft);
    border: 1px solid var(--line);
}
#realtime-indicator::before {
    content: ''; width: 6px; height: 6px;
    background: var(--warning); border-radius: 50%;
    animation: status-pulse 1.2s infinite;
}
#realtime-indicator.connected::before { background: var(--success); animation: none; }
#realtime-indicator.offline::before { background: var(--danger); animation: none; }

/* ---- Responsive ---------- */
@media (max-width: 900px) {
    .plans-grid { grid-template-columns: 1fr; }
    .two-col { grid-template-columns: 1fr; }
    .app-main { padding: var(--sp-5) var(--sp-4); }
    .sidebar { width: 70px; padding: var(--sp-3) 6px; }
    .sidebar .nav-item span:not(.nav-badge),
    .sidebar-brand span:not(.brand-dot),
    .sidebar-footer .user-name,
    .sidebar-footer .user-role,
    .sidebar-footer .lang-switch,
    .sidebar-footer form { display: none; }
    .sidebar .nav-item { justify-content: center; }
}

/* ---------- RTL fine-tuning ---------- */
[dir="rtl"] .conv-search input { padding: 9px 36px 9px 12px; }
[dir="rtl"] .conv-search::before { inset-inline-start: auto; inset-inline-end: 12px; }
[dir="rtl"] .bubble-row.mine { flex-direction: row; }

/* Phone numbers always LTR */
.ltr-force, [dir="ltr"] { unicode-bidi: isolate; }

/* ---------- Spinners & loaders ---------- */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--line);
    border-top-color: var(--brand-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
    background: linear-gradient(90deg, var(--bg-soft) 25%, var(--line) 50%, var(--bg-soft) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.4s ease infinite;
    border-radius: var(--r-xs);
}
@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- Tooltip ---------- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    inset-inline-start: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 4px 10px;
    border-radius: var(--r-xs);
    font-size: 11.5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t) var(--ease);
    z-index: 50;
}
[data-tooltip]:hover::after { opacity: 1; }

/* =========================================================================
   V2.1 — Composants supplémentaires (superuser, forms, panels)
   ========================================================================= */

/* Panel narrow (forms) */
.panel-narrow { max-width: 720px; }

/* Header actions */
.header-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* Filter pills (assign agent) */
.check.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-pill);
    cursor: pointer;
    transition: all var(--t) var(--ease);
    background: var(--panel);
    font-size: 13.5px;
    user-select: none;
}
.check.pill:hover { border-color: var(--brand-300); background: var(--brand-50); }
.check.pill input[type="checkbox"] {
    appearance: none;
    width: 16px; height: 16px;
    border: 1.5px solid var(--line);
    border-radius: 4px;
    background: var(--panel);
    cursor: pointer;
    position: relative;
    transition: all var(--t) var(--ease);
}
.check.pill input[type="checkbox"]:checked {
    background: var(--brand-600);
    border-color: var(--brand-600);
}
.check.pill input[type="checkbox"]:checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #fff;
    font-size: 10px;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
.check.pill:has(input:checked) {
    border-color: var(--brand-500);
    background: var(--brand-50);
    color: var(--brand-700);
    font-weight: 600;
}

/* Code block improvements */
.code-block {
    background: #0b1220;
    color: #e2e8f0;
    padding: var(--sp-4) var(--sp-5);
    border-radius: var(--r-md);
    overflow-x: auto;
    font-size: 12.5px;
    line-height: 1.7;
    direction: ltr;
    text-align: start;
    font-family: var(--font-mono);
    border: 1px solid #1e293b;
}
.code-block code { white-space: pre; color: #cbd5e1; }
.code-block code::before { color: #64748b; }

/* Sessions table fix */
.session-line { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

/* Form stacks */
form.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
form .field-row { margin-bottom: 0; }

/* Empty states */
.panel .empty { padding: var(--sp-6); text-align: center; font-style: italic; color: var(--muted); }

/* Tenant detail tables */
.panel h3 { font-size: 1rem; font-weight: 700; margin: var(--sp-5) 0 var(--sp-3); letter-spacing: -0.01em; }

/* Code blocks for API docs */
pre.code-block { margin: var(--sp-3) 0; position: relative; }
pre.code-block::before {
    content: 'BASH';
    position: absolute;
    top: 8px;
    inset-inline-end: 12px;
    font-size: 10px;
    color: #64748b;
    letter-spacing: 0.1em;
    font-weight: 700;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
 
.phone {
    direction: ltr !important;
}

html[dir="ltr"] .phone {
    text-align: left !important;
}

html[dir="rtl"] .phone {
    text-align: right !important;
}

.link-strong{
    font-weight: 600;
    text-decoration: none;
    color: var(--sidebar-soft);
}

/* =========================================================================
   V3.4 — Cellule identité de la liste /chat (conversation <tr>)
   =========================================================================
   Avant : le nom (<a>) et le numéro étaient posés côte à côte dans un
   div.phone en flex-row inline → « nom collé au numéro », et l'avatar
   flottait (float:right) hors du flux. Désormais :
   .conv-cell  = flex row (avatar + bloc identité), RTL/LTR automatique ;
   .conv-idblock = colonne empilée : NOM / numéro / aperçu du dernier msg.
   Le JS temps réel (chat-list.js) reste compatible : il insère l'aperçu
   manquant dans `.conv-cell > div:last-child` (= .conv-idblock). */
.conv-cell {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}
.conv-cell .conv-avatar {
    float: none;          /* neutralise l'ancien float:right */
    margin: 0;
    position: relative;   /* nécessaire au point vert de non-lecture */
    flex-shrink: 0;
}
.conv-idblock {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.conv-idblock .link-strong {
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.conv-idblock .conv-last {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================================================================
   V2.2.4 — CORRECTIONS DESIGN DE /chat/{id}
   =========================================================================
   La page chat/{id} était « complètement pétée » à cause de 4 bugs CSS
   cumulés :

   1. `.chat-wrap` est défini comme grid 2 colonnes (340px 1fr) pour la
      liste+room. Mais sur /chat/{id} il n'y a QUE la room → la grid
      casse tout (header écrasé à gauche, body à droite, composer en bas).

      → Correctif : ajout du modifieur `.chat-wrap--room` qui passe la grid
        en 1 colonne pleine largeur.

   2. `.chat-title` était utilisé dans le Blade mais n'existait pas en CSS
      (c'était `.chat-header-info`). Le titre n'était donc pas stylé.

      → Correctif : le Blade utilise maintenant `.chat-header-info`.

   3. `.chat-room-panel` (cadre arrondi + ombre) était défini mais jamais
      utilisé dans le HTML → la room flottait sans cadre.

      → Correctif : le Blade wrappe maintenant header+body+composer dans
        `.chat-room-panel`.

   4. `.composer-main` (wrapper input + send button) était défini mais
      absent du HTML → input et bouton étaient empilés en colonne.

      → Correctif : le Blade wrappe maintenant input+send dans
        `.composer-main`.
   ========================================================================= */

/* V2.2.4 — Layout 1 colonne pour /chat/{id} (room seule, pas de liste). */
.chat-wrap.chat-wrap--room {
    display: block;
    grid-template-columns: none;
    height: calc(100vh - 120px);
    background: transparent;
}

/* La room occupe toute la hauteur disponible. */
.chat-wrap.chat-wrap--room .chat-room-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Le body des messages prend tout l'espace restant (flex:1 déjà présent
   dans .chat-body, mais on s'assure que le flex container est correct). */
.chat-wrap.chat-wrap--room .chat-room-panel > .chat-body {
    flex: 1 1 auto;
    min-height: 0;
}

/* Le composer reste scotché en bas, ne grandit pas. */
.chat-wrap.chat-wrap--room .chat-room-panel > .chat-composer {
    flex: 0 0 auto;
}

/* V2.2.4 — Sur mobile, on garde la hauteur naturelle (pas de 100vh
   qui colle le composer tout en bas d'un écran tactile). */
@media (max-width: 980px) {
    .chat-wrap.chat-wrap--room {
        height: auto;
    }
    .chat-wrap.chat-wrap--room .chat-room-panel {
        height: auto;
        min-height: 70vh;
    }
}

/* V2.2.4 — Spacing entre la room et le panel d'assignation. */
.assign-panel {
    margin-top: var(--sp-5);
}

/* V2.2.4 — L'indicateur temps réel ne doit paswrap. */
.chat-header #realtime-indicator {
    flex-shrink: 0;
    margin-inline-start: auto;
    font-size: 12px;
}

/* V3.1 — L'ancien hack attribut `[style*="display:none"]` + `:not([data-visible])`
   en `!important` maintenait l'aperçu de pièce jointe caché EN PERMANENCE
   (le JS ne pose jamais l'attribut data-visible). Remplacé par l'état caché
   par défaut + `.is-visible` défini plus haut dans la section Composer. */

/* V2.2.4 — Le bouton "back" du header de la room. */
.chat-header .btn-ghost.btn-sm {
    flex-shrink: 0;
    padding: 8px 10px;
}

/* V2.2.4 — Le `.chat-header-avatar` doit avoir la même taille que l'avatar
   qu'il contient (sinon il prend toute la place et pousse le titre). */
.chat-header-avatar {
    width: 44px;   /* = .avatar-md */
    height: 44px;
    flex-shrink: 0;
}

/* V2.2.4 — Le `.chat-header-info` doit prendre tout l'espace restant
   (avant, sans cette règle, le titre était écrasé par l'indicateur). */
.chat-header-info {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.chat-header-info strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* V2.2.4 — Le `.composer-main` (wrapper input + send).
   V3.3 — + textarea multi-lignes. */
.composer-main {
    display: flex;
    gap: var(--sp-2);
    align-items: flex-end;
    width: 100%;
}

.composer-main input[type="text"],
.composer-main textarea#composer-input {
    flex: 1 1 auto;
}

.composer-main #composer-send {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* V2.2.4 — Le `.composer-tools-v2` (boutons outils) aligné à gauche,
   avec un petit séparateur visuel au-dessus de l'input. */
.composer-tools-v2 {
    border-bottom: 1px solid var(--line-soft);
    padding-bottom: 4px;
}

/* V2.2.4 — L'empty state de la chat-body. */
.chat-body .chat-empty {
    margin: auto;
    text-align: center;
    color: var(--muted-2);
    padding: var(--sp-10) var(--sp-4);
}

.chat-body .chat-empty i {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: var(--sp-3);
    display: block;
}

/* ============================================================
   V2.2.6 — Spinner CSS pur (sans Font Awesome)
   ============================================================
   Avant : le placeholder QR utilisait <i class="fa fa-spinner fa-spin">
   + un <link> CDN Font Awesome DANS le div. Si cdnjs.cloudflare.com
   était injoignable (ERR_CONNECTION_TIMED_OUT), le navigateur
   bloquait le rendu du QR jusqu'au time-out (~30 s).
   Maintenant : spinner en CSS pur, affiché instantanément.
   ============================================================ */
.qr-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--line-soft, #e2e8f0);
    border-top-color: var(--brand-500, #10b981);
    border-radius: 50%;
    animation: qr-spin 0.8s linear infinite;
    margin: 0 auto var(--sp-3, 12px);
}

@keyframes qr-spin {
    to { transform: rotate(360deg); }
}

.qr-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--sp-6, 24px);
    min-height: 280px;
}

.qr-placeholder-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-strong, #1f2937);
    margin: 0 0 var(--sp-1, 4px);
}

/* V2.2.6 — Composer désactivé quand aucune session WhatsApp connectée.
   Évite que l'utilisateur écrive un message pour rien (avant : le message
   partait en HTTP, revenait en 409, et l'UI affichait "déconnecté"
   de façon confuse). Maintenant : le composer est grisé + un bandeau
   explicite propose d'aller scanner le QR. */
.composer-locked-no-session {
    background: var(--bg-soft, #f8fafc);
    border: 1px dashed var(--line-strong, #cbd5e1);
    border-radius: var(--radius, 12px);
    padding: var(--sp-4, 16px);
    text-align: center;
    color: var(--muted-2, #64748b);
    margin-top: var(--sp-3, 12px);
}

.composer-locked-no-session a {
    color: var(--brand-600, #059669);
    font-weight: 600;
    text-decoration: underline;
}

/* ==========================================================================
   V4.1 — Fonctionnalités WhatsApp : menu contextuel, réactions, épinglage,
   transfert, lightbox, apparence, appels, barre de réponse, journal unifié.
   ========================================================================== */

/* ---- Bulle : bouton ⓘ (infos en un clic) — visible au survol ---- */
.bubble-row { position: relative; }

.bubble-info-btn {
    border: 0;
    background: transparent;
    color: inherit;
    opacity: 0;
    cursor: pointer;
    font-size: 0.72rem;
    padding: 0 0.2rem;
    vertical-align: middle;
    transition: opacity 0.15s ease;
}
.bubble-row:hover .bubble-info-btn { opacity: 0.55; }
.bubble-info-btn:hover { opacity: 1 !important; color: #21c063; }

/* ---- Badge « Transféré » ---- */
.bubble-forwarded {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-style: italic;
    opacity: 0.75;
    margin-bottom: 0.25rem;
}
.bubble-forwarded i { font-size: 0.7rem; }

/* ---- Aperçu du message cité (réponse) ---- */
.bubble-reply-preview {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    border-left: 3px solid #21c063;
    background: rgba(33, 192, 99, 0.08);
    border-radius: 6px;
    padding: 0.35rem 0.55rem;
    margin-bottom: 0.35rem;
    max-width: 100%;
    overflow: hidden;
}
.bubble-reply-preview > i { color: #21c063; margin-top: 0.15rem; font-size: 0.8rem; }
.bubble-reply-to { font-size: 0.72rem; font-weight: 600; color: #1fa855; }
.bubble-reply-body { font-size: 0.78rem; opacity: 0.85; word-break: break-word; }

/* ---- Réactions (chips sous la bulle) ---- */
.bubble-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.3rem;
}
.reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    font-size: 0.78rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    cursor: default;
}
.reaction-count { font-size: 0.68rem; color: #555; }

/* ---- Indicateur d'épinglage ---- */
.bubble-pin-indicator {
    position: absolute;
    top: -0.45rem;
    inset-inline-end: 0.4rem;
    background: #f0b429;
    color: #fff;
    border-radius: 999px;
    width: 1.15rem;
    height: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* ---- Barre des messages épinglés (haut de la conversation) ---- */
.pinned-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.9rem;
    background: #fffbe8;
    border-bottom: 1px solid #f0e6bd;
}
.pinned-bar > i { color: #f0b429; }
.pinned-list { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.pinned-item {
    color: #444;
    text-decoration: none;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.pinned-item:hover { color: #1fa855; }
.pinned-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }

/* ---- Barre de réponse au-dessus du composer ---- */
.reply-bar {
    display: none;
    align-items: center;
    gap: 0.6rem;
    background: #f5f5f5;
    border-left: 3px solid #21c063;
    border-radius: 8px;
    padding: 0.45rem 0.7rem;
    margin-bottom: 0.4rem;
}
.reply-bar.is-visible { display: flex; }
.reply-bar > i { color: #21c063; }
.reply-preview { min-width: 0; flex: 1; }
.reply-to-name { font-size: 0.75rem; font-weight: 700; color: #1fa855; }
.reply-to-text { font-size: 0.78rem; color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Menu contextuel V2 (façon WhatsApp) ---- */
.context-menu-v2 {
    position: fixed;
    z-index: 3000;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    padding: 0.35rem;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    animation: ctx-pop 0.12s ease;
}
@keyframes ctx-pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

.menu-reaction-row {
    display: flex;
    justify-content: space-between;
    gap: 0.15rem;
    padding: 0.25rem 0.2rem 0.45rem;
    border-bottom: 1px solid #eee;
    margin-bottom: 0.3rem;
}
.menu-react {
    border: 0;
    background: transparent;
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 50%;
    width: 2.1rem;
    height: 2.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, background 0.12s ease;
}
.menu-react:hover { background: #f0f0f0; transform: scale(1.25); }

.context-menu-v2 > button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: start;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #333;
}
.context-menu-v2 > button:hover { background: #f2f7f4; color: #111; }
.context-menu-v2 > button i { width: 1.1rem; color: #1fa855; }

/* ---- Modal Transférer ---- */
.modal-forward { width: min(420px, 94vw); }
.forward-message-preview {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.82rem;
    color: #555;
    margin-bottom: 0.6rem;
    max-height: 4.5rem;
    overflow: hidden;
}
.forward-search {
    width: 100%;
    padding: 0.45rem 0.7rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 0.6rem;
    font-size: 0.85rem;
}
.forward-list { max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 0.15rem; }
.forward-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.55rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.86rem;
}
.forward-item:hover { background: #f4f7f5; }
.forward-item input[type="checkbox"] { accent-color: #21c063; }
.forward-item-icon { color: #1fa855; width: 1.2rem; text-align: center; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem 0.5rem;
    border-top: 1px solid #eee;
}

/* ---- Lightbox média (Échap / flèches) ---- */
.media-lightbox {
    position: fixed;
    inset: 0;
    z-index: 4000;
    background: rgba(0, 0, 0, 0.88);
    display: none;
    align-items: center;
    justify-content: center;
}
.media-lightbox.is-visible { display: flex; }
.lightbox-figure { margin: 0; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.lightbox-figure img {
    max-width: 92vw;
    max-height: 84vh;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.lightbox-caption { color: #eee; font-size: 0.85rem; text-align: center; max-width: 80ch; }
.lightbox-close {
    position: absolute;
    top: 1rem;
    inset-inline-end: 1.2rem;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 0;
    border-radius: 50%;
    width: 2.4rem;
    height: 2.4rem;
    font-size: 1.4rem;
    cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 0;
    border-radius: 50%;
    width: 2.6rem;
    height: 2.6rem;
    font-size: 1.05rem;
    cursor: pointer;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox-prev { inset-inline-start: 1.2rem; }
.lightbox-next { inset-inline-end: 1.2rem; }

/* ---- Panneau Apparence ---- */
.appearance-panel {
    position: fixed;
    top: 4.5rem;
    inset-inline-end: 1.2rem;
    z-index: 3500;
    width: min(300px, 92vw);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: none;
}
.appearance-panel.is-visible { display: block; }
.appearance-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #eee;
}
.appearance-header h3 { margin: 0; font-size: 0.95rem; display: flex; align-items: center; gap: 0.4rem; }
.appearance-body { padding: 0.9rem 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.7rem; }
.appearance-label { font-size: 0.8rem; font-weight: 600; color: #555; display: block; }
.wallpaper-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.3rem; }
.wallpaper-swatch {
    height: 2.1rem;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}
.wallpaper-swatch.is-active { border-color: #21c063; box-shadow: 0 0 0 2px rgba(33, 192, 99, 0.25); }
.appearance-toggle { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 500; }
.appearance-toggle input { accent-color: #21c063; }
.appearance-panel input[type="range"] { accent-color: #21c063; }

/* ---- Popover appel (limitation API documentée) ---- */
.chat-call-buttons { display: inline-flex; gap: 0.25rem; }
.call-popover {
    position: fixed;
    top: 4.5rem;
    inset-inline-end: 1.2rem;
    z-index: 3500;
    width: min(280px, 92vw);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 0.9rem 1rem;
    display: none;
}
.call-popover.is-visible { display: block; }
.call-popover h4 { margin: 0 0 0.4rem; font-size: 0.9rem; display: flex; align-items: center; gap: 0.4rem; }
.call-popover .btn-block { margin-top: 0.45rem; }

/* ---- Fond sombre du chat (wallpaper sombre) ---- */
.chat-body.chat-body-dark { color: #e9edef; }
.chat-body.chat-body-dark .bubble-their { background: #202c33; color: #e9edef; }
.chat-body.chat-body-dark .bubble-their .bubble-sender { color: #53bdeb; }

/* ---- Journal unifié : lignes système atténuées ---- */
.activity-row-system { opacity: 0.62; }
.badge-warning { background: #f0b429; color: #3d2e00; }

/* ---- Bulles temps réel : réactions héritent du positionnement ---- */
.bubble { position: relative; }

/* ---- V4.2 — sous-menu durées d'épinglage + expiration ---- */
.context-menu-v2 .menu-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #8a94a6;
    padding: 0.35rem 0.65rem 0.25rem;
}
.context-menu-v2 .menu-back {
    border-top: 1px solid #eee;
    margin-top: 0.25rem;
    border-radius: 0 0 8px 8px;
}
.context-menu-v2 .menu-back i { color: #8a94a6 !important; }

.pinned-expiry {
    font-size: 0.68rem;
    color: #8a94a6;
    white-space: nowrap;
    flex-shrink: 0;
}
.pinned-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* ==========================================================================
   V4.5 — « est en train d'écrire » (indicateur de frappe)
   Deux rendus : en-tête du chat (points animés + texte) et aperçu de la
   liste des conversations (texte vert italique, comme WhatsApp).
   ========================================================================== */

.chat-typing {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 2px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--brand-600);
    min-height: 17px;
}
.chat-typing[hidden] { display: none; }

/* Trois points qui pulsent en cascade (décalage 160 ms) */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}
.typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--brand-500);
    animation: typingPulse 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes typingPulse {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30%           { transform: translateY(-3px); opacity: 1; }
}

/* Aperçu de la liste des conversations : remplace temporairement le texte
   du dernier message (chat-list.js restaure l'original sur paused/délai). */
.conv-last.conv-typing {
    color: var(--brand-600);
    font-style: italic;
    font-weight: 600;
}
.conv-last.conv-typing::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--brand-500);
    margin-inline-end: 4px;
    vertical-align: middle;
    animation: typingPulse 1.2s ease-in-out infinite;
}

/* Accessibilité : pas d'animation pour les utilisateurs sensibles */
@media (prefers-reduced-motion: reduce) {
    .typing-dots span,
    .conv-last.conv-typing::before {
        animation: none;
    }
}

/* ====================================================================
   V4.7 — VERROUILLAGE DES CONVERSATIONS + PANNEAU DE SUPERVISION
   ==================================================================== */

/* Ligne verrouillée (liste) : légère teinte + cadenas */
tr.row-locked .link-strong {
    color: var(--danger-600, #b91c1c);
}
.conv-lock-badge {
    margin-inline-start: 6px;
    font-size: 10px;
    padding: 2px 6px;
    vertical-align: middle;
}

/* Badge « Verrouillée » dans l'en-tête de la conversation */
#chat-locked-badge {
    margin-inline-end: 6px;
}

/* Bouton verrou en-tête : état actif */
#chat-lock-btn[data-locked="1"] {
    color: var(--danger-600, #b91c1c);
}

/* Compteur du bouton supervision (encadré par-dessus l'icône) */
#chat-viewers-btn {
    position: relative;
}
#chat-viewers-count {
    position: absolute;
    top: -6px;
    inset-inline-end: -6px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    padding: 0 4px;
    font-size: 10px;
    border-radius: 999px;
    text-align: center;
}

/* Panneau de consultation (EXCLUSIF directeur/responsable) */
.viewers-panel {
    position: absolute;
    top: 64px;
    inset-inline-end: 16px;
    z-index: 40;
    width: min(360px, calc(100% - 32px));
    background: var(--bg-elevated, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    overflow: hidden;
}
.chat-room-panel { position: relative; }
.viewers-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-subtle, #f8fafc);
}
.viewers-panel-body {
    max-height: 320px;
    overflow-y: auto;
    padding: 6px 0;
}
.viewers-section-title {
    padding: 6px 14px 2px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted, #64748b);
}
.viewers-list {
    padding: 2px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.viewer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.viewer-row .avatar-xs {
    flex: 0 0 auto;
}
.viewer-row .viewer-meta {
    min-width: 0;
    flex: 1;
}
.viewer-row .viewer-meta .viewer-name {
    font-weight: 600;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.viewer-row .viewer-meta .viewer-times {
    color: var(--muted, #64748b);
    font-size: 11px;
    display: block;
}
.viewer-row.viewer-live .viewer-name::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-inline-start: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: viewerPulse 1.6s ease-in-out infinite;
}
@keyframes viewerPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
    .viewer-row.viewer-live .viewer-name::after { animation: none; }
}

/* RTL : le panneau s'aligne à gauche */
[dir="rtl"] .viewers-panel {
    inset-inline-end: auto;
    inset-inline-start: 16px;
}

/* ------------------------------------------------------------------ */
/* V4.8 — CLIENTS ANONYMES : interrupteur de l'encadrement (page /chat) */
/* ------------------------------------------------------------------ */
#anonymous-clients-panel .switch input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--muted, #cbd5e1);
    position: relative;
    cursor: pointer;
    transition: background 0.15s ease;
    margin: 0;
    flex-shrink: 0;
}

#anonymous-clients-panel .switch input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 3px;
    inset-inline-start: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease;
}

#anonymous-clients-panel .switch input[type="checkbox"]:checked {
    background: var(--primary, #16a34a);
}

#anonymous-clients-panel .switch input[type="checkbox"]:checked::after {
    transform: translateX(18px);
}

[dir="rtl"] #anonymous-clients-panel .switch input[type="checkbox"]:checked::after {
    transform: translateX(-18px);
}

#anonymous-clients-panel .switch {
    flex-direction: row;
}

/* ============================================================
   V4.9 — WIZARD CHATBOT (création guidée en 5 étapes)
   ============================================================ */
.wizard-steps {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
}
.wizard-step {
    flex: 1;
    min-width: 130px;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all .15s ease;
}
.wizard-step:hover { border-color: var(--brand-300, #93c5fd); color: var(--ink); }
.wizard-step.active {
    background: var(--brand-50);
    border-color: var(--brand-500);
    color: var(--brand-700);
}
.wizard-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-soft);
    font-size: 12px;
    font-weight: 700;
    flex: 0 0 auto;
}
.wizard-step.active .wizard-step-num { background: var(--brand-500); color: #fff; }
.wizard-pane { animation: wizardIn .18s ease; }
@keyframes wizardIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.trigger-card {
    flex: 1;
    min-width: 200px;
    align-items: flex-start;
    gap: var(--sp-2);
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.trigger-card:hover { border-color: var(--brand-300, #93c5fd); }
.trigger-card:has(input:checked) { border-color: var(--brand-500); background: var(--brand-50); }
.trigger-card input { margin-top: 3px; }

.knowledge-row .knowledge-remove { margin-bottom: 6px; }

/* Badge BOT (message émis par un chatbot) */
.bot-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 999px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
}
.bot-badge .fas { font-size: 9px; }

/* ================================================================
   V5.1 — Extensions : présence sur la page de liste, suppression
   de conversation, rapport détaillé (audit) d'une conversation,
   verrou anti-doublon. Styles locaux, aucune classe existante touchée.
   ================================================================ */

/* ---- V5.1 — Bandeau « qui regarde cette page » (liste /chat) ---- */
.page-viewers-panel { padding: 0.6rem 0.9rem; }
.page-viewers-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.page-viewers-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
}
.page-viewers-label .fas { color: #1fa855; }
.page-viewers-list { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.page-viewer-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--surface-2, #f1f3f5);
    border-radius: 999px;
    padding: 0.15rem 0.6rem 0.15rem 0.2rem;
    font-size: 0.8rem;
    max-width: 220px;
}
.page-viewer-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- V5.1 — Actions de ligne (ouverture + suppression encadrement) ---- */
.conv-actions { display: inline-flex; align-items: center; gap: 0.3rem; }
.conv-delete-form { display: inline-flex; margin: 0; }
.conv-delete-btn { color: #d64545; }
.conv-delete-btn:hover { background: #fdeaea; color: #b83232; }

/* ---- V5.1 — Modal rapport détaillé (audit conversation + archive stats) ---- */
.modal-audit { width: min(560px, 94vw); }
.modal-audit .modal-body { max-height: 60vh; overflow-y: auto; }
.audit-timeline { display: flex; flex-direction: column; gap: 0.15rem; margin-top: 0.5rem; }
.audit-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0.25rem;
    border-bottom: 1px dashed var(--border, #e5e7eb);
    font-size: 0.85rem;
}
.audit-row:last-child { border-bottom: none; }
.audit-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--surface-2, #f1f3f5);
    color: #2563eb;
    font-size: 0.7rem;
    flex-shrink: 0;
}
.audit-viewed .audit-icon { color: #1fa855; }
.audit-left .audit-icon { color: #94a3b8; }
.audit-replied .audit-icon { color: #2563eb; }
.audit-assigned .audit-icon { color: #7c3aed; }
.audit-unassigned .audit-icon { color: #b45309; }
.audit-locked .audit-icon { color: #d64545; }
.audit-unlocked .audit-icon { color: #1fa855; }
.audit-meta { display: flex; flex-direction: column; min-width: 0; }
.audit-text { overflow-wrap: anywhere; }
.audit-time { color: #94a3b8; font-size: 0.72rem; }
[dir="rtl"] .audit-row { flex-direction: row; }

/* ============================================================
   V5.2 — Styles additionnels (aucune classe existante modifiée)
   ============================================================ */

/* ---- PROBLÈME 19 : carte de visite (contact partagé) ---- */
.bubble-contact .contact-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 10px 12px;
    min-width: 200px;
    max-width: 280px;
}
.contact-card-icon {
    font-size: 22px;
    color: var(--brand-600);
    flex-shrink: 0;
}
.contact-card-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.contact-card-info strong { overflow-wrap: anywhere; }
.contact-card .btn { flex-shrink: 0; }

/* ---- PROBLÈME 10 : badge étiquette anonyme (encadrement uniquement) ---- */
.alias-badge { font-size: 11px; font-weight: 600; margin-inline-start: .35rem; vertical-align: middle; }

/* ---- PROBLÈME 19 (suite) : STICKERS (webp statique/animé) ----
   Rendu « flottant » comme WhatsApp : pas de fond de bulle média, taille
   contenue, animation webp conservée nativement par <img>. */
.bubble-sticker img, .bubble-sticker a img {
    width: 150px;
    max-width: 150px;
    max-height: 150px;
    height: auto;
    display: block;
    background: transparent;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: transform var(--t) var(--ease);
}
.bubble-sticker:hover img { transform: scale(1.04); }
/* La bulle elle-même reste lisible (heure/statut) mais neutre pour un
   sticker : fond atténué, pas de bordure média. Aucune classe existante
   modifiée — sélecteur composé nouveau uniquement. */
.bubble .bubble-sticker { margin-bottom: 2px; }

/* V5.6.1 — PAGE D'ACCUEIL PUBLIQUE (landing multilingue)
   Tabs pour le sélecteur de langue dans les Paramètres superuser. */
.tab-btn { cursor: pointer; font: inherit; padding: .5rem 1rem; border: none; background: none; color: var(--muted, #64748b); border-bottom: 2px solid transparent; transition: border-color .15s, color .15s; }
.tab-btn:hover { color: var(--brand-600, #065f46); }
.tab-btn.active { color: var(--brand-600, #065f46); border-bottom-color: var(--brand-600, #065f46); font-weight: 600; }
.tabs { display: flex; gap: .5rem; border-bottom: 1px solid var(--border, #e2e8f0); margin-bottom: 1rem; }


/* =========================================================================
   V5.6.4 — WHATSAPP WEB EXPERIENCE
   1. Palette WhatsApp officielle (boutons, bulles, accents)
   2. Thème sombre [data-theme="dark"] + police/taille [data-font/-textsize]
   3. Sidebar compacte (icônes + bouton d'expansion, .app-shell--compact)
   4. Vue fusionnée liste+conversation (grid 2 colonnes, une seule page)
   5. Lignes de liste compactes façon WhatsApp + mini-cartes (CARTO)
   Tout est ADDITIF : les règles plus haut restent la base ; celles-ci
   les affinent avec une spécificité égale ou supérieure (fin de fichier
   = priorité). Aucun sélecteur existant n'est supprimé.
   ========================================================================= */

/* ---------- 1. Palette WhatsApp (tokens) ---------- */
:root {
    /* Vert WhatsApp 2023+ : CTA #00a884, vert vif #06cf9c, vert foncé #005c4b */
    --brand-50:  #e7fff5;
    --brand-100: #d2f8ee;
    --brand-400: #06cf9c;
    --brand-500: #00a884;
    --brand-600: #008f72;
    --brand-700: #008069;
    --brand-800: #005c4b;
    /* L'accent suit le vert WhatsApp (avant : indigo — demandé client) */
    --accent-500: #00a884;
    --accent-600: #008f72;
    --accent-700: #006e59;
    --sidebar-active: linear-gradient(135deg, #00a884, #008f72);
}
/* Bouton principal WhatsApp : vert plein (fini le dégradé « SaaS »). */
.btn-primary {
    background: var(--brand-500);
    border-color: transparent;
    box-shadow: 0 2px 8px -2px rgba(0, 168, 132, 0.5);
}
.btn-primary:hover {
    background: var(--brand-600);
    border-color: transparent;
    box-shadow: 0 6px 16px -4px rgba(0, 168, 132, 0.55);
}
/* Bulle sortante WhatsApp clair : vert d'eau #d9fdd3 + texte sombre. */
.bubble-mine {
    background: #d9fdd3;
    color: #111b21;
    border: 1px solid #c5e8c0;
    border-start-end-radius: 4px;
    box-shadow: var(--sh-xs);
}
.bubble-mine .bubble-sender { color: #005c4b; }
.bubble-mine .bubble-caption { color: #1f2c33; }
.bubble-mine .bubble-text { color: #111b21; }
.bubble-mine .bubble-meta { color: rgba(17, 27, 33, 0.55); }
.bubble-mine .bubble-meta .status-icon { color: rgba(17, 27, 33, 0.6); }
.bubble-mine .bubble-meta .status-icon.status-read { color: #53bdeb; }
.bubble-mine .bubble-reply-preview { background: rgba(0, 92, 75, 0.10); border-color: rgba(0, 92, 75, 0.25); }
.bubble-mine .bubble-reply-to { color: #005c4b; }
.bubble-mine .bubble-author { color: rgba(17, 27, 33, 0.6); }
.bubble-mine .bubble-forwarded { color: #005c4b; }

/* ---------- 2a. Thème sombre WhatsApp [data-theme="dark"] ---------- */
html[data-theme="dark"] {
    --bg: #0b141a;
    --bg-soft: #111b21;
    --panel: #202c33;
    --panel-glass: rgba(32, 44, 51, 0.85);
    --ink: #e9edef;
    --ink-soft: #d1d7db;
    --muted: #8696a0;
    --muted-2: #667781;
    --line: #2a3942;
    --line-soft: #222d34;
    --sidebar: #111b21;
    --sidebar-soft: #202c33;
    --brand-50: rgba(0, 168, 132, 0.16);
    --brand-100: rgba(0, 168, 132, 0.26);
    --danger-soft: rgba(239, 68, 68, 0.16);
    --success-soft: rgba(0, 168, 132, 0.16);
    --warning-soft: rgba(245, 158, 11, 0.14);
    --info-soft: rgba(83, 189, 235, 0.14);
    --sh-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --sh-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --sh-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
    --sh-lg: 0 12px 28px -6px rgba(0, 0, 0, 0.5);
    --sh-xl: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
}
html[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: #2a3942;
    border-color: #3b4a54;
    color: var(--ink);
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: var(--muted); }
html[data-theme="dark"] .btn { background: #2a3942; border: 1px solid #3b4a54; color: var(--ink); }
html[data-theme="dark"] .btn:hover { background: #33434e; }
html[data-theme="dark"] .btn-primary { background: var(--brand-500); border-color: transparent; color: #fff; }
html[data-theme="dark"] .btn-primary:hover { background: var(--brand-400); }
html[data-theme="dark"] .btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
html[data-theme="dark"] .table { color: var(--ink-soft); }
html[data-theme="dark"] .empty { color: var(--muted); }
html[data-theme="dark"] .bubble-their { background: #202c33; color: #e9edef; }
html[data-theme="dark"] .bubble-their .bubble-sender { color: #53bdeb; }
html[data-theme="dark"] .bubble-their .bubble-text { color: #e9edef; }
html[data-theme="dark"] .bubble-their .bubble-caption { color: #d1d7db; }
html[data-theme="dark"] .bubble-mine { background: #005c4b; color: #e9edef; border-color: transparent; }
html[data-theme="dark"] .bubble-mine .bubble-text { color: #e9edef; }
html[data-theme="dark"] .bubble-mine .bubble-sender { color: #7fe3c0; }
html[data-theme="dark"] .bubble-mine .bubble-caption { color: rgba(233, 231, 223, 0.9); }
html[data-theme="dark"] .bubble-mine .bubble-meta { color: rgba(233, 231, 223, 0.6); }
html[data-theme="dark"] .bubble-mine .bubble-meta .status-icon.status-read { color: #53bdeb; }
html[data-theme="dark"] .bubble-mine .bubble-reply-preview { background: rgba(0,0,0,0.25); border-color: rgba(233,231,223,0.2); }
html[data-theme="dark"] .bubble-mine .bubble-reply-to { color: #7fe3c0; }
/* Bulle de localisation / contact : fond cohérent en sombre. */
html[data-theme="dark"] .bubble-location,
html[data-theme="dark"] .bubble-contact { background: rgba(0,0,0,0.2); }
html[data-theme="dark"] .chat-body {
    /* !important : le wallpaper LOCAL (inline JS V4.1) reste prioritaire en
       thème clair, mais le thème sombre WhatsApp impose son fond sombre
       (#0b141a) — sinon la crème claire transparaissait en dark. */
    background: #0b141a !important;
    background-image: none !important;
}
html[data-theme="dark"] .chat-body .bubble-their { background: #202c33; }
html[data-theme="dark"] .chat-header { background: #202c33; border-bottom-color: var(--line); }
html[data-theme="dark"] .chat-composer { background: #202c33; border-top-color: var(--line); }
html[data-theme="dark"] .composer-tool { background: rgba(0,0,0,0.25); color: var(--ink-soft); }
html[data-theme="dark"] #composer-input { background: #2a3942; border-color: #3b4a54; color: var(--ink); }
html[data-theme="dark"] .flash { border-color: var(--line); }
html[data-theme="dark"] .modal { background: #202c33; color: var(--ink); }
html[data-theme="dark"] .modal-header { border-bottom-color: var(--line); }
html[data-theme="dark"] .modal-footer { border-top-color: var(--line); }

/* ---------- 2b. Police / taille du texte (préférences utilisateur) ---------- */
html[data-font="segoe"] { --font-sans: 'Segoe UI', 'Helvetica Neue', system-ui, sans-serif; }
html[data-font="tahoma"] { --font-sans: Tahoma, 'Segoe UI', Arial, sans-serif; }
html[data-font="noto"]   { --font-sans: 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif; }
html[data-textsize="small"]  body { font-size: 13.5px; }
html[data-textsize="medium"] body { font-size: 14.5px; }
html[data-textsize="large"]  body { font-size: 16px; }
html[data-textsize="large"] .bubble-text { font-size: 15px; }
html[data-textsize="large"] .conv-preview,
html[data-textsize="large"] .conv-last { font-size: 13.5px; }
html[data-textsize="small"] .bubble-text { font-size: 13px; }

/* ---------- 3. Sidebar compacte (.app-shell--compact) + toggle ---------- */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    margin: 0 auto var(--sp-3);
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--sidebar-ink);
    cursor: pointer;
    transition: background var(--t) var(--ease);
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, 0.14); }
.sidebar-toggle .fas { font-size: 15px; }
/* Chaque item porte son icône (nav-label = texte, masqué en compact). */
.nav-item .fas, .nav-item .fab { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.app-shell--compact .sidebar { width: 76px; padding-inline: var(--sp-2); }
.app-shell--compact .brand-label,
.app-shell--compact .nav-label { display: none; }
.app-shell--compact .sidebar-brand { justify-content: center; padding-inline: 0; }
.app-shell--compact .nav-item {
    justify-content: center;
    padding-inline: 0;
    gap: 0;
}
.app-shell--compact .nav-item .nav-badge { display: none; }
.app-shell--compact .user-chip { flex-direction: column; gap: 4px; padding: 8px 0; }
.app-shell--compact .user-chip > div:last-child { display: none; }
.app-shell--compact .lang-switch { display: none; }
.app-shell--compact .sidebar-footer form .btn { font-size: 0; padding: 8px; }
.app-shell--compact .sidebar-footer form .btn::before {
    content: '\f52b';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 14px;
}
.app-shell--compact .sidebar-toggle .fas { transform: rotate(90deg); }

/* ---------- 4. Vue fusionnée WhatsApp Web (une seule page) ---------- */
/* body.chat-page : pleines largeur/hauteur pour la grid 2 panneaux. */
body.chat-page .app-main {
    max-width: none;
    padding: var(--sp-4) var(--sp-5);
    animation: none;
}
.chat-shell { min-width: 0; }
.chat-wrap, .chat-wrap.chat-wrap--room {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 0;
    height: calc(100vh - 74px);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--sh-sm);
}
/* Panneau gauche : liste WhatsApp (une seule fenêtre, bordure interne). */
.chat-wrap .conv-list-panel,
.chat-wrap.chat-wrap--room .conv-list-panel {
    border: none;
    border-inline-end: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    min-height: 0;
}
/* Panneau droit : room (plus de cadre interne — la fenêtre globale l'a). */
.chat-room-col { display: flex; min-width: 0; min-height: 0; }
.chat-wrap.chat-wrap--room .chat-room-panel {
    border: none;
    border-radius: 0;
    box-shadow: none;
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
}
.chat-back-btn { display: none; } /* desktop : inutile (liste visible) */

/* Mobile (<980px) : UN seul panneau à la fois, comme l'app WhatsApp. */
@media (max-width: 980px) {
    .chat-wrap, .chat-wrap.chat-wrap--room {
        grid-template-columns: 1fr;
        height: auto;
        min-height: calc(100vh - 130px);
    }
    /* Liste ouverte sans room → panneau droit masqué. */
    .chat-wrap:not(.chat-wrap--room) .chat-room-col { display: none; }
    /* Room ouverte → liste masquée + bouton retour visible. */
    .chat-wrap.chat-wrap--room .conv-list-panel { display: none; }
    .chat-wrap.chat-wrap--room .chat-room-panel { min-height: calc(100vh - 130px); }
    .chat-back-btn { display: inline-flex; }
    body.chat-page .app-main { padding: var(--sp-3); }
}

/* Écran d'accueil WhatsApp (aucune conversation ouverte). */
.chat-empty-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 80%, rgba(0,168,132,0.04) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0,168,132,0.05) 0%, transparent 50%),
        #efeae2;
    border-inline-start: 1px solid var(--line);
    min-height: 320px;
}
html[data-theme="dark"] .chat-empty-panel { background: #0b141a; }
.chat-empty-hero { text-align: center; max-width: 420px; padding: var(--sp-6); }
.chat-empty-hero h2 { margin: var(--sp-3) 0 var(--sp-2); font-size: 1.6rem; }
.chat-empty-hero p { margin: 0; }
.chat-empty-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 92px; height: 92px;
    border-radius: 50%;
    background: var(--brand-500);
    color: #fff;
    box-shadow: var(--sh-brand);
}
.chat-empty-logo .fab { font-size: 3rem; }
.chat-empty-divider {
    height: 1px;
    width: 180px;
    margin: var(--sp-5) auto;
    background: linear-gradient(to right, transparent, var(--brand-500), transparent);
    opacity: 0.4;
}

/* ---------- 5. Lignes de liste compactes façon WhatsApp ---------- */
.conv-list-header { padding: var(--sp-3) var(--sp-3) var(--sp-2); }
.conv-list-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-list-title h2 { font-size: 1.05rem; font-weight: 800; margin: 0 0 2px; }
.conv-list-title #realtime-indicator { font-size: 11px; }
.conv-search { margin-top: var(--sp-2); }
.conv-search input { width: 100%; border-radius: var(--r-pill); }
.session-tabs-vertical {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: var(--sp-2);
}
.session-tabs-vertical .session-tab-h {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    font-size: 13px;
}
.session-tabs-vertical .session-tab-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.page-viewers-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 12px;
    min-height: 30px;
    overflow: hidden;
}
.page-viewers-strip .fas { color: var(--muted-2); font-size: 11px; }
.page-viewers-strip .page-viewers-list {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    overflow: hidden;
    flex: 1;
}
/* Table devenue liste : zéro bordures, zéro padding de cellule. */
.table.table-conv { border: none; }
.table-conv td, .table-conv .conv-row-cell { border: none; padding: 0; }
.conv-row-cell { position: relative; }
.conv-row-cell .conv-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 10px 14px 10px 12px;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid var(--line-soft);
    transition: background var(--t) var(--ease);
    position: relative;
    min-height: 64px;
}
.conv-row-cell .conv-item:hover { background: var(--bg-soft); text-decoration: none; }
.conv-row-cell .conv-item.active { background: var(--brand-50); }
.conv-row-cell .conv-item.active::before {
    content: '';
    position: absolute;
    inset-inline-start: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--brand-500);
}
.conv-row-cell .conv-avatar-wrap { flex-shrink: 0; }
.conv-row-cell .conv-avatar { position: relative; display: inline-flex; }
.conv-row-cell .conv-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-row-cell .conv-name {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
}
.conv-row-cell .conv-name-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
}
.conv-row-cell .conv-name-text .link-strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
    text-decoration: none;
}
.conv-type-icon { color: var(--muted-2); font-size: 12px; }
.conv-account-badge { font-size: 10px; padding: 1px 6px; }
.conv-time { font-size: 11.5px; flex-shrink: 0; }
.conv-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}
.conv-preview .preview-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.conv-preview .conv-unread-badge {
    background: var(--brand-500);
    color: #fff;
    border-radius: var(--r-pill);
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.unread-cell[hidden] { display: none; }
.conv-phone { font-size: 12px; }
/* Corbeille (encadrement) : apparaît au survol, hors du lien. */
.conv-row-cell .conv-delete-form { position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); opacity: 0; transition: opacity var(--t) var(--ease); margin: 0; }
.conv-row-cell:hover .conv-delete-form,
.conv-row-cell:focus-within .conv-delete-form { opacity: 1; }
.conv-list-footer {
    border-top: 1px solid var(--line-soft);
    padding: 4px 8px;
    background: var(--panel);
}
.conv-list-footer nav { font-size: 12px; margin: 0; }
.row-unread .conv-name .link-strong { font-weight: 800; }

/* Mini-cartes Leaflet des bulles de localisation (CARTO/Esri — V5.6.4). */
.bubble-location { min-width: 220px; }
.bubble-location .mini-map { z-index: 0; }
.bubble-location .mini-map .leaflet-container { z-index: 0; }
.bubble-location .mini-map .leaflet-control-attribution { font-size: 9px; background: rgba(255,255,255,0.7); }

/* Loading shimmer de la liste (attente réseau perçue comme fluide). */
.conv-list { scrollbar-width: thin; }
.conv-list::-webkit-scrollbar { width: 6px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--muted-2); border-radius: 3px; }
.table.table-conv {
    width: 405px !important;
    max-width: 405px !important;
    table-layout: fixed !important;
}

.conversation-list {
    width: 405px !important;
    max-width: 405px !important;
    min-width: 0 !important;
}
/* =========================================================================
   V5.6.4.1 — COUCHE « WHATSAPP 100 % » + LAZY LOADING (additive, fin de
   fichier = priorité).Demandes client : conversations identiques à
   WhatsApp Web, loader entre conversations, wallpaper doodle, chips de
   jour, méta flottante dans les bulles, composer/header/liste WhatsApp.
   Thème sombre = palette officielle WhatsApp (#0b141a/#202c33/#005c4b).
   ========================================================================= */

/* ---------- 0. Loader d'ouverture paresseuse ---------- */
.chat-room-col { position: relative; }
.room-lazy-overlay {
    position: absolute; inset: 0; z-index: 40;
    background: var(--panel);
    display: flex; align-items: center; justify-content: center;
}
.room-lazy-box { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.room-lazy-dots { display: inline-flex; gap: 7px; }
.room-lazy-dots i {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--brand-500);
    opacity: .35; transform: scale(.6);
    animation: room-lazy-b 1.15s infinite ease-in-out;
}
.room-lazy-dots i:nth-child(2) { animation-delay: .16s; }
.room-lazy-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes room-lazy-b { 40% { opacity: 1; transform: scale(1); } }
.room-lazy-text { font-size: 13px; color: #667781; }
html[data-theme="dark"] .room-lazy-text { color: #8696a0; }

/* ---------- 1. Wallpaper doodle WhatsApp ---------- */
.chat-body {
    background: var(--wa-paper, #efeae2);
    background-image: var(--wa-doodle);
    background-size: 280px 280px;
    gap: 2px;
    padding: 18px 6% 10px;
}
:root {
    --wa-doodle: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='280'%20height='280'%20viewBox='0%200%20280%20280'%3E%0A%3Cg%20fill='none'%20stroke='%2523ffffff'%20stroke-width='1.6'%20stroke-linecap='round'%20opacity='0.42'%3E%0A%3Ccircle%20cx='24'%20cy='26'%20r='7'/%3E%0A%3Cpath%20d='M62%2018c3-5%209-5%2012%200c3-5%209-5%2012%200c0%206-12%2012-12%2012S62%2024%2062%2018z'/%3E%0A%3Crect%20x='112'%20y='14'%20width='20'%20height='14'%20rx='3'/%3E%0A%3Cpath%20d='M158%2016l3%206h-6z'/%3E%0A%3Ccircle%20cx='196'%20cy='22'%20r='4'/%3E%0A%3Cpath%20d='M228%2014v14M221%2021h14'/%3E%0A%3Cpath%20d='M20%2076q9-11%2018%200t18%200'/%3E%0A%3Ccircle%20cx='96'%20cy='74'%20r='8'/%3E%3Ccircle%20cx='93'%20cy='72'%20r='1.2'%20fill='%2523ffffff'/%3E%3Ccircle%20cx='99'%20cy='72'%20r='1.2'%20fill='%2523ffffff'/%3E%3Cpath%20d='M92%2077q4%204%208%200'/%3E%0A%3Cpath%20d='M136%2070h14v10h-14z'/%3E%0A%3Cpath%20d='M170%2072q4-6%208%200t8%200'/%3E%0A%3Cpath%20d='M214%2066c2-4%207-4%209%200c2-4%207-4%209%200c0%205-9%2010-9%2010S214%2071%20214%2066z'/%3E%0A%3Cpath%20d='M252%2072l2%205%205%201-4%204%201%205-4-3-4%203%201-5-4-4%205-1z'/%3E%0A%3Ccircle%20cx='28'%20cy='132'%20r='5'/%3E%0A%3Cpath%20d='M60%20126l7%207-7%207-7-7z'/%3E%0A%3Cpath%20d='M100%20124v16M92%20132h16'/%3E%0A%3Crect%20x='136'%20y='122'%20width='16'%20height='12'%20rx='2'/%3E%3Cpath%20d='M140%20122v-4h8v4'/%3E%0A%3Cpath%20d='M176%20128q5-8%2010%200t10%200'/%3E%0A%3Cpath%20d='M218%20122c3-5%208-5%2011%200c3-5%208-5%2011%200c0%206-11%2012-11%2012S218%20128%20218%20122z'/%3E%0A%3Ccircle%20cx='258'%20cy='130'%20r='6'/%3E%0A%3Cpath%20d='M26%20184q8-10%2016%200t16%200'/%3E%0A%3Cpath%20d='M92%20176c4-6%2011-6%2015%200c4-6%2011-6%2015%200c0%208-15%2016-15%2016S92%20184%2092%20176z'/%3E%0A%3Crect%20x='148'%20y='174'%20width='14'%20height='14'%20rx='4'/%3E%0A%3Cpath%20d='M188%20178h12v10h-12z'/%3E%0A%3Ccircle%20cx='230'%20cy='182'%20r='7'/%3E%3Ccircle%20cx='227'%20cy='180'%20r='1.2'%20fill='%2523ffffff'/%3E%3Ccircle%20cx='233'%20cy='180'%20r='1.2'%20fill='%2523ffffff'/%3E%3Cpath%20d='M226%20185q4%203%208%200'/%3E%0A%3Cpath%20d='M14%20236l2%205%205%201-4%204%201%205-4-3-4%203%201-5-4-4%205-1z'/%3E%0A%3Ccircle%20cx='66'%20cy='232'%20r='6'/%3E%0A%3Cpath%20d='M104%20228v14M97%20235h14'/%3E%0A%3Cpath%20d='M140%20230h16v8h-16z'/%3E%0A%3Cpath%20d='M182%20228q5-7%2010%200t10%200'/%3E%0A%3Cpath%20d='M226%20222c4-6%2011-6%2015%200c4-6%2011-6%2015%200c0%208-15%2016-15%2016S226%20228%20226%20222z'/%3E%0A%3C/g%3E%3C/svg%3E");
    --wa-paper: #efeae2;
}
html[data-theme="dark"] {
    --wa-doodle: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='280'%20height='280'%20viewBox='0%200%20280%20280'%3E%0A%3Cg%20fill='none'%20stroke='%2523ffffff'%20stroke-width='1.6'%20stroke-linecap='round'%20opacity='0.05'%3E%0A%3Ccircle%20cx='24'%20cy='26'%20r='7'/%3E%0A%3Cpath%20d='M62%2018c3-5%209-5%2012%200c3-5%209-5%2012%200c0%206-12%2012-12%2012S62%2024%2062%2018z'/%3E%0A%3Crect%20x='112'%20y='14'%20width='20'%20height='14'%20rx='3'/%3E%0A%3Cpath%20d='M158%2016l3%206h-6z'/%3E%0A%3Ccircle%20cx='196'%20cy='22'%20r='4'/%3E%0A%3Cpath%20d='M228%2014v14M221%2021h14'/%3E%0A%3Cpath%20d='M20%2076q9-11%2018%200t18%200'/%3E%0A%3Ccircle%20cx='96'%20cy='74'%20r='8'/%3E%3Ccircle%20cx='93'%20cy='72'%20r='1.2'%20fill='%2523ffffff'/%3E%3Ccircle%20cx='99'%20cy='72'%20r='1.2'%20fill='%2523ffffff'/%3E%3Cpath%20d='M92%2077q4%204%208%200'/%3E%0A%3Cpath%20d='M136%2070h14v10h-14z'/%3E%0A%3Cpath%20d='M170%2072q4-6%208%200t8%200'/%3E%0A%3Cpath%20d='M214%2066c2-4%207-4%209%200c2-4%207-4%209%200c0%205-9%2010-9%2010S214%2071%20214%2066z'/%3E%0A%3Cpath%20d='M252%2072l2%205%205%201-4%204%201%205-4-3-4%203%201-5-4-4%205-1z'/%3E%0A%3Ccircle%20cx='28'%20cy='132'%20r='5'/%3E%0A%3Cpath%20d='M60%20126l7%207-7%207-7-7z'/%3E%0A%3Cpath%20d='M100%20124v16M92%20132h16'/%3E%0A%3Crect%20x='136'%20y='122'%20width='16'%20height='12'%20rx='2'/%3E%3Cpath%20d='M140%20122v-4h8v4'/%3E%0A%3Cpath%20d='M176%20128q5-8%2010%200t10%200'/%3E%0A%3Cpath%20d='M218%20122c3-5%208-5%2011%200c3-5%208-5%2011%200c0%206-11%2012-11%2012S218%20128%20218%20122z'/%3E%0A%3Ccircle%20cx='258'%20cy='130'%20r='6'/%3E%0A%3Cpath%20d='M26%20184q8-10%2016%200t16%200'/%3E%0A%3Cpath%20d='M92%20176c4-6%2011-6%2015%200c4-6%2011-6%2015%200c0%208-15%2016-15%2016S92%20184%2092%20176z'/%3E%0A%3Crect%20x='148'%20y='174'%20width='14'%20height='14'%20rx='4'/%3E%0A%3Cpath%20d='M188%20178h12v10h-12z'/%3E%0A%3Ccircle%20cx='230'%20cy='182'%20r='7'/%3E%3Ccircle%20cx='227'%20cy='180'%20r='1.2'%20fill='%2523ffffff'/%3E%3Ccircle%20cx='233'%20cy='180'%20r='1.2'%20fill='%2523ffffff'/%3E%3Cpath%20d='M226%20185q4%203%208%200'/%3E%0A%3Cpath%20d='M14%20236l2%205%205%201-4%204%201%205-4-3-4%203%201-5-4-4%205-1z'/%3E%0A%3Ccircle%20cx='66'%20cy='232'%20r='6'/%3E%0A%3Cpath%20d='M104%20228v14M97%20235h14'/%3E%0A%3Cpath%20d='M140%20230h16v8h-16z'/%3E%0A%3Cpath%20d='M182%20228q5-7%2010%200t10%200'/%3E%0A%3Cpath%20d='M226%20222c4-6%2011-6%2015%200c4-6%2011-6%2015%200c0%208-15%2016-15%2016S226%20228%20226%20222z'/%3E%0A%3C/g%3E%3C/svg%3E");
    --wa-paper: #0b141a;
}

/* ---------- 2. Chips de jour (miroir JS/serveur : d/m/Y) ---------- */
.chat-day-sep {
    align-self: center;
    display: flex; justify-content: center;
    margin: 14px 0 6px;
    flex: 0 0 auto; width: 100%;
}
.chat-day-sep span {
    background: #ffffff;
    color: #54656f;
    font-size: 12.5px; font-weight: 500;
    padding: 6px 12px; border-radius: 8px;
    box-shadow: 0 1px .5px rgba(11, 20, 26, .18);
}
html[data-theme="dark"] .chat-day-sep span { background: #182229; color: #ffd279; }

/* ---------- 3. Bulles WhatsApp (sans bord, méta flottante) ---------- */
.bubble {
    border: none;
    border-radius: 8px;
    padding: 6px 9px 20px;
    box-shadow: 0 1px .5px rgba(11, 20, 26, .18);
    min-width: 0;
    max-width: 100%;
}
.bubble-their { background: #ffffff; border-start-start-radius: 2px; }
.bubble-mine {
    background: #d9fdd3;
    border: none;
    border-start-end-radius: 2px;
    box-shadow: 0 1px .5px rgba(11, 20, 26, .18);
}
.bubble-text { font-size: 14.2px; line-height: 1.42; }
.bubble-meta {
    position: absolute;
    inset-inline-end: 9px;
    bottom: 4px;
    margin: 0;
    display: flex; align-items: center; gap: 3px;
    font-size: 11px;
    color: rgba(84, 101, 112, .9);
    text-shadow: 0 0 5px rgba(255, 255, 255, .95), 0 0 3px rgba(255, 255, 255, .95);
    pointer-events: none;
    white-space: nowrap;
}
.bubble-mine .bubble-meta {
    color: rgba(17, 27, 33, .55);
    text-shadow: 0 0 5px rgba(217, 253, 211, .95), 0 0 3px rgba(217, 253, 211, .95);
}
.bubble-mine .bubble-meta .status-icon.status-read { color: #53bdeb; text-shadow: none; }
.bubble-their .bubble-media { margin-bottom: 8px; }
.bubble-row { margin-bottom: 3px; max-width: 78%; }
.bubble-audio audio { width: 252px; }
.bubble-ptt { gap: 6px; }
.bubble-ptt .fas { color: #54656f; font-size: 15px; }
.bubble-unread { box-shadow: 0 0 0 2px rgba(0, 168, 132, .35), 0 1px .5px rgba(11,20,26,.18); }
.bubble-sender { font-size: 12.5px; font-weight: 700; margin-bottom: 1px; }
.bubble-reply-preview { border-inline-start-width: 3px; }

/* Bulles réponse/réactions/forward sur fond WhatsApp */
.bubble-their .bubble-reply-preview { background: rgba(225, 245, 254, .9); border-color: #95b8c9; }
.bubble-mine .bubble-reply-preview { background: rgba(0, 92, 75, .12); border-color: #06cf9c; }
.bubble-their .bubble-reactions .reaction-chip { background: #ffffff; }
html[data-theme="dark"] .bubble-their .bubble-reactions .reaction-chip { background: #2a3942; }

/* ---------- 4. Thème sombre — bulles officielles ---------- */
html[data-theme="dark"] .bubble { box-shadow: none; }
html[data-theme="dark"] .bubble-their { background: #202c33; color: #e9edef; }
html[data-theme="dark"] .bubble-mine { background: #005c4b; color: #e9edef; }
html[data-theme="dark"] .bubble-mine .bubble-text { color: #e9edef; }
html[data-theme="dark"] .bubble-mine .bubble-caption { color: rgba(233, 237, 239, .92); }
html[data-theme="dark"] .bubble-mine .bubble-meta { color: rgba(233, 237, 239, .6); text-shadow: 0 0 5px rgba(0, 92, 75, .95); }
html[data-theme="dark"] .bubble-their .bubble-meta { color: rgba(233, 237, 239, .6); text-shadow: 0 0 5px rgba(32, 44, 51, .95); }
html[data-theme="dark"] .bubble-mine .bubble-author { color: rgba(233, 237, 239, .7); }
html[data-theme="dark"] .bubble-ptt .fas { color: #8696a0; }

/* ---------- 5. En-tête de conversation WhatsApp ---------- */
.chat-header {
    background: #f0f2f5;
    border-bottom: 1px solid #e9edef;
    min-height: 60px;
    padding: 8px 16px;
    gap: 14px;
}
html[data-theme="dark"] .chat-header { background: #202c33; border-color: #111b21; }
.chat-header-info strong { font-size: 16px; font-weight: 600; }
.chat-header-info .muted { font-size: 13px; color: #667781; }
html[data-theme="dark"] .chat-header-info .muted { color: #8696a0; }
.chat-header { color: #111b21; }
html[data-theme="dark"] .chat-header { color: #e9edef; }

/* ---------- 6. Composer WhatsApp ---------- */
.chat-composer {
    background: #f0f2f5;
    border-top: 1px solid #e9edef;
    padding: 8px 16px;
    gap: 6px;
}
html[data-theme="dark"] .chat-composer { background: #202c33; border-color: #111b21; }
.composer-main textarea#composer-input,
.composer-main input[type="text"] {
    background: #ffffff;
    border: none;
    border-radius: 21px;
    padding: 10px 20px;
    font-size: 15px;
    color: #111b21;
    box-shadow: none;
    min-height: 42px;
}
.composer-main textarea#composer-input:focus,
.composer-main input:focus {
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(0, 168, 132, .35);
}
html[data-theme="dark"] .composer-main textarea#composer-input,
html[data-theme="dark"] .composer-main input[type="text"] {
    background: #2a3942; color: #e9edef;
    border: 1px solid #2a3942;
}
html[data-theme="dark"] .composer-main textarea#composer-input::placeholder { color: #8696a0; }
.composer-tool { color: #54656f; }
.composer-tool:hover { background: rgba(0, 0, 0, .06); color: #111b21; transform: none; }
html[data-theme="dark"] .composer-tool { color: #8696a0; }
html[data-theme="dark"] .composer-tool:hover { background: rgba(255, 255, 255, .08); color: #e9edef; }
#composer-send {
    background: var(--brand-500);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 42px; height: 42px;
    flex: 0 0 42px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
#composer-send:hover { background: var(--brand-600); transform: none; }
.composer-session-select { border-radius: var(--r-pill); border: none; background: rgba(0, 0, 0, .05); }

/* ---------- 7. Liste de conversations WhatsApp ---------- */
.conv-item { padding: 9px 14px; border-bottom: none; }
.conv-item:hover { background: #f5f6f6; }
.conv-item.active { background: #f0f2f5; }
.conv-item.active::before { display: none; }
html[data-theme="dark"] .conv-item:hover { background: #111b21; }
html[data-theme="dark"] .conv-item.active { background: #2a3942; }
.conv-name { font-size: 16px; }
.conv-name .conv-time { font-size: 12px; color: #667781; font-weight: 400; }
html[data-theme="dark"] .conv-name .conv-time { color: #8696a0; }
.conv-preview { font-size: 13.5px; color: #667781; }
html[data-theme="dark"] .conv-preview { color: #8696a0; }
.conv-unread-badge { background: var(--brand-500); }
.unread-dot { background: var(--brand-500); border-color: var(--panel); box-shadow: none; animation: none; }
.conv-avatar, .conv-avatar img { border-radius: 50%; object-fit: cover; }
.conv-list-header { background: var(--brand-500); }
html[data-theme="dark"] .conv-list-header { background: #202c33; }

/* ---------- 8. Scrollbars fins (WhatsApp Web) ---------- */
.chat-body, .conv-list, .chat-shell {
    scrollbar-width: thin;
    scrollbar-color: rgba(134, 150, 160, .35) transparent;
}
html[data-theme="dark"] .chat-body,
html[data-theme="dark"] .conv-list {
    scrollbar-color: rgba(134, 150, 160, .25) transparent;
}
.chat-body::-webkit-scrollbar, .conv-list::-webkit-scrollbar { width: 6px; height: 6px; }
.chat-body::-webkit-scrollbar-track, .conv-list::-webkit-scrollbar-track { background: transparent; }
.chat-body::-webkit-scrollbar-thumb, .conv-list::-webkit-scrollbar-thumb {
    background: rgba(134, 150, 160, .4);
    border-radius: 3px;
}
html[data-theme="dark"] .page-viewer-chip,
html[data-theme="dark"] .chat-body::-webkit-scrollbar-thumb,
html[data-theme="dark"] .conv-list::-webkit-scrollbar-thumb { background: rgba(134, 150, 160, .25); }

/* ---------- 9. Ptt / audio : lecture fluide (correctif V5.6.4.1) ---------- */
.bubble-audio audio { display: block; }
.bubble-audio audio::-webkit-media-controls-panel { background: transparent; }
.chat-pagination{ display: grid; text-align: center; }