/* ============================================================================
   admin-clients-v9.css
   Refonte premium onglet Admin Clients — mobile-first, glass v9
   Design: Linear / Stripe Dashboard / Notion B2B
   Brand: Suisse rouge #DC2626, fonts Inter / JetBrains Mono / Instrument Serif
   ============================================================================ */

/* ─── Tokens locaux ─── */
.ec-clients-shell {
    --ecx-red: #DC2626;
    --ecx-red-soft: rgba(220, 38, 38, 0.14);
    --ecx-red-ring: rgba(220, 38, 38, 0.32);
    --ecx-red-grad: linear-gradient(135deg, #ef4444 0%, #DC2626 50%, #b91c1c 100%);
    --ecx-amber: #f59e0b;
    --ecx-violet: #8b5cf6;
    --ecx-emerald: #10b981;
    --ecx-slate: #64748b;
    --ecx-glass: rgba(15, 23, 42, 0.65);
    --ecx-glass-2: rgba(20, 28, 48, 0.55);
    --ecx-border: rgba(255, 255, 255, 0.08);
    --ecx-border-strong: rgba(255, 255, 255, 0.14);
    --ecx-text: #e6e8ee;
    --ecx-text-2: #a4adbe;
    --ecx-text-3: #6b748a;
    --ecx-radius: 14px;
    --ecx-radius-sm: 10px;
    --ecx-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px -8px rgba(0,0,0,0.45);
    --ecx-shadow-lg: 0 1px 0 rgba(255,255,255,0.06) inset, 0 18px 48px -12px rgba(0,0,0,0.6);
}

/* ============================================================================
   1. SHELL CONTAINER
   ============================================================================ */
.ec-clients-shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: var(--ecx-text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ============================================================================
   2. HEADER (titre + count + export)
   ============================================================================ */
.ec-clients-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 4px 2px 0;
}
.ec-clients-head__title {
    margin: 0;
    padding: 0;
    border: 0 !important;
    font-family: 'Instrument Serif', 'Inter', serif;
    font-weight: 500;
    font-size: clamp(1.6rem, 2.5vw, 2.2rem);
    line-height: 1.1;
    letter-spacing: -0.01em;
    background: linear-gradient(180deg, #fff 0%, #d6dae4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.ec-clients-head__sub {
    margin: 4px 0 0;
    color: var(--ecx-text-2);
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}
.ec-clients-head__sub strong {
    color: var(--ecx-text);
    font-weight: 600;
}
.ec-clients-head__sub b.live-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ecx-red);
    font-weight: 600;
}
.ec-clients-head__sub b.live-dot::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ecx-red);
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6);
    animation: ecx-pulse 1.8s infinite;
}
@keyframes ecx-pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}
.ec-clients-head__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================================================
   3. TOOLBAR / FILTRES
   ============================================================================ */
.ec-clients-toolbar {
    background: var(--ecx-glass);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border: 1px solid var(--ecx-border);
    border-radius: var(--ecx-radius);
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 10px;
    align-items: center;
    box-shadow: var(--ecx-shadow);
    position: sticky;
    top: 12px;
    z-index: 5;
}
.ec-clients-search {
    position: relative;
    display: flex;
    align-items: center;
}
.ec-clients-search__icon {
    position: absolute;
    left: 16px;
    color: var(--ecx-text-3);
    font-size: 0.95rem;
    pointer-events: none;
    line-height: 1;
}
.ec-clients-search input {
    width: 100%;
    height: 44px;
    padding: 0 40px 0 46px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--ecx-border);
    border-radius: var(--ecx-radius-sm);
    color: var(--ecx-text);
    font-size: 16px; /* iOS no-zoom */
    font-family: inherit;
    transition: border-color .18s, box-shadow .18s, background .18s;
}
.ec-clients-search input::placeholder { color: var(--ecx-text-3); }
.ec-clients-search input:focus {
    outline: none;
    border-color: var(--ecx-red-ring);
    background: rgba(220, 38, 38, 0.04);
    box-shadow: 0 0 0 3px var(--ecx-red-soft);
}
.ec-clients-search__clear {
    position: absolute;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 0;
    background: transparent;
    color: var(--ecx-text-3);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.ec-clients-search__clear:hover { background: rgba(255,255,255,0.05); color: var(--ecx-text); }
.ec-clients-search.has-value .ec-clients-search__clear { display: inline-flex; }

.ec-clients-select {
    position: relative;
}
.ec-clients-select select {
    appearance: none;
    -webkit-appearance: none;
    height: 44px;
    padding: 0 36px 0 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--ecx-border);
    border-radius: var(--ecx-radius-sm);
    color: var(--ecx-text);
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    min-width: 160px;
    transition: border-color .18s, box-shadow .18s;
}
.ec-clients-select select:focus {
    outline: none;
    border-color: var(--ecx-red-ring);
    box-shadow: 0 0 0 3px var(--ecx-red-soft);
}
.ec-clients-select::after {
    content: "\f078";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--ecx-text-3);
    font-size: 0.7rem;
}

.ec-clients-toolbar__btn {
    height: 44px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--ecx-border);
    border-radius: var(--ecx-radius-sm);
    color: var(--ecx-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
    font-family: inherit;
}
.ec-clients-toolbar__btn:hover {
    background: rgba(220, 38, 38, 0.08);
    border-color: var(--ecx-red-ring);
    color: #fff;
}
.ec-clients-toolbar__btn--primary {
    background: var(--ecx-red-grad);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 14px -4px rgba(220, 38, 38, 0.5);
}
.ec-clients-toolbar__btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px -4px rgba(220, 38, 38, 0.65);
    color: #fff;
}

/* Bulk-actions bar (apparait quand selection > 0) */
.ec-clients-bulkbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.12), rgba(220, 38, 38, 0.04));
    border: 1px solid var(--ecx-red-ring);
    border-radius: var(--ecx-radius-sm);
    color: var(--ecx-text);
    font-size: 0.85rem;
    flex-wrap: wrap;
    animation: ecx-slide-down .25s ease both;
}
.ec-clients-bulkbar__count {
    font-weight: 700;
    color: var(--ecx-red);
    font-variant-numeric: tabular-nums;
    font-family: 'JetBrains Mono', monospace;
}
@keyframes ecx-slide-down {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   4. TABLE DESKTOP
   ============================================================================ */
.ec-clients-table-wrap {
    background: var(--ecx-glass);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border: 1px solid var(--ecx-border);
    border-radius: var(--ecx-radius);
    overflow: hidden;
    box-shadow: var(--ecx-shadow);
}
.ec-clients-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.ec-clients-table thead {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--ecx-border);
}
.ec-clients-table th {
    padding: 12px 14px;
    text-align: left;
    color: var(--ecx-text-2);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    user-select: none;
}
.ec-clients-table th.sortable { cursor: pointer; transition: color .15s; }
.ec-clients-table th.sortable:hover { color: #fff; }
.ec-clients-table th .sort-arrow {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.65rem;
    opacity: 0.6;
}
.ec-clients-table th.sorted-asc .sort-arrow,
.ec-clients-table th.sorted-desc .sort-arrow {
    color: var(--ecx-red);
    opacity: 1;
}
.ec-clients-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background .15s;
    cursor: default;
}
.ec-clients-table tbody tr:last-child { border-bottom: 0; }
.ec-clients-table tbody tr:hover { background: rgba(220, 38, 38, 0.04); }
.ec-clients-table tbody tr.is-selected { background: rgba(220, 38, 38, 0.07); }
.ec-clients-table td {
    padding: 14px;
    vertical-align: middle;
    color: var(--ecx-text);
}
.ec-clients-table td.col-checkbox { width: 36px; padding-right: 0; }
.ec-clients-table td.col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

/* Avatar */
.ec-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
    transition: transform .2s;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 2px 6px -2px rgba(0,0,0,0.3);
}
.ec-clients-table tbody tr:hover .ec-avatar { transform: scale(1.05); }

/* Nom + email cell */
.ec-cell-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
}
.ec-cell-identity__txt { display: flex; flex-direction: column; min-width: 0; }
.ec-cell-identity__email {
    font-weight: 600;
    color: var(--ecx-text);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}
.ec-cell-identity__name {
    font-size: 0.78rem;
    color: var(--ecx-text-2);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}
.ec-cell-company {
    font-size: 0.85rem;
    color: var(--ecx-text);
}
.ec-cell-company__meta {
    font-size: 0.75rem;
    color: var(--ecx-text-3);
    margin-top: 2px;
}

/* Pills */
.ec-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
    border: 1px solid;
}
.ec-pill--active   { background: rgba(220, 38, 38, 0.12); border-color: rgba(220, 38, 38, 0.35); color: #fca5a5; }
.ec-pill--trial    { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.35); color: #fcd34d; }
.ec-pill--inactive { background: rgba(100, 116, 139, 0.14); border-color: rgba(100, 116, 139, 0.32); color: #94a3b8; }
.ec-pill--new      { background: rgba(139, 92, 246, 0.14); border-color: rgba(139, 92, 246, 0.35); color: #c4b5fd; }
.ec-pill--success  { background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.32); color: #6ee7b7; }
.ec-pill--danger   { background: rgba(220, 38, 38, 0.14); border-color: rgba(220, 38, 38, 0.4); color: #fca5a5; }
.ec-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.ec-pill--no-dot::before { display: none; }

/* MRR cell */
.ec-cell-mrr {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--ecx-text);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}
.ec-cell-mrr small {
    color: var(--ecx-text-3);
    font-weight: 400;
    margin-left: 4px;
}
.ec-cell-mrr--zero { color: var(--ecx-text-3); }

/* Date cell */
.ec-cell-date {
    color: var(--ecx-text-2);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Action buttons */
.ec-btn-detail {
    height: 32px;
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--ecx-border);
    border-radius: 8px;
    color: var(--ecx-text);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .15s;
    font-family: inherit;
    text-decoration: none;
    min-height: 32px;
}
.ec-btn-detail:hover {
    background: var(--ecx-red-grad);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px -4px rgba(220, 38, 38, 0.5);
}
.ec-btn-kebab {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 0;
    color: var(--ecx-text-2);
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, color .15s;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}
.ec-btn-kebab:hover {
    background: rgba(255,255,255,0.06);
    color: var(--ecx-text);
}

/* Checkbox */
.ec-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    border: 1.5px solid var(--ecx-border-strong);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    position: relative;
    transition: all .15s;
    margin: 0;
    flex-shrink: 0;
}
.ec-checkbox:hover { border-color: var(--ecx-red-ring); }
.ec-checkbox:checked {
    background: var(--ecx-red);
    border-color: var(--ecx-red);
}
.ec-checkbox:checked::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    inset: 0;
    color: #fff;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ec-checkbox:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ecx-red-soft);
}

/* ============================================================================
   5. PAGINATION
   ============================================================================ */
.ec-clients-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-top: 1px solid var(--ecx-border);
    background: rgba(255, 255, 255, 0.015);
    color: var(--ecx-text-2);
    font-size: 0.82rem;
    flex-wrap: wrap;
    gap: 12px;
}
.ec-clients-foot__pager {
    display: flex;
    gap: 6px;
    align-items: center;
}
.ec-clients-foot__pager button {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    background: transparent;
    border: 1px solid var(--ecx-border);
    border-radius: 8px;
    color: var(--ecx-text);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all .15s;
    font-family: 'JetBrains Mono', monospace;
}
.ec-clients-foot__pager button:hover:not(:disabled) {
    border-color: var(--ecx-red-ring);
    color: var(--ecx-red);
}
.ec-clients-foot__pager button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.ec-clients-foot__pager button.is-current {
    background: var(--ecx-red-grad);
    border-color: transparent;
    color: #fff;
    font-weight: 700;
}

/* ============================================================================
   6. EMPTY STATE
   ============================================================================ */
.ec-clients-empty {
    padding: 80px 24px;
    text-align: center;
    color: var(--ecx-text-2);
}
.ec-clients-empty__icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.08), rgba(220, 38, 38, 0.02));
    border: 1px solid var(--ecx-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--ecx-red);
}
.ec-clients-empty__title {
    color: var(--ecx-text);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 8px;
    font-family: 'Instrument Serif', serif;
}
.ec-clients-empty__sub {
    margin: 0 0 20px;
    font-size: 0.9rem;
    color: var(--ecx-text-3);
}

/* ============================================================================
   7. SKELETON LOADERS
   ============================================================================ */
.ec-skel-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-bottom: 1px solid var(--ecx-border);
}
.ec-skel-row:last-child { border-bottom: 0; }
.ec-skel {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 100%);
    background-size: 200% 100%;
    animation: ecx-shimmer 1.5s infinite linear;
    border-radius: 6px;
    height: 14px;
}
.ec-skel-circle { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.ec-skel-line-1 { flex: 1; height: 12px; }
.ec-skel-line-2 { flex: 0.6; height: 12px; }
.ec-skel-pill { width: 60px; height: 22px; border-radius: 999px; }
.ec-skel-btn { width: 70px; height: 30px; border-radius: 8px; }
@keyframes ecx-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================================
   8. DRAWER CLIENT DETAIL
   ============================================================================ */
/* MODAL CENTRÉE (était drawer slide-right). Overlay et drawer sont siblings : on centre le drawer en position fixed top/left 50% + translate. */
.ec-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 16, 0.62);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}
.ec-drawer-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}
.ec-drawer {
    position: fixed;
    top: 50%;
    left: 50%;
    width: min(960px, calc(100vw - 48px));
    min-height: min(60vh, 520px);
    max-height: min(90vh, 980px);
    background: linear-gradient(180deg, #0c121f 0%, #0a0e18 100%);
    border: 1px solid var(--ecx-border-strong);
    border-radius: 18px;
    z-index: 9999;
    transform: translate(-50%, calc(-50% + 12px)) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition:
        transform .3s cubic-bezier(0.22, 1, 0.36, 1),
        opacity .25s ease;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 30px 60px -20px rgba(0, 0, 0, 0.65),
        0 12px 28px -10px rgba(0, 0, 0, 0.45),
        0 1px 0 rgba(255, 255, 255, 0.05) inset;
    overflow: hidden;
}
.ec-drawer.is-open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}

[data-theme="light"] .ec-drawer-overlay {
    background: rgba(20, 18, 12, 0.42);
}
[data-theme="light"] .ec-drawer {
    background: linear-gradient(180deg, #FFFEF8 0%, #FAF7EE 100%);
    border-color: rgba(20, 18, 12, 0.12);
    box-shadow:
        0 30px 60px -20px rgba(120, 80, 40, 0.25),
        0 12px 28px -10px rgba(120, 80, 40, 0.15),
        0 1px 0 rgba(255, 255, 255, 0.6) inset;
}

@media (max-width: 640px) {
    .ec-drawer {
        width: calc(100vw - 24px);
        max-height: 92vh;
        border-radius: 14px;
    }
}

.ec-drawer__head {
    padding: 18px 20px;
    border-bottom: 1px solid var(--ecx-border);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}
.ec-drawer__close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--ecx-border);
    background: transparent;
    color: var(--ecx-text-2);
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ec-drawer__close:hover {
    background: rgba(220, 38, 38, 0.1);
    border-color: var(--ecx-red-ring);
    color: var(--ecx-red);
}
.ec-drawer__title {
    flex: 1;
    min-width: 0;
}
.ec-drawer__title h3 {
    margin: 0;
    border: 0 !important;
    padding: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ecx-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Inter', sans-serif;
}
.ec-drawer__title small {
    display: block;
    color: var(--ecx-text-3);
    font-size: 0.75rem;
    margin-top: 2px;
    font-family: 'JetBrains Mono', monospace;
}

.ec-drawer__body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.ec-drawer__body::-webkit-scrollbar { width: 8px; }
.ec-drawer__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

.ec-drawer__hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.06), rgba(220, 38, 38, 0.01));
    border: 1px solid var(--ecx-border);
    border-radius: var(--ecx-radius);
    margin-bottom: 16px;
}
.ec-drawer__hero .ec-avatar { width: 56px; height: 56px; font-size: 1.3rem; }
.ec-drawer__hero-meta { flex: 1; min-width: 0; }
.ec-drawer__hero-meta h4 {
    margin: 0 0 4px;
    border: 0 !important;
    padding: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ecx-text);
    font-family: 'Inter', sans-serif;
}
.ec-drawer__hero-meta p {
    margin: 0;
    color: var(--ecx-text-2);
    font-size: 0.85rem;
    word-break: break-word;
}

.ec-drawer__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.ec-drawer__stat {
    background: var(--ecx-glass-2);
    border: 1px solid var(--ecx-border);
    border-radius: var(--ecx-radius-sm);
    padding: 12px 14px;
    transition: border-color .15s;
}
.ec-drawer__stat:hover { border-color: var(--ecx-red-ring); }
.ec-drawer__stat-label {
    font-size: 0.7rem;
    color: var(--ecx-text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-bottom: 6px;
}
.ec-drawer__stat-value {
    font-family: 'Instrument Serif', serif;
    font-size: 1.5rem;
    color: var(--ecx-text);
    line-height: 1;
    font-weight: 500;
    background: linear-gradient(180deg, #fff 0%, #c8ccd7 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.ec-drawer__stat-value small {
    -webkit-text-fill-color: var(--ecx-text-3);
    color: var(--ecx-text-3);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    margin-left: 4px;
    font-weight: 400;
}

.ec-drawer__section {
    margin-bottom: 18px;
}
.ec-drawer__section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 8px;
    flex-wrap: wrap;
}
.ec-drawer__section-title {
    margin: 0;
    border: 0 !important;
    padding: 0;
    font-size: 0.78rem;
    color: var(--ecx-text-2);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.ec-drawer__section-count {
    color: var(--ecx-text-3);
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
}

.ec-license-card {
    background: var(--ecx-glass-2);
    border: 1px solid var(--ecx-border);
    border-radius: var(--ecx-radius-sm);
    padding: 14px;
    margin-bottom: 10px;
    transition: border-color .15s;
}
.ec-license-card:hover { border-color: var(--ecx-red-ring); }
.ec-license-card__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.ec-license-card__key {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ec-license-card__key code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--ecx-text);
    background: rgba(255, 255, 255, 0.04);
    padding: 4px 8px;
    border-radius: 6px;
    word-break: break-all;
    user-select: all;
}
.ec-license-card__btn-copy {
    height: 26px;
    padding: 0 10px;
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid var(--ecx-red-ring);
    color: #fca5a5;
    border-radius: 6px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}
.ec-license-card__btn-copy:hover { background: var(--ecx-red); color: #fff; }
.ec-license-card__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ec-license-card__actions .ec-btn-mini {
    height: 30px;
    padding: 0 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--ecx-border);
    border-radius: 8px;
    color: var(--ecx-text);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    min-height: 30px;
    min-width: 44px;
}
.ec-license-card__actions .ec-btn-mini:hover { border-color: var(--ecx-red-ring); color: var(--ecx-red); }
.ec-license-card__actions .ec-btn-mini--danger:hover { border-color: var(--ecx-red); background: rgba(220,38,38,0.1); color: #fca5a5; }
.ec-license-card__machine {
    background: rgba(0,0,0,0.2);
    border: 1px dashed var(--ecx-border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 0.78rem;
}
.ec-license-card__machine .lbl { color: var(--ecx-text-3); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.ec-license-card__machine .val { color: var(--ecx-text); font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; word-break: break-word; }
.ec-license-card__expires {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--ecx-text-2);
}

.ec-drawer__create-sub {
    background: rgba(220, 38, 38, 0.04);
    border: 1px solid var(--ecx-red-ring);
    border-radius: var(--ecx-radius-sm);
    padding: 14px;
    margin-bottom: 12px;
}
.ec-drawer__create-sub label { font-size: 0.75rem; color: var(--ecx-text-2); margin-bottom: 4px; display: block; }
.ec-drawer__create-sub select,
.ec-drawer__create-sub input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--ecx-border);
    border-radius: 8px;
    color: var(--ecx-text);
    font-size: 16px;
    font-family: inherit;
}
.ec-drawer__create-sub-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.ec-extend-form {
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed var(--ecx-border);
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.ec-extend-form input {
    height: 36px;
    padding: 0 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--ecx-border);
    border-radius: 8px;
    color: var(--ecx-text);
    font-size: 16px;
    font-family: inherit;
}
.ec-extend-form input[type="number"] { width: 80px; }
.ec-extend-form .sep { color: var(--ecx-text-3); font-size: 0.78rem; }
.ec-extend-form .ec-btn-mini { height: 36px; }

.ec-audit-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ec-audit-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--ecx-border);
    border-radius: 8px;
    padding: 8px 10px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    font-size: 0.78rem;
}
.ec-audit-item .when { color: var(--ecx-text-3); font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; white-space: nowrap; }
.ec-audit-item .what { color: var(--ecx-text); font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; }
.ec-audit-item .who { color: var(--ecx-text-3); font-size: 0.72rem; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ec-drawer__foot {
    flex-shrink: 0;
    padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--ecx-border);
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.ec-drawer__foot .ec-btn-mini { height: 38px; min-height: 38px; padding: 0 14px; }

/* ============================================================================
   9. FAB (mobile create)
   ============================================================================ */
.ec-fab {
    display: none;
    position: fixed;
    right: 16px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 0;
    background: var(--ecx-red-grad);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 24px -6px rgba(220, 38, 38, 0.6), 0 2px 6px rgba(0,0,0,0.4);
    z-index: 30;
    transition: transform .15s, box-shadow .15s;
    display: none; /* hidden until mobile */
    align-items: center;
    justify-content: center;
}
.ec-fab:hover { transform: scale(1.06); box-shadow: 0 10px 28px -6px rgba(220, 38, 38, 0.7); }
.ec-fab:active { transform: scale(0.98); }

/* ============================================================================
   10. RESPONSIVE — TABLET (≤1024px)
   ============================================================================ */
@media (max-width: 1024px) {
    .ec-clients-toolbar {
        grid-template-columns: 1fr 1fr;
        position: static;
    }
    .ec-clients-search { grid-column: 1 / -1; }
    .ec-clients-toolbar__btn--export { display: none; }
    /* anti scroll-x v11 : laisse la table scroller localement entre 769-1024px */
    .ec-clients-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .ec-clients-table { min-width: 760px; }
}

/* ============================================================================
   11. RESPONSIVE — MOBILE (≤768px) — CARDS STACKEES
   ============================================================================ */
@media (max-width: 768px) {
    .ec-clients-shell { gap: 12px; padding-bottom: 88px; /* room for FAB */ }
    .ec-clients-head { padding: 0 4px; }
    .ec-clients-head__actions { width: 100%; }
    .ec-clients-head__actions .ec-clients-toolbar__btn { flex: 1; justify-content: center; }

    .ec-clients-toolbar {
        position: sticky;
        top: 8px;
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 8px;
    }
    .ec-clients-select select { min-width: 100%; }
    .ec-clients-toolbar__btn { width: 100%; justify-content: center; }

    /* Transform table → cards stack */
    .ec-clients-table-wrap { background: transparent; border: 0; box-shadow: none; padding: 0; overflow: visible; }
    .ec-clients-table,
    .ec-clients-table thead,
    .ec-clients-table tbody,
    .ec-clients-table tr,
    .ec-clients-table th,
    .ec-clients-table td {
        display: block;
        width: 100%;
    }
    .ec-clients-table thead { display: none; }
    .ec-clients-table tbody tr {
        background: var(--ecx-glass);
        backdrop-filter: blur(18px) saturate(140%);
        -webkit-backdrop-filter: blur(18px) saturate(140%);
        border: 1px solid var(--ecx-border) !important;
        border-radius: var(--ecx-radius);
        padding: 14px;
        margin-bottom: 10px;
        box-shadow: var(--ecx-shadow);
        cursor: pointer;
        transition: border-color .15s, transform .15s;
        position: relative;
    }
    .ec-clients-table tbody tr:hover,
    .ec-clients-table tbody tr:active {
        background: var(--ecx-glass);
        border-color: var(--ecx-red-ring) !important;
    }
    .ec-clients-table tbody tr.is-selected {
        border-color: var(--ecx-red-ring) !important;
        background: rgba(220, 38, 38, 0.05);
    }

    .ec-clients-table td {
        padding: 0;
        border: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
        margin-bottom: 8px;
    }
    .ec-clients-table td:last-child { margin-bottom: 0; }
    .ec-clients-table td.col-checkbox {
        position: absolute;
        top: 16px;
        right: 16px;
        width: auto;
        margin: 0;
    }
    .ec-clients-table td.col-actions {
        margin-top: 8px;
        text-align: left;
    }
    .ec-clients-table td.col-actions .ec-btn-detail {
        width: 100%;
        height: 44px;
        justify-content: center;
        font-size: 0.85rem;
        background: rgba(220, 38, 38, 0.08);
        border-color: var(--ecx-red-ring);
        color: #fca5a5;
    }

    /* Pre-label using data-label attr for context */
    .ec-clients-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.65rem;
        color: var(--ecx-text-3);
        text-transform: uppercase;
        letter-spacing: 0.08em;
        font-weight: 600;
        margin-bottom: 2px;
    }
    .ec-clients-table td.col-identity::before,
    .ec-clients-table td.col-actions::before { display: none; }

    .ec-cell-identity { max-width: calc(100% - 36px); /* checkbox pinned right */ }
    .ec-cell-identity__email { white-space: normal; word-break: break-word; max-width: none; }
    .ec-cell-identity__name { white-space: normal; max-width: none; }

    /* Drawer fullscreen on mobile */
    .ec-drawer {
        width: 100vw;
        border-left: 0;
        background: linear-gradient(180deg, #0c121f 0%, #060912 100%);
    }
    .ec-drawer__head { padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top, 0)); }
    .ec-drawer__body { padding: 16px; }
    .ec-drawer__hero { flex-direction: column; align-items: flex-start; text-align: left; }
    .ec-drawer__hero .ec-avatar { width: 48px; height: 48px; font-size: 1.1rem; }
    .ec-drawer__stats { grid-template-columns: 1fr 1fr; }
    .ec-drawer__create-sub-row { grid-template-columns: 1fr; }
    .ec-license-card__machine { grid-template-columns: 1fr; }

    .ec-drawer__foot {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .ec-drawer__foot .ec-btn-mini {
        width: 100%;
        height: 44px;
        min-height: 44px;
    }

    /* FAB visible mobile */
    .ec-fab { display: inline-flex; }

    /* Pagination compact */
    .ec-clients-foot {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        background: var(--ecx-glass);
        border: 1px solid var(--ecx-border);
        border-radius: var(--ecx-radius);
        margin-top: 8px;
    }
    .ec-clients-foot__pager { justify-content: center; flex-wrap: wrap; }
}

/* ============================================================================
   12. SMALL MOBILE (≤360px) safety
   ============================================================================ */
@media (max-width: 360px) {
    .ec-drawer__stats { grid-template-columns: 1fr; }
    .ec-license-card__top { flex-direction: column; align-items: stretch; }
}

/* ============================================================================
   13. REDUCED MOTION
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    .ec-clients-shell *,
    .ec-clients-shell *::before,
    .ec-clients-shell *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .ec-drawer { transition: none; }
}

/* ============================================================================
   14. FOCUS VISIBLE — WCAG 2.4.11
   ============================================================================ */
.ec-clients-shell button:focus-visible,
.ec-clients-shell select:focus-visible,
.ec-clients-shell input:focus-visible,
.ec-clients-shell a:focus-visible,
.ec-drawer button:focus-visible,
.ec-drawer select:focus-visible,
.ec-drawer input:focus-visible,
.ec-fab:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--ecx-red-soft);
}

/* ============================================================================
   15. PRINT (admin shouldn't print but safe)
   ============================================================================ */
@media print {
    .ec-clients-toolbar,
    .ec-clients-foot__pager,
    .ec-fab,
    .ec-drawer-overlay,
    .ec-drawer { display: none !important; }
}


/* light-theme override des variables LOCALES (scopées sur .ec-clients-shell, pas :root).
   Couvre .ec-clients-toolbar, .ec-clients-table-wrap, .ec-cell-*, .ec-pill-*, etc. */
[data-theme="light"] .ec-clients-shell {
    --ecx-glass: rgba(255, 254, 248, 0.85);
    --ecx-glass-2: rgba(255, 254, 248, 0.95);
    --ecx-border: rgba(20, 18, 12, 0.10);
    --ecx-border-strong: rgba(20, 18, 12, 0.18);
    --ecx-text: #1A1A1F;
    --ecx-text-2: #3B3B3D;
    --ecx-text-3: #6F6E6A;
    --ecx-red-soft: rgba(220, 38, 38, 0.10);
    --ecx-red-ring: rgba(220, 38, 38, 0.30);
    --ecx-shadow: 0 1px 0 rgba(120,80,40,0.04) inset, 0 8px 24px -8px rgba(120,80,40,0.18);
    --ecx-shadow-lg: 0 1px 0 rgba(120,80,40,0.06) inset, 0 18px 48px -12px rgba(120,80,40,0.28);
}

/* search input bg + border light + neutralise le bg dark hardcoded ligne 139 */
[data-theme="light"] .ec-clients-search input {
    background: rgba(20, 18, 12, 0.03);
}
[data-theme="light"] .ec-clients-search input:focus {
    background: rgba(220, 38, 38, 0.05);
}


/* light-theme : titre Clients/etc avec gradient sombre (était blanc → gris clair invisible sur crème) */
[data-theme="light"] .ec-clients-head__title {
    background: linear-gradient(180deg, #1A1A1F 0%, #3B3B3D 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}


/* light-theme : toolbar btn (Exporter CSV, Actualiser) — bg rgba(255,255,255,0.03) invisible sur crème, hover color:#fff illisible */
[data-theme="light"] .ec-clients-toolbar__btn {
    background: rgba(20, 18, 12, 0.04);
}
[data-theme="light"] .ec-clients-toolbar__btn:hover {
    background: rgba(220, 38, 38, 0.10);
    border-color: rgba(220, 38, 38, 0.40);
    color: #991B1B;
}

/* ═══════════════════════════════════════════════════════════════════════════
   scroll-x guard 2026-05-03
   Cause root: .ec-clients-table { min-width: 760px } @media ≤1024px (ligne
   1079) avec wrapper .ec-clients-table-wrap { overflow-x: auto }. Le scroll
   local est OK. On renforce containment shell + drawer + cards.
   ═══════════════════════════════════════════════════════════════════════════ */
.ec-clients-shell,
.ec-clients-page-card,
.ec-clients-toolbar,
.ec-clients-header,
.ec-clients-foot,
.ec-clients-pagination,
.ec-drawer,
.ec-drawer__body,
.ec-drawer__head,
.ec-drawer__stats,
.ec-license-card,
.ec-license-card__machine,
.ec-audit-item,
.ec-cell-identity {
    max-width: 100%;
    min-width: 0;
}
.ec-clients-page-card { overflow: hidden; }
.ec-clients-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Identity cell : nom+email longs */
.ec-cell-identity__email,
.ec-cell-identity__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* License cards machine info */
.ec-license-card__machine,
.ec-license-card__top,
.ec-license-card__actions { min-width: 0; flex-wrap: wrap; }

/* Audit items "who" déjà géré (max-width:200px) — on renforce wrap */
.ec-audit-item .who,
.ec-audit-item .when { max-width: 100%; min-width: 0; }

/* Drawer stats grid */
.ec-drawer__stats { min-width: 0; }

/* Select min-width:160px peut être limite à 320px viewport (160 + checkbox
   + autres flex items) — on autorise shrink. */
@media (max-width: 420px) {
    .ec-clients-select select { min-width: 0 !important; width: 100% !important; }
}
