.crm-agent-root {
    position: fixed;
    top: auto;
    left: auto;
    right: 20px;
    bottom: 20px;
    z-index: 10050;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    pointer-events: none;
}

.crm-agent-root > * {
    pointer-events: auto;
}

.crm-agent-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    font-size: 1.35rem;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.crm-agent-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 28px rgba(79, 70, 229, 0.55);
}

.crm-agent-panel {
    position: absolute;
    right: 0;
    bottom: 68px;
    width: min(400px, calc(100vw - 40px));
    max-height: min(520px, calc(100vh - 120px));
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.2);
    border: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.crm-agent-panel[hidden] {
    display: none !important;
}

.crm-agent-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.crm-agent-panel__title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #0f172a;
}

.crm-agent-panel__close {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: #64748b;
    padding: 0 4px;
}

.crm-agent-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    max-height: 320px;
}

.crm-agent-msg {
    max-width: 92%;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.875rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.crm-agent-msg--user {
    align-self: flex-end;
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 2px;
}

.crm-agent-msg--assistant {
    align-self: flex-start;
    background: #f1f5f9;
    color: #0f172a;
    border-bottom-left-radius: 2px;
}

.crm-agent-msg--system {
    align-self: center;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.8rem;
}

.crm-agent-panel__pending {
    padding: 0 12px 8px;
    border-top: 1px dashed #e2e8f0;
}

.crm-agent-pending-card {
    background: #fff7ed;
    border: 1px solid #fdba74;
    border-radius: 8px;
    padding: 10px;
    font-size: 0.85rem;
}

.crm-agent-pending-card p {
    margin: 0 0 8px;
}

.crm-agent-pending-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.crm-agent-panel__composer {
    display: flex;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid #e2e8f0;
    align-items: flex-end;
}

.crm-agent-panel__composer textarea {
    flex: 1;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px;
    font-size: 0.875rem;
}

@media (max-width: 576px) {
    .crm-agent-root {
        right: 12px;
        bottom: 12px;
    }

    .crm-agent-panel {
        width: calc(100vw - 24px);
    }
}
