/* =========================================================================
   WHATSAPP SAAS — 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); }

@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;
}
