/* Inline AI action status boxes in chat threads */
.ai-chatbot-chat-action-badge {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    max-width: 100%;
    border: 1px solid transparent;
}

.ai-chatbot-chat-action-badge-status {
    font-weight: 500;
    opacity: 0.9;
}

.ai-chatbot-sandbox-msg--customer .ai-chatbot-chat-action-badge {
    align-self: flex-start;
    text-align: left;
}

.message-bubble.inbound .ai-chatbot-chat-action-badge {
    margin-top: 6px;
}

.ai-chatbot-chat-action-badge i {
    flex-shrink: 0;
    margin-top: 1px;
}

.ai-chatbot-chat-action-badge--pending {
    background: rgba(255, 149, 0, 0.12);
    border-color: rgba(255, 149, 0, 0.4);
    color: #b45309;
}

.ai-chatbot-chat-action-badge--approved {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.42);
    color: #15803d;
}

.ai-chatbot-chat-action-badge--declined {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.38);
    color: #b91c1c;
}

html[data-theme="dark"] .ai-chatbot-chat-action-badge--pending {
    background: rgba(255, 149, 0, 0.16);
    color: #fbbf24;
}

html[data-theme="dark"] .ai-chatbot-chat-action-badge--approved {
    background: rgba(34, 197, 94, 0.16);
    color: #4ade80;
}

html[data-theme="dark"] .ai-chatbot-chat-action-badge--declined {
    background: rgba(239, 68, 68, 0.16);
    color: #f87171;
}

/* CRM — AI auto-reply sent label on outbound bubbles */
.crm-ai-sent-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: rgba(88, 86, 214, 0.14);
    color: #5856d6;
    align-self: flex-end;
}

.message-bubble.outbound .crm-ai-sent-label {
    margin-right: 2px;
}

html[data-theme="dark"] .crm-ai-sent-label {
    background: rgba(129, 140, 248, 0.2);
    color: #a5b4fc;
}

/* CRM — AI active/paused dot on conversation list (left sidebar) */
.crm-global-ai-indicator {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 999px;
    line-height: 1.2;
    white-space: nowrap;
}

.crm-global-ai-indicator--on {
    background: rgba(34, 197, 94, 0.15);
    color: #15803d;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.crm-global-ai-indicator--off {
    background: rgba(107, 114, 128, 0.12);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.28);
}

/* Chat header — per-client AI toggle (right side) */
.chat-actions .crm-ai-status-wrap {
    flex-shrink: 0;
    margin-right: 4px;
}

.chat-actions .crm-ai-status-menu {
    left: auto;
    right: 0;
}

.chat-actions {
    align-items: center;
}

.crm-ai-list-dot-wrap {
    position: relative;
    display: inline-flex;
    align-self: center;
    flex-shrink: 0;
    margin-right: 2px;
    cursor: help;
    outline: none;
}

.crm-ai-list-dot-wrap:focus-visible .crm-ai-list-dot {
    box-shadow: 0 0 0 2px #5856d6;
}

.crm-ai-list-dot-tooltip {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 2000;
    min-width: 220px;
    max-width: 300px;
    padding: 9px 11px;
    border-radius: 8px;
    background: #1e293b;
    color: #f8fafc;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.45;
    white-space: pre-line;
    text-align: left;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
    border: 1px solid rgba(148, 163, 184, 0.35);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, visibility 0.12s ease;
}

.crm-ai-list-dot-wrap:hover .crm-ai-list-dot-tooltip,
.crm-ai-list-dot-wrap:focus .crm-ai-list-dot-tooltip,
.crm-ai-list-dot-wrap:focus-within .crm-ai-list-dot-tooltip {
    opacity: 1;
    visibility: visible;
}

html[data-theme="dark"] .crm-ai-list-dot-tooltip {
    background: #0f172a;
    border-color: rgba(148, 163, 184, 0.45);
}

.crm-ai-list-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    align-self: center;
    margin-right: 0;
}

.crm-ai-list-dot--active {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.crm-ai-list-dot--inactive {
    background: #9ca3af;
}

.crm-ai-list-dot--pending {
    background: #cbd5e1;
    animation: crm-ai-dot-pulse 1.2s ease-in-out infinite;
}

@keyframes crm-ai-dot-pulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

.crm-ai-list-dot-wrap--pending {
    cursor: default;
}

.conversation-item.active .crm-ai-list-dot--active {
    background: #86efac;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.conversation-item.active .crm-ai-list-dot--inactive {
    background: rgba(255, 255, 255, 0.55);
    box-shadow: none;
}

html[data-theme="dark"] .crm-ai-list-dot--active {
    background: #4ade80;
}

html[data-theme="dark"] .crm-ai-list-dot--inactive {
    background: #6b7280;
}

.crm-ai-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid transparent;
    white-space: nowrap;
}

.crm-ai-status--hidden {
    display: none !important;
}

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

.crm-ai-status--active {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
    color: #15803d;
}

.crm-ai-status--active .crm-ai-status-dot {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.crm-ai-status--inactive {
    background: rgba(107, 114, 128, 0.12);
    border-color: rgba(107, 114, 128, 0.28);
    color: #6b7280;
}

.crm-ai-status--inactive .crm-ai-status-dot {
    background: #9ca3af;
}

html[data-theme="dark"] .crm-ai-status--active {
    background: rgba(34, 197, 94, 0.16);
    color: #4ade80;
}

html[data-theme="dark"] .crm-ai-status--inactive {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

.crm-ai-status-wrap {
    position: relative;
    display: inline-flex;
}

.crm-ai-status-wrap--hidden {
    display: none !important;
}

.crm-ai-status-icon {
    font-size: 10px;
    opacity: 0.85;
}

.crm-ai-status-chevron {
    font-size: 8px;
    opacity: 0.55;
    margin-left: -2px;
}

button.crm-ai-status {
    cursor: pointer;
    font: inherit;
    appearance: none;
    -webkit-appearance: none;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

button.crm-ai-status:hover {
    box-shadow: 0 0 0 2px rgba(88, 86, 214, 0.12);
}

button.crm-ai-status:focus-visible {
    outline: 2px solid #5856d6;
    outline-offset: 2px;
}

.crm-ai-status-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 1200;
    min-width: 220px;
    max-width: 280px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.crm-ai-status-menu-reason {
    margin: 0 0 8px;
    font-size: 11px;
    line-height: 1.4;
    color: #64748b;
    white-space: pre-line;
}

.crm-ai-status-menu-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.crm-ai-status-menu-action:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.crm-ai-status-menu-action--off {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
    color: #b91c1c;
}

.crm-ai-status-menu-action--off:hover {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.35);
}

.crm-ai-status-menu-action--on {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #15803d;
}

.crm-ai-status-menu-action--on:hover {
    background: rgba(34, 197, 94, 0.16);
    border-color: rgba(34, 197, 94, 0.4);
}

.crm-ai-status-menu-link {
    display: block;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 600;
    color: #5856d6;
    text-align: center;
    text-decoration: none;
}

.crm-ai-status-menu-link:hover {
    text-decoration: underline;
}

html[data-theme="dark"] .crm-ai-status-menu-link {
    color: #a5b4fc;
}

html[data-theme="dark"] .crm-ai-status-menu {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .crm-ai-status-menu-reason {
    color: #94a3b8;
}

html[data-theme="dark"] .crm-ai-status-menu-action {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

html[data-theme="dark"] .crm-ai-status-menu-action:hover {
    background: #1e293b;
}

html[data-theme="dark"] .crm-ai-status-menu-action--off {
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
}

html[data-theme="dark"] .crm-ai-status-menu-action--on {
    background: rgba(34, 197, 94, 0.14);
    color: #4ade80;
}

/* Legacy class — map to pending style */
.ai-chatbot-profile-update-badge {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    max-width: 100%;
    background: rgba(255, 149, 0, 0.12);
    border: 1px solid rgba(255, 149, 0, 0.35);
    color: #b45309;
}
