/* =====================================================================
 * WhatsApp Bulk Messenger — Design System
 * Light, minimal, airy. Arabic RTL primary. Overrides Bootstrap 5 RTL.
 * Token reference: see plan §"Design System (light, minimal, Arabic RTL)".
 * ===================================================================== */

:root {
    /* ----- Palette ----- */
    --brand-primary:        #2563EB;
    --brand-primary-hover:  #1D4ED8;
    --brand-primary-soft:   #DBEAFE;
    --accent:               #16A34A;
    --accent-hover:         #15803D;
    --accent-soft:          #DCFCE7;
    --success:              #22C55E;
    --warning:              #F59E0B;
    --warning-soft:         #FEF3C7;
    --danger:               #EF4444;
    --danger-hover:         #B91C1C;
    --danger-soft:          #FEE2E2;
    --bg-canvas:            #F8FAFC;
    --bg-surface:           #FFFFFF;
    --bg-subtle:            #F1F5F9;
    --border:               #E2E8F0;
    --border-strong:        #CBD5E1;
    --text-primary:         #0F172A;
    --text-secondary:       #475569;
    --text-muted:           #64748B;
    --focus-ring:           rgba(37, 99, 235, 0.25);

    /* ----- Spacing ----- */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  24px;
    --space-6:  32px;
    --space-8:  48px;

    /* ----- Radius ----- */
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   14px;
    --radius-pill: 999px;

    /* ----- Shadow ----- */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 24px rgba(15, 23, 42, 0.08), 0 4px 8px rgba(15, 23, 42, 0.04);

    /* ----- Type scale ----- */
    --text-xs:  12px;
    --text-sm:  14px;
    --text-base: 16px;
    --text-lg:  18px;
    --text-xl:  22px;
    --text-2xl: 28px;
    --text-3xl: 36px;

    /* ----- Layout ----- */
    --topbar-height: 64px;
    --sidebar-width: 260px;
    --content-max: 1240px;
}

/* ----- Bootstrap variable overrides ----- */
:root {
    --bs-primary:        var(--brand-primary);
    --bs-primary-rgb:    37, 99, 235;
    --bs-success:        var(--success);
    --bs-warning:        var(--warning);
    --bs-danger:         var(--danger);
    --bs-body-bg:        var(--bg-canvas);
    --bs-body-color:     var(--text-primary);
    --bs-body-font-family: 'Cairo', 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-body-font-size:    var(--text-base);
    --bs-border-color:   var(--border);
    --bs-border-radius:  var(--radius-md);
    --bs-border-radius-lg: var(--radius-lg);
    --bs-border-radius-pill: var(--radius-pill);
    --bs-link-color:     var(--brand-primary);
    --bs-link-hover-color: var(--brand-primary-hover);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    background: var(--bg-canvas);
    color: var(--text-primary);
    font-family: 'Cairo', 'Inter', system-ui, sans-serif;
    font-size: var(--text-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.tabular {
    font-family: 'Inter', 'Cairo', sans-serif;
    font-feature-settings: 'tnum';
    font-variant-numeric: tabular-nums;
}

/* Universal focus ring — never use scale transforms which cause shift */
:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
    border-radius: var(--radius-sm);
}

/* =====================================================================
 * SHELL — topbar + sidebar + main
 * RTL layout: sidebar is anchored to the right (margin-inline-start).
 * ===================================================================== */

.wa-shell {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-width);
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas:
        "topbar  topbar"
        "main    sidebar";
    min-height: 100vh;
}

@media (max-width: 768px) {
    .wa-shell {
        grid-template-columns: 1fr;
        grid-template-areas: "topbar" "main";
    }
}

.wa-topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-5);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.wa-topbar__menu {
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    font-size: 24px;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.wa-topbar__menu:hover { background: var(--bg-subtle); }

.wa-topbar__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--text-primary);
    text-decoration: none;
}
.wa-topbar__brand i { color: var(--accent); font-size: 24px; }

.wa-topbar__spacer { flex: 1; }

.wa-topbar__user {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}
.wa-topbar__user i { font-size: 22px; }

.wa-sidebar {
    grid-area: sidebar;
    background: var(--bg-surface);
}

/* Desktop: static sticky rail. Scoped to ≥768px so we never fight Bootstrap's
   offcanvas (fixed + transform) on mobile — that was breaking the close button. */
@media (min-width: 768px) {
    .wa-sidebar {
        border-inline-start: 1px solid var(--border);
        position: sticky;
        top: var(--topbar-height);
        align-self: start;
        height: calc(100vh - var(--topbar-height));
        overflow-y: auto;
    }
}

/* offcanvas-body is the flex column that lets the footer pin to the bottom */
.wa-sidebar__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-3);
    height: 100%;
}

.wa-sidebar__cta {
    margin-bottom: var(--space-2);
}

.wa-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.wa-sidebar__footer {
    margin-top: auto;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.wa-sidebar__user {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    min-width: 0;
}
.wa-sidebar__user i { font-size: 22px; flex-shrink: 0; }

.wa-sidebar__item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--text-sm);
    min-height: 44px;
    transition: background-color 200ms ease, color 200ms ease;
    position: relative;
}

.wa-sidebar__item:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.wa-sidebar__item.is-active {
    background: var(--brand-primary-soft);
    color: var(--brand-primary);
}

.wa-sidebar__item.is-active::after {
    /* RTL: the active rail is on the right edge of the nav item */
    content: "";
    position: absolute;
    inset-inline-end: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--brand-primary);
    border-radius: var(--radius-pill);
}

.wa-sidebar__item i { font-size: 20px; }

.wa-main {
    grid-area: main;
    padding: var(--space-5);
    max-width: var(--content-max);
    width: 100%;
}

/* =====================================================================
 * PAGE HEADER + CARDS
 * ===================================================================== */

.wa-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.wa-page-title {
    font-size: var(--text-xl);
    font-weight: 700;
    margin: 0;
}

.wa-page-actions {
    display: inline-flex;
    gap: var(--space-2);
}

.wa-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.wa-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}
.wa-card__title { font-size: var(--text-lg); font-weight: 600; margin: 0; }

.wa-card__body {
    padding: var(--space-5);
}

/* =====================================================================
 * KPI cards (dashboard)
 * ===================================================================== */

.wa-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-4);
}
@media (max-width: 1024px) { .wa-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .wa-kpi-grid { grid-template-columns: 1fr; } }

.wa-kpi {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-xs);
    transition: box-shadow 200ms ease;
}
.wa-kpi:hover { box-shadow: var(--shadow-sm); }

.wa-kpi__icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: var(--brand-primary-soft);
    color: var(--brand-primary);
    margin-bottom: var(--space-3);
}
.wa-kpi--accent .wa-kpi__icon { background: var(--accent-soft); color: var(--accent-hover); }
.wa-kpi--danger .wa-kpi__icon { background: var(--danger-soft); color: var(--danger-hover); }
.wa-kpi--muted  .wa-kpi__icon { background: var(--bg-subtle); color: var(--text-muted); }

.wa-kpi__value {
    font-size: var(--text-3xl);
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
}
.wa-kpi__label {
    margin-top: var(--space-1);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* =====================================================================
 * BUTTONS — override Bootstrap to match our tokens
 * 44px touch target floor.
 * ===================================================================== */

.btn {
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: var(--text-sm);
    padding: 10px var(--space-4);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
    cursor: pointer;
}
.btn:disabled, .btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-sm {
    min-height: 36px;
    padding: 6px var(--space-3);
    font-size: var(--text-sm);
}

.btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}
.btn-primary:hover, .btn-primary:focus { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); color:#fff; }

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-accent:hover, .btn-accent:focus { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-secondary:hover { background: var(--bg-subtle); color: var(--text-primary); }

.btn-ghost {
    background: transparent;
    border: 0;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-primary); }

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }

/* =====================================================================
 * FORMS
 * ===================================================================== */

.form-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-control, .form-select {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-base);
    padding: 10px var(--space-3);
    min-height: 44px;
    transition: border-color 200ms ease, box-shadow 200ms ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: none;
}

.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--danger);
}
.invalid-feedback {
    color: var(--danger);
    font-size: var(--text-sm);
    margin-top: var(--space-1);
}

textarea.form-control { min-height: 120px; line-height: 1.6; }

/* =====================================================================
 * STATUS CHIPS
 * ===================================================================== */

.wa-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    min-height: 24px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}
.wa-chip i { font-size: 14px; }

.wa-chip--connected     { background: var(--accent-soft);        color: var(--accent-hover); }
.wa-chip--connecting    { background: var(--warning-soft);       color: #A16207; }
.wa-chip--qr_pending    { background: var(--brand-primary-soft); color: var(--brand-primary); }
.wa-chip--disconnected  { background: var(--bg-subtle);          color: var(--text-secondary); }
.wa-chip--banned        { background: var(--danger-soft);        color: var(--danger-hover); }
.wa-chip--asleep        { background: var(--brand-primary-soft); color: var(--brand-primary); }

.wa-chip--queued        { background: var(--bg-subtle);          color: var(--text-muted); }
.wa-chip--sent          { background: var(--bg-subtle);          color: var(--text-secondary); }
.wa-chip--delivered     { background: var(--bg-subtle);          color: var(--text-secondary); }
.wa-chip--read          { background: var(--brand-primary-soft); color: var(--brand-primary); }
.wa-chip--failed        { background: var(--danger-soft);        color: var(--danger-hover); }
.wa-chip--cancelled     { background: var(--bg-subtle);          color: var(--text-muted); }

/* =====================================================================
 * TABLES
 * ===================================================================== */

.table {
    --bs-table-bg: var(--bg-surface);
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--bg-subtle);
    --bs-table-hover-bg: var(--bg-subtle);
    border-collapse: separate;
    border-spacing: 0;
}
.table > thead {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.table > thead th {
    font-weight: 600;
    padding: 10px var(--space-4);
    border-bottom: 1px solid var(--border);
}
.table > tbody > tr > td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: var(--text-sm);
}
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table > tbody > tr:hover { background: var(--bg-subtle); }

/* Wrap any table in .table-responsive for safe overflow */
.table-responsive {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    overflow: auto;
}

/* =====================================================================
 * RESPONSIVE TABLE → CARDS (.wa-rtable)
 * On mobile, each row becomes a stacked card with data-label captions,
 * so wide tables stay readable without horizontal scrolling.
 * ===================================================================== */
@media (max-width: 767px) {
    .wa-rtable thead { display: none; }
    .wa-rtable, .wa-rtable tbody, .wa-rtable tr, .wa-rtable td { display: block; width: 100%; }
    .wa-rtable tr {
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: var(--space-2) var(--space-3);
        margin-bottom: var(--space-3);
    }
    .wa-rtable td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3);
        padding: var(--space-2) 0;
        border-bottom: 1px solid var(--bg-subtle);
        text-align: start;
    }
    .wa-rtable td:last-child { border-bottom: 0; }
    .wa-rtable td::before {
        content: attr(data-label);
        font-size: var(--text-xs);
        font-weight: 600;
        color: var(--text-muted);
        flex-shrink: 0;
    }
    /* Action row: let buttons fill the width */
    .wa-rtable td:last-child { justify-content: flex-end; }
}

/* =====================================================================
 * MODAL — Bootstrap overrides
 * RTL: close button in the top-LEFT corner.
 * ===================================================================== */

.modal-content {
    border-radius: var(--radius-lg);
    border: 0;
    box-shadow: var(--shadow-lg);
    background: var(--bg-surface);
}
.modal-header {
    border-bottom: 1px solid var(--border);
    padding: var(--space-4) var(--space-5);
}
.modal-title { font-size: var(--text-lg); font-weight: 600; }
.modal-body { padding: var(--space-5); }
.modal-footer { border-top: 1px solid var(--border); padding: var(--space-4) var(--space-5); gap: var(--space-2); }
.modal-backdrop.show { opacity: 0.4; background: #0F172A; }

/* =====================================================================
 * EMPTY STATES
 * ===================================================================== */

.wa-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-6);
    color: var(--text-muted);
    text-align: center;
}
.wa-empty-state i { font-size: 40px; color: var(--text-muted); }
.wa-empty-state--large { padding: var(--space-8); }
.wa-empty-state--large i { font-size: 64px; }
.wa-empty-state--large h1 { color: var(--text-primary); font-weight: 600; }

/* =====================================================================
 * AUTH (login / setup) — bare layout
 * ===================================================================== */

.wa-auth-page {
    background: var(--bg-canvas);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
}
.wa-auth-shell {
    width: 100%;
    max-width: 420px;
}
.wa-auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-6);
}
.wa-auth-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: var(--space-5);
}
.wa-auth-brand i { color: var(--accent); font-size: 28px; }
.wa-auth-title {
    font-size: var(--text-xl);
    font-weight: 700;
    margin: 0 0 var(--space-2);
}
.wa-auth-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    margin-bottom: var(--space-5);
}
.wa-auth-tagline {
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-align: center;
    margin-top: var(--space-4);
}

/* =====================================================================
 * QR MODAL — the visible QR + spinner state
 * ===================================================================== */

.wa-qr-frame {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-5);
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    min-height: 320px;
}
.wa-qr-frame img {
    width: 256px;
    height: 256px;
    border: 8px solid #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.wa-qr-frame__placeholder {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* =====================================================================
 * UTILITIES
 * ===================================================================== */

.text-muted   { color: var(--text-muted) !important; }
.text-success { color: var(--accent-hover) !important; }
.text-danger  { color: var(--danger-hover) !important; }

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-hover); text-decoration: underline; }

hr { border-color: var(--border); opacity: 1; }

/* =====================================================================
 * ALERTS + ADDITIONAL UTILITIES
 * ===================================================================== */

.alert {
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}
.alert i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--accent-soft);  color: var(--accent-hover); border-color: rgba(22,163,74,.15); }
.alert-warning { background: var(--warning-soft); color: #92400E;             border-color: rgba(245,158,11,.15); }
.alert-danger  { background: var(--danger-soft);  color: var(--danger-hover); border-color: rgba(239,68,68,.15); }
.alert-info    { background: var(--brand-primary-soft); color: var(--brand-primary); border-color: rgba(37,99,235,.15); }

.form-text {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.form-check-input {
    cursor: pointer;
    width: 18px;
    height: 18px;
    margin-top: 0.25em;
}
.form-check-input:checked { background-color: var(--brand-primary); border-color: var(--brand-primary); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--focus-ring); border-color: var(--brand-primary); }

/* Bootstrap nav tabs in our colors */
.nav-tabs {
    border-bottom: 1px solid var(--border);
    gap: var(--space-1);
}
.nav-tabs .nav-link {
    color: var(--text-secondary);
    border: 0;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: var(--space-2) var(--space-4);
    font-weight: 500;
    font-size: var(--text-sm);
    background: transparent;
}
.nav-tabs .nav-link:hover { color: var(--text-primary); background: var(--bg-subtle); }
.nav-tabs .nav-link.active {
    color: var(--brand-primary);
    background: var(--bg-surface);
    border-bottom: 2px solid var(--brand-primary);
}

/* Toast variants */
.toast.text-bg-success { background: var(--accent) !important; color: #fff !important; }
.toast.text-bg-danger  { background: var(--danger) !important; color: #fff !important; }
.toast.text-bg-warning { background: var(--warning) !important; color: #0F172A !important; }
.toast.text-bg-info    { background: var(--brand-primary) !important; color: #fff !important; }
.toast { border-radius: var(--radius-md); box-shadow: var(--shadow-md); }

/* Bootstrap progress bar */
.progress { border-radius: var(--radius-pill); }
.progress-bar { transition: width 400ms ease; }

/* Code spans inside form-text */
code {
    background: var(--bg-subtle);
    color: var(--text-primary);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Number / dimension inputs read better LTR even in RTL layout */
input[type="number"], input[type="time"], input[type="datetime-local"],
input[type="tel"], input[type="email"], input[type="url"] {
    direction: ltr;
    text-align: end;
}

/* Spinner sizing inside small buttons */
.btn-sm .spinner-border-sm { width: 1rem; height: 1rem; }

/* =====================================================================
 * CAMPAIGN COMPOSER
 * ===================================================================== */

/* Account / generic pick tile */
.wa-pick {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 200ms ease, background-color 200ms ease;
}
.wa-pick:hover { border-color: var(--border-strong); }
.wa-pick:has(input:checked) { border-color: var(--brand-primary); background: var(--brand-primary-soft); }

/* Recipient accordion: each mode is visually distinct with icon + text + count */
.wa-rcp .accordion-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md) !important;
    margin-bottom: var(--space-2);
    overflow: hidden;
    background: var(--bg-surface);
}
.wa-rcp .accordion-button {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface);
    box-shadow: none;
    font-family: inherit;
}
.wa-rcp .accordion-button:not(.collapsed) {
    background: var(--brand-primary-soft);
    color: var(--text-primary);
}
.wa-rcp .accordion-button:focus { box-shadow: 0 0 0 3px var(--focus-ring); }
.wa-rcp__icon {
    font-size: 24px;
    color: var(--brand-primary);
    flex-shrink: 0;
}
.wa-rcp__text { display: flex; flex-direction: column; gap: 2px; text-align: start; }
.wa-rcp__text strong { font-size: var(--text-base); font-weight: 600; }
.wa-rcp__text small { font-size: var(--text-xs); color: var(--text-muted); font-weight: 400; line-height: 1.4; }
.wa-rcp__count {
    margin-inline-start: auto;
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    border-radius: var(--radius-pill);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* RTL: flip Bootstrap's accordion chevron position handled by bootstrap.rtl */

/* Select-all toolbar above each pick list */
.wa-picklist-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-2);
    margin-bottom: var(--space-2);
    background: var(--brand-primary-soft);
    border-radius: var(--radius-sm);
}
.wa-selectall {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-primary);
    margin: 0;
}

/* Scrollable pick lists */
.wa-picklist {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
}
.wa-pickrow {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.wa-pickrow:hover { background: var(--bg-subtle); }

/* Select-all toolbar above pick lists */
.wa-picklist-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) 0;
    margin-bottom: var(--space-2);
    border-bottom: 1px dashed var(--border);
}
.wa-selectall {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-sm);
}

/* A/B variant blocks */
.wa-variant {
    position: relative;
    padding-top: 22px;
}
.wa-variant__tag {
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
}
.wa-variant__remove {
    position: absolute;
    top: -4px;
    inset-inline-end: 0;
    min-height: 28px;
    padding: 2px 8px;
}

/* Variable insert bar */
.wa-varbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}
.wa-varbar__label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; }
.wa-var-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    border: 1px dashed var(--border-strong);
    background: var(--bg-surface);
    color: var(--brand-primary);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
}
.wa-var-chip:hover { background: var(--brand-primary-soft); border-color: var(--brand-primary); }

/* Pacing — single duration control */
.wa-duration {
    display: flex;
    align-items: stretch;
    gap: var(--space-2);
    max-width: 420px;
}
.wa-duration .form-control { max-width: 160px; font-size: var(--text-lg); font-weight: 600; }
.wa-unit .btn { min-height: 44px; }
.wa-unit .btn-check:checked + .btn {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}
.wa-pace-readout {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
}
.wa-pace-readout .wa-chip { font-size: var(--text-sm); }
.form-range { accent-color: var(--brand-primary); }

/* Dashboard chart grid */
.wa-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
}
.wa-chart-card--wide { grid-column: 1 / -1; }
@media (max-width: 768px) {
    .wa-chart-grid { grid-template-columns: 1fr; }
}

/* Table pager bar (client-side enhancer) */
.wa-pager-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border);
}
.wa-pager { display: inline-flex; align-items: center; gap: var(--space-1); }
.wa-table-search {
    max-width: 320px;
    margin-bottom: var(--space-3);
}

/* Respect reduced-motion preference (accessibility floor) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
