/* =================================================================
   WA-AI · Tenant Workspace UI — respond.io-inspired design system
   Layered on top of Bootstrap 5. Loaded only by the tenant portal;
   the admin dashboard keeps portal-ui.css.
   ================================================================= */

:root {
    /* Action / identity colors */
    --blue:         #3662e3;
    --blue-dark:    #2b51c4;
    --blue-soft:    #e8eefc;
    --green:        #25d366;
    --green-dark:   #1aa851;
    --green-soft:   #e2f8eb;
    --green-text:   #0f8c41;
    --purple:       #7c5cfc;
    --purple-soft:  #efeaff;
    --red:          #e5484d;
    --red-soft:     #fdebec;
    --amber:        #b87400;
    --amber-soft:   #fff4dd;

    /* Neutrals */
    --bg:           #f0f2f7;
    --surface:      #ffffff;
    --surface-2:    #f7f9fc;
    --border:       #e4e8f1;
    --border-soft:  #eef1f7;
    --text:         #17223b;
    --muted:        #65718b;
    --faint:        #9aa4ba;

    /* Shell */
    --sidebar-bg:   #101b2e;
    --sidebar-bg-2: #0b1322;
    --sidebar-w:    264px;
    --topbar-h:     64px;

    --radius:       14px;
    --radius-sm:    10px;
    --radius-pill:  999px;

    --shadow-sm:    0 1px 2px rgba(23, 34, 59, .06);
    --shadow:       0 6px 24px rgba(23, 34, 59, .08);
    --shadow-lg:    0 18px 48px rgba(23, 34, 59, .16);
}

/* ---------- Base ---------- */
* { -webkit-font-smoothing: antialiased; }

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    letter-spacing: .1px;
}

h1, h2, h3, h4, h5, h6 { color: var(--text); letter-spacing: -.2px; }
.text-muted { color: var(--muted) !important; }
a { text-decoration: none; color: var(--blue); }
a:hover { color: var(--blue-dark); }

.metric-label {
    font-size: .62rem;
    letter-spacing: .07em;
    color: var(--faint);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 2px;
}

/* ===============================================================
   SIDEBAR
   =============================================================== */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: linear-gradient(186deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    position: fixed;
    top: 0; left: 0;
    z-index: 1040;
    box-shadow: 4px 0 30px rgba(8, 11, 22, .16);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}

.sidebar .brand {
    padding: 1.25rem 1.25rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    display: flex;
    align-items: center;
    gap: .7rem;
}
.sidebar .brand .brand-logo {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, var(--green), var(--green-dark));
    color: #fff;
    font-size: 1.25rem;
    box-shadow: 0 6px 16px rgba(37, 211, 102, .32);
    flex-shrink: 0;
}
.sidebar .brand .brand-text { line-height: 1.15; min-width: 0; }
.sidebar .brand span {
    color: #fff; font-weight: 700; font-size: 1rem;
    display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar .brand small {
    color: rgba(255, 255, 255, .42);
    font-size: .66rem; display: block; letter-spacing: .5px;
    text-transform: uppercase; margin-top: 2px;
}

.sidebar .nav-section {
    padding: 1.1rem 1.35rem .35rem;
    font-size: .62rem;
    letter-spacing: .12em;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .32);
}

.sidebar .nav { padding: 0 .65rem; gap: 2px; }
.sidebar .nav-link {
    color: rgba(255, 255, 255, .68);
    padding: .6rem .8rem;
    border-radius: 10px;
    font-size: .89rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    position: relative;
    transition: background .15s, color .15s;
}
.sidebar .nav-link .bi {
    width: 24px; display: inline-block;
    font-size: 1.02rem; margin-right: .4rem;
    opacity: .85;
}
.sidebar .nav-link:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(54, 98, 227, .32), rgba(54, 98, 227, .14));
}
.sidebar .nav-link.active::before {
    content: "";
    position: absolute;
    left: -.65rem; top: 50%;
    transform: translateY(-50%);
    width: 4px; height: 22px;
    border-radius: 0 4px 4px 0;
    background: var(--green);
}
.sidebar .nav-link.active .bi { opacity: 1; }

.sidebar .nav-badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: .66rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    padding: .14rem .46rem;
    line-height: 1.2;
}

.sidebar .sidebar-foot {
    padding: .9rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .07);
}
.sidebar .sidebar-foot .user-row {
    display: flex; align-items: center; gap: .6rem;
}
.sidebar .sidebar-foot .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(140deg, var(--blue), #5d82f2);
    color: #fff; display: grid; place-items: center;
    font-weight: 700; font-size: .82rem; flex-shrink: 0;
}
.sidebar .sidebar-foot .user-meta { min-width: 0; flex-grow: 1; line-height: 1.25; }
.sidebar .sidebar-foot .user-name {
    color: rgba(255, 255, 255, .92);
    font-size: .8rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar .sidebar-foot .user-email {
    color: rgba(255, 255, 255, .45);
    font-size: .68rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar .btn-logout {
    border: none;
    color: rgba(255, 255, 255, .55);
    background: rgba(255, 255, 255, .06);
    border-radius: 9px;
    width: 32px; height: 32px;
    display: grid; place-items: center;
    font-size: .95rem;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.sidebar .btn-logout:hover { background: var(--red); color: #fff; }

/* ===============================================================
   LAYOUT SHELL
   =============================================================== */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.topbar .topbar-title { line-height: 1.2; }
.topbar h6 {
    font-size: 1.08rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -.3px;
}
.topbar .topbar-sub { color: var(--faint); font-size: .74rem; display: block; }
.topbar .sidebar-toggle {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 38px; height: 38px;
    border-radius: 10px;
    display: none;
    align-items: center; justify-content: center;
    font-size: 1.15rem;
}

.content-area { padding: 1.5rem; }
.content-area.content-flush { padding: 0; }
.content-area.content-flush .alert { margin: 1rem 1rem 0; }

/* Sidebar mobile overlay */
.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(10, 14, 24, .5);
    backdrop-filter: blur(2px);
    z-index: 1035;
    opacity: 0; visibility: hidden;
    transition: opacity .25s;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

/* ===============================================================
   CARDS
   =============================================================== */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.card .card-body { padding: 1.25rem 1.35rem; }

.card-head {
    padding: 1rem 1.35rem;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.card-head .card-head-title { font-weight: 700; font-size: .95rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.card-head .card-head-title .bi { color: var(--blue); }
.card-head .card-head-sub { color: var(--muted); font-size: .78rem; margin: 2px 0 0; }

.stat-card {
    transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .card-body { padding: 1.15rem 1.25rem; }

.stat-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.stat-icon.bg-success   { background: var(--green-soft) !important;  color: var(--green-text) !important; }
.stat-icon.bg-primary   { background: var(--blue-soft) !important;   color: var(--blue) !important; }
.stat-icon.bg-warning   { background: var(--amber-soft) !important;  color: var(--amber) !important; }
.stat-icon.bg-info      { background: #d9f1fb !important;            color: #0a93b8 !important; }
.stat-icon.bg-danger    { background: var(--red-soft) !important;    color: var(--red) !important; }
.stat-icon.bg-secondary { background: #eceef3 !important;            color: #5a6473 !important; }

.card h6.fw-semibold, .card .card-title { font-weight: 700; letter-spacing: -.2px; }

/* ===============================================================
   BUTTONS
   =============================================================== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    letter-spacing: .1px;
    padding: .5rem 1rem;
    transition: transform .12s ease, box-shadow .15s ease, background .15s, border-color .15s, color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .36rem .75rem; border-radius: 9px; font-size: .8rem; }

.btn-primary {
    background: var(--blue);
    border: none;
    box-shadow: 0 4px 12px rgba(54, 98, 227, .26);
}
.btn-primary:hover, .btn-primary:focus { background: var(--blue-dark); box-shadow: 0 8px 18px rgba(54, 98, 227, .3); }

.btn-success {
    background: linear-gradient(140deg, var(--green), var(--green-dark));
    border: none;
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 211, 102, .26);
}
.btn-success:hover { background: linear-gradient(140deg, #2bdc70, var(--green-dark)); color: #fff; }

.btn-outline-secondary { border-color: var(--border); color: var(--muted); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--surface-2); border-color: #d3d9e3; color: var(--text); }

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

.btn-outline-success { border-color: var(--green-dark); color: var(--green-text); }
.btn-outline-success:hover { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }

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

.btn-light { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-light:hover { background: #eaeef4; }

/* Small icon-only ghost button */
.btn-icon {
    width: 32px; height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center; justify-content: center;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: .9rem;
    transition: background .15s, color .15s, border-color .15s;
}
.btn-icon:hover { background: var(--blue-soft); color: var(--blue); border-color: #cdd9f6; }

/* ===============================================================
   TABLES
   =============================================================== */
.table { margin-bottom: 0; color: var(--text); }
.table > :not(caption) > * > * { padding: .8rem 1rem; }
.table thead th,
.table > thead.table-light th {
    background: transparent;
    color: var(--faint);
    text-transform: uppercase;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .6px;
    border-bottom: 1px solid var(--border);
}
.table tbody td {
    border-top: 1px solid var(--border-soft);
    border-bottom: none;
    vertical-align: middle;
}
.table tbody tr:first-child td { border-top: none; }
.table-hover tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: var(--surface-2); }

/* ===============================================================
   BADGES & PILLS
   =============================================================== */
.badge {
    font-weight: 600;
    padding: .38em .68em;
    border-radius: var(--radius-pill);
    letter-spacing: .2px;
    font-size: .7rem;
}
.badge.bg-success   { background: var(--green-soft) !important; color: var(--green-text) !important; }
.badge.bg-primary   { background: var(--blue-soft) !important;  color: var(--blue) !important; }
.badge.bg-warning   { background: var(--amber-soft) !important; color: var(--amber) !important; }
.badge.bg-danger    { background: var(--red-soft) !important;   color: var(--red) !important; }
.badge.bg-info      { background: #d9f1fb !important;           color: #0a8eb0 !important; }
.badge.bg-secondary { background: #eceef3 !important;           color: #5a6473 !important; }

/* Status pill (assistant / human) used in chat header + list */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .72rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    padding: .3rem .7rem;
    white-space: nowrap;
}
.status-pill::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
}
.status-pill.is-bot   { background: var(--green-soft); color: var(--green-text); }
.status-pill.is-human { background: var(--red-soft); color: var(--red); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .7rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    padding: .22rem .6rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
}
.chip .bi { font-size: .75rem; }
.chip-green  { background: var(--green-soft);  border-color: #c4eed6; color: var(--green-text); }
.chip-blue   { background: var(--blue-soft);   border-color: #d4dffa; color: var(--blue); }
.chip-purple { background: var(--purple-soft); border-color: #e0d7fd; color: var(--purple); }
.chip-red    { background: var(--red-soft);    border-color: #f8d3d4; color: var(--red); }
.chip-amber  { background: var(--amber-soft);  border-color: #f3e1b8; color: var(--amber); }

/* ===============================================================
   FORMS
   =============================================================== */
.form-label { font-weight: 600; font-size: .85rem; color: var(--text); margin-bottom: .4rem; }
.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .55rem .8rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    font-size: .9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(54, 98, 227, .12);
}
.form-control-sm, .form-select-sm { border-radius: 9px; padding: .4rem .65rem; }
.input-group-text { border-radius: var(--radius-sm); border-color: var(--border); background: var(--surface-2); color: var(--muted); }

/* ===============================================================
   PROGRESS / METERS
   =============================================================== */
.progress { background: var(--border-soft); border-radius: var(--radius-pill); overflow: hidden; }
.progress-bar { border-radius: var(--radius-pill); }
.progress-bar.bg-success { background: linear-gradient(90deg, var(--green), var(--green-dark)) !important; }

.meter { margin-bottom: .85rem; }
.meter .meter-top {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: .3rem;
}
.meter .meter-top .meter-name { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.meter .meter-top .meter-val { font-size: .78rem; font-weight: 700; }
.meter .meter-bar { height: 6px; border-radius: var(--radius-pill); background: var(--border-soft); overflow: hidden; }
.meter .meter-bar > span { display: block; height: 100%; border-radius: var(--radius-pill); }

.mini-bar { height: 5px; border-radius: 4px; background: var(--border-soft); overflow: hidden; }
.mini-bar > span { display: block; height: 100%; }

/* ===============================================================
   ALERTS
   =============================================================== */
.alert {
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: .9rem;
    box-shadow: var(--shadow-sm);
}
.alert-success { background: #e9faf0; border-color: #bdedcf; color: #0f7a3c; }
.alert-danger  { background: var(--red-soft); border-color: #f6cccc; color: #c22f2f; }
.alert-warning { background: var(--amber-soft); border-color: #f3e1b8; color: var(--amber); }

/* ===============================================================
   AVATARS
   =============================================================== */
.avatar-circle {
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    background: var(--blue-soft);
    color: var(--blue);
    position: relative;
}
.avatar-circle.av-sm { width: 32px; height: 32px; font-size: .72rem; }
.avatar-circle.av-md { width: 42px; height: 42px; font-size: .85rem; }
.avatar-circle.av-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar-circle.av-green  { background: var(--green-soft);  color: var(--green-text); }
.avatar-circle.av-purple { background: var(--purple-soft); color: var(--purple); }

.avatar-circle .channel-dot {
    position: absolute;
    right: -2px; bottom: -2px;
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    display: grid; place-items: center;
    font-size: .55rem;
    color: #fff;
}
.avatar-circle.av-lg .channel-dot { width: 22px; height: 22px; font-size: .72rem; }
.channel-dot.ch-whatsapp { background: var(--green); }
.channel-dot.ch-web      { background: var(--blue); }

/* ===============================================================
   INBOX (conversation list)
   =============================================================== */
.inbox-toolbar {
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
}
.inbox-search { position: relative; flex: 1 1 220px; max-width: 340px; }
.inbox-search .bi {
    position: absolute; left: .75rem; top: 50%;
    transform: translateY(-50%);
    color: var(--faint); font-size: .85rem;
}
.inbox-search input { padding-left: 2.1rem; }

.filter-chip {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    border-radius: var(--radius-pill);
    font-size: .76rem;
    font-weight: 600;
    padding: .34rem .85rem;
    transition: all .15s;
}
.filter-chip:hover { border-color: #cdd9f6; color: var(--blue); }
.filter-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.inbox-list { display: flex; flex-direction: column; }
.inbox-item {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .85rem 1.35rem;
    border-top: 1px solid var(--border-soft);
    cursor: pointer;
    transition: background .12s;
}
.inbox-item:first-child { border-top: none; }
.inbox-item:hover { background: var(--surface-2); }
.inbox-item .inbox-main { min-width: 0; flex: 1 1 auto; }
.inbox-item .inbox-name {
    font-weight: 700;
    font-size: .9rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
}
.inbox-item .inbox-snippet {
    color: var(--muted);
    font-size: .8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 520px;
    margin-top: 2px;
}
.inbox-item .inbox-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .3rem;
    flex-shrink: 0;
}
.inbox-item .inbox-time { font-size: .7rem; color: var(--faint); white-space: nowrap; }
.inbox-item .inbox-stats { display: flex; align-items: center; gap: .45rem; }
.inbox-item .inbox-stats .stat {
    font-size: .7rem; font-weight: 700;
    color: var(--muted);
    display: inline-flex; align-items: center; gap: .2rem;
}

/* ===============================================================
   CHAT WORKSPACE (3 panes)
   =============================================================== */
.inbox-shell {
    display: flex;
    height: calc(100vh - var(--topbar-h));
    overflow: hidden;
    background: var(--surface);
}

/* ----- Left rail: conversation list ----- */
.inbox-rail {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--surface);
}
.inbox-rail-head {
    padding: .9rem 1rem;
    border-bottom: 1px solid var(--border-soft);
}
.inbox-rail-head .rail-title {
    font-weight: 700; font-size: .92rem;
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: .6rem;
}
.inbox-rail-list { overflow-y: auto; flex: 1; }
.rail-item {
    display: flex;
    gap: .65rem;
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--border-soft);
    align-items: center;
    transition: background .12s;
}
.rail-item:hover { background: var(--surface-2); }
.rail-item.active { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.rail-item .rail-main { min-width: 0; flex: 1; }
.rail-item .rail-top { display: flex; align-items: baseline; justify-content: space-between; gap: .4rem; }
.rail-item .rail-name {
    font-size: .82rem; font-weight: 700; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-item .rail-time { font-size: .65rem; color: var(--faint); flex-shrink: 0; }
.rail-item .rail-snippet {
    font-size: .74rem; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 1px;
}
.rail-item .rail-flags { display: flex; gap: .25rem; margin-top: .25rem; }

/* ----- Center: chat pane ----- */
.chat-pane {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #f0f3f9;
}
.chat-head {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .7rem 1.1rem;
    display: flex;
    align-items: center;
    gap: .8rem;
    flex-shrink: 0;
}
.chat-head .chat-head-meta { min-width: 0; flex: 1; line-height: 1.25; }
.chat-head .chat-name {
    font-size: .98rem;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: -.2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-head .chat-sub {
    font-size: .72rem;
    color: var(--muted);
    display: flex; align-items: center; gap: .45rem;
    white-space: nowrap; overflow: hidden;
}
.chat-head .chat-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

.chat-thread {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.25rem 1.4rem;
    background-image: radial-gradient(rgba(54, 98, 227, .055) 1px, transparent 1px);
    background-size: 22px 22px;
}

/* Day separator */
.chat-day {
    display: flex;
    justify-content: center;
    margin: 1rem 0 .85rem;
}
.chat-day span {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: .68rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    padding: .25rem .8rem;
    box-shadow: var(--shadow-sm);
}

/* System / event line */
.chat-event {
    display: flex;
    justify-content: center;
    margin: .6rem 0;
}
.chat-event span {
    background: var(--amber-soft);
    border: 1px solid #f3e1b8;
    color: var(--amber);
    font-size: .72rem;
    border-radius: var(--radius-pill);
    padding: .3rem .85rem;
    max-width: 80%;
    text-align: center;
}

/* Message rows */
.msg {
    display: flex;
    gap: .6rem;
    margin-bottom: .9rem;
    align-items: flex-end;
}
.msg .msg-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: .68rem; font-weight: 700;
    flex-shrink: 0;
    margin-bottom: 2px;
}
.msg-in .msg-avatar  { background: var(--blue-soft); color: var(--blue); }
.msg-out .msg-avatar { background: var(--green-soft); color: var(--green-text); }
.msg-out .msg-avatar.av-agent { background: var(--purple-soft); color: var(--purple); }

.msg .msg-main { max-width: min(72%, 640px); min-width: 0; }
.msg-out { flex-direction: row-reverse; }
.msg-out .msg-main { display: flex; flex-direction: column; align-items: flex-end; }

.msg .msg-name {
    font-size: .7rem;
    font-weight: 700;
    margin: 0 .35rem 3px;
    letter-spacing: .1px;
}
.name-customer { color: var(--blue); }
.name-bot      { color: var(--green-text); }
.name-agent    { color: var(--purple); }

.msg .msg-bubble {
    padding: .55rem .8rem .45rem;
    border-radius: 14px;
    font-size: .875rem;
    line-height: 1.45;
    white-space: normal;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
    position: relative;
}
.msg .msg-text { white-space: pre-wrap; }
.bubble-in {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.bubble-bot {
    background: #dcf8e7;
    border: 1px solid #c2eed4;
    border-bottom-right-radius: 4px;
}
.bubble-agent {
    background: #e4ebff;
    border: 1px solid #d2ddfb;
    border-bottom-right-radius: 4px;
}
.msg .msg-time {
    display: inline-block;
    float: right;
    font-size: .62rem;
    color: var(--faint);
    margin: .55em 0 0 .65em;
}

/* Composer */
.chat-composer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: .8rem 1.1rem;
    flex-shrink: 0;
}
.composer-error {
    background: var(--red-soft);
    border: 1px solid #f8d3d4;
    color: var(--red);
    border-radius: 10px;
    font-size: .78rem;
    padding: .45rem .75rem;
    margin-bottom: .55rem;
}
.composer-box {
    display: flex;
    align-items: flex-end;
    gap: .6rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    padding: .45rem .5rem .45rem .9rem;
    transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(54, 98, 227, .1);
    background: var(--surface);
}
.composer-box textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: .9rem;
    line-height: 1.45;
    max-height: 140px;
    padding: .3rem 0;
    color: var(--text);
}
.composer-box textarea:focus { outline: none; box-shadow: none; }
.composer-send {
    width: 38px; height: 38px;
    border-radius: 11px;
    border: none;
    background: var(--blue);
    color: #fff;
    display: grid; place-items: center;
    font-size: .95rem;
    flex-shrink: 0;
    transition: background .15s, transform .12s;
    box-shadow: 0 4px 10px rgba(54, 98, 227, .3);
}
.composer-send:hover:not(:disabled) { background: var(--blue-dark); }
.composer-send:disabled { opacity: .55; }
.composer-hint {
    font-size: .68rem;
    color: var(--faint);
    margin-top: .45rem;
    display: flex;
    align-items: center;
    gap: .3rem;
}
.composer-note {
    background: var(--surface-2);
    border: 1px dashed var(--border);
    color: var(--muted);
    border-radius: 12px;
    font-size: .8rem;
    padding: .7rem .9rem;
    text-align: center;
}

/* ----- Right rail: contact & insights ----- */
.chat-side {
    width: 324px;
    flex-shrink: 0;
    border-left: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.side-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1rem 1.1rem;
}
.side-card .side-card-title {
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--faint);
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: .45rem;
}
.side-card .side-card-title .bi { color: var(--blue); font-size: .85rem; }

.contact-card { text-align: center; }
.contact-card .contact-name {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--blue);
    margin-top: .65rem;
    letter-spacing: -.2px;
    word-break: break-word;
}
.contact-card .contact-id {
    font-size: .74rem;
    color: var(--muted);
    font-family: var(--bs-font-monospace, monospace);
    word-break: break-all;
    margin-top: .15rem;
}
.contact-card .contact-chips {
    display: flex; justify-content: center; gap: .35rem;
    flex-wrap: wrap; margin-top: .6rem;
}

.detail-list { font-size: .8rem; }
.detail-list .detail-row {
    display: flex;
    justify-content: space-between;
    gap: .8rem;
    padding: .42rem 0;
    border-top: 1px solid var(--border-soft);
}
.detail-list .detail-row:first-child { border-top: none; }
.detail-list .detail-key { color: var(--muted); flex-shrink: 0; }
.detail-list .detail-val { font-weight: 600; text-align: right; word-break: break-word; min-width: 0; }

.mood-banner {
    display: flex;
    align-items: center;
    gap: .8rem;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: .7rem .9rem;
    margin-bottom: .9rem;
}
.mood-banner .mood-emoji { font-size: 1.7rem; line-height: 1; }
.mood-banner .mood-name { font-weight: 700; text-transform: capitalize; font-size: .9rem; }
.mood-banner .mood-desc { font-size: .7rem; color: var(--muted); }

.insight-callout {
    background: var(--blue-soft);
    border: 1px solid #d4dffa;
    border-radius: 12px;
    padding: .65rem .85rem;
    font-size: .78rem;
    color: var(--text);
}
.insight-callout .bi { color: var(--blue); }

/* Side panel as off-canvas on smaller screens */
.chat-side-backdrop {
    position: fixed; inset: 0;
    background: rgba(10, 14, 24, .45);
    z-index: 1041;
    opacity: 0; visibility: hidden;
    transition: opacity .22s;
}
.chat-side-backdrop.show { opacity: 1; visibility: visible; }

/* ===============================================================
   EMPTY STATES
   =============================================================== */
.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 2.5rem 1rem;
}
.empty-state .bi { font-size: 2rem; color: var(--faint); display: block; margin-bottom: .6rem; }

/* ===============================================================
   PAGINATION
   =============================================================== */
.pagination { margin-bottom: 0; gap: 4px; }
.pagination .page-link {
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 9px !important;
    font-size: .82rem;
    font-weight: 600;
    padding: .35rem .7rem;
}
.pagination .page-link:hover { background: var(--surface-2); color: var(--text); }
.pagination .page-item.active .page-link { background: var(--blue); border-color: var(--blue); color: #fff; }
.pagination .page-item.disabled .page-link { color: var(--faint); background: transparent; }

/* ===============================================================
   LIST ROWS (training sources, leads extras)
   =============================================================== */
.list-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .8rem 0;
    border-top: 1px solid var(--border-soft);
}
.list-row:first-of-type { border-top: none; }
.list-row .row-icon {
    width: 38px; height: 38px;
    border-radius: 11px;
    display: grid; place-items: center;
    font-size: 1rem;
    flex-shrink: 0;
    background: var(--blue-soft);
    color: var(--blue);
}
.list-row .row-icon.is-doc { background: var(--purple-soft); color: var(--purple); }
.list-row .row-main { min-width: 0; flex: 1; }

/* ===============================================================
   CONTACTS
   =============================================================== */
.contacts-grid {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}
.contacts-filter-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: .9rem;
    box-shadow: var(--shadow-sm);
}
.contacts-filter-panel .panel-label {
    font-size: .66rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--faint);
    font-weight: 800;
    margin: .1rem .25rem .55rem;
}
.segment-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .7rem;
    border-radius: 10px;
    color: var(--muted);
    padding: .55rem .65rem;
    font-size: .84rem;
    font-weight: 700;
    transition: background .15s, color .15s;
}
.segment-link span {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}
.segment-link strong {
    color: var(--faint);
    font-size: .72rem;
}
.segment-link:hover,
.segment-link.active {
    background: var(--blue-soft);
    color: var(--blue);
}
.segment-link.active strong { color: var(--blue); }
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}
.contacts-table-card { min-width: 0; }
.contacts-search-form {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.contacts-search-form .inbox-search { max-width: 360px; min-width: min(260px, 100%); }
.contact-row-name {
    color: var(--blue);
    max-width: 230px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contact-muted {
    color: var(--muted);
    font-size: .82rem;
}
.contact-tags {
    display: flex;
    gap: .3rem;
    flex-wrap: wrap;
    max-width: 240px;
}
.contact-import-drop {
    display: flex;
    gap: 1rem;
    align-items: center;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    padding: .95rem 1rem;
}
.contact-import-drop > .bi {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 1.35rem;
    flex-shrink: 0;
}

/* ===============================================================
   RESPONSIVE
   =============================================================== */
@media (max-width: 1399.98px) {
    .inbox-rail { width: 270px; }
    .chat-side { width: 300px; }
}

@media (max-width: 1199.98px) {
    .inbox-rail { display: none; }
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar .sidebar-toggle { display: inline-flex; }
    .content-area { padding: 1.1rem 1rem; }
    .content-area.content-flush { padding: 0; }

    /* Right rail becomes an overlay drawer */
    .chat-side {
        position: fixed;
        top: 0; right: 0; bottom: 0;
        z-index: 1042;
        width: min(340px, 92vw);
        transform: translateX(102%);
        transition: transform .26s cubic-bezier(.4, 0, .2, 1);
        box-shadow: var(--shadow-lg);
        border-left: 1px solid var(--border);
    }
    .chat-side.show { transform: translateX(0); }

    .msg .msg-main { max-width: 84%; }
}

@media (max-width: 767.98px) {
    .contacts-grid {
        grid-template-columns: 1fr;
    }
    .contacts-filter-panel {
        position: static;
    }
    .contacts-search-form {
        width: 100%;
    }
    .contacts-search-form .inbox-search {
        max-width: none;
        width: 100%;
    }
    .contact-import-drop {
        align-items: flex-start;
    }
}

/* ===============================================================
   LOGIN
   =============================================================== */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background: var(--bg);
}
.auth-brand-pane {
    flex: 1 1 52%;
    background:
        radial-gradient(700px 420px at 85% -10%, rgba(54, 98, 227, .35), transparent 60%),
        radial-gradient(600px 420px at -10% 110%, rgba(37, 211, 102, .25), transparent 60%),
        linear-gradient(160deg, #13203a 0%, #0b1322 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem 4.5rem;
    position: relative;
    overflow: hidden;
}
.auth-brand-pane .auth-logo-row { display: flex; align-items: center; gap: .8rem; margin-bottom: 2.2rem; }
.auth-brand-pane .auth-logo {
    width: 46px; height: 46px;
    border-radius: 13px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, var(--green), var(--green-dark));
    color: #fff; font-size: 1.4rem;
    box-shadow: 0 10px 24px rgba(37, 211, 102, .4);
}
.auth-brand-pane .auth-product { font-weight: 800; font-size: 1.1rem; letter-spacing: -.2px; color: #fff; }
.auth-brand-pane h1 {
    color: #fff;
    font-weight: 800;
    font-size: clamp(1.6rem, 2.6vw, 2.3rem);
    letter-spacing: -.6px;
    line-height: 1.2;
    max-width: 520px;
}
.auth-brand-pane p { color: rgba(255, 255, 255, .6); max-width: 460px; font-size: .95rem; }
.auth-brand-pane .auth-points { margin-top: 1.6rem; display: flex; flex-direction: column; gap: .8rem; }
.auth-brand-pane .auth-point { display: flex; align-items: center; gap: .7rem; color: rgba(255,255,255,.82); font-size: .9rem; }
.auth-brand-pane .auth-point .bi {
    width: 30px; height: 30px;
    border-radius: 9px;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, .08);
    color: var(--green);
    font-size: .9rem;
    flex-shrink: 0;
}

.auth-form-pane {
    flex: 1 1 48%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--surface);
}
.auth-card { width: 100%; max-width: 396px; }
.auth-title { font-weight: 800; font-size: 1.45rem; letter-spacing: -.4px; }
.auth-sub { color: var(--muted); font-size: .9rem; }
.auth-foot { text-align: center; margin-top: 2rem; color: var(--faint); font-size: .76rem; }

@media (max-width: 899.98px) {
    .auth-brand-pane { display: none; }
}

/* ============================================================
   Attention alerts (bell + panel + toasts) — portal-alerts.js
   ============================================================ */
.alert-bell-wrap { position: relative; }

.alert-bell {
    position: relative;
    width: 38px; height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-soft, #5b6b8c);
    font-size: 1.05rem;
    display: inline-flex; align-items: center; justify-content: center;
    transition: border-color .15s, color .15s;
}
.alert-bell:hover { border-color: var(--blue); color: var(--blue); }
.alert-bell.has-alerts { color: var(--red); border-color: var(--red); animation: alert-bell-pulse 2.4s ease-in-out infinite; }

@keyframes alert-bell-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .28); }
    50%      { box-shadow: 0 0 0 6px rgba(229, 72, 77, 0); }
}

.alert-bell-badge {
    position: absolute; top: -6px; right: -6px;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px;
    background: var(--red); color: #fff;
    font-size: .68rem; font-weight: 700; line-height: 18px;
    text-align: center;
}

.alert-panel {
    display: none;
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 340px; max-width: calc(100vw - 32px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(23, 34, 59, .14);
    z-index: 1080;
    overflow: hidden;
}
.alert-panel.show { display: block; }

.alert-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    font-weight: 700; font-size: .85rem;
}
.alert-mute {
    border: 0; background: transparent;
    color: var(--blue); font-size: .75rem; font-weight: 600;
}
.alert-mute.is-muted { color: var(--text-soft, #5b6b8c); }

.alert-panel-list { max-height: 330px; overflow-y: auto; }

.alert-panel-empty {
    display: flex; align-items: center; gap: 8px;
    padding: 18px 14px;
    color: var(--text-soft, #5b6b8c); font-size: .85rem;
}
.alert-panel-empty i { color: var(--green-dark); font-size: 1.05rem; }

.alert-panel-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-soft);
    text-decoration: none; color: var(--text);
}
.alert-panel-item:last-child { border-bottom: 0; }
.alert-panel-item:hover { background: var(--surface-2); }

.alert-item-icon {
    flex: 0 0 34px; height: 34px;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1rem;
}
.kind-handoff  .alert-item-icon { background: var(--purple-soft); color: var(--purple); }
.kind-hot_lead .alert-item-icon { background: var(--red-soft); color: var(--red); }

.alert-item-body { min-width: 0; display: flex; flex-direction: column; }
.alert-item-title { font-size: .84rem; font-weight: 700; line-height: 1.25; }
.alert-item-detail {
    font-size: .76rem; color: var(--text-soft, #5b6b8c);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.alert-item-go { margin-left: auto; color: var(--text-soft, #5b6b8c); font-size: .8rem; }

/* Toasts (bottom-right, clickable) */
.alert-toast-wrap {
    position: fixed; right: 18px; bottom: 18px;
    display: flex; flex-direction: column; gap: 10px;
    z-index: 1090;
    max-width: min(360px, calc(100vw - 36px));
}
.alert-toast {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--blue);
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(23, 34, 59, .18);
    text-decoration: none; color: var(--text);
    animation: alert-toast-in .25s ease-out;
}
.alert-toast.kind-handoff  { border-left-color: var(--purple); }
.alert-toast.kind-hot_lead { border-left-color: var(--red); }
.alert-toast.leaving { opacity: 0; transform: translateY(6px); transition: all .35s; }

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

.alert-toast-close {
    margin-left: auto;
    border: 0; background: transparent;
    color: var(--text-soft, #5b6b8c);
    font-size: 1.1rem; line-height: 1;
}

/* ===========================================================
   Agent-assist: handoff briefing, canned replies, CSAT, gaps
   =========================================================== */

/* Handoff briefing card */
.brief-points { list-style: none; margin: 0 0 .5rem; padding: 0; }
.brief-points li {
    position: relative; padding-left: 1rem;
    font-size: .78rem; line-height: 1.45; color: var(--text);
    margin-bottom: .25rem;
}
.brief-points li::before {
    content: ""; position: absolute; left: 0; top: .5rem;
    width: 5px; height: 5px; border-radius: 50%; background: var(--blue);
}
.draft-box {
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--blue-soft, #e8eefc); padding: .6rem .7rem; margin-top: .25rem;
}
.draft-label {
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--blue-dark, #2b51c4); margin-bottom: .35rem;
}
.draft-text {
    font-size: .8rem; line-height: 1.5; color: var(--text);
    margin: 0 0 .5rem; white-space: pre-wrap;
}

/* CSAT */
.csat-result { display: inline-flex; align-items: center; gap: .25rem; }

/* Composer: canned-reply picker */
.composer-tools { position: relative; margin-bottom: .4rem; display: flex; align-items: center; gap: .4rem; }
.composer-tool-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    border: 1px solid var(--border); background: var(--surface); color: var(--muted);
    border-radius: 8px; padding: .25rem .6rem;
    font-size: .76rem; font-weight: 600; cursor: pointer;
}
.composer-tool-btn:hover { color: var(--blue); border-color: var(--blue); }
.canned-panel {
    position: absolute; bottom: calc(100% + 6px); left: 0;
    width: min(420px, 80vw); max-height: 320px;
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 12px 32px rgba(23, 34, 59, .16);
    z-index: 40; overflow: hidden;
}
.canned-search { position: relative; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.canned-search i {
    position: absolute; left: 1.05rem; top: 50%; transform: translateY(-50%);
    color: var(--muted); font-size: .8rem;
}
.canned-search input {
    width: 100%; border: 0; outline: 0; padding: .3rem .3rem .3rem 1.5rem;
    font-size: .82rem; background: transparent; color: var(--text);
}
.canned-list { overflow-y: auto; }
.canned-item {
    display: grid; grid-template-columns: 1fr auto; gap: .15rem .5rem;
    width: 100%; text-align: left; border: 0; background: transparent;
    border-bottom: 1px solid var(--border); padding: .55rem .7rem; cursor: pointer;
}
.canned-item:last-child { border-bottom: 0; }
.canned-item:hover { background: var(--surface-2, #f0f2f7); }
.canned-item-title { font-size: .82rem; font-weight: 600; color: var(--text); }
.canned-item-preview {
    grid-column: 1 / -1; font-size: .73rem; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* AI tools panel — rewrite the agent's draft (tone / translate / grammar / simplify / concise). */
.ai-panel {
    position: absolute; bottom: calc(100% + 6px); left: 0;
    width: min(360px, 86vw);
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 12px 32px rgba(23, 34, 59, .16);
    padding: .5rem; z-index: 40;
}
.ai-panel-head {
    display: flex; align-items: center; gap: .35rem;
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    color: var(--muted); padding: .2rem .35rem .4rem;
}
.ai-section { padding: .3rem 0; border-top: 1px solid var(--border); }
.ai-section:first-of-type { border-top: 0; padding-top: 0; }
.ai-section-label { font-size: .7rem; font-weight: 600; color: var(--muted); padding: .15rem .35rem .35rem; }
.ai-item {
    display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left;
    border: 0; background: transparent; color: var(--text);
    border-radius: 8px; padding: .45rem .5rem; font-size: .82rem; font-weight: 500; cursor: pointer;
}
.ai-item:hover { background: var(--surface-2, #f0f2f7); color: var(--blue); }
.ai-item i { color: var(--muted); font-size: .9rem; }
.ai-item:hover i { color: var(--blue); }
.ai-chips { display: flex; flex-wrap: wrap; gap: .3rem; padding: 0 .35rem; }
.ai-chip {
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 999px; padding: .2rem .6rem; font-size: .76rem; font-weight: 500; cursor: pointer;
}
.ai-chip:hover { border-color: var(--blue); color: var(--blue); background: var(--surface-2, #f0f2f7); }

/* AI tools trigger — a gradient "magic" pill so the AI feature stands out next
   to the plainer composer buttons. Used on both the conversation & ticket boxes. */
.ai-tools-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    border: 0; border-radius: 999px; line-height: 1.2; cursor: pointer;
    background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 100%);
    color: #fff; font-weight: 600; padding: .34rem .85rem; font-size: .78rem;
    box-shadow: 0 3px 10px rgba(124, 92, 252, .28);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.ai-tools-btn:hover, .ai-tools-btn:focus {
    color: #fff; filter: brightness(1.07); transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(124, 92, 252, .42);
}
.ai-tools-btn:active { transform: translateY(0); box-shadow: 0 3px 10px rgba(124, 92, 252, .3); }
.ai-tools-btn:disabled { opacity: .6; box-shadow: none; transform: none; filter: none; cursor: default; }
.ai-tools-btn .bi { font-size: .9rem; }
.ai-tools-btn.dropdown-toggle::after { margin-left: .15rem; opacity: .9; vertical-align: .15em; }

/* Knowledge gaps */
.gap-examples { list-style: none; margin: 0; padding: 0; }
.gap-examples li { font-size: .76rem; color: var(--muted); line-height: 1.4; margin-bottom: .15rem; }
.gap-unrec { display: flex; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.gap-unrec:last-child { border-bottom: 0; }
.gap-unrec > i { color: var(--blue); font-size: .9rem; margin-top: .1rem; }

/* Conversation tags (editor chips + inbox tag chips) */
.chip-tag { text-decoration: none; cursor: pointer; }
.chip-tag:hover { filter: brightness(.97); }
.tag-editor { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.tag-editor:empty { display: none; }
.tag-chip {
    display: inline-flex; align-items: center; gap: .2rem;
    background: var(--blue-soft, #e8eefc); color: var(--blue-dark, #2b51c4);
    border-radius: 999px; padding: .15rem .25rem .15rem .55rem;
    font-size: .75rem; font-weight: 600;
}
.tag-chip-x {
    border: 0; background: transparent; cursor: pointer; line-height: 1;
    color: var(--blue-dark, #2b51c4); font-size: .95rem; padding: 0 .3rem; border-radius: 50%;
}
.tag-chip-x:hover { background: rgba(0, 0, 0, .08); }

/* Internal notes */
.notes-hint { font-size: .72rem; color: var(--muted); margin-bottom: .5rem; }
.note-form { margin-bottom: .75rem; }
.notes-list { display: flex; flex-direction: column; gap: .5rem; }
.notes-empty { font-size: .8rem; color: var(--muted); }
.note-item {
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2, #f7f8fb); padding: .5rem .6rem;
}
.note-meta { display: flex; align-items: center; gap: .4rem; margin-bottom: .2rem; }
.note-author { font-size: .76rem; font-weight: 700; color: var(--text); }
.note-time { font-size: .68rem; color: var(--muted); }
.note-del {
    margin-left: auto; border: 0; background: transparent; cursor: pointer;
    color: var(--muted); font-size: .8rem; padding: .1rem .25rem;
}
.note-del:hover { color: var(--red); }
.note-body { font-size: .8rem; line-height: 1.5; color: var(--text); white-space: pre-wrap; }

/* Inbox active-filter bar */
.active-filters {
    display: flex; align-items: center; flex-wrap: wrap; gap: .5rem;
    padding: .6rem 1rem; border-bottom: 1px solid var(--border-soft);
}
.clear-filters {
    display: inline-flex; align-items: center; gap: .25rem;
    font-size: .76rem; color: var(--muted); text-decoration: none;
}
.clear-filters:hover { color: var(--red); }

/* Voice notes (transcribed inbound + audio player) */
.voice-tag, .media-tag {
    display: flex; align-items: center; gap: .25rem;
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    opacity: .65; margin-bottom: .3rem;
}
.voice-tag i, .media-tag i { font-size: .8rem; }
.voice-audio { display: block; width: 230px; max-width: 100%; height: 38px; margin: 0 0 .35rem; }
.msg-image-link { display: block; margin-bottom: .35rem; }
.msg-image { display: block; max-width: 240px; max-height: 280px; width: auto; height: auto; border-radius: 10px; border: 1px solid var(--border); }
.msg-image-desc { display: flex; align-items: flex-start; gap: .3rem; font-size: .72rem; font-style: italic; opacity: .75; margin-bottom: .3rem; }
.msg-image-desc i { margin-top: .15rem; font-style: normal; }
.msg-file {
    display: inline-flex; align-items: center; gap: .4rem;
    max-width: 250px; margin-bottom: .35rem; padding: .45rem .6rem;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface, #fff); color: var(--text); text-decoration: none;
}
.msg-file:hover { border-color: var(--blue); color: var(--blue); }
.msg-file-name { flex: 1; font-size: .8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-file-dl { font-size: .85rem; opacity: .7; }
.composer-attach {
    width: 38px; height: 38px; border-radius: 11px; border: none; flex-shrink: 0;
    background: transparent; color: var(--muted); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.composer-attach:hover { color: var(--blue); background: var(--blue-soft, #e8eefc); }
.composer-attach:disabled { opacity: .5; cursor: default; }
.composer-attach.is-recording { color: #e23b3b; background: rgba(226, 59, 59, .12); }

/* Voice message recorder (agent → customer) */
.voice-recorder { margin-top: .5rem; }
.voice-rec-row {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .4rem .6rem;
}
.voice-rec-dot {
    width: 10px; height: 10px; border-radius: 50%; background: #e23b3b; flex-shrink: 0;
    animation: voicePulse 1.1s ease-in-out infinite;
}
@keyframes voicePulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.voice-rec-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .82rem; color: var(--text); }
.voice-rec-status { font-size: .78rem; color: var(--muted); }
.voice-rec-actions { margin-left: auto; display: flex; gap: .4rem; align-items: center; }
.voice-rec-preview .voice-audio { margin: 0; flex: 1; min-width: 160px; }

/* Agent translation panel */
.translate-list { max-height: 320px; overflow-y: auto; }
.translate-item { border-top: 1px solid var(--border); padding: .4rem 0; }
.translate-item:first-child { border-top: 0; }
.translate-en { font-size: .8rem; color: var(--text); line-height: 1.4; }
.translate-og { font-size: .72rem; color: var(--muted); font-style: italic; margin-top: .1rem; }
