:root{--brand-primary:#2563EB;--brand-dark:#1E40AF;--brand-accent:#F59E0B;}
/* ============================================
   WhatsApp CRM - Design System (neutral defaults; per-instance brand from config)
   ============================================ */

:root {
    --brand-teal: var(--brand-primary);
    /* shade variants DERIVED from the config-driven brand colors (no hardcoded palette) */
    --brand-teal-dark: color-mix(in srgb, var(--brand-primary) 78%, black);
    --brand-teal-light: color-mix(in srgb, var(--brand-primary) 12%, white);
    --accent-orange: var(--brand-accent);
    --brand-turquoise: var(--brand-dark);
    --accent-orange-dark: color-mix(in srgb, var(--brand-accent) 80%, black);
    --accent-orange-light: color-mix(in srgb, var(--brand-accent) 16%, white);

    --bg-app: #f5f6f8;
    --bg-card: #ffffff;
    --bg-hover: #f8f9fb;
    --bg-active: #eff5f8;
    --bg-active-strong: #d8e7ec;

    --text-primary: #1a1f2e;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --text-on-dark: #ffffff;

    --border: #e8eaed;
    --border-strong: #d1d5db;

    /* ── semantic colors (universal, NOT brand — always distinguishable) ──
       primary = blue (brand, config-driven) · CTA = orange (brand accent, used sparingly)
       success = green · warning = amber · danger = red · info = blue */
    --primary: var(--brand-primary);
    --cta: var(--brand-accent);
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: var(--brand-primary);
    --info-light: #eff6ff;
    --purple: #8b5cf6;

    --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
    --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
    --shadow-md: 0 4px 12px rgba(16,24,40,.08), 0 2px 4px rgba(16,24,40,.04);
    --shadow-lg: 0 10px 25px rgba(16,24,40,.08), 0 4px 10px rgba(16,24,40,.04);

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

    /* ── spacing scale (4px base) ── */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* ── typography scale ── */
    --fs-xs: 11px;
    --fs-sm: 12.5px;
    --fs-base: 14px;
    --fs-md: 15px;
    --fs-lg: 17px;
    --fs-xl: 20px;
    --fs-2xl: 26px;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    --topbar-h: 64px;
    --sidebar-w: 240px;
    --conv-list-w: 360px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Heebo', system-ui, -apple-system, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    direction: rtl;
    height: 100%;
    overflow: hidden;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, textarea, select {
    font-family: inherit;
    color: inherit;
}

/* ============================================
   TOPBAR
   ============================================ */
.app-topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr auto;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1.5rem;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.topbar-logo {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: contain;
}

.topbar-logo-fallback {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
}

.topbar-title-main {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--brand-teal);
    line-height: 1.1;
}

.topbar-title-sub {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 1px;
}

.topbar-search {
    position: relative;
    max-width: 480px;
    display: flex;
    align-items: center;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 .75rem;
    transition: all .15s;
}

.topbar-search:focus-within {
    background: white;
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 3px rgba(29,72,85,.08);
}

.topbar-search svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.topbar-search input {
    flex: 1;
    border: none;
    background: transparent;
    padding: .65rem .5rem;
    font-size: .9rem;
    outline: none;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.btn-primary-lg {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: var(--accent-orange);
    color: white;
    padding: .625rem 1.125rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: .9rem;
    transition: all .15s;
    box-shadow: 0 2px 8px rgba(232,122,61,.25);
}

.btn-primary-lg:hover {
    background: var(--accent-orange-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(232,122,61,.35);
}

.btn-secondary {
    padding: .625rem 1.125rem;
    border-radius: 10px;
    background: var(--bg-app);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: .9rem;
    transition: all .15s;
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text-primary);
}

.topbar-user {
    position: relative;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .35rem .65rem .35rem .85rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s;
    border: 1px solid var(--border);
    background: white;
}

.user-chip:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.user-info {
    line-height: 1.15;
}

.user-name {
    font-weight: 700;
    font-size: .85rem;
    color: var(--text-primary);
}

.user-role {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.user-chev {
    font-size: .55rem;
    color: var(--text-muted);
    margin-right: .35rem;
}

.user-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 50;
}

.user-menu.show {
    display: block;
}

.user-menu-item {
    display: block;
    padding: .65rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    transition: background .12s;
}

.user-menu-item:hover {
    background: var(--bg-hover);
}

/* ============================================
   LAYOUT
   ============================================ */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) var(--conv-list-w) 1fr;
    height: calc(100vh - var(--topbar-h));
    overflow: hidden;
}

/* 4.2: מזעור פאנלים (אדמין) — רשימת השיחות האמצעית + פאנל פרטי הלקוח, כל אחד בנפרד */
body.collapsed-convlist .app-layout { grid-template-columns: var(--sidebar-w) 0 1fr; }
body.collapsed-convlist .app-conv-list { display: none; }
body.collapsed-custpanel .conv-view-body { grid-template-columns: 1fr 0 !important; }
body.collapsed-custpanel .customer-panel { display: none; }
.panel-toggle-btn { padding: .5rem .7rem; border-radius: 8px; background: var(--bg-app); color: var(--text-secondary); font-size: 1rem; transition: all .15s; }
.panel-toggle-btn:hover { background: var(--border); color: var(--text-primary); }
.panel-toggle-btn.active { background: var(--brand-teal-light); color: var(--brand-teal); }

/* ============================================
   SIDEBAR
   ============================================ */
.app-sidebar {
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    padding: 1rem .75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section-title {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 0 .75rem;
    margin-bottom: .5rem;
}

.sidebar-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: none;
    padding: .55rem .75rem;
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, color .12s;
    border-radius: 6px;
}

.sidebar-section-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.section-chev {
    font-size: .65rem;
    color: var(--text-muted);
    transition: transform .18s ease;
}

.sidebar-section.collapsed .section-chev {
    transform: rotate(-90deg);
}

.sidebar-section.collapsed .sidebar-section-body {
    display: none;
}

.sidebar-section-body {
    animation: sectionExpand .2s ease-out;
}

@keyframes sectionExpand {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.sidebar-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    border-radius: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all .12s;
    margin-bottom: 2px;
    text-decoration: none;
    text-align: right;
}

.sidebar-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-item.active {
    background: var(--bg-active);
    color: var(--brand-teal);
    font-weight: 600;
}

.sidebar-item.active .sidebar-icon {
    transform: scale(1.05);
}

.sidebar-icon {
    font-size: 1.1rem;
    line-height: 1;
    transition: transform .12s;
    flex-shrink: 0;
}

.sidebar-label {
    flex: 1;
    font-size: .9rem;
}

.sidebar-count {
    background: var(--border);
    color: var(--text-secondary);
    padding: .1rem .5rem;
    border-radius: 10px;
    font-size: .7rem;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
}

.sidebar-item.active .sidebar-count {
    background: var(--brand-teal);
    color: white;
}

.badge-warning {
    background: var(--warning) !important;
    color: white !important;
}

.dept-item, .agent-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .75rem;
    border-radius: 8px;
    transition: all .12s;
    cursor: pointer;
    text-align: right;
}

.dept-item:hover, .agent-item:hover {
    background: var(--bg-hover);
}

.dept-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dept-name, .agent-name {
    flex: 1;
    font-size: .85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.dept-count, .agent-count {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.agent-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.sidebar-link {
    display: block;
    padding: .5rem .75rem;
    color: var(--text-muted);
    font-size: .8rem;
    text-decoration: none;
    border-radius: 6px;
    transition: all .12s;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.admin-shortcut {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem .85rem;
    background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-dark));
    color: white;
    border-radius: 10px;
    text-decoration: none;
    font-size: .9rem;
    transition: all .15s;
    box-shadow: 0 2px 6px rgba(29,72,85,.25);
}

.admin-shortcut:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(29,72,85,.35);
}

.admin-shortcut-arrow { margin-right: auto; font-weight: 700; }

/* ============================================
   CONVERSATIONS LIST
   ============================================ */
.app-conv-list {
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.conv-list-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.conv-list-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.conv-count-badge {
    background: var(--bg-app);
    color: var(--text-secondary);
    padding: .15rem .6rem;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 700;
}

.conv-list-body {
    flex: 1;
    overflow-y: auto;
}

.conv-card {
    display: flex;
    gap: .75rem;
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .1s;
    position: relative;
}

.conv-card:hover {
    background: var(--bg-hover);
}

.conv-card.selected {
    background: var(--bg-active);
}

.conv-card.selected::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--brand-teal);
}

.conv-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .95rem;
    flex-shrink: 0;
    position: relative;
}

.conv-avatar.avatar-orange {
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-orange-dark));
}

.conv-avatar.avatar-purple {
    background: linear-gradient(135deg, var(--purple), #6d28d9);
}

.conv-status-dot {
    position: absolute;
    bottom: -2px;
    left: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.status-bot { background: var(--info); }
.status-queue { background: var(--warning); animation: pulse 1.8s infinite; }
.status-human { background: var(--success); }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: .7; }
}

.conv-content {
    flex: 1;
    min-width: 0;
}

.conv-row1 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
}

.conv-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.conv-row2 {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-top: .25rem;
    font-size: .8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

/* חלק 3: chip אחיד לכל התגיות והשמות בשורת השיחה — גודל זהה, שורה אחת */
.conv-row2 > span {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    white-space: nowrap;
    font-size: .72rem;
    line-height: 1.5;
    border-radius: 10px;
    padding: 1px 8px;
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-phone {
    font-family: 'Heebo', monospace;
    direction: ltr;
    background: var(--bg-app);
    color: #1a1a1a;
    font-weight: 600;
}

.conv-dept-tag {
    background: var(--bg-app) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border);
    font-weight: 600;
}

.conv-agent-tag {
    background: var(--bg-app) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border);
    font-weight: 500;
}

.conv-stage-tag {
    font-weight: 600;
    border: none;
}

.conv-preview {
    margin-top: .3rem;
    font-size: .82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: .35rem;
}

.preview-sender {
    color: var(--text-muted);
    font-weight: 600;
    font-size: .75rem;
}

.unread-badge {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-orange);
    color: white;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: .68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   CONVERSATION VIEW (right pane)
   ============================================ */
.app-conv-view {
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
    overflow: hidden;
    min-height: 0;   /* #6: let the inner scroll area shrink so the composer is never pushed off-screen */
}

.conv-view-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: .85rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.conv-view-header .conv-avatar {
    width: 40px;
    height: 40px;
    font-size: .85rem;
}

.conv-view-info {
    flex: 1;
    min-width: 0;
}

.conv-view-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.conv-view-meta {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.conv-view-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all .15s;
    background: transparent;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-icon.btn-icon-primary {
    background: var(--brand-teal);
    color: white;
}

.btn-icon.btn-icon-primary:hover {
    background: var(--brand-teal-dark);
}

.btn-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: .82rem;
    transition: all .15s;
}

.btn-pill-take {
    background: var(--brand-teal);
    color: white;
}

.btn-pill-take:hover {
    background: var(--brand-teal-dark);
}

.btn-pill-release {
    background: var(--bg-app);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-pill-release:hover {
    background: var(--border);
}

/* #7: סגירת/פתיחת שיחה (סיום טיפול) */
.btn-pill-close {
    background: #16a34a;
    color: #fff;
}
.btn-pill-close:hover {
    background: #15803d;
}
.btn-pill-reopen {
    background: var(--bg-app);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-pill-reopen:hover {
    background: var(--border);
}

.conv-view-body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 280px;
    overflow: hidden;
    min-height: 0;   /* #6 */
}

.chat-area {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-app);
    min-height: 0;   /* #6: the composer (.chat-input-area, flex-shrink:0) always stays visible */
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    background: #efeae2;   /* WhatsApp-style chat background (white customer bubbles stand out) */
}

.msg-row {
    display: flex;
    margin-bottom: 1rem;
    gap: .65rem;
}

.msg-row.msg-out {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    margin-top: 18px;
}

.msg-avatar-bot { background: var(--info); }
.msg-avatar-customer { background: var(--brand-teal); }
.msg-avatar-agent { background: var(--accent-orange); }

.msg-content-wrap {
    max-width: 65%;
    display: flex;
    flex-direction: column;
}

.msg-out .msg-content-wrap {
    align-items: flex-end;
}

.msg-meta {
    font-size: .7rem;
    color: var(--text-muted);
    margin-bottom: .2rem;
    padding: 0 .25rem;
    font-weight: 500;
}

.msg-bubble {
    background: white;
    padding: .65rem .85rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: .92rem;
    line-height: 1.45;
}

.msg-row.msg-sender-customer .msg-bubble {
    background: white;
    border-radius: 12px 12px 12px 4px;
}

.msg-row.msg-sender-bot .msg-bubble {
    background: var(--brand-teal-light);
    border-color: #c8d9de;
    border-radius: 4px 12px 12px 12px;
}

/* WhatsApp-style: our (outgoing) messages = WhatsApp green with dark text; customer = white */
.msg-row.msg-out:not(.msg-sender-bot) .msg-bubble {
    background: #d9fdd3;
    color: #111b21;
    border-color: #c5efbb;
    border-radius: 4px 12px 12px 12px;
}

.msg-time-inline {
    font-size: .68rem;
    color: var(--text-muted);
    margin-top: .2rem;
    padding: 0 .25rem;
}

.chat-input-area {
    background: white;
    border-top: 1px solid var(--border);
    padding: .75rem 1rem;
    flex-shrink: 0;
    position: relative;
}

.quick-replies-bar {
    display: flex;
    align-items: center;
    margin-bottom: .5rem;
    position: relative;
}

.qr-toggle {
    background: var(--brand-teal-light);
    color: var(--brand-teal);
    padding: .35rem .75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: .8rem;
    transition: all .15s;
    border: 1px solid transparent;
    display: inline-flex;           /* one design language: consistent alignment across the group */
    align-items: center;
    gap: .3rem;
    line-height: 1;
}

.qr-toggle:hover {
    background: var(--brand-teal);
    color: white;
}

/* the icon-only composer buttons (attach / voice) — crisper, larger glyph + a proper click area (#5) */
.qr-attach { font-size: 1.1rem; padding: .3rem .6rem; }
.qr-attach:hover { background: var(--brand-teal); color: #fff; }

.qr-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    left: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 30;
}

.qr-menu.show {
    display: block;
}

.qr-item {
    padding: .65rem .85rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .12s;
}

.qr-item:last-child { border-bottom: none; }
.qr-item:hover { background: var(--bg-hover); }

.qr-item-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .15rem;
}

.qr-shortcut {
    background: var(--accent-orange);
    color: white;
    padding: .1rem .45rem;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 700;
    font-family: monospace;
}

.qr-title {
    font-weight: 700;
    font-size: .85rem;
    color: var(--text-primary);
    flex: 1;
}

.qr-cat {
    font-size: .7rem;
    color: var(--text-muted);
    background: var(--bg-app);
    padding: .1rem .5rem;
    border-radius: 4px;
}

.qr-preview {
    font-size: .78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-right: 0;
}

/* Emoji Picker */
.emoji-picker {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    width: 320px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 30;
}

.emoji-picker.show { display: block; }

.emoji-tabs {
    display: flex;
    gap: 2px;
    padding: .35rem;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.emoji-tab {
    background: transparent;
    border: none;
    padding: .35rem .65rem;
    border-radius: 6px;
    font-size: .8rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: all .12s;
}

.emoji-tab:hover { background: var(--bg-hover); }
.emoji-tab.active { background: var(--brand-teal); color: white; }

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: .5rem;
    max-height: 240px;
    overflow-y: auto;
}

.emoji-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    padding: .4rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all .1s;
    line-height: 1;
}

.emoji-btn:hover {
    background: var(--brand-teal-light);
    transform: scale(1.15);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: 3.4rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    z-index: 3000;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 14px;
    box-shadow: 0 14px 40px rgba(0,0,0,.28), 0 0 0 2px var(--accent-orange);
    padding: 1rem 1.15rem;
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    width: 420px;
    max-width: 92vw;
    pointer-events: auto;
    cursor: pointer;
    transition: all .2s;
    border-right: 5px solid var(--accent-orange);
}

.toast:hover {
    transform: translateX(-4px);
    box-shadow: 0 15px 40px rgba(0,0,0,.22);
}

.toast-in {
    animation: toastSlideIn .35s cubic-bezier(.34,1.56,.64,1);
}

.toast-out {
    animation: toastSlideOut .3s ease-in forwards;
}

@keyframes toastSlideIn {
    from { transform: translateX(-120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
    to { transform: translateX(-120%); opacity: 0; }
}

.toast-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
}

.toast-avatar.avatar-orange { background: linear-gradient(135deg, var(--accent-orange), var(--accent-orange-dark)); }
.toast-avatar.avatar-purple { background: linear-gradient(135deg, var(--purple), #6d28d9); }

.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 700; font-size: .9rem; color: var(--text-primary); }
.toast-meta { font-size: .72rem; color: var(--text-muted); margin: 1px 0 .3rem; direction: ltr; text-align: right; }
.toast-preview { font-size: .85rem; color: var(--text-secondary); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.toast-close {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
    transition: all .15s;
}

.toast-close:hover { background: var(--bg-app); color: var(--text-primary); }

/* #25: ריאקציות להודעה */
.msg-react-btn {
    cursor: pointer;
    opacity: .55;
    margin-right: .3rem;
    font-size: .85rem;
    transition: opacity .15s;
}
.msg-react-btn:hover { opacity: 1; }
.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-top: .35rem;
}
.msg-reaction-pill {
    background: rgba(0,0,0,.06);
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    padding: .05rem .4rem;
    font-size: .9rem;
    line-height: 1.3;
}
.react-picker {
    position: fixed;
    z-index: 100000;
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 8px 28px rgba(0,0,0,.28);
    padding: .3rem .4rem;
    display: flex;
    gap: .15rem;
}
.react-picker button {
    border: none;
    background: transparent;
    font-size: 1.35rem;
    cursor: pointer;
    border-radius: 50%;
    width: 2.1rem;
    height: 2.1rem;
    transition: transform .1s, background .1s;
}
.react-picker button:hover { transform: scale(1.25); background: var(--bg-app); }
.react-picker .react-remove { font-size: 1rem; color: var(--text-muted); }

/* ============================================
   LEGAL CASE - Red border + popup
   ============================================ */
.conv-view-legal .conv-view-header {
    background: linear-gradient(90deg, #fef2f2 0%, white 60%);
    border-bottom: 2px solid var(--danger);
}

.conv-view-legal .chat-area {
    border: 3px solid var(--danger);
    border-top: none;
}

.legal-banner-mini {
    display: inline-block;
    background: #fee2e2;
    color: #991b1b;
    padding: .25rem .65rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: .75rem;
    margin-right: .5rem;
}

.legal-popup {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.6);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: legalPopupIn .2s ease-out;
}

@keyframes legalPopupIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.legal-popup-content {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(220,38,38,.3);
    border: 3px solid var(--danger);
    animation: legalPopupZoom .3s cubic-bezier(.34,1.56,.64,1);
}

@keyframes legalPopupZoom {
    from { transform: scale(.85); }
    to { transform: scale(1); }
}

.legal-popup-icon {
    font-size: 3.5rem;
    margin-bottom: .75rem;
    animation: legalShake .5s ease-out;
}

@keyframes legalShake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.legal-popup-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--danger);
    margin-bottom: .75rem;
}

.legal-popup-text {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* ============================================
   Slash dropdown for quick replies
   ============================================ */
.slash-dropdown {
    display: none;
    position: fixed;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1500;
}

.slash-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    cursor: pointer;
    transition: background .12s;
    border-bottom: 1px solid var(--border);
}

.slash-item:last-child { border-bottom: none; }

.slash-item:hover, .slash-item.active {
    background: var(--brand-teal-light);
}

.slash-item-info { flex: 1; min-width: 0; }

.slash-item-title {
    font-weight: 700;
    font-size: .82rem;
    color: var(--text-primary);
}

.slash-item-preview {
    font-size: .72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* Templates button - distinguished from shortcuts */
.qr-toggle-template {
    background: var(--accent-orange-light) !important;
    color: var(--accent-orange-dark) !important;
}

.qr-toggle-template:hover {
    background: var(--accent-orange) !important;
    color: white !important;
}

/* ============================================
   Team Chat (internal team chats per dept/role)
   ============================================ */
.team-chat-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: right;
    transition: all .12s;
    margin-bottom: 2px;
    position: relative;
}

.team-chat-item:hover {
    background: var(--bg-hover);
}

.team-chat-item.active {
    background: var(--bg-active);
    color: var(--brand-teal);
    font-weight: 700;
}

.team-chat-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.team-chat-name {
    flex: 1;
    font-size: .88rem;
    color: var(--text-primary);
}

.team-chat-unread {
    background: var(--accent-orange);
    color: white;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: .68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Team chat view */
.team-chat-header {
    background: linear-gradient(90deg, var(--brand-teal-light), white 70%) !important;
}

.team-chat-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: var(--shadow-sm);
}

.team-chat-messages {
    background: #f5f7fa;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Ccircle cx='30' cy='30' r='1' fill='%23e0e5ed'/%3E%3C/svg%3E");
}

.team-msg {
    display: flex;
    gap: .65rem;
    margin-bottom: 1rem;
}

.team-msg-me {
    flex-direction: row-reverse;
}

.team-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.team-msg-body {
    max-width: 65%;
    background: white;
    border-radius: 12px;
    padding: .6rem .85rem;
    box-shadow: var(--shadow-sm);
}

.team-msg-me .team-msg-body {
    background: var(--brand-teal);
    color: white;
    border-radius: 12px 12px 4px 12px;
}

.team-msg-me .team-msg-name {
    color: rgba(255,255,255,.8) !important;
}

.team-msg-me .team-msg-time {
    color: rgba(255,255,255,.7) !important;
}

.team-msg-head {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .15rem;
}

.team-msg-name {
    font-weight: 700;
    font-size: .8rem;
    color: var(--text-primary);
}

.team-msg-time {
    font-size: .7rem;
    color: var(--text-muted);
}

.team-msg-content {
    font-size: .92rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chat-input-row {
    display: flex;
    gap: .5rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .65rem .85rem;
    font-size: .92rem;
    resize: none;
    min-height: 42px;
    max-height: 150px;
    outline: none;
    transition: border-color .15s;
    line-height: 1.4;
}

.chat-input:focus {
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 3px rgba(29,72,85,.08);
}

.btn-send {
    background: var(--accent-orange);
    color: white;
    padding: 0 1.25rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: .92rem;
    height: 42px;
    transition: all .15s;
}

.btn-send:hover {
    background: var(--accent-orange-dark);
}

.btn-send:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.bot-mode-banner {
    background: var(--brand-teal-light);
    color: var(--brand-teal);
    padding: .5rem .85rem;
    border-radius: 8px;
    font-size: .82rem;
    margin-bottom: .5rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    font-weight: 600;
}

/* ============================================
   CUSTOMER INFO PANEL (right of chat)
   ============================================ */
.customer-panel {
    background: white;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1.25rem;
}

.panel-section {
    margin-bottom: 1.5rem;
}

.panel-section:last-child {
    margin-bottom: 0;
}

.panel-title {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .6rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border);
}

.panel-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .35rem 0;
    font-size: .85rem;
    gap: .5rem;
}

.panel-row dt {
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.panel-row dd {
    color: var(--text-primary);
    font-weight: 600;
    text-align: left;
    word-break: break-word;
}

/* קיבוץ שדות בכרטיס לקוח — היררכיה ברורה בין קבוצות */
.panel-group {
    padding: .35rem .6rem;
    margin-top: .5rem;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius, 10px);
}
.panel-group:first-child { margin-top: 0; }
.panel-group-label {
    font-size: .66rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: .1rem;
    opacity: .9;
}
.panel-group .panel-row { padding: .28rem 0; }
.panel-group .panel-row:not(:last-child) { border-bottom: 1px dashed var(--border); }

.panel-row.panel-row-stacked {
    flex-direction: column;
    align-items: stretch;
    gap: .15rem;
}

.panel-row-stacked dd {
    text-align: right;
}

.zebra-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: var(--accent-orange);
    font-weight: 700;
    font-size: .85rem;
    text-decoration: none;
    margin-top: .5rem;
}

.zebra-link:hover {
    color: var(--accent-orange-dark);
}

.zebra-card-badge {
    background: var(--accent-orange-light);
    color: var(--accent-orange-dark);
    padding: .15rem .55rem;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 700;
    display: inline-block;
}

.collected-tag {
    display: inline-block;
    background: var(--brand-teal-light);
    color: var(--brand-teal);
    padding: .2rem .55rem;
    border-radius: 6px;
    font-size: .72rem;
    margin: .15rem .15rem 0 0;
    font-weight: 600;
}

.btn-export-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    width: 100%;
    background: var(--text-primary);
    color: white;
    padding: .55rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: .82rem;
    margin-top: .5rem;
    text-decoration: none;
    transition: background .15s;
}

.btn-export-panel:hover {
    background: black;
}

.assignees-list { display: flex; flex-direction: column; gap: .5rem; }

.assignee-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .65rem;
    background: var(--bg-app);
    border-radius: 8px;
    border-right: 3px solid var(--brand-teal);
    transition: all .15s;
}

.assignee-chip:hover { background: var(--bg-hover); }

.assignee-info { flex: 1; min-width: 0; }

.assignee-name {
    font-weight: 700;
    font-size: .85rem;
    color: var(--text-primary);
}

.assignee-source {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.assignee-remove {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: all .15s;
    border: 1px solid transparent;
}

.assignee-remove:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* ============================================
   CONTEXT MENU (right-click)
   ============================================ */
.context-menu {
    display: none;
    position: fixed;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.04);
    min-width: 220px;
    z-index: 1000;
    overflow: hidden;
    animation: cmFadeIn .12s ease-out;
}

@keyframes cmFadeIn {
    from { opacity: 0; transform: scale(.97); }
    to { opacity: 1; transform: scale(1); }
}

.cm-header {
    padding: .65rem .9rem;
    background: var(--bg-app);
    font-size: .85rem;
}

.cm-divider {
    height: 1px;
    background: var(--border);
    margin: .25rem 0;
}

.cm-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .9rem;
    cursor: pointer;
    font-size: .88rem;
    color: var(--text-primary);
    transition: background .1s;
}

.cm-item:hover { background: var(--bg-hover); }

.cm-icon {
    font-size: 1rem;
    width: 22px;
    text-align: center;
}

.cm-danger { color: var(--danger); }
.cm-danger:hover { background: #fef2f2; }

/* ============================================
   ASSIGN AGENT MODAL
   ============================================ */
.assign-search {
    margin-bottom: 1rem;
}

.assign-search input {
    width: 100%;
    padding: .7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .95rem;
    font-family: inherit;
    outline: none;
    transition: all .15s;
}

.assign-search input:focus {
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 3px rgba(29,72,85,.08);
}

.assign-by-dept {
    max-height: 60vh;
    overflow-y: auto;
}

.assign-dept-group {
    margin-bottom: 1.25rem;
}

.assign-dept-group:last-child {
    margin-bottom: 0;
}

.assign-dept-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: .88rem;
    color: var(--text-secondary);
    padding: 0 .25rem .5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.assign-dept-count {
    margin-right: auto;
    background: var(--bg-app);
    color: var(--text-muted);
    padding: .1rem .5rem;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 700;
}

.assign-agents-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
}

.assign-agent-card {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .75rem;
    background: var(--bg-app);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all .15s;
    text-align: right;
    font-family: inherit;
}

.assign-agent-card:hover {
    background: var(--brand-teal-light);
    border-color: var(--brand-teal);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.assign-agent-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.assign-agent-info {
    flex: 1;
    min-width: 0;
}

.assign-agent-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assign-agent-meta {
    font-size: .73rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Conversation flags */
.conv-card-urgent { background: linear-gradient(90deg, rgba(239,68,68,.04), transparent); border-right: 3px solid var(--danger); }
.conv-card-pinned { background: linear-gradient(90deg, rgba(232,122,61,.06), transparent); }
.conv-card-pinned::after {
    content: '📌';
    position: absolute;
    top: .5rem;
    left: .5rem;
    font-size: .8rem;
    opacity: .7;
}

.conv-urgent, .conv-pin {
    display: inline-block;
    margin-left: .3rem;
}

.conv-tag {
    background: var(--accent-orange-light);
    color: var(--accent-orange-dark);
    padding: .05rem .4rem;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 700;
    margin-right: .25rem;
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state-large {
    padding: 5rem 2rem;
    margin: auto;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: .5;
}

.empty-state-large .empty-icon {
    font-size: 4.5rem;
}

.empty-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: .35rem;
}

.empty-sub {
    font-size: .9rem;
    color: var(--text-muted);
}

/* ============================================
   MODAL
   ============================================ */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
    z-index: 2000; /* מעל mainnav(1000)+subnav(900) — המודל חייב לכסות את הניווט */
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn .2s ease-out;
}

@keyframes modalIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-app);
    color: var(--text-secondary);
    font-size: 1.4rem;
    line-height: 1;
    transition: all .15s;
}

.modal-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: .35rem;
    font-size: .88rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem .8rem;
    font-size: .92rem;
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 3px rgba(29,72,85,.08);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: .25rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-start;
    gap: .5rem;
    margin-top: 1.25rem;
    flex-direction: row-reverse;
}

/* ============================================
   ADMIN DASHBOARD
   ============================================ */
.admin-topbar {
    grid-template-columns: 320px 1fr auto;
    background: linear-gradient(90deg, var(--brand-teal), var(--brand-teal-dark));
    height: 80px;
}

.admin-topbar .topbar-title-main { color: white; font-size: 1.4rem; }
.admin-topbar .topbar-title-sub { color: rgba(255,255,255,.7); }
.admin-topbar .topbar-logo { background: white; padding: 3px; width: 56px; height: 56px; box-shadow: 0 4px 12px rgba(0,0,0,.2); }

.admin-badge {
    background: var(--accent-orange);
    color: white;
    padding: .2rem .55rem;
    border-radius: 6px;
    font-size: .7rem;
    font-weight: 700;
    margin-top: 2px;
    display: inline-block;
}

.admin-nav {
    display: flex;
    gap: .35rem;
    justify-self: start;
}

.admin-nav-item {
    color: rgba(255,255,255,.85);
    text-decoration: none;
    padding: .55rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: .88rem;
    transition: all .15s;
}

.admin-nav-item:hover {
    background: rgba(255,255,255,.12);
    color: white;
}

.admin-nav-item.active {
    background: rgba(255,255,255,.18);
    color: white;
}

.admin-main {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    height: calc(100vh - var(--topbar-h));
    background: var(--bg-app);
}

.admin-section {
    background: white;
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.admin-section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.admin-section-grid .admin-section {
    margin-bottom: 0;
}

.admin-h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--brand-teal-light);
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.big-stat {
    background: var(--bg-app);
    padding: 1.25rem;
    border-radius: 12px;
    text-align: center;
    border-top: 4px solid var(--brand-teal);
}

.big-stat-blue { border-top-color: var(--brand-primary); }
.big-stat-orange { border-top-color: var(--accent-orange); }
.big-stat-green { border-top-color: var(--success); }

.big-stat-num {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.big-stat-label {
    font-size: .85rem;
    color: var(--text-muted);
    margin-top: .35rem;
    font-weight: 600;
}

.admin-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.alert-card {
    padding: 1.25rem;
    border-radius: 12px;
    border-right: 4px solid;
    background: var(--bg-app);
}

.alert-card-red { border-right-color: var(--danger); background: #fef2f2; }
.alert-card-orange { border-right-color: var(--warning); background: #fffbeb; }
.alert-card-blue { border-right-color: var(--info); background: #eff6ff; }

.alert-num {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
}

.alert-card-red .alert-num { color: var(--danger); }
.alert-card-orange .alert-num { color: var(--warning); }
.alert-card-blue .alert-num { color: var(--info); }

.alert-label {
    font-weight: 700;
    margin: .35rem 0;
    color: var(--text-primary);
}

.alert-sub {
    font-size: .8rem;
    color: var(--text-secondary);
}

.alert-link {
    display: inline-block;
    margin-top: .65rem;
    color: var(--brand-teal);
    font-weight: 700;
    text-decoration: none;
    font-size: .85rem;
}

.alert-link:hover { color: var(--brand-teal-dark); }

.dept-bar {
    margin-bottom: 1rem;
}

.dept-bar-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .35rem;
}

.dept-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
    font-size: .9rem;
}

.dept-count-big {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.dept-bar-track {
    background: var(--bg-app);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
}

.dept-bar-fill {
    height: 100%;
    transition: width .4s ease;
    border-radius: 5px;
}

.template-summary { display: flex; flex-direction: column; gap: .5rem; }

.tmpl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .65rem .85rem;
    background: var(--bg-app);
    border-radius: 8px;
}

.tmpl-status {
    font-weight: 600;
    font-size: .9rem;
}

.tmpl-approved { color: var(--success); }
.tmpl-pending { color: var(--warning); }
.tmpl-draft { color: var(--text-muted); }
.tmpl-rejected { color: var(--danger); }

.tmpl-num { font-weight: 800; font-size: 1.2rem; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    text-align: right;
    padding: .65rem .85rem;
    background: var(--bg-app);
    font-weight: 700;
    font-size: .85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: .75rem .85rem;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

.admin-table tr:hover td { background: var(--bg-hover); }

.agent-avatar-mini {
    display: inline-flex;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .7rem;
    margin-left: .4rem;
    vertical-align: middle;
}

.badge-active, .badge-success {
    background: #d1fae5;
    color: #065f46;
    padding: .15rem .55rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 700;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
    padding: .15rem .55rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 700;
}

/* Templates page */
.meta-info-box {
    background: var(--brand-teal-light);
    border-right: 4px solid var(--brand-teal);
    padding: 1rem 1.25rem;
    border-radius: 8px;
}
.meta-info-box h3 { margin-bottom: .5rem; color: var(--brand-teal); }
.meta-info-box ol { margin-right: 1.5rem; margin-top: .5rem; }
.meta-info-box li { margin-bottom: .25rem; font-size: .9rem; }
.meta-info-box p { line-height: 1.6; }

.template-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: box-shadow .15s;
}
.template-card:hover { box-shadow: var(--shadow); }

.template-card-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.template-card h3 { font-size: 1.05rem; color: var(--text-primary); margin: .25rem 0; }
.template-meta { font-size: .8rem; color: var(--text-muted); text-align: left; }

.template-body {
    background: var(--bg-app);
    padding: .85rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: .9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    border-right: 3px solid var(--brand-teal);
}

.template-vars { margin-top: .75rem; font-size: .85rem; }

.var-chip {
    display: inline-block;
    background: var(--accent-orange-light);
    color: var(--accent-orange-dark);
    padding: .15rem .55rem;
    border-radius: 4px;
    margin: 0 .25rem;
    font-size: .8rem;
    font-weight: 600;
}

.template-actions { margin-top: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ============================================
   SIMULATOR (kept simple)
   ============================================ */
.simulator-page {
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 2rem;
    max-width: 1100px;
    margin: 0 auto;
}

.sim-info {
    background: white;
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.phone-mockup {
    background: var(--brand-teal);
    border-radius: 28px;
    padding: 10px;
    box-shadow: var(--shadow-lg);
    height: 620px;
    display: flex;
    flex-direction: column;
}

.phone-header {
    background: var(--brand-teal);
    color: white;
    padding: .85rem 1rem;
    border-radius: 18px 18px 0 0;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 3px;
}

.phone-chat {
    flex: 1;
    background: #ece5dd;
    padding: 1rem;
    overflow-y: auto;
}

.bubble {
    max-width: 80%;
    padding: .55rem .85rem;
    border-radius: 8px;
    margin-bottom: .5rem;
    font-size: .9rem;
    line-height: 1.4;
    box-shadow: var(--shadow-sm);
    white-space: pre-wrap;
}

.bubble-bot {
    background: white;
}

.bubble-customer {
    background: var(--accent-orange-light);
    border-right: 3px solid var(--accent-orange);
    margin-right: auto;
}

.phone-input {
    display: flex;
    gap: .5rem;
    padding: .75rem;
    background: #f0f2f5;
    border-radius: 0 0 18px 18px;
}

.phone-input input {
    flex: 1;
    padding: .6rem 1rem;
    border: none;
    border-radius: 22px;
    outline: none;
}

.phone-input button {
    width: 44px;
    height: 44px;
    background: var(--accent-orange);
    color: white;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    border: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .conv-view-body { grid-template-columns: 1fr; }
    .customer-panel { display: none; }
}

@media (max-width: 900px) {
    :root { --sidebar-w: 200px; --conv-list-w: 280px; }
    .topbar-search { display: none; }
}

/* סבב 2: כפתור תפריט (עיצוב conv-agent-tag עבר לבלוק chip האחיד של חלק 3) */
.conv-menu-btn:hover { color:var(--brand-teal) !important; }

/* 5.1: וי/וי-וי — סימוני מסירה/קריאה */
.msg-tick { display: inline-flex; align-items: center; gap: 3px; direction: ltr; unicode-bidi: isolate; margin-right: .3rem; font-size: .85em; opacity: .85; vertical-align: middle; }
.msg-tick .tick-mark { letter-spacing: -3px; }
.msg-tick .tick-label { letter-spacing: normal; direction: rtl; unicode-bidi: isolate; }
.msg-tick-read { color: #34b7f1; opacity: 1; }

/* 5.2: באנר חלון 24 שעות */
.window-banner {
    margin: .4rem .6rem .55rem;
    padding: .55rem .8rem;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 500;
    line-height: 1.4;
}
.window-warn {
    background: var(--accent-orange-light);
    color: var(--accent-orange-dark);
    border: 1px solid var(--accent-orange);
}
.window-closed {
    background: #fde8e8;
    color: #b91c1c;
    border: 1px solid #f5a9a9;
}

/* חלק 5: פאנל "פרטי הלקוח" מאוחד */
.cust-exist {
    display: inline-block;
    padding: .3rem .7rem;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 700;
    margin: .2rem 0 .6rem;
}
.cust-exist-yes { background: #dcfce7; color: #16a34a; }
.cust-exist-no { background: #fee2e2; color: #dc2626; }
.cust-exist-loading { background: var(--bg-app); color: var(--text-muted); }
.cust-src { font-size: .72rem; color: var(--text-muted); font-weight: 500; }
.cust-file {
    margin-top: .7rem;
    padding: .6rem .7rem;
    border-radius: 8px;
    background: var(--bg-app);
    border: 1px solid var(--border);
}
.cust-file-legal {
    background: #fde8e8;
    border: 1px solid #f5a9a9;
}
.cust-file-title {
    font-size: .78rem;
    font-weight: 700;
    margin-bottom: .4rem;
    color: var(--text-primary);
}
.cust-file-row {
    display: flex;
    justify-content: space-between;
    padding: .2rem 0;
    font-size: .82rem;
}

/* עיגול "לא נקרא" על האווטר — מופיע רק בשיחה לא-נקראה, יורד אחרי קריאה */
.conv-unread-dot { background: var(--brand-accent) !important; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }

/* 0.3 team accordion */
.dept-group-head { width: 100%; }
.dept-group-chev { transition: transform .15s; display: inline-block; font-size: .7rem; color: var(--text-muted); }
.dept-group:not(.open) .dept-group-chev { transform: rotate(-90deg); }
.dept-group-body { margin: .1rem 0 .3rem; }
.agent-item-sub { padding-right: 1.5rem; font-size: .88rem; }
.agent-item-sub.active { background: var(--brand-teal-light, #e6f2f0); font-weight: 600; }

/* 0.3 inline dept accordion */
.team-chat-group { display:block; }
.team-dept-row { display:flex; align-items:center; gap:.4rem; cursor:pointer; width:100%; }
.team-chat-group:not(.open) .dept-group-chev { transform: rotate(-90deg); }
.dept-group-chev { font-size:.7rem; color:var(--text-muted); transition:transform .15s; }
.team-dept-openchat { margin-inline-start:auto; opacity:.55; cursor:pointer; font-size:.9rem; }
.team-dept-openchat:hover { opacity:1; }
.dept-agents-acc { margin:.1rem 0 .4rem; padding-inline-start:.6rem; }
.dept-agents-acc .agent-item-sub { padding-inline-start:1.2rem; font-size:.86rem; }
.dept-agents-acc .agent-item-sub.active { background:var(--brand-teal-light,#e6f2f0); font-weight:600; }

/* 2.1 inline group members bar */
.team-members-bar { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; padding:.5rem .8rem; background:var(--bg-app); border-bottom:1px solid var(--border); font-size:.82rem; }
.team-members-label { color:var(--text-muted); font-weight:600; margin-inline-end:.2rem; }
.team-member-chip { display:inline-flex; align-items:center; gap:.3rem; background:#fff; border:1px solid var(--border); border-radius:999px; padding:.15rem .5rem .15rem .25rem; }
.team-member-dot { width:20px; height:20px; border-radius:50%; color:#fff; font-size:.65rem; font-weight:700; display:inline-flex; align-items:center; justify-content:center; }
.team-members-all { color:var(--text-secondary); font-style:italic; }

/* 3.1 my-agents list */
.my-agents-list { margin:.1rem 0 .3rem; padding-inline-start:1rem; }
.sidebar-subitem { display:flex; align-items:center; gap:.4rem; width:100%; background:none; border:none; cursor:pointer; padding:.3rem .6rem; border-radius:8px; font-size:.85rem; color:var(--text-secondary); }
.sidebar-subitem:hover { background:var(--bg-hover,#f0f0f0); }
.sidebar-subitem.active { background:var(--brand-teal-light,#e6f2f0); color:var(--brand-teal); font-weight:600; }
.sidebar-subitem .sidebar-label { flex:1; text-align:start; }
.sidebar-subitem .sidebar-count { color:var(--text-muted); font-size:.78rem; }

/* admin delete menu item */
.cm-item-danger { color: var(--danger, #e02424); }
.cm-item-danger:hover { background: #fde8e8; }

/* 0.1 stage chips */
.conv-stage-empty { background:transparent !important; color:var(--text-muted) !important; border:1px dashed var(--border); opacity:.7; }
.conv-stage-empty:hover { opacity:1; border-color:var(--brand-teal); color:var(--brand-teal) !important; }

/* 1.2 header assignees */
.conv-view-assignees { display:flex; flex-wrap:wrap; gap:.4rem; margin-top:.15rem; font-size:.78rem; }
.conv-head-dept { background:var(--bg-app); color:var(--text-secondary); border-radius:6px; padding:.05rem .4rem; }
.conv-head-agents { color:var(--brand-teal); font-weight:600; }

/* 2.4 batch select */
.conv-card.batch-selected { background: var(--brand-teal-light,#e6f2f0); box-shadow: inset 3px 0 0 var(--brand-teal,var(--brand-primary)); }
.batch-bar { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 3000; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); display: flex; align-items: center; gap: .4rem; padding: .5rem .7rem; }
.batch-bar .batch-count { font-weight: 700; margin-inline-end: .3rem; color: var(--brand-teal,var(--brand-primary)); }
.batch-bar button { border: none; background: var(--bg-app,#f0f0f0); border-radius: 8px; padding: .35rem .6rem; cursor: pointer; font-size: .85rem; }
.batch-bar button:hover { background: var(--border,#ddd); }
.batch-bar .batch-clear { color: var(--danger,#e02424); }

/* dm delete */
.dm-del{margin-inline-start:auto;color:var(--text-muted);opacity:.5;cursor:pointer;font-weight:700;padding:0 .3rem}
.dm-del:hover{opacity:1;color:var(--danger,#e02424)}
.team-chat-item:hover .dm-del{opacity:.8}


/* round6 fixes: nihul + members-inline + drag */
/* #7 enlarge ניהול block (first, top) */
.nihul-section { background: linear-gradient(180deg,#f7faf9,#fff); border:1px solid var(--border); border-radius:12px; padding:.6rem; margin-bottom:.6rem; }
.nihul-title { font-size:1.05rem !important; font-weight:800 !important; color:var(--brand-teal,var(--brand-primary)) !important; margin-bottom:.5rem !important; }
.nihul-link { font-size:1rem !important; padding:.5rem .6rem !important; border-radius:8px; display:block; }
.nihul-link:hover { background:var(--bg-app,#f0f0f0); }

/* #3 members inline in the group-chat header */
.team-members-inline { display:flex; flex-wrap:wrap; gap:.35rem; margin-top:.35rem; }
.team-members-inline .team-member-chip { display:inline-flex; align-items:center; gap:.3rem; background:#fff; border:1px solid var(--border); border-radius:999px; padding:.1rem .5rem .1rem .2rem; font-size:.8rem; cursor:pointer; }
.team-members-inline .team-member-chip:hover { border-color:var(--brand-teal,var(--brand-primary)); background:var(--brand-teal-light,#e6f2f0); }
.team-members-inline .team-member-dot { width:18px; height:18px; border-radius:50%; color:#fff; font-size:.6rem; font-weight:700; display:inline-flex; align-items:center; justify-content:center; }

/* #6 accordion agent -> personal chat hint */
.dm-go { margin-inline-start:auto; opacity:.5; font-size:.85rem; }
.agent-item-sub:hover .dm-go { opacity:1; }

/* #8 drag reorder */
.sec-draggable { cursor:grab; }
.sec-dragging { opacity:.5; outline:2px dashed var(--brand-teal,var(--brand-primary)); }

/* drag handle */
.sec-drag-handle{cursor:grab;color:var(--text-muted);opacity:.35;margin-inline-end:.35rem;font-size:.9rem;user-select:none}
.sec-drag-handle:hover{opacity:.9}
.sec-drag-handle:active{cursor:grabbing}
.sidebar-section:hover .sec-drag-handle{opacity:.6}

/* reply feature */
.msg-reply-btn{cursor:pointer;opacity:0;margin-inline-start:.4rem;font-size:.85rem;color:var(--text-muted);transition:opacity .1s}
.msg-row:hover .msg-reply-btn{opacity:.6}
.msg-reply-btn:hover{opacity:1;color:var(--brand-teal,var(--brand-primary))}
/* כפתור העתקת הודעה (📋) — קבוע גלוי כמו הסמיילי (לא רק בריחוף) */
.msg-copy-btn{cursor:pointer;opacity:.55;margin-inline-start:.4rem;font-size:.82rem;color:var(--text-muted);transition:opacity .15s}
.msg-copy-btn:hover{opacity:1;color:var(--brand-teal,var(--brand-primary))}
.msg-row.msg-out:not(.msg-sender-bot) .msg-copy-btn{color:#54656f !important;opacity:.8}
.msg-row.msg-out:not(.msg-sender-bot) .msg-copy-btn:hover{color:#111b21 !important;opacity:1}
/* ציטוט תגובה לחיץ → קפיצה להודעה המקורית + הבהוב */
.msg-quote{cursor:pointer}
.msg-quote:hover{opacity:1}
@keyframes msgJumpFlash{0%{box-shadow:0 0 0 3px rgba(235,96,37,.75)}100%{box-shadow:0 0 0 0 rgba(235,96,37,0)}}
.msg-jump-flash .msg-bubble{animation:msgJumpFlash 1.6s ease-out}
.reply-banner{display:flex;align-items:center;justify-content:space-between;gap:.5rem;background:var(--bg-app,#f0f0f0);border-inline-start:3px solid var(--brand-teal,var(--brand-primary));border-radius:8px;padding:.4rem .6rem;margin-bottom:.4rem}
.reply-banner-body{display:flex;flex-direction:column;overflow:hidden}
.reply-banner-who{font-weight:700;font-size:.78rem;color:var(--brand-teal,var(--brand-primary))}
.reply-banner-snip{font-size:.8rem;color:var(--text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:60vw}
.reply-banner-x{cursor:pointer;color:var(--text-muted);font-weight:700;padding:0 .3rem}
.reply-banner-x:hover{color:var(--danger,#e02424)}
/* אזור גרירה-ושחרור לקובץ (drag & drop) — הדגשה + רמז "שחרר כאן" */
.dropzone{position:relative}
.dropzone-active{outline:2px dashed var(--brand-teal,var(--brand-dark));outline-offset:-4px;background:rgba(34,79,85,.06)}
.dropzone-active::after{content:attr(data-drophint);position:absolute;inset:0;display:flex;align-items:center;justify-content:center;text-align:center;font-weight:800;font-size:.9rem;color:var(--brand-teal,var(--brand-dark));background:rgba(255,255,255,.82);border-radius:10px;pointer-events:none;z-index:20}

/* day separator */
.day-sep{display:flex;align-items:center;justify-content:center;margin:.8rem 0}
.day-sep span{background:var(--bg-app,#eceff1);color:var(--text-secondary);font-size:.75rem;font-weight:600;padding:.2rem .8rem;border-radius:999px;box-shadow:0 1px 2px rgba(0,0,0,.06)}

.panel-toggle-btn.notif-off{opacity:.45;}
#notifBellBtn{font-size:1.05rem;}

.msg-del-btn{cursor:pointer;opacity:0;margin-inline-start:.35rem;font-size:.82rem;color:var(--text-muted);transition:opacity .1s}
.msg-row:hover .msg-del-btn{opacity:.55}
.msg-del-btn:hover{opacity:1;color:#E02424}

.team-msg .msg-del-btn{opacity:.3}
.team-msg:hover .msg-del-btn{opacity:.7}
.team-msg .msg-del-btn:hover{opacity:1;color:#E02424}

.msg-quote{display:block;border-inline-start:3px solid var(--brand-orange,var(--brand-accent));background:rgba(0,0,0,.05);border-radius:6px;padding:.3rem .5rem;margin-bottom:.35rem;font-size:.8rem;opacity:.85}
.msg-quote-who{display:block;font-weight:700;color:var(--brand-teal,var(--brand-primary));font-size:.72rem;margin-bottom:.1rem}
.msg-quote-out{border-inline-start-color:var(--brand-teal,var(--brand-primary))}
.msg-quote-text{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:230px}
.msg-tick-failed{color:#E02424;font-weight:600}

/* נעיצת הודעות (pin) */
.msg-pin-btn{cursor:pointer;opacity:0;margin-inline-start:.35rem;font-size:.8rem;filter:grayscale(1);transition:opacity .12s,filter .12s}
.msg-row:hover .msg-pin-btn{opacity:.5}
.msg-pin-btn:hover{opacity:1;filter:grayscale(0)}
.msg-pin-btn.is-pinned{opacity:1;filter:grayscale(0)}
.msg-pinned .msg-bubble{box-shadow:0 0 0 2px rgba(37,99,235,.25);}
.msg-pin-flag{font-size:.7rem;margin-inline-end:.25rem;vertical-align:middle;opacity:.85}
/* הבר של ההודעות הנעוצות בראש השיחה */
.pinned-bar{display:flex;flex-direction:column;gap:.25rem;padding:.4rem .7rem;background:#fff;border-bottom:1px solid var(--border,#e5e7eb)}
.pinned-item{display:flex;align-items:center;gap:.45rem;background:var(--bg-app,#f5f6f8);border-inline-start:3px solid var(--brand-primary,#2563eb);border-radius:8px;padding:.3rem .55rem;cursor:pointer;font-size:.82rem}
.pinned-item:hover{background:#eef2f7}
.pinned-ico{flex-shrink:0}
.pinned-text{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--text-secondary,#4a5568)}
.pinned-unpin{flex-shrink:0;color:var(--text-muted,#94a3b8);font-weight:700;padding:0 .25rem;cursor:pointer}
.pinned-unpin:hover{color:var(--danger,#e02424)}

/* כפתורי השב/מחק על בועה ירוקה (יוצאת) — אפור כהה כמו וואטסאפ, כדי שלא ייבלעו */
.msg-row.msg-out:not(.msg-sender-bot) .msg-reply-btn,
.msg-row.msg-out:not(.msg-sender-bot) .msg-del-btn{color:#54656f !important}
.msg-row.msg-out:not(.msg-sender-bot):hover .msg-reply-btn,
.msg-row.msg-out:not(.msg-sender-bot):hover .msg-del-btn{opacity:.95}
.msg-row.msg-out:not(.msg-sender-bot) .msg-reply-btn:hover,
.msg-row.msg-out:not(.msg-sender-bot) .msg-del-btn:hover{color:#111b21 !important;opacity:1}

/* ===================================================================== */
/* Unified fixed top navigation (_topnav.html) — clean fintech style      */
/* (interim direction: Financy-inspired — light, rounded, pill nav)       */
/* ===================================================================== */
:root{ --mainnav-h:64px; }
.mainnav{
  position:sticky; inset-block-start:0; z-index:1000;
  height:var(--mainnav-h); display:flex; align-items:center; gap:1rem;
  padding:0 1.25rem; background:#ffffff; color:var(--text,#1f2430);
  border-bottom:1px solid rgba(16,24,40,.06); box-shadow:0 1px 3px rgba(16,24,40,.05);
}
/* light app canvas */
body.has-mainnav{ background:var(--bg-app,#f4f5fb); }
/* scroll pages: allow document scroll (override the global html,body overflow:hidden) */
html:has(body.nav-scroll), body.nav-scroll{ height:auto; overflow:auto; }
.mainnav-brand{ display:flex; align-items:center; gap:.6rem; text-decoration:none; color:inherit; flex:0 0 auto; }
.mainnav-logo{ width:34px; height:34px; border-radius:10px; object-fit:cover; }
.mainnav-logo-fallback{ width:34px; height:34px; border-radius:10px; background:var(--brand-primary,#2563eb); color:#fff;
  display:flex; align-items:center; justify-content:center; font-weight:800; font-size:.9rem; }
.mainnav-name{ font-weight:800; font-size:1.05rem; white-space:nowrap; color:var(--brand-dark,#1e293b); }
/* centered segmented pill group */
.mainnav-links{ display:flex; align-items:center; gap:.15rem; margin-inline:auto; background:var(--bg-app,#f1f2f8); padding:.28rem; border-radius:999px; }
.mainnav-link{
  display:inline-flex; align-items:center; gap:.4rem; padding:.5rem .95rem; border-radius:999px;
  color:var(--text-muted,#5b6472); text-decoration:none; font-weight:600; font-size:.92rem; white-space:nowrap;
  transition:all .15s;
}
.mainnav-link:hover{ color:var(--brand-dark,#1e293b); background:rgba(16,24,40,.05); }
.mainnav-link.active{ background:var(--brand-primary,#2563eb); color:#fff; box-shadow:0 2px 8px rgba(37,99,235,.28); }
.mainnav-user{ flex:0 0 auto; }
/* native <details> dropdown — no JS */
.usermenu{ position:relative; }
.usermenu-chip{
  list-style:none; cursor:pointer; display:flex; align-items:center; gap:.5rem;
  padding:.3rem .5rem; border-radius:999px; transition:background .15s;
}
.usermenu-chip::-webkit-details-marker{ display:none; }
.usermenu-chip:hover{ background:rgba(16,24,40,.05); }
.mainnav-avatar{
  width:34px; height:34px; border-radius:50%; background:var(--brand-primary,#2563eb); color:#fff;
  display:flex; align-items:center; justify-content:center; font-weight:800; font-size:.85rem; flex:0 0 auto;
}
.usermenu-meta{ display:flex; flex-direction:column; line-height:1.15; }
.usermenu-name{ font-weight:700; font-size:.88rem; color:var(--brand-dark,#1e293b); }
.usermenu-role{ font-size:.72rem; color:var(--text-muted,#8a94a6); }
.usermenu-chev{ opacity:.5; font-size:.7rem; }
.usermenu-drop{
  position:absolute; inset-block-start:calc(100% + 8px); inset-inline-end:0; min-width:210px;
  background:#fff; color:var(--text,#1f2430); border:1px solid rgba(16,24,40,.08); border-radius:14px;
  box-shadow:0 12px 40px rgba(16,24,40,.14); padding:.4rem; z-index:1100;
}
.usermenu-item{ display:block; padding:.55rem .7rem; border-radius:10px; text-decoration:none; color:inherit; font-weight:600; font-size:.9rem; }
.usermenu-item:hover{ background:var(--bg-app,#f4f5fb); }
.usermenu-logout{ color:#e02424; }
@media (max-width:640px){
  .mainnav{ padding:0 .75rem; gap:.5rem; }
  .mainnav-name{ display:none; }
  .mainnav-link{ padding:.5rem .7rem; }
  .usermenu-meta{ display:none; }
}

/* inbox with global nav: mainnav on top, existing app-topbar becomes the search+actions toolbar below it.
   brand + user are hidden (now provided by mainnav) but kept in DOM so app.js refs don't break. */
body.has-mainnav .app-topbar .topbar-brand,
body.has-mainnav .app-topbar .topbar-user{ display:none; }
body.has-mainnav .app-topbar{ grid-template-columns: 1fr auto; }
body.has-mainnav .app-layout{ height: calc(100vh - var(--mainnav-h) - var(--topbar-h)); }

/* secondary sub-nav (admin/settings sections) — sticky under the mainnav */
.subnav{ position:sticky; inset-block-start:var(--mainnav-h); z-index:900; background:#fff;
  border-bottom:1px solid rgba(16,24,40,.06); padding:.55rem 1.25rem; }
.subnav-inner{ display:flex; gap:.15rem; align-items:center; background:var(--bg-app,#f1f2f8);
  padding:.25rem; border-radius:999px; width:max-content; max-width:100%; overflow-x:auto; }
.subnav-link{ display:inline-flex; align-items:center; gap:.35rem; padding:.4rem .85rem; border-radius:999px;
  color:var(--text-muted,#5b6472); text-decoration:none; font-weight:600; font-size:.88rem; white-space:nowrap; transition:all .15s; }
.subnav-link:hover{ color:var(--brand-dark,#1e293b); background:rgba(16,24,40,.05); }
.subnav-link.active{ background:#fff; color:var(--brand-primary,#2563eb); box-shadow:0 1px 4px rgba(16,24,40,.14); }
/* admin pages become normal scroll pages under the fixed nav (no 100vh math) */
body.has-mainnav .admin-main{ height:auto; overflow:visible; }
.page-actions{ display:flex; justify-content:flex-end; gap:.5rem; padding:1rem 2rem 0; }

/* unified inline-SVG icons (_icons.html) */
.ico{ width:18px; height:18px; flex:0 0 auto; vertical-align:-.2em; }
.mainnav-link .ico, .subnav-link .ico{ opacity:.9; }
.mainnav-link.active .ico{ opacity:1; }
.usermenu-item{ display:flex; align-items:center; gap:.55rem; }
.usermenu-item .ico{ width:16px; height:16px; opacity:.7; }
/* sidebar (inbox) icons */
.sidebar-icon{ display:inline-flex; align-items:center; justify-content:center; }
.sidebar-icon .ico{ width:18px; height:18px; }
.sidebar-link .ico, .nihul-title .ico{ width:17px; height:17px; vertical-align:-.22em; }
.admin-h2 .ico{ width:1.05em; height:1.05em; vertical-align:-.15em; opacity:.7; }

/* ---- premium depth (subtle 3D) + reusable page headers + width guard ---- */
:root{ --shadow-card: 0 1px 2px rgba(16,24,40,.05), 0 8px 22px -6px rgba(16,24,40,.13); }
.admin-section, .set-card{ box-shadow:var(--shadow-card); border:1px solid rgba(16,24,40,.05); border-radius:16px; }
.big-stat, .alert-card, .step{ box-shadow:var(--shadow-card); }
/* keep admin content readable — not stretched across the whole screen */
body.has-mainnav .admin-main{ max-width:1180px; margin-inline:auto; }
/* reusable premium page header */
.page-head{ display:flex; justify-content:space-between; align-items:flex-end; gap:1rem; flex-wrap:wrap; margin-bottom:1.3rem; }
.page-title{ font-size:1.5rem; font-weight:800; color:var(--brand-dark,#1e293b); margin:0; }
.page-sub{ color:var(--text-muted,#6b7280); font-size:.92rem; margin:.2rem 0 0; }


/* =========================================================================
   Design-system polish — consistent focus / inputs / buttons (tokens-based)
   Additive layer: applies the token system globally without redesigning.
   ========================================================================= */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
button:focus:not(:focus-visible) { outline: none; }
button, .btn, .btn-primary-lg, .btn-secondary, .btn-pill, .qr-toggle { transition: background .15s ease, box-shadow .15s ease, border-color .15s ease, opacity .12s ease, transform .04s ease; }
button:not(:disabled), .btn:not(:disabled) { cursor: pointer; }
button:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
/* thin, quiet scrollbars for a more polished feel */
* { scrollbar-width: thin; scrollbar-color: #cbd2da transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #cbd2da; border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: #aab3bd; }

/* Notifications-permission prompt — subtle dismissible card (bottom-start), not an error bar */
.notif-prompt{position:fixed;bottom:16px;inset-inline-start:16px;z-index:9000;display:flex;align-items:center;gap:.6rem;max-width:430px;background:var(--bg-card,#fff);color:var(--text-secondary);border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow-lg);padding:.55rem .75rem;font-size:.84rem;font-weight:var(--fw-semibold,600);animation:npIn .25s ease}
@keyframes npIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.notif-prompt .np-ico{font-size:1.05rem;flex-shrink:0}
.notif-prompt .np-text{flex:1;line-height:1.35}
.notif-prompt .np-cta{background:var(--primary);color:#fff;border:none;border-radius:8px;padding:.35rem .85rem;font-weight:700;font-size:.82rem;cursor:pointer;flex-shrink:0}
.notif-prompt .np-cta:hover{filter:brightness(1.06)}
.notif-prompt .np-x{background:transparent;border:none;color:var(--text-muted);font-size:.95rem;line-height:1;cursor:pointer;padding:.15rem .35rem;flex-shrink:0;border-radius:6px}
.notif-prompt .np-x:hover{color:var(--text-primary);background:var(--bg-hover)}

/* ============================================================
   Reusable state components (loading / empty / error) — #10
   Used across Contacts and other data views for consistency.
   ============================================================ */
.c-spin{
    display:inline-block;width:14px;height:14px;
    border:2px solid var(--border);border-top-color:var(--primary);
    border-radius:50%;animation:c-spin .7s linear infinite;vertical-align:-2px;
}
@keyframes c-spin{to{transform:rotate(360deg)}}
.state-msg{
    text-align:center;color:var(--text-muted);
    padding:2.4rem 1rem;line-height:1.5;
}
.state-msg .state-ico{font-size:1.7rem;display:block;margin-bottom:.4rem;opacity:.85}
.state-msg .state-link{color:var(--primary);font-weight:700;cursor:pointer;text-decoration:none}
.state-msg .state-link:hover{text-decoration:underline}
.state-msg.state-error{color:var(--danger)}

/* ============================================================
   Broadcast flow clarity (#7) — numbered steps + note banner
   ============================================================ */
.bc-step{
    display:inline-flex;align-items:center;justify-content:center;
    width:19px;height:19px;border-radius:50%;
    background:var(--primary);color:#fff;font-size:.72rem;font-weight:700;
    margin-inline-end:.4rem;vertical-align:1px;
}
.bc-note{
    /* guidance, not a warning — a gentle info box in the brand palette (#8) */
    background:#f0f9f7;
    border:1px solid #cfe8e2;
    color:#20504a;border-radius:var(--radius,10px);
    padding:.6rem .8rem;font-size:.85rem;line-height:1.5;margin-bottom:.75rem;
}

/* ============================================================
   Notification-sound control — icon-only trigger + menu
   (separate from the alerts bell; 🔊 on / 🔇 off)
   ============================================================ */
#notifModeBtn{font-size:1.05rem;line-height:1;border:none;cursor:pointer}
#notifModeBtn.notif-off{opacity:.5}
.notif-menu{
    position:absolute;top:130%;inset-inline-end:0;min-width:200px;
    background:#fff;border:1px solid var(--border);border-radius:var(--radius,10px);
    box-shadow:var(--shadow-lg,0 12px 40px rgba(16,24,40,.18));
    z-index:3000;padding:.35rem;flex-direction:column;gap:.1rem;
}
.notif-menu-head{
    font-size:.7rem;font-weight:700;color:var(--text-muted);
    padding:.3rem .55rem .4rem;letter-spacing:.02em;
}
.notif-opt{
    font-family:inherit;font-size:.84rem;text-align:start;
    padding:.42rem .55rem;border:none;background:none;border-radius:8px;
    cursor:pointer;color:var(--text-primary);white-space:nowrap;
    display:flex;align-items:center;gap:.3rem;transition:background .12s;
}
.notif-opt:hover{background:var(--bg-app)}
.notif-opt.active{background:var(--info-light,#eff6ff);color:var(--primary);font-weight:700}
.notif-opt.active::after{content:'✓';margin-inline-start:auto;font-weight:700}
